Commit f037cdc4 by Mohan Maiya Committed by Commit Bot

Check for precision match of uniforms only if there is static use

There are legacy apps that have uniforms declared with different precisions across shaders. There is some wiggle room in the ESSL spec to accommodate such cases as long as the uniforms are not statically used in shaders. We choose this lenient interpretation since it allows for more apps to be compatible with ANGLE. This change allows BADLANDS to progress past a black screen. Bug: angleproject:4971 Tests: angle_end2end_tests --gtest_filter=GLSLTest_ES31.UniformPrecisionMatchValidation* Change-Id: Icdd2056c8415803eb34f2840b0758e1acf53c23a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2495493 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent 23c12db2
...@@ -51,11 +51,13 @@ LinkMismatchError LinkValidateUniforms(const sh::ShaderVariable &uniform1, ...@@ -51,11 +51,13 @@ LinkMismatchError LinkValidateUniforms(const sh::ShaderVariable &uniform1,
std::string *mismatchedStructFieldName) std::string *mismatchedStructFieldName)
{ {
#if ANGLE_PROGRAM_LINK_VALIDATE_UNIFORM_PRECISION == ANGLE_ENABLED #if ANGLE_PROGRAM_LINK_VALIDATE_UNIFORM_PRECISION == ANGLE_ENABLED
const bool validatePrecision = true; const bool validatePrecisionFeature = true;
#else #else
const bool validatePrecision = false; const bool validatePrecisionFeature = false;
#endif #endif
// Validate precision match of uniforms iff they are statically used
bool validatePrecision = uniform1.staticUse && uniform2.staticUse && validatePrecisionFeature;
LinkMismatchError linkError = Program::LinkValidateVariablesBase( LinkMismatchError linkError = Program::LinkValidateVariablesBase(
uniform1, uniform2, validatePrecision, true, mismatchedStructFieldName); uniform1, uniform2, validatePrecision, true, mismatchedStructFieldName);
if (linkError != LinkMismatchError::NO_MISMATCH) if (linkError != LinkMismatchError::NO_MISMATCH)
......
...@@ -8687,6 +8687,65 @@ void main() { ...@@ -8687,6 +8687,65 @@ void main() {
GLuint program = CompileProgram(kVS, kFS); GLuint program = CompileProgram(kVS, kFS);
EXPECT_NE(0u, program); EXPECT_NE(0u, program);
} }
// Verify that precision match validation of uniforms is performed only if they are statically used
TEST_P(GLSLTest_ES31, UniformPrecisionMatchValidation)
{
// Nvidia driver bug: http://anglebug.com/5240
ANGLE_SKIP_TEST_IF(IsOpenGL() && IsWindows() && IsNVIDIA());
constexpr char kVSUnused[] = R"(#version 300 es
precision highp float;
uniform highp vec4 positionIn;
void main()
{
gl_Position = vec4(1, 0, 0, 1);
})";
constexpr char kVSStaticUse[] = R"(#version 300 es
precision highp float;
uniform highp vec4 positionIn;
void main()
{
gl_Position = positionIn;
})";
constexpr char kFSUnused[] = R"(#version 300 es
precision highp float;
uniform highp vec4 positionIn;
out vec4 my_FragColor;
void main()
{
my_FragColor = vec4(1, 0, 0, 1);
})";
constexpr char kFSStaticUse[] = R"(#version 300 es
precision highp float;
uniform mediump vec4 positionIn;
out vec4 my_FragColor;
void main()
{
my_FragColor = vec4(1, 0, 0, positionIn.z);
})";
GLuint program = 0;
program = CompileProgram(kVSUnused, kFSUnused);
EXPECT_NE(0u, program);
program = CompileProgram(kVSUnused, kFSStaticUse);
EXPECT_NE(0u, program);
program = CompileProgram(kVSStaticUse, kFSUnused);
EXPECT_NE(0u, program);
program = CompileProgram(kVSStaticUse, kFSStaticUse);
EXPECT_EQ(0u, program);
}
} // anonymous namespace } // anonymous namespace
// Use this to select which configurations (e.g. which renderer, which GLES major version) these // Use this to select which configurations (e.g. which renderer, which GLES major version) these
......
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