diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-04-11 16:56:42 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-04-11 16:56:43 +0000 |
commit | aeef6dd8f52a1ea27fa13b5a451b5863070633be (patch) | |
tree | 775a2fc9f39490e8c5e40ce53def654c5c7d35b6 | |
parent | 521361d83d2d48116ecdbd235934ed7c42ec74d4 (diff) | |
parent | 337d8f30c861d07fcc50b575b332efac35a5f094 (diff) | |
download | deqp-aeef6dd8f52a1ea27fa13b5a451b5863070633be.tar.gz |
Merge "Try harder to defeat GLSL compiler dead-code optimizations" into nougat-cts-dev
3 files changed, 31 insertions, 5 deletions
diff --git a/modules/gles31/functional/es31fProgramInterfaceDefinitionUtil.cpp b/modules/gles31/functional/es31fProgramInterfaceDefinitionUtil.cpp index e0efa0ed3..2137de563 100644 --- a/modules/gles31/functional/es31fProgramInterfaceDefinitionUtil.cpp +++ b/modules/gles31/functional/es31fProgramInterfaceDefinitionUtil.cpp @@ -1475,6 +1475,21 @@ std::vector<std::string> getProgramInterfaceResourceList (const ProgramInterface return resources; } +/** + * Name of the dummy uniform added by generateProgramInterfaceProgramSources + * + * A uniform named "dummyZero" is added by + * generateProgramInterfaceProgramSources. It is used in expressions to + * prevent various program resources from being eliminated by the GLSL + * compiler's optimizer. + * + * \sa deqp::gles31::Functional::ProgramInterfaceDefinition::generateProgramInterfaceProgramSources + */ +const char* getDummyZeroUniformName() +{ + return "dummyZero"; +} + glu::ProgramSources generateProgramInterfaceProgramSources (const ProgramInterfaceDefinition::Program* program) { glu::ProgramSources sources; @@ -1513,9 +1528,10 @@ glu::ProgramSources generateProgramInterfaceProgramSources (const ProgramInterfa // Use inputs and outputs so that they won't be removed by the optimizer - usageBuf << "highp vec4 readInputs()\n" + usageBuf << "highp uniform vec4 " << getDummyZeroUniformName() << "; // Default value is vec4(0.0).\n" + "highp vec4 readInputs()\n" "{\n" - " highp vec4 retValue = vec4(0.0);\n"; + " highp vec4 retValue = " << getDummyZeroUniformName() << ";\n"; // User-defined inputs diff --git a/modules/gles31/functional/es31fProgramInterfaceDefinitionUtil.hpp b/modules/gles31/functional/es31fProgramInterfaceDefinitionUtil.hpp index efd9e03e1..d4a22fb50 100644 --- a/modules/gles31/functional/es31fProgramInterfaceDefinitionUtil.hpp +++ b/modules/gles31/functional/es31fProgramInterfaceDefinitionUtil.hpp @@ -174,6 +174,7 @@ bool shaderContainsIOBlocks (const ProgramInterfaceDefinition::S glu::ShaderType getProgramTransformFeedbackStage (const ProgramInterfaceDefinition::Program* program); std::vector<std::string> getProgramInterfaceResourceList (const ProgramInterfaceDefinition::Program* program, ProgramInterface interface); std::vector<std::string> getProgramInterfaceBlockMemberResourceList (const glu::InterfaceBlock& interfaceBlock); +const char* getDummyZeroUniformName (); glu::ProgramSources generateProgramInterfaceProgramSources (const ProgramInterfaceDefinition::Program* program); bool findProgramVariablePathByPathName (std::vector<ProgramInterfaceDefinition::VariablePathComponent>& typePath, const ProgramInterfaceDefinition::Program* program, const std::string& pathName, const ProgramInterfaceDefinition::VariableSearchFilter& filter); void generateVariableTypeResourceNames (std::vector<std::string>& resources, const std::string& name, const glu::VarType& type, deUint32 resourceNameGenerationFlags); diff --git a/modules/gles31/functional/es31fProgramInterfaceQueryTests.cpp b/modules/gles31/functional/es31fProgramInterfaceQueryTests.cpp index ede1c0b50..2b06602f7 100644 --- a/modules/gles31/functional/es31fProgramInterfaceQueryTests.cpp +++ b/modules/gles31/functional/es31fProgramInterfaceQueryTests.cpp @@ -1026,7 +1026,13 @@ bool ResourceListTestCase::verifyResourceList (const std::vector<std::string>& r m_testCtx.getLog() << tcu::TestLog::Message << "GL returned resources:" << tcu::TestLog::EndMessage; for (int ndx = 0; ndx < (int)resourceList.size(); ++ndx) - m_testCtx.getLog() << tcu::TestLog::Message << "\t" << ndx << ": " << resourceList[ndx] << tcu::TestLog::EndMessage; + { + // dummyZero is a uniform that may be added by + // generateProgramInterfaceProgramSources. Omit it here to avoid + // confusion about the output. + if (resourceList[ndx] != getDummyZeroUniformName()) + m_testCtx.getLog() << tcu::TestLog::Message << "\t" << ndx << ": " << resourceList[ndx] << tcu::TestLog::EndMessage; + } m_testCtx.getLog() << tcu::TestLog::Message << "Expected list of resources:" << tcu::TestLog::EndMessage; @@ -1048,8 +1054,11 @@ bool ResourceListTestCase::verifyResourceList (const std::vector<std::string>& r { if (!de::contains(expectedResources.begin(), expectedResources.end(), resourceList[ndx])) { - // Ignore all builtin variables, mismatch causes errors otherwise - if (deStringBeginsWith(resourceList[ndx].c_str(), "gl_") == DE_FALSE) + // Ignore all builtin variables or the variable dummyZero, + // mismatch causes errors otherwise. dummyZero is a uniform that + // may be added by generateProgramInterfaceProgramSources. + if (deStringBeginsWith(resourceList[ndx].c_str(), "gl_") == DE_FALSE && + resourceList[ndx] != getDummyZeroUniformName()) { m_testCtx.getLog() << tcu::TestLog::Message << "Error, resource list contains unexpected resource name " << resourceList[ndx] << tcu::TestLog::EndMessage; error = true; |