mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-18 13:25:25 +00:00
Initial GX Backend
This commit is contained in:
@@ -1 +1,2 @@
|
||||
add_library(HECLBackend HECLBackend.cpp)
|
||||
add_library(HECLBackend
|
||||
GX.cpp)
|
||||
|
||||
74
hecl/lib/Backend/GX.cpp
Normal file
74
hecl/lib/Backend/GX.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
#include <LogVisor/LogVisor.hpp>
|
||||
#include "HECL/Backend/GX.hpp"
|
||||
#include "HECL/Frontend.hpp"
|
||||
|
||||
static LogVisor::LogModule Log("HECL::GX");
|
||||
|
||||
namespace HECL
|
||||
{
|
||||
namespace Backend
|
||||
{
|
||||
|
||||
unsigned GX::addKColor(const Color& color)
|
||||
{
|
||||
for (unsigned i=0 ; i<m_kcolorCount ; ++i)
|
||||
if (m_kcolors[i] == color)
|
||||
return i;
|
||||
if (m_kcolorCount >= 4)
|
||||
Log.report(LogVisor::FatalError, "GX KColor overflow");
|
||||
m_kcolors[m_kcolorCount] = color;
|
||||
return m_kcolorCount++;
|
||||
}
|
||||
|
||||
void GX::reset(const Frontend::IR& ir)
|
||||
{
|
||||
m_tevCount = 0;
|
||||
m_tcgCount = 0;
|
||||
m_kcolorCount = 0;
|
||||
|
||||
/* Final instruction is the root call by hecl convention */
|
||||
const Frontend::IR::Instruction& rootCall = ir.m_instructions.back();
|
||||
bool doAlpha = false;
|
||||
if (!rootCall.m_call.m_name.compare("HECLOpaque"))
|
||||
{
|
||||
m_blendSrc = BL_ONE;
|
||||
m_blendDst = BL_ZERO;
|
||||
}
|
||||
else if (!rootCall.m_call.m_name.compare("HECLAlpha"))
|
||||
{
|
||||
m_blendSrc = BL_SRCALPHA;
|
||||
m_blendDst = BL_INVSRCALPHA;
|
||||
doAlpha = true;
|
||||
}
|
||||
else if (!rootCall.m_call.m_name.compare("HECLAdditive"))
|
||||
{
|
||||
m_blendSrc = BL_SRCALPHA;
|
||||
m_blendDst = BL_ONE;
|
||||
doAlpha = true;
|
||||
}
|
||||
|
||||
for (const Frontend::IR::Instruction& inst : ir.m_instructions)
|
||||
{
|
||||
switch (inst.m_op)
|
||||
{
|
||||
case Frontend::IR::OpCall:
|
||||
{
|
||||
const std::string& name = inst.m_call.m_name;
|
||||
if (!name.compare("ColorReg"))
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Frontend::IR::OpLoadImm:
|
||||
{
|
||||
addKColor(inst.m_loadImm.m_immVec);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Log.report(LogVisor::FatalError, "invalid inst op");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef IBACKENDFRAGEMITTER_HPP
|
||||
#define IBACKENDFRAGEMITTER_HPP
|
||||
|
||||
#endif // IBACKENDFRAGEMITTER_HPP
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef IBACKENDOBJECT_HPP
|
||||
#define IBACKENDOBJECT_HPP
|
||||
|
||||
#endif // IBACKENDOBJECT_HPP
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef IBACKENDSPEC_HPP
|
||||
#define IBACKENDSPEC_HPP
|
||||
|
||||
#endif // IBACKENDSPEC_HPP
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef IBACKENDVERTEMITTER_HPP
|
||||
#define IBACKENDVERTEMITTER_HPP
|
||||
|
||||
#endif // IBACKENDVERTEMITTER_HPP
|
||||
@@ -12,7 +12,8 @@ add_library(HECLCommon
|
||||
ProjectPath.cpp
|
||||
WideStringConvert.cpp
|
||||
../include/HECL/HECL.hpp
|
||||
../include/HECL/Backend.hpp
|
||||
../include/HECL/Backend/Backend.hpp
|
||||
../include/HECL/Backend/GX.hpp
|
||||
../include/HECL/Frontend.hpp
|
||||
../include/HECL/Database.hpp
|
||||
../include/HECL/Runtime.hpp
|
||||
|
||||
@@ -345,7 +345,7 @@ void Lexer::EmitVec3(IR& ir, const Lexer::OperationNode* funcNode, IR::RegID tar
|
||||
vec.vec[0] = imms[0]->m_tokenFloat;
|
||||
vec.vec[1] = imms[1]->m_tokenFloat;
|
||||
vec.vec[2] = imms[2]->m_tokenFloat;
|
||||
vec.vec[3] = 0.0;
|
||||
vec.vec[3] = 1.0;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -569,7 +569,7 @@ void Lexer::EmitVectorSwizzle(IR& ir, const Lexer::OperationNode* swizNode, IR::
|
||||
eval.vec[0] = opt->vec[SwizzleCompIdx(str[0])];
|
||||
eval.vec[1] = opt->vec[SwizzleCompIdx(str[1])];
|
||||
eval.vec[2] = opt->vec[SwizzleCompIdx(str[2])];
|
||||
eval.vec[3] = 0.0;
|
||||
eval.vec[3] = 1.0;
|
||||
break;
|
||||
case 4:
|
||||
eval.vec[0] = opt->vec[SwizzleCompIdx(str[0])];
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CEXPRADD_HPP
|
||||
#define CEXPRADD_HPP
|
||||
|
||||
#endif // CEXPRADD_HPP
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CEXPRBASE_HPP
|
||||
#define CEXPRBASE_HPP
|
||||
|
||||
#endif // CEXPRBASE_HPP
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CEXPRCALL_HPP
|
||||
#define CEXPRCALL_HPP
|
||||
|
||||
#endif // CEXPRCALL_HPP
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CEXPRGROUP_HPP
|
||||
#define CEXPRGROUP_HPP
|
||||
|
||||
#endif // CEXPRGROUP_HPP
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CEXPRLIGHTING_HPP
|
||||
#define CEXPRLIGHTING_HPP
|
||||
|
||||
#endif // CEXPRLIGHTING_HPP
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CEXPRMUL_HPP
|
||||
#define CEXPRMUL_HPP
|
||||
|
||||
#endif // CEXPRMUL_HPP
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CEXPRROOT_HPP
|
||||
#define CEXPRROOT_HPP
|
||||
|
||||
#endif // CEXPRROOT_HPP
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CEXPRSUB_HPP
|
||||
#define CEXPRSUB_HPP
|
||||
|
||||
#endif // CEXPRSUB_HPP
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CEXPRTEXTURE_HPP
|
||||
#define CEXPRTEXTURE_HPP
|
||||
|
||||
#endif // CEXPRTEXTURE_HPP
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef CEXPRTEXTUREGATHER_HPP
|
||||
#define CEXPRTEXTUREGATHER_HPP
|
||||
|
||||
#endif // CEXPRTEXTUREGATHER_HPP
|
||||
@@ -1,15 +0,0 @@
|
||||
#ifndef EXPR_HPP
|
||||
#define EXPR_HPP
|
||||
|
||||
#include "CExprBase.hpp"
|
||||
#include "CExprRoot.hpp"
|
||||
#include "CExprCall.hpp"
|
||||
#include "CExprGroup.hpp"
|
||||
#include "CExprMul.hpp"
|
||||
#include "CExprAdd.hpp"
|
||||
#include "CExprSub.hpp"
|
||||
#include "CExprTexture.hpp"
|
||||
#include "CExprTextureGather.hpp"
|
||||
#include "CExprLighting.hpp"
|
||||
|
||||
#endif // EXPR_HPP
|
||||
Reference in New Issue
Block a user