GLSL generation fixes

This commit is contained in:
Jack Andersen 2016-08-01 19:54:40 -10:00
parent d43087247f
commit e17d5c0b83
4 changed files with 22 additions and 16 deletions

2
hecl/extern/boo vendored

@ -1 +1 @@
Subproject commit 6c12cd0ce83e23dcc90ebcb1f89e2feb30a16353 Subproject commit 758be7d76cc6fac9fddab6c075dd6bd5f79c0ace

View File

@ -72,11 +72,21 @@ private:
return hecl::Format("sampling%u.a", samplingIdx); return hecl::Format("sampling%u.a", samplingIdx);
} }
virtual std::string EmitColorRegUse(unsigned idx) const virtual std::string EmitColorRegUseRaw(unsigned idx) const
{ {
return hecl::Format("colorReg%u", idx); return hecl::Format("colorReg%u", idx);
} }
virtual std::string EmitColorRegUseRGB(unsigned idx) const
{
return hecl::Format("colorReg%u.rgb", idx);
}
virtual std::string EmitColorRegUseAlpha(unsigned idx) const
{
return hecl::Format("colorReg%u.a", idx);
}
std::string EmitLightingRaw() const std::string EmitLightingRaw() const
{ {
return std::string("lighting"); return std::string("lighting");

View File

@ -195,12 +195,10 @@ std::string GLSL::makeFrag(const char* glslVer, bool alphaTest,
if (lighting.m_source) if (lighting.m_source)
lightingSrc = lighting.m_source; lightingSrc = lighting.m_source;
else else
lightingSrc = "UBINDING2 uniform LightingUniform\n" lightingSrc = "const vec4 colorReg0 = vec4(1.0);\n"
"{\n" "const vec4 colorReg1 = vec4(1.0);\n"
" vec4 colorReg0;\n" "const vec4 colorReg2 = vec4(1.0);\n"
" vec4 colorReg1;\n" "\n";
" vec4 colorReg2;\n"
"};\n";
std::string texMapDecl; std::string texMapDecl;
for (unsigned i=0 ; i<m_texMapEnd ; ++i) for (unsigned i=0 ; i<m_texMapEnd ; ++i)
@ -250,12 +248,10 @@ std::string GLSL::makeFrag(const char* glslVer, bool alphaTest,
if (lighting.m_source) if (lighting.m_source)
lightingSrc = lighting.m_source; lightingSrc = lighting.m_source;
else else
lightingSrc = "UBINDING2 uniform LightingUniform\n" lightingSrc = "const vec4 colorReg0 = vec4(1.0);\n"
"{\n" "const vec4 colorReg1 = vec4(1.0);\n"
" vec4 colorReg0;\n" "const vec4 colorReg2 = vec4(1.0);\n"
" vec4 colorReg1;\n" "\n";
" vec4 colorReg2;\n"
"};\n";
std::string postSrc; std::string postSrc;
if (post.m_source) if (post.m_source)

View File

@ -104,7 +104,7 @@ std::string ProgrammableCommon::RecursiveTraceColor(const IR& ir, Diagnostics& d
{ {
const IR::Instruction& idxInst = inst.getChildInst(ir, 0); const IR::Instruction& idxInst = inst.getChildInst(ir, 0);
unsigned idx = unsigned(idxInst.getImmVec().vec[0]); unsigned idx = unsigned(idxInst.getImmVec().vec[0]);
return EmitColorRegUse(idx); return toSwizzle ? EmitColorRegUseRaw(idx) : EmitColorRegUseRGB(idx);
} }
else if (!name.compare("Lighting")) else if (!name.compare("Lighting"))
{ {
@ -191,7 +191,7 @@ std::string ProgrammableCommon::RecursiveTraceAlpha(const IR& ir, Diagnostics& d
{ {
const IR::Instruction& idxInst = inst.getChildInst(ir, 0); const IR::Instruction& idxInst = inst.getChildInst(ir, 0);
unsigned idx = unsigned(idxInst.getImmVec().vec[0]); unsigned idx = unsigned(idxInst.getImmVec().vec[0]);
return EmitColorRegUse(idx); return EmitColorRegUseAlpha(idx);
} }
else if (!name.compare("Lighting")) else if (!name.compare("Lighting"))
{ {