Commit 6ee26d7a by Olli Etuaho Committed by Commit Bot

Fix linking of non-existent XFB varyings with gl_ prefix

Non-existent XFB varyings with the gl_ prefix used to pass linking on the D3D11 backend. On a debug build they would cause an assert. Fix these issues. BUG=angleproject:2141 TEST=angle_end2end_tests Change-Id: Iecc3d03823d02700d6b28c44d77df7a2f9e70a5b Reviewed-on: https://chromium-review.googlesource.com/645747Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent c634a637
......@@ -259,39 +259,35 @@ bool VaryingPacking::packUserVaryings(gl::InfoLog &infoLog,
}
}
// Make sure transform feedback varyings aren't optimized out.
for (const std::string &transformFeedbackVaryingName : transformFeedbackVaryings)
{
if (transformFeedbackVaryingName.compare(0, 3, "gl_") == 0)
{
// do not pack builtin XFB varyings
continue;
}
size_t subscript = GL_INVALID_INDEX;
std::string tfVaryingBaseName = ParseResourceName(transformFeedbackVaryingName, &subscript);
bool found = false;
for (const PackedVarying &packedVarying : packedVaryings)
{
const auto &varying = *packedVarying.varying;
size_t subscript = GL_INVALID_INDEX;
std::string baseName = ParseResourceName(transformFeedbackVaryingName, &subscript);
bool found = (uniqueVaryingNames.count(transformFeedbackVaryingName) > 0 ||
uniqueVaryingNames.count(tfVaryingBaseName) > 0);
// Make sure transform feedback varyings aren't optimized out.
if (uniqueVaryingNames.count(transformFeedbackVaryingName) > 0 ||
uniqueVaryingNames.count(baseName) > 0)
{
found = true;
break;
}
if (baseName == varying.name)
if (!found)
{
for (const PackedVarying &packedVarying : packedVaryings)
{
if (!packVarying(packedVarying))
const auto &varying = *packedVarying.varying;
if (tfVaryingBaseName == varying.name)
{
infoLog << "Could not pack varying " << varying.name;
return false;
// only pack varyings that are not builtins.
if (transformFeedbackVaryingName.compare(0, 3, "gl_") != 0)
{
if (!packVarying(packedVarying))
{
infoLog << "Could not pack varying " << varying.name;
return false;
}
uniqueVaryingNames.insert(packedVarying.nameWithArrayIndex());
}
found = true;
break;
}
uniqueVaryingNames.insert(packedVarying.nameWithArrayIndex());
found = true;
break;
}
}
......
......@@ -1213,21 +1213,18 @@ TEST_P(TransformFeedbackTest, NonExistentTransformFeedbackVarying)
const std::string &vertexShaderSource =
"#version 300 es\n"
"in vec4 a_position;\n"
"out vec4 v_position;\n"
"void main()\n"
"{\n"
" v_position = a_position;\n"
" gl_Position = a_position;\n"
"}\n";
const std::string &fragmentShaderSource =
"#version 300 es\n"
"precision mediump float;\n"
"in vec4 v_position;\n"
"out vec4 fragColor;\n"
"void main()\n"
"{\n"
" fragColor = v_position;\n"
" fragColor = vec4(0);\n"
"}\n";
std::vector<std::string> tfVaryings;
......@@ -1238,6 +1235,35 @@ TEST_P(TransformFeedbackTest, NonExistentTransformFeedbackVarying)
ASSERT_EQ(0u, mProgram);
}
// Test that nonexistent transform feedback varyings don't assert when linking. In this test the
// nonexistent varying is prefixed with "gl_".
TEST_P(TransformFeedbackTest, NonExistentTransformFeedbackVaryingWithGLPrefix)
{
const std::string &vertexShaderSource =
"#version 300 es\n"
"in vec4 a_position;\n"
"void main()\n"
"{\n"
" gl_Position = a_position;\n"
"}\n";
const std::string &fragmentShaderSource =
"#version 300 es\n"
"precision mediump float;\n"
"out vec4 fragColor;\n"
"void main()\n"
"{\n"
" fragColor = vec4(0);\n"
"}\n";
std::vector<std::string> tfVaryings;
tfVaryings.push_back("gl_Bogus");
mProgram = CompileProgramWithTransformFeedback(vertexShaderSource, fragmentShaderSource,
tfVaryings, GL_INTERLEAVED_ATTRIBS);
ASSERT_EQ(0u, mProgram);
}
// Test transform feedback names can be reserved names in GLSL, as long as they're not reserved in
// GLSL ES.
TEST_P(TransformFeedbackTest, VaryingReservedOpenGLName)
......
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