Merge "Try harder to defeat GLSL compiler dead-code optimizations" into nougat-cts...
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 11 Apr 2017 17:35:53 +0000 (17:35 +0000)
committerandroid-build-merger <android-build-merger@google.com>
Tue, 11 Apr 2017 17:35:53 +0000 (17:35 +0000)
am: 995657a4be

Change-Id: I6c8054a50950a6487cc387b2a8c3367c2456a291

modules/gles31/functional/es31fProgramInterfaceDefinitionUtil.cpp
modules/gles31/functional/es31fProgramInterfaceDefinitionUtil.hpp
modules/gles31/functional/es31fProgramInterfaceQueryTests.cpp

index d37ecae..c31d754 100644 (file)
@@ -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
 
index dd7cfa4..eb56fa0 100644 (file)
@@ -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);
index 95d1950..f8eb8d7 100644 (file)
@@ -1014,7 +1014,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;
 
@@ -1036,8 +1042,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;