Commit 4f52da4a by Olli Etuaho

Remove no-op functionality from IdentifyBuiltIns and refactor

Adding array built-ins like gl_FragData and gl_LastFragData to the symbol table with a name that included their size in brackets was incorrect and unnecessary. Remove this. The array built-ins should only be added with their proper name and with an array type. Also refactor the code to reduce unnecessary repetition of conditions. The previous version attempted to split the built-ins that had dependencies on resources into their own part of the code, but this split was not clearly defined and only made the code harder to follow and prone to issues. TEST=WebGL conformance tests Change-Id: I7a77865a594864a22f3b566f9d3da1d0ead46466 Reviewed-on: https://chromium-review.googlesource.com/258751Reviewed-by: 's avatarNicolas Capens <capn@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent 61ffec88
...@@ -479,7 +479,7 @@ void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec, ...@@ -479,7 +479,7 @@ void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec,
TSymbolTable &symbolTable) TSymbolTable &symbolTable)
{ {
// //
// First, insert some special built-in variables that are not in // Insert some special built-in variables that are not in
// the built-in header files. // the built-in header files.
// //
switch (type) switch (type)
...@@ -500,27 +500,34 @@ void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec, ...@@ -500,27 +500,34 @@ void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec,
{ {
symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragColor"), symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragColor"),
TType(EbtFloat, EbpMedium, EvqFragColor, 4))); TType(EbtFloat, EbpMedium, EvqFragColor, 4)));
symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData[gl_MaxDrawBuffers]"), TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true);
TType(EbtFloat, EbpMedium, EvqFragData, 4))); fragData.setArraySize(resources.MaxDrawBuffers);
symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData"), fragData));
if (resources.EXT_frag_depth) if (resources.EXT_frag_depth)
{ {
symbolTable.insert(ESSL1_BUILTINS, "GL_EXT_frag_depth", new TVariable(NewPoolTString("gl_FragDepthEXT"), symbolTable.insert(ESSL1_BUILTINS, "GL_EXT_frag_depth", new TVariable(NewPoolTString("gl_FragDepthEXT"),
TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, EvqFragDepth, 1))); TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, EvqFragDepth, 1)));
} }
if (resources.EXT_shader_framebuffer_fetch)
{ if (resources.EXT_shader_framebuffer_fetch || resources.NV_shader_framebuffer_fetch)
symbolTable.insert(ESSL1_BUILTINS, "GL_EXT_shader_framebuffer_fetch",
new TVariable(NewPoolTString("gl_LastFragData[gl_MaxDrawBuffers]"),
TType(EbtFloat, EbpMedium, EvqLastFragData, 4)));
}
else if (resources.NV_shader_framebuffer_fetch)
{ {
symbolTable.insert(ESSL1_BUILTINS, "GL_NV_shader_framebuffer_fetch", TType lastFragData(EbtFloat, EbpMedium, EvqLastFragData, 4, 1, true);
new TVariable(NewPoolTString("gl_LastFragColor"), lastFragData.setArraySize(resources.MaxDrawBuffers);
TType(EbtFloat, EbpMedium, EvqLastFragColor, 4)));
symbolTable.insert(ESSL1_BUILTINS, "GL_NV_shader_framebuffer_fetch", if (resources.EXT_shader_framebuffer_fetch)
new TVariable(NewPoolTString("gl_LastFragData[gl_MaxDrawBuffers]"), {
TType(EbtFloat, EbpMedium, EvqLastFragData, 4))); symbolTable.insert(ESSL1_BUILTINS, "GL_EXT_shader_framebuffer_fetch",
new TVariable(NewPoolTString("gl_LastFragData"), lastFragData));
}
else if (resources.NV_shader_framebuffer_fetch)
{
symbolTable.insert(ESSL1_BUILTINS, "GL_NV_shader_framebuffer_fetch",
new TVariable(NewPoolTString("gl_LastFragColor"),
TType(EbtFloat, EbpMedium, EvqLastFragColor, 4)));
symbolTable.insert(ESSL1_BUILTINS, "GL_NV_shader_framebuffer_fetch",
new TVariable(NewPoolTString("gl_LastFragData"), lastFragData));
}
} }
else if (resources.ARM_shader_framebuffer_fetch) else if (resources.ARM_shader_framebuffer_fetch)
{ {
...@@ -551,38 +558,6 @@ void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec, ...@@ -551,38 +558,6 @@ void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec,
default: default:
assert(false && "Language not supported"); assert(false && "Language not supported");
} }
// Finally add resource-specific variables.
switch (type)
{
case GL_FRAGMENT_SHADER:
if (spec != SH_CSS_SHADERS_SPEC)
{
TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true);
fragData.setArraySize(resources.MaxDrawBuffers);
symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData"), fragData));
if (resources.EXT_shader_framebuffer_fetch || resources.NV_shader_framebuffer_fetch)
{
TType lastFragData(EbtFloat, EbpMedium, EvqLastFragData, 4, 1, true);
lastFragData.setArraySize(resources.MaxDrawBuffers);
if (resources.EXT_shader_framebuffer_fetch)
{
symbolTable.insert(ESSL1_BUILTINS, "GL_EXT_shader_framebuffer_fetch",
new TVariable(NewPoolTString("gl_LastFragData"), lastFragData));
}
else if (resources.NV_shader_framebuffer_fetch)
{
symbolTable.insert(ESSL1_BUILTINS, "GL_NV_shader_framebuffer_fetch",
new TVariable(NewPoolTString("gl_LastFragData"), lastFragData));
}
}
}
break;
default:
break;
}
} }
void InitExtensionBehavior(const ShBuiltInResources& resources, void InitExtensionBehavior(const ShBuiltInResources& resources,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment