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

Side by Side Diff: gpu/command_buffer/client/gles2_implementation.cc

Issue 10581029: Make GL_CHROMIUM_consistent_uniform_locations slighty more robust (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
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 // A class to emulate GLES2 over command buffers. 5 // A class to emulate GLES2 over command buffers.
6 6
7 #include "../client/gles2_implementation.h" 7 #include "../client/gles2_implementation.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 3277 matching lines...) Expand 10 before | Expand all | Expand 10 after
3288 } 3288 }
3289 3289
3290 bool operator()(const GLint lhs, const GLint rhs) const { 3290 bool operator()(const GLint lhs, const GLint rhs) const {
3291 return strcmp(uniforms_[lhs].name, uniforms_[rhs].name) < 0; 3291 return strcmp(uniforms_[lhs].name, uniforms_[rhs].name) < 0;
3292 } 3292 }
3293 3293
3294 private: 3294 private:
3295 const GLUniformDefinitionCHROMIUM* uniforms_; 3295 const GLUniformDefinitionCHROMIUM* uniforms_;
3296 }; 3296 };
3297 3297
3298
3299
3298 } // anonymous namespace. 3300 } // anonymous namespace.
3299 3301
3300 void GLES2Implementation::GetUniformLocationsCHROMIUM( 3302 void GLES2Implementation::GetUniformLocationsCHROMIUM(
3303 GLuint program,
3301 const GLUniformDefinitionCHROMIUM* uniforms, 3304 const GLUniformDefinitionCHROMIUM* uniforms,
3302 GLsizei count, 3305 GLsizei count,
3303 GLsizei max_locations, 3306 GLsizei max_locations,
3304 GLint* locations) { 3307 GLint* locations) {
3308 (void)program; // To keep the compiler happy as it's unused in release.
3309
3305 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3310 GPU_CLIENT_SINGLE_THREAD_CHECK();
3306 GPU_CLIENT_LOG("[" << this << "] glGenUniformLocationsCHROMIUM(" 3311 GPU_CLIENT_LOG("[" << this << "] glGenUniformLocationsCHROMIUM("
3307 << static_cast<const void*>(uniforms) << ", " << count << ", " 3312 << static_cast<const void*>(uniforms) << ", " << count << ", "
3308 << max_locations << ", " << static_cast<const void*>(locations) << ")"); 3313 << max_locations << ", " << static_cast<const void*>(locations) << ")");
3309 3314
3310 if (count <= 0) { 3315 if (count <= 0) {
3311 SetGLError(GL_INVALID_VALUE, "glGetUniformLocationsCHROMIUM", "count <= 0"); 3316 SetGLError(GL_INVALID_VALUE, "glGetUniformLocationsCHROMIUM", "count <= 0");
3312 return; 3317 return;
3313 } 3318 }
3314 3319
(...skipping 20 matching lines...) Expand all
3335 reverse_map[indices[ii]] = ii; 3340 reverse_map[indices[ii]] = ii;
3336 } 3341 }
3337 3342
3338 for (GLsizei ii = 0; ii < count; ++ii) { 3343 for (GLsizei ii = 0; ii < count; ++ii) {
3339 const GLUniformDefinitionCHROMIUM& def = uniforms[ii]; 3344 const GLUniformDefinitionCHROMIUM& def = uniforms[ii];
3340 GLint base_location = reverse_map[ii]; 3345 GLint base_location = reverse_map[ii];
3341 for (GLsizei jj = 0; jj < def.size; ++jj) { 3346 for (GLsizei jj = 0; jj < def.size; ++jj) {
3342 if (max_locations <= 0) { 3347 if (max_locations <= 0) {
3343 return; 3348 return;
3344 } 3349 }
3345 *locations++ = GLES2Util::SwizzleLocation( 3350 GLint location = GLES2Util::SwizzleLocation(
3346 GLES2Util::MakeFakeLocation(base_location, jj)); 3351 GLES2Util::MakeFakeLocation(base_location, jj));
3352 *locations++ = location;
3353 #if defined(GPU_CLIENT_DEBUG)
3354 std::string name(def.name);
3355 if (jj > 0) {
3356 char buf[20];
3357 sprintf(buf, "%d", jj);
3358 name = name + "[" + buf + "]";
3359 }
3360 GPU_DCHECK_EQ(
3361 location,
3362 share_group_->program_info_manager()->GetUniformLocation(
3363 this, program, name.c_str()));
3364 #endif
3347 --max_locations; 3365 --max_locations;
3366
3348 } 3367 }
3349 } 3368 }
3350 } 3369 }
3351 3370
3352 } // namespace gles2 3371 } // namespace gles2
3353 } // namespace gpu 3372 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_c_lib_autogen.h ('k') | gpu/command_buffer/client/gles2_implementation_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698