Commit 92e4e079 by Olli Etuaho Committed by Commit Bot

Test shader builtin accessibility from different stages

Test that fragment, vertex or compute shader exclusive builtins are not accessible from another shader stage. This will protect against regressions when refactoring the symbol table. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I50f97cbde3f1c5cb4584568e3008f1dab724b769 Reviewed-on: https://chromium-review.googlesource.com/941953 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent ff32734d
...@@ -5782,3 +5782,58 @@ TEST_F(FragmentShaderValidationTest, ESSL300StandardDerivatives) ...@@ -5782,3 +5782,58 @@ TEST_F(FragmentShaderValidationTest, ESSL300StandardDerivatives)
FAIL() << "Shader compilation failed, expecting success:\n" << mInfoLog; FAIL() << "Shader compilation failed, expecting success:\n" << mInfoLog;
} }
} }
// Test that vertex shader built-in gl_Position is not accessible in fragment shader.
TEST_F(FragmentShaderValidationTest, GlPosition)
{
const std::string &shaderString =
R"(#version 300 es
precision mediump float;
in vec4 iv;
out vec4 my_FragColor;
void main()
{
gl_Position = iv;
my_FragColor = iv;
})";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog;
}
}
// Test that compute shader built-in gl_LocalInvocationID is not accessible in fragment shader.
TEST_F(FragmentShaderValidationTest, GlLocalInvocationID)
{
const std::string &shaderString =
R"(#version 310 es
precision mediump float;
out vec3 my_FragColor;
void main()
{
my_FragColor = vec3(gl_LocalInvocationID);
})";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog;
}
}
// Test that fragment shader built-in gl_FragCoord is not accessible in vertex shader.
TEST_F(VertexShaderValidationTest, GlFragCoord)
{
const std::string &shaderString =
R"(#version 300 es
precision mediump float;
void main()
{
gl_Position = vec4(gl_FragCoord);
})";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog;
}
}
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