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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « gpu/command_buffer/service/program_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <GLES2/gl2.h> 5 #include <GLES2/gl2.h>
6 #include <GLES2/gl2ext.h> 6 #include <GLES2/gl2ext.h>
7 #include <GLES2/gl2extchromium.h> 7 #include <GLES2/gl2extchromium.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "gpu/command_buffer/tests/gl_manager.h" 10 #include "gpu/command_buffer/tests/gl_manager.h"
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError()); 354 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError());
355 glGetUniformfv(program, -1, &get_result); 355 glGetUniformfv(program, -1, &get_result);
356 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError()); 356 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError());
357 357
358 // Updating an unbound, non-existing location still causes 358 // Updating an unbound, non-existing location still causes
359 // an error. 359 // an error.
360 glUniform1f(kUnboundLocation, 0.25f); 360 glUniform1f(kUnboundLocation, 0.25f);
361 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError()); 361 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError());
362 } 362 }
363 363
364 // Test for a bug where using a sampler caused GL error if the program had
365 // uniforms that were optimized away by the driver. This was only a problem with
366 // glBindUniformLocationCHROMIUM implementation. This could be reproed by
367 // binding the sampler to a location higher than the amount of active uniforms.
368 TEST_P(BindUniformLocationTest, UseSamplerWhenUnusedUniforms) {
369 enum {
370 kTexLocation = 54
371 };
372 // clang-format off
373 static const char* vertexShaderString = SHADER(
374 void main() {
375 gl_Position = vec4(0);
376 }
377 );
378 static const char* fragmentShaderString = SHADER(
379 uniform sampler2D tex;
380 void main() {
381 gl_FragColor = texture2D(tex, vec2(1));
382 }
383 );
384 // clang-format on
385 GLuint vs = GLTestHelper::CompileShader(GL_VERTEX_SHADER, vertexShaderString);
386 GLuint fs = GLTestHelper::CompileShader(GL_FRAGMENT_SHADER,
387 fragmentShaderString);
388
389 GLuint program = glCreateProgram();
390 glBindUniformLocationCHROMIUM(program, kTexLocation, "tex");
391
392 glAttachShader(program, vs);
393 glAttachShader(program, fs);
394
395 glLinkProgram(program);
396
397 GLint linked = 0;
398 glGetProgramiv(program, GL_LINK_STATUS, &linked);
399 EXPECT_NE(0, linked);
400 glUseProgram(program);
401 glUniform1i(kTexLocation, 0);
402 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
403 }
404
364 INSTANTIATE_TEST_CASE_P(WithAndWithoutShaderNameMapping, 405 INSTANTIATE_TEST_CASE_P(WithAndWithoutShaderNameMapping,
365 BindUniformLocationTest, 406 BindUniformLocationTest,
366 ::testing::Bool()); 407 ::testing::Bool());
367 408
368 } // namespace gpu 409 } // namespace gpu
369 410
370 411
371 412
OLDNEW
« 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