Index: gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc |
diff --git a/gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc b/gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc |
index 3afb5f716ad1e0133f42562ba5f64116af8511dc..8856500348f0dca67f3b8cffb7257480e8111999 100644 |
--- a/gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc |
+++ b/gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc |
@@ -361,6 +361,47 @@ TEST_P(BindUniformLocationTest, UnusedUniformUpdate) { |
EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError()); |
} |
+// Test for a bug where using a sampler caused GL error if the program had |
+// uniforms that were optimized away by the driver. This was only a problem with |
+// glBindUniformLocationCHROMIUM implementation. This could be reproed by |
+// binding the sampler to a location higher than the amount of active uniforms. |
+TEST_P(BindUniformLocationTest, UseSamplerWhenUnusedUniforms) { |
+ enum { |
+ kTexLocation = 54 |
+ }; |
+ // clang-format off |
+ static const char* vertexShaderString = SHADER( |
+ void main() { |
+ gl_Position = vec4(0); |
+ } |
+ ); |
+ static const char* fragmentShaderString = SHADER( |
+ uniform sampler2D tex; |
+ void main() { |
+ gl_FragColor = texture2D(tex, vec2(1)); |
+ } |
+ ); |
+ // clang-format on |
+ GLuint vs = GLTestHelper::CompileShader(GL_VERTEX_SHADER, vertexShaderString); |
+ GLuint fs = GLTestHelper::CompileShader(GL_FRAGMENT_SHADER, |
+ fragmentShaderString); |
+ |
+ GLuint program = glCreateProgram(); |
+ glBindUniformLocationCHROMIUM(program, kTexLocation, "tex"); |
+ |
+ glAttachShader(program, vs); |
+ glAttachShader(program, fs); |
+ |
+ glLinkProgram(program); |
+ |
+ GLint linked = 0; |
+ glGetProgramiv(program, GL_LINK_STATUS, &linked); |
+ EXPECT_NE(0, linked); |
+ glUseProgram(program); |
+ glUniform1i(kTexLocation, 0); |
+ EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
+} |
+ |
INSTANTIATE_TEST_CASE_P(WithAndWithoutShaderNameMapping, |
BindUniformLocationTest, |
::testing::Bool()); |