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

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

Issue 895933004: Add UniformBlocks related commands to command buffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@uniform
Patch Set: Working Created 5 years, 10 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
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 "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <GLES2/gl2ext.h> 9 #include <GLES2/gl2ext.h>
10 #include <GLES2/gl2extchromium.h> 10 #include <GLES2/gl2extchromium.h>
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetFragDataLocation(" 1093 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetFragDataLocation("
1094 << program << ", " << name << ")"); 1094 << program << ", " << name << ")");
1095 TRACE_EVENT0("gpu", "GLES2::GetFragDataLocation"); 1095 TRACE_EVENT0("gpu", "GLES2::GetFragDataLocation");
1096 GLint loc = share_group_->program_info_manager()->GetFragDataLocation( 1096 GLint loc = share_group_->program_info_manager()->GetFragDataLocation(
1097 this, program, name); 1097 this, program, name);
1098 GPU_CLIENT_LOG("returned " << loc); 1098 GPU_CLIENT_LOG("returned " << loc);
1099 CheckGLError(); 1099 CheckGLError();
1100 return loc; 1100 return loc;
1101 } 1101 }
1102 1102
1103 GLuint GLES2Implementation::GetUniformBlockIndexHelper(
1104 GLuint program, const char* name) {
1105 typedef cmds::GetUniformBlockIndex::Result Result;
1106 Result* result = GetResultAs<Result*>();
1107 if (!result) {
1108 return GL_INVALID_INDEX;
1109 }
1110 *result = GL_INVALID_INDEX;
1111 SetBucketAsCString(kResultBucketId, name);
1112 helper_->GetUniformBlockIndex(
1113 program, kResultBucketId, GetResultShmId(), GetResultShmOffset());
1114 WaitForCmd();
1115 helper_->SetBucketSize(kResultBucketId, 0);
1116 return *result;
1117 }
1118
1119 GLuint GLES2Implementation::GetUniformBlockIndex(
1120 GLuint program, const char* name) {
1121 GPU_CLIENT_SINGLE_THREAD_CHECK();
1122 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetUniformBlockIndex("
1123 << program << ", " << name << ")");
1124 TRACE_EVENT0("gpu", "GLES2::GetUniformBlockIndex");
1125 GLuint index = share_group_->program_info_manager()->GetUniformBlockIndex(
1126 this, program, name);
1127 GPU_CLIENT_LOG("returned " << index);
1128 CheckGLError();
1129 return index;
1130 }
1131
1103 void GLES2Implementation::LinkProgram(GLuint program) { 1132 void GLES2Implementation::LinkProgram(GLuint program) {
1104 GPU_CLIENT_SINGLE_THREAD_CHECK(); 1133 GPU_CLIENT_SINGLE_THREAD_CHECK();
1105 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glLinkProgram(" << program << ")"); 1134 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glLinkProgram(" << program << ")");
1106 helper_->LinkProgram(program); 1135 helper_->LinkProgram(program);
1107 share_group_->program_info_manager()->CreateInfo(program); 1136 share_group_->program_info_manager()->CreateInfo(program);
1108 CheckGLError(); 1137 CheckGLError();
1109 } 1138 }
1110 1139
1111 void GLES2Implementation::ShaderBinary( 1140 void GLES2Implementation::ShaderBinary(
1112 GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, 1141 GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary,
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
2274 if (type) { 2303 if (type) {
2275 GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type)); 2304 GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type));
2276 } 2305 }
2277 if (name) { 2306 if (name) {
2278 GPU_CLIENT_LOG(" name: " << name); 2307 GPU_CLIENT_LOG(" name: " << name);
2279 } 2308 }
2280 } 2309 }
2281 CheckGLError(); 2310 CheckGLError();
2282 } 2311 }
2283 2312
2313 bool GLES2Implementation::GetActiveUniformBlockNameHelper(
2314 GLuint program, GLuint index, GLsizei bufsize,
2315 GLsizei* length, char* name) {
2316 DCHECK_LE(0, bufsize);
2317 // Clear the bucket so if the command fails nothing will be in it.
2318 helper_->SetBucketSize(kResultBucketId, 0);
2319 typedef cmds::GetActiveUniformBlockName::Result Result;
2320 Result* result = GetResultAs<Result*>();
2321 if (!result) {
2322 return false;
2323 }
2324 // Set as failed so if the command fails we'll recover.
2325 *result = 0;
2326 helper_->GetActiveUniformBlockName(program, index, kResultBucketId,
2327 GetResultShmId(), GetResultShmOffset());
2328 WaitForCmd();
2329 if (*result) {
2330 if (bufsize == 0) {
2331 if (length) {
2332 *length = 0;
2333 }
2334 } else if (length || name) {
2335 std::vector<int8> str;
2336 GetBucketContents(kResultBucketId, &str);
2337 DCHECK(str.size() > 0);
2338 GLsizei max_size =
2339 std::min(bufsize, static_cast<GLsizei>(str.size())) - 1;
2340 if (length) {
2341 *length = max_size;
2342 }
2343 if (name) {
2344 memcpy(name, &str[0], max_size);
2345 name[max_size] = '\0';
2346 }
2347 }
2348 }
2349 return *result != 0;
2350 }
2351
2352 void GLES2Implementation::GetActiveUniformBlockName(
2353 GLuint program, GLuint index, GLsizei bufsize,
2354 GLsizei* length, char* name) {
2355 GPU_CLIENT_SINGLE_THREAD_CHECK();
2356 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetActiveUniformBlockName("
2357 << program << ", " << index << ", " << bufsize << ", "
2358 << static_cast<const void*>(length) << ", "
2359 << static_cast<const void*>(name) << ", ");
2360 if (bufsize < 0) {
2361 SetGLError(GL_INVALID_VALUE, "glGetActiveUniformBlockName", "bufsize < 0");
2362 return;
2363 }
2364 TRACE_EVENT0("gpu", "GLES2::GetActiveUniformBlockName");
2365 bool success =
2366 share_group_->program_info_manager()->GetActiveUniformBlockName(
2367 this, program, index, bufsize, length, name);
2368 if (success) {
2369 if (name) {
2370 GPU_CLIENT_LOG(" name: " << name);
2371 }
2372 }
2373 CheckGLError();
2374 }
2375
2284 void GLES2Implementation::GetAttachedShaders( 2376 void GLES2Implementation::GetAttachedShaders(
2285 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { 2377 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) {
2286 GPU_CLIENT_SINGLE_THREAD_CHECK(); 2378 GPU_CLIENT_SINGLE_THREAD_CHECK();
2287 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetAttachedShaders(" 2379 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetAttachedShaders("
2288 << program << ", " << maxcount << ", " 2380 << program << ", " << maxcount << ", "
2289 << static_cast<const void*>(count) << ", " 2381 << static_cast<const void*>(count) << ", "
2290 << static_cast<const void*>(shaders) << ", "); 2382 << static_cast<const void*>(shaders) << ", ");
2291 if (maxcount < 0) { 2383 if (maxcount < 0) {
2292 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders", "maxcount < 0"); 2384 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders", "maxcount < 0");
2293 return; 2385 return;
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
3508 return; 3600 return;
3509 } 3601 }
3510 if (static_cast<size_t>(bufsize) < result.size()) { 3602 if (static_cast<size_t>(bufsize) < result.size()) {
3511 SetGLError(GL_INVALID_OPERATION, 3603 SetGLError(GL_INVALID_OPERATION,
3512 "glProgramInfoCHROMIUM", "bufsize is too small for result."); 3604 "glProgramInfoCHROMIUM", "bufsize is too small for result.");
3513 return; 3605 return;
3514 } 3606 }
3515 memcpy(info, &result[0], result.size()); 3607 memcpy(info, &result[0], result.size());
3516 } 3608 }
3517 3609
3610 void GLES2Implementation::GetUniformBlocksCHROMIUMHelper(
3611 GLuint program, std::vector<int8>* result) {
3612 DCHECK(result);
3613 // Clear the bucket so if the command fails nothing will be in it.
3614 helper_->SetBucketSize(kResultBucketId, 0);
3615 helper_->GetUniformBlocksCHROMIUM(program, kResultBucketId);
3616 GetBucketContents(kResultBucketId, result);
3617 }
3618
3619 void GLES2Implementation::GetUniformBlocksCHROMIUM(
3620 GLuint program, GLsizei bufsize, GLsizei* size, void* info) {
3621 GPU_CLIENT_SINGLE_THREAD_CHECK();
3622 if (bufsize < 0) {
3623 SetGLError(
3624 GL_INVALID_VALUE, "glUniformBlocksCHROMIUM", "bufsize less than 0.");
3625 return;
3626 }
3627 if (size == NULL) {
3628 SetGLError(GL_INVALID_VALUE, "glUniformBlocksCHROMIUM", "size is null.");
3629 return;
3630 }
3631 // Make sure they've set size to 0 else the value will be undefined on
3632 // lost context.
3633 DCHECK_EQ(0, *size);
3634 std::vector<int8> result;
3635 GetUniformBlocksCHROMIUMHelper(program, &result);
3636 if (result.empty()) {
3637 return;
3638 }
3639 *size = result.size();
3640 if (!info) {
3641 return;
3642 }
3643 if (static_cast<size_t>(bufsize) < result.size()) {
3644 SetGLError(GL_INVALID_OPERATION,
3645 "glUniformBlocksCHROMIUM", "bufsize is too small for result.");
3646 return;
3647 }
3648 memcpy(info, &result[0], result.size());
3649 }
3650
3518 GLuint GLES2Implementation::CreateStreamTextureCHROMIUM(GLuint texture) { 3651 GLuint GLES2Implementation::CreateStreamTextureCHROMIUM(GLuint texture) {
3519 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3652 GPU_CLIENT_SINGLE_THREAD_CHECK();
3520 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] CreateStreamTextureCHROMIUM(" 3653 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] CreateStreamTextureCHROMIUM("
3521 << texture << ")"); 3654 << texture << ")");
3522 TRACE_EVENT0("gpu", "GLES2::CreateStreamTextureCHROMIUM"); 3655 TRACE_EVENT0("gpu", "GLES2::CreateStreamTextureCHROMIUM");
3523 helper_->CommandBufferHelper::Flush(); 3656 helper_->CommandBufferHelper::Flush();
3524 return gpu_control_->CreateStreamTexture(texture); 3657 return gpu_control_->CreateStreamTexture(texture);
3525 } 3658 }
3526 3659
3527 void GLES2Implementation::PostSubBufferCHROMIUM( 3660 void GLES2Implementation::PostSubBufferCHROMIUM(
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
4388 return false; 4521 return false;
4389 } 4522 }
4390 4523
4391 // Include the auto-generated part of this file. We split this because it means 4524 // Include the auto-generated part of this file. We split this because it means
4392 // we can easily edit the non-auto generated parts right here in this file 4525 // we can easily edit the non-auto generated parts right here in this file
4393 // instead of having to edit some template or the code generator. 4526 // instead of having to edit some template or the code generator.
4394 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 4527 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
4395 4528
4396 } // namespace gles2 4529 } // namespace gles2
4397 } // namespace gpu 4530 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.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