Commit 82a468af by Geoff Lang Committed by Commit Bot

Don't unpack un-referenced varyings in the pixel shader.

Transform feedback varyings that were optimized out were still being unpacked causing HLSL compilation failures. This was triggering failures in the conformance2/state/gl-object-get-calls.html test. BUG=angleproject:1422 Change-Id: I297cccd5b99435dfb69a3c2b0fd3086b6ddf0b3a Reviewed-on: https://chromium-review.googlesource.com/354590Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 4b7f12b2
......@@ -720,7 +720,9 @@ bool DynamicHLSL::generateShaderLinkHLSL(const gl::ContextState &data,
ASSERT(!varying.isBuiltIn() && !varying.isStruct());
// Don't reference VS-only transform feedback varyings in the PS.
if (registerInfo.packedVarying->vertexOnly)
// TODO: Consider updating the fragment shader's varyings with a parameter signaling that a
// varying is only used in the vertex shader in MergeVaryings
if (packedVarying.vertexOnly || (!varying.staticUse && !packedVarying.isStructField()))
continue;
pixelStream << " ";
......
......@@ -707,6 +707,55 @@ TEST_P(TransformFeedbackTest, PackingBug)
ASSERT_GL_NO_ERROR();
}
// Test that transform feedback varyings that can be optimized out yet do not cause program
// compilation to fail
TEST_P(TransformFeedbackTest, OptimizedVaryings)
{
const std::string &vertexShaderSource =
"#version 300 es\n"
"in vec4 a_vertex;\n"
"in vec3 a_normal; \n"
"\n"
"uniform Transform\n"
"{\n"
" mat4 u_modelViewMatrix;\n"
" mat4 u_projectionMatrix;\n"
" mat3 u_normalMatrix;\n"
"};\n"
"\n"
"out vec3 normal;\n"
"out vec4 ecPosition;\n"
"\n"
"void main()\n"
"{\n"
" normal = normalize(u_normalMatrix * a_normal);\n"
" ecPosition = u_modelViewMatrix * a_vertex;\n"
" gl_Position = u_projectionMatrix * ecPosition;\n"
"}\n";
const std::string &fragmentShaderSource =
"#version 300 es\n"
"precision mediump float;\n"
"\n"
"in vec3 normal;\n"
"in vec4 ecPosition;\n"
"\n"
"out vec4 fragColor;\n"
"\n"
"void main()\n"
"{\n"
" fragColor = vec4(normal/2.0+vec3(0.5), 1);\n"
"}\n";
std::vector<std::string> tfVaryings;
tfVaryings.push_back("normal");
tfVaryings.push_back("ecPosition");
mProgram = CompileProgramWithTransformFeedback(vertexShaderSource, fragmentShaderSource,
tfVaryings, GL_INTERLEAVED_ATTRIBS);
ASSERT_NE(0u, mProgram);
}
class TransformFeedbackLifetimeTest : public TransformFeedbackTest
{
protected:
......
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