if (shader->getDefaultBlock().variables[ndx].storage == glu::STORAGE_OUT)
{
// missing location qualifier means location == 0
- const int outputLocation = (shader->getDefaultBlock().variables[ndx].layout.location == -1)
+ const int outputLocation = (shader->getDefaultBlock().variables[ndx].layout.location == -1)
? (0)
: (shader->getDefaultBlock().variables[ndx].layout.location);
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
enum ResourceNameGenerationFlag
{
- RESOURCE_NAME_GENERATION_FLAG_DEFAULT = 0x0,
+ RESOURCE_NAME_GENERATION_FLAG_DEFAULT = 0x0,
RESOURCE_NAME_GENERATION_FLAG_TOP_LEVEL_BUFFER_VARIABLE = 0x1,
RESOURCE_NAME_GENERATION_FLAG_TRANSFORM_FEEDBACK_VARIABLE = 0x2,
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);
bool isStagePresent (glu::ShaderType stage) const;
bool isStageReferencing (glu::ShaderType stage) const;
- deUint32 getPresentMask (void) const;
deUint32 getReferencingMask (void) const;
const glu::GLSLVersion m_version;
return m_stageReferencing[stage];
}
-deUint32 ShaderSet::getPresentMask (void) const
-{
- deUint32 mask = 0;
- for (deUint32 stage = 0; stage < glu::SHADERTYPE_LAST; ++stage)
- {
- if (m_stagePresent[stage])
- mask |= (1u << stage);
- }
- return mask;
-}
-
deUint32 ShaderSet::getReferencingMask (void) const
{
deUint32 mask = 0;
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;
const glu::ShaderType shaderType = (selector == 0) ? (glu::SHADERTYPE_GEOMETRY)
: (selector == 1) ? (glu::SHADERTYPE_TESSELLATION_CONTROL)
: (selector == 2) ? (glu::SHADERTYPE_TESSELLATION_EVALUATION)
- : (glu::SHADERTYPE_LAST);
+ : (glu::SHADERTYPE_LAST);
return ResourceDefinition::Node::SharedPtr(new ResourceDefinition::Shader(program, shaderType, glu::GLSL_VERSION_310_ES));
}