Commit da41ac69 by Olli Etuaho Committed by Commit Bot

Fix decorating ViewID_OVR in HLSL output

ViewID_OVR should not be decorated in HLSL output since it is an internal variable. Make sure that DecorateVariableIfNeeded() is used for varyings instead of just Decorate() so that the internalness is checked correctly and ViewID_OVR doesn't get decorated. This avoids possible name conflicts between the internal ViewID_OVR and any user-defined variables named ViewID_OVR. BUG=angleproject:2062 TEST=angle_end2end_tests, angle_unittests Change-Id: I9ed9876d4b2c760e7a11b0b270a2190993e840e5 Reviewed-on: https://chromium-review.googlesource.com/1143398Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent da92a476
...@@ -282,6 +282,17 @@ int main(int argc, char *argv[]) ...@@ -282,6 +282,17 @@ int main(int argc, char *argv[])
} }
if (compiler) if (compiler)
{ {
switch (output)
{
case SH_HLSL_3_0_OUTPUT:
case SH_HLSL_4_1_OUTPUT:
case SH_HLSL_4_0_FL9_3_OUTPUT:
compileOptions &= ~SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER;
break;
default:
break;
}
bool compiled = CompileFile(argv[0], compiler, compileOptions); bool compiled = CompileFile(argv[0], compiler, compileOptions);
LogMsg("BEGIN", "COMPILER", numCompiles, "INFO LOG"); LogMsg("BEGIN", "COMPILER", numCompiles, "INFO LOG");
......
...@@ -453,12 +453,11 @@ void OutputHLSL::writeReferencedVaryings(TInfoSinkBase &out) const ...@@ -453,12 +453,11 @@ void OutputHLSL::writeReferencedVaryings(TInfoSinkBase &out) const
for (const auto &varying : mReferencedVaryings) for (const auto &varying : mReferencedVaryings)
{ {
const TType &type = varying.second->getType(); const TType &type = varying.second->getType();
const ImmutableString &name = varying.second->name();
// Program linking depends on this exact format // Program linking depends on this exact format
out << "static " << InterpolationString(type.getQualifier()) << " " << TypeString(type) out << "static " << InterpolationString(type.getQualifier()) << " " << TypeString(type)
<< " " << Decorate(name) << ArrayString(type) << " = " << zeroInitializer(type) << " " << DecorateVariableIfNeeded(*varying.second) << ArrayString(type) << " = "
<< ";\n"; << zeroInitializer(type) << ";\n";
} }
} }
...@@ -958,8 +957,8 @@ void OutputHLSL::visitSymbol(TIntermSymbol *node) ...@@ -958,8 +957,8 @@ void OutputHLSL::visitSymbol(TIntermSymbol *node)
else if (IsVarying(qualifier)) else if (IsVarying(qualifier))
{ {
mReferencedVaryings[uniqueId.get()] = &variable; mReferencedVaryings[uniqueId.get()] = &variable;
out << Decorate(name); out << DecorateVariableIfNeeded(variable);
if (name == "ViewID_OVR") if (variable.symbolType() == SymbolType::AngleInternal && name == "ViewID_OVR")
{ {
mUsesViewID = true; mUsesViewID = true;
} }
......
...@@ -516,17 +516,17 @@ void DynamicHLSL::generateShaderLinkHLSL(const gl::Context *context, ...@@ -516,17 +516,17 @@ void DynamicHLSL::generateShaderLinkHLSL(const gl::Context *context,
if (vertexBuiltins.glViewIDOVR.enabled) if (vertexBuiltins.glViewIDOVR.enabled)
{ {
vertexStream << " output.gl_ViewID_OVR = _ViewID_OVR;\n"; vertexStream << " output.gl_ViewID_OVR = ViewID_OVR;\n";
} }
if (programMetadata.hasANGLEMultiviewEnabled() && programMetadata.canSelectViewInVertexShader()) if (programMetadata.hasANGLEMultiviewEnabled() && programMetadata.canSelectViewInVertexShader())
{ {
ASSERT(vertexBuiltins.glViewportIndex.enabled && vertexBuiltins.glLayer.enabled); ASSERT(vertexBuiltins.glViewportIndex.enabled && vertexBuiltins.glLayer.enabled);
vertexStream << " if (multiviewSelectViewportIndex)\n" vertexStream << " if (multiviewSelectViewportIndex)\n"
<< " {\n" << " {\n"
<< " output.gl_ViewportIndex = _ViewID_OVR;\n" << " output.gl_ViewportIndex = ViewID_OVR;\n"
<< " } else {\n" << " } else {\n"
<< " output.gl_ViewportIndex = 0;\n" << " output.gl_ViewportIndex = 0;\n"
<< " output.gl_Layer = _ViewID_OVR;\n" << " output.gl_Layer = ViewID_OVR;\n"
<< " }\n"; << " }\n";
} }
...@@ -694,7 +694,7 @@ void DynamicHLSL::generateShaderLinkHLSL(const gl::Context *context, ...@@ -694,7 +694,7 @@ void DynamicHLSL::generateShaderLinkHLSL(const gl::Context *context,
if (fragmentShader->usesViewID()) if (fragmentShader->usesViewID())
{ {
ASSERT(pixelBuiltins.glViewIDOVR.enabled); ASSERT(pixelBuiltins.glViewIDOVR.enabled);
pixelStream << " _ViewID_OVR = input.gl_ViewID_OVR;\n"; pixelStream << " ViewID_OVR = input.gl_ViewID_OVR;\n";
} }
if (pixelBuiltins.glFragCoord.enabled) if (pixelBuiltins.glFragCoord.enabled)
......
...@@ -558,6 +558,9 @@ TEST_F(WEBGLMultiviewVertexShaderOutputCodeTest, ViewIDAndInstanceIDHaveCorrectV ...@@ -558,6 +558,9 @@ TEST_F(WEBGLMultiviewVertexShaderOutputCodeTest, ViewIDAndInstanceIDHaveCorrectV
EXPECT_TRUE(foundInAllGLSLCode("InstanceID = int((uint(gl_InstanceID) / 3u))")); EXPECT_TRUE(foundInAllGLSLCode("InstanceID = int((uint(gl_InstanceID) / 3u))"));
EXPECT_TRUE(foundInHLSLCode("ViewID_OVR = (uint_ctor(gl_InstanceID) % 3)")); EXPECT_TRUE(foundInHLSLCode("ViewID_OVR = (uint_ctor(gl_InstanceID) % 3)"));
#if defined(ANGLE_ENABLE_HLSL)
EXPECT_FALSE(foundInHLSLCode("_ViewID_OVR = (uint_ctor(gl_InstanceID) % 3)"));
#endif
EXPECT_TRUE(foundInHLSLCode("InstanceID = int_ctor((uint_ctor(gl_InstanceID) / 3))")); EXPECT_TRUE(foundInHLSLCode("InstanceID = int_ctor((uint_ctor(gl_InstanceID) / 3))"));
} }
......
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