2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 23:47:43 +00:00

Initial GX Backend

This commit is contained in:
Jack Andersen
2015-10-09 20:59:40 -10:00
parent 96b8c4c8d8
commit 45b1d2edf3
43 changed files with 354 additions and 79 deletions

View File

@@ -1 +1,2 @@
add_library(HECLBackend HECLBackend.cpp)
add_library(HECLBackend
GX.cpp)

74
hecl/lib/Backend/GX.cpp Normal file
View 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");
}
}
}
}
}

View File

@@ -1,4 +0,0 @@
#ifndef IBACKENDFRAGEMITTER_HPP
#define IBACKENDFRAGEMITTER_HPP
#endif // IBACKENDFRAGEMITTER_HPP

View File

@@ -1,4 +0,0 @@
#ifndef IBACKENDOBJECT_HPP
#define IBACKENDOBJECT_HPP
#endif // IBACKENDOBJECT_HPP

View File

@@ -1,4 +0,0 @@
#ifndef IBACKENDSPEC_HPP
#define IBACKENDSPEC_HPP
#endif // IBACKENDSPEC_HPP

View File

@@ -1,4 +0,0 @@
#ifndef IBACKENDVERTEMITTER_HPP
#define IBACKENDVERTEMITTER_HPP
#endif // IBACKENDVERTEMITTER_HPP