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;
// 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
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);
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;
{
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;