mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 08:27:42 +00:00
Major refactor of hecl parser using @hackyourlife architecture
This commit is contained in:
@@ -578,6 +578,8 @@ struct GLSLBackendFactory : IShaderBackendFactory
|
||||
std::string vertSource = r.readString();
|
||||
std::string fragSource = r.readString();
|
||||
|
||||
printf("%s\n%s\n", vertSource.c_str(), fragSource.c_str());
|
||||
|
||||
if (r.hasError())
|
||||
return false;
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ unsigned GX::RecursiveTraceTexGen(const IR& ir, Diagnostics& diag, const IR::Ins
|
||||
if (inst.getChildCount() < 1)
|
||||
diag.reportBackendErr(inst.m_loc, "TexCoordGen UV(layerIdx) requires one argument");
|
||||
const IR::Instruction& idxInst = inst.getChildInst(ir, 0);
|
||||
const atVec4f& idxImm = idxInst.getImmVec();
|
||||
auto& idxImm = idxInst.getImmVec();
|
||||
return addTexCoordGen(diag, inst.m_loc, TexGenSrc(TG_TEX0 + unsigned(idxImm.vec[0])), mtx, normalize, pmtx);
|
||||
}
|
||||
else if (!tcgName.compare("Normal"))
|
||||
@@ -125,7 +125,7 @@ GX::TraceResult GX::RecursiveTraceColor(const IR& ir, Diagnostics& diag, const I
|
||||
diag.reportBackendErr(inst.m_loc, "Texture(map, texgen) requires 2 arguments");
|
||||
|
||||
const IR::Instruction& mapInst = inst.getChildInst(ir, 0);
|
||||
const atVec4f& mapImm = mapInst.getImmVec();
|
||||
auto& mapImm = mapInst.getImmVec();
|
||||
newStage.m_texMapIdx = unsigned(mapImm.vec[0]);
|
||||
newStage.m_color[0] = swizzleAlpha ? CC_TEXA : CC_TEXC;
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ unsigned ProgrammableCommon::RecursiveTraceTexGen(const IR& ir, Diagnostics& dia
|
||||
if (inst.getChildCount() < 1)
|
||||
diag.reportBackendErr(inst.m_loc, "TexCoordGen UV(layerIdx) requires one argument");
|
||||
const IR::Instruction& idxInst = inst.getChildInst(ir, 0);
|
||||
const atVec4f& idxImm = idxInst.getImmVec();
|
||||
auto& idxImm = idxInst.getImmVec();
|
||||
return addTexCoordGen(TexGenSrc::UV, idxImm.vec[0], mtx, normalize);
|
||||
}
|
||||
else if (!tcgName.compare("Normal"))
|
||||
@@ -91,7 +91,7 @@ std::string ProgrammableCommon::RecursiveTraceColor(const IR& ir, Diagnostics& d
|
||||
diag.reportBackendErr(inst.m_loc, "Texture(map, texgen) requires 2 arguments");
|
||||
|
||||
const IR::Instruction& mapInst = inst.getChildInst(ir, 0);
|
||||
const atVec4f& mapImm = mapInst.getImmVec();
|
||||
auto& mapImm = mapInst.getImmVec();
|
||||
unsigned mapIdx = unsigned(mapImm.vec[0]);
|
||||
|
||||
const IR::Instruction& tcgInst = inst.getChildInst(ir, 1);
|
||||
@@ -111,6 +111,17 @@ std::string ProgrammableCommon::RecursiveTraceColor(const IR& ir, Diagnostics& d
|
||||
m_lighting = true;
|
||||
return toSwizzle ? EmitLightingRaw() : EmitLightingRGB();
|
||||
}
|
||||
else if (!name.compare("vec3"))
|
||||
{
|
||||
if (inst.getChildCount() < 3)
|
||||
diag.reportBackendErr(inst.m_loc, "vec3(r,g,b) requires 3 arguments");
|
||||
const IR::Instruction& aInst = inst.getChildInst(ir, 0);
|
||||
const IR::Instruction& bInst = inst.getChildInst(ir, 1);
|
||||
const IR::Instruction& cInst = inst.getChildInst(ir, 2);
|
||||
return EmitVec3(RecursiveTraceAlpha(ir, diag, aInst, false),
|
||||
RecursiveTraceAlpha(ir, diag, bInst, false),
|
||||
RecursiveTraceAlpha(ir, diag, cInst, false));
|
||||
}
|
||||
else
|
||||
diag.reportBackendErr(inst.m_loc, "unable to interpret '%s'", name.c_str());
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user