mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2025-02-17 20:31:57 -05:00
Fixing a uniform parsing issue.
This commit is contained in:
parent
2819f93f26
commit
643d7939d7
1 changed files with 5 additions and 7 deletions
|
@ -507,6 +507,8 @@ bool compileHLSLShader(bx::CommandLine& _cmdLine, uint32_t _d3d, const std::stri
|
|||
|
||||
if (firstPass && unusedUniforms.size() > 0)
|
||||
{
|
||||
const size_t strLength = strlen("uniform");
|
||||
|
||||
// first time through, we just find unused uniforms and get rid of them
|
||||
std::stringstream output;
|
||||
LineReader reader(_code.c_str());
|
||||
|
@ -519,24 +521,20 @@ bool compileHLSLShader(bx::CommandLine& _cmdLine, uint32_t _d3d, const std::stri
|
|||
if (index == std::string::npos)
|
||||
continue;
|
||||
|
||||
size_t index2 = line.find_first_not_of(' ', index);
|
||||
if (index2 == std::string::npos)
|
||||
continue;
|
||||
|
||||
// matching lines like: uniform u_name;
|
||||
// we want to replace "uniform" with "static" so that it's no longer
|
||||
// included in the uniform blob that the application must upload
|
||||
// we can't just remove them, because unused functions might still reference
|
||||
// them and cause a compile error when they're gone
|
||||
if (line.find(*it, index2) == index2)
|
||||
if (line.find(*it) != std::string::npos)
|
||||
{
|
||||
line = line.replace(index, 7, "static");
|
||||
line = line.replace(index, strLength, "static");
|
||||
unusedUniforms.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
output << line << std::endl;
|
||||
output << line;
|
||||
}
|
||||
|
||||
// recompile with the unused uniforms converted to statics
|
||||
|
|
Loading…
Reference in a new issue