Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Unified Diff: gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc

Issue 1610613002: command_buffer: Fix setting samplers with bound uniforms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clarification Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/service/program_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « gpu/command_buffer/service/program_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698