From 6626557cc4e57d3176ebdc75dabc0d36944f511b Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Tue, 26 Feb 2019 18:50:13 -1000 Subject: [PATCH] TexGen bug fix with diffuse-only pass --- hecl/extern/boo | 2 +- hecl/include/hecl/Backend/ProgrammableCommon.hpp | 1 + hecl/lib/Backend/ProgrammableCommon.cpp | 12 +++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/hecl/extern/boo b/hecl/extern/boo index f8b22ecb1..66cf60ea5 160000 --- a/hecl/extern/boo +++ b/hecl/extern/boo @@ -1 +1 @@ -Subproject commit f8b22ecb13a7e2bc61e5622b47ac21e50bc78649 +Subproject commit 66cf60ea558d62353fb48c753710ff84c948b013 diff --git a/hecl/include/hecl/Backend/ProgrammableCommon.hpp b/hecl/include/hecl/Backend/ProgrammableCommon.hpp index 78789dc4c..83b2ba13c 100644 --- a/hecl/include/hecl/Backend/ProgrammableCommon.hpp +++ b/hecl/include/hecl/Backend/ProgrammableCommon.hpp @@ -42,6 +42,7 @@ struct ProgrammableCommon : IBackend { static const char* BlendFactorToDefine(BlendFactor factor, BlendFactor defaultFactor); private: + void resetResourceAccumulators(); unsigned addTexCoordGen(TexGenSrc src, int uvIdx, int mtx, bool normalize); unsigned addTexSampling(unsigned mapIdx, unsigned tcgIdx); std::string RecursiveTraceDiffuseColor(const IR& ir, Diagnostics& diag, const IR::Instruction& inst, bool toSwizzle, diff --git a/hecl/lib/Backend/ProgrammableCommon.cpp b/hecl/lib/Backend/ProgrammableCommon.cpp index b00de5dde..834b657e9 100644 --- a/hecl/lib/Backend/ProgrammableCommon.cpp +++ b/hecl/lib/Backend/ProgrammableCommon.cpp @@ -299,6 +299,13 @@ std::string ProgrammableCommon::RecursiveTraceAlpha(const IR& ir, Diagnostics& d return std::string(); } +void ProgrammableCommon::resetResourceAccumulators() { + m_texSamplings.clear(); + m_texMapEnd = 0; + m_tcgs.clear(); + m_texMtxRefs.clear(); +} + void ProgrammableCommon::reset(const IR& ir, Diagnostics& diag, const char* backendName) { m_lighting = false; m_texSamplings.clear(); @@ -330,8 +337,11 @@ void ProgrammableCommon::reset(const IR& ir, Diagnostics& diag, const char* back /* Follow Color Chain */ const IR::Instruction& colorRoot = ir.m_instructions.at(rootCall.m_call.m_argInstIdxs.at(0)); m_diffuseColorExpr = RecursiveTraceDiffuseColor(ir, diag, colorRoot, false, false); - if (m_diffuseColorExpr.empty()) + resetResourceAccumulators(); + if (m_diffuseColorExpr.empty()) { m_diffuseColorExpr = RecursiveTraceDiffuseColor(ir, diag, colorRoot, false, true); + resetResourceAccumulators(); + } m_colorExpr = RecursiveTraceColor(ir, diag, colorRoot, false); /* Follow Alpha Chain */