OLD | NEW |
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 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetUniformLocation(" << program | 1059 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetUniformLocation(" << program |
1060 << ", " << name << ")"); | 1060 << ", " << name << ")"); |
1061 TRACE_EVENT0("gpu", "GLES2::GetUniformLocation"); | 1061 TRACE_EVENT0("gpu", "GLES2::GetUniformLocation"); |
1062 GLint loc = share_group_->program_info_manager()->GetUniformLocation( | 1062 GLint loc = share_group_->program_info_manager()->GetUniformLocation( |
1063 this, program, name); | 1063 this, program, name); |
1064 GPU_CLIENT_LOG("returned " << loc); | 1064 GPU_CLIENT_LOG("returned " << loc); |
1065 CheckGLError(); | 1065 CheckGLError(); |
1066 return loc; | 1066 return loc; |
1067 } | 1067 } |
1068 | 1068 |
| 1069 bool GLES2Implementation::GetUniformIndicesHelper( |
| 1070 GLuint program, GLsizei count, const char* const* names, GLuint* indices) { |
| 1071 typedef cmds::GetUniformIndices::Result Result; |
| 1072 Result* result = GetResultAs<Result*>(); |
| 1073 if (!result) { |
| 1074 return false; |
| 1075 } |
| 1076 result->SetNumResults(0); |
| 1077 if (!PackStringsToBucket(count, names, NULL, "glGetUniformIndices")) { |
| 1078 return false; |
| 1079 } |
| 1080 helper_->GetUniformIndices(program, kResultBucketId, |
| 1081 GetResultShmId(), GetResultShmOffset()); |
| 1082 WaitForCmd(); |
| 1083 if (result->GetNumResults() != count) { |
| 1084 return false; |
| 1085 } |
| 1086 result->CopyResult(indices); |
| 1087 return true; |
| 1088 } |
| 1089 |
| 1090 void GLES2Implementation::GetUniformIndices( |
| 1091 GLuint program, GLsizei count, const char* const* names, GLuint* indices) { |
| 1092 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1093 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetUniformIndices(" << program |
| 1094 << ", " << count << ", " << names << ", " << indices << ")"); |
| 1095 TRACE_EVENT0("gpu", "GLES2::GetUniformIndices"); |
| 1096 if (count < 0) { |
| 1097 SetGLError(GL_INVALID_VALUE, "glGetUniformIndices", "count < 0"); |
| 1098 return; |
| 1099 } |
| 1100 if (count == 0) { |
| 1101 return; |
| 1102 } |
| 1103 bool success = share_group_->program_info_manager()->GetUniformIndices( |
| 1104 this, program, count, names, indices); |
| 1105 if (success) { |
| 1106 GPU_CLIENT_LOG_CODE_BLOCK({ |
| 1107 for (GLsizei ii = 0; ii < count; ++ii) { |
| 1108 GPU_CLIENT_LOG(" " << ii << ": " << indices[ii]); |
| 1109 } |
| 1110 }); |
| 1111 } |
| 1112 CheckGLError(); |
| 1113 } |
| 1114 |
1069 bool GLES2Implementation::GetProgramivHelper( | 1115 bool GLES2Implementation::GetProgramivHelper( |
1070 GLuint program, GLenum pname, GLint* params) { | 1116 GLuint program, GLenum pname, GLint* params) { |
1071 bool got_value = share_group_->program_info_manager()->GetProgramiv( | 1117 bool got_value = share_group_->program_info_manager()->GetProgramiv( |
1072 this, program, pname, params); | 1118 this, program, pname, params); |
1073 GPU_CLIENT_LOG_CODE_BLOCK({ | 1119 GPU_CLIENT_LOG_CODE_BLOCK({ |
1074 if (got_value) { | 1120 if (got_value) { |
1075 GPU_CLIENT_LOG(" 0: " << *params); | 1121 GPU_CLIENT_LOG(" 0: " << *params); |
1076 } | 1122 } |
1077 }); | 1123 }); |
1078 return got_value; | 1124 return got_value; |
(...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2356 return *result != 0; | 2402 return *result != 0; |
2357 } | 2403 } |
2358 | 2404 |
2359 void GLES2Implementation::GetActiveUniformBlockName( | 2405 void GLES2Implementation::GetActiveUniformBlockName( |
2360 GLuint program, GLuint index, GLsizei bufsize, | 2406 GLuint program, GLuint index, GLsizei bufsize, |
2361 GLsizei* length, char* name) { | 2407 GLsizei* length, char* name) { |
2362 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 2408 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
2363 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetActiveUniformBlockName(" | 2409 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetActiveUniformBlockName(" |
2364 << program << ", " << index << ", " << bufsize << ", " | 2410 << program << ", " << index << ", " << bufsize << ", " |
2365 << static_cast<const void*>(length) << ", " | 2411 << static_cast<const void*>(length) << ", " |
2366 << static_cast<const void*>(name) << ", "); | 2412 << static_cast<const void*>(name) << ")"); |
2367 if (bufsize < 0) { | 2413 if (bufsize < 0) { |
2368 SetGLError(GL_INVALID_VALUE, "glGetActiveUniformBlockName", "bufsize < 0"); | 2414 SetGLError(GL_INVALID_VALUE, "glGetActiveUniformBlockName", "bufsize < 0"); |
2369 return; | 2415 return; |
2370 } | 2416 } |
2371 TRACE_EVENT0("gpu", "GLES2::GetActiveUniformBlockName"); | 2417 TRACE_EVENT0("gpu", "GLES2::GetActiveUniformBlockName"); |
2372 bool success = | 2418 bool success = |
2373 share_group_->program_info_manager()->GetActiveUniformBlockName( | 2419 share_group_->program_info_manager()->GetActiveUniformBlockName( |
2374 this, program, index, bufsize, length, name); | 2420 this, program, index, bufsize, length, name); |
2375 if (success) { | 2421 if (success) { |
2376 if (name) { | 2422 if (name) { |
2377 GPU_CLIENT_LOG(" name: " << name); | 2423 GPU_CLIENT_LOG(" name: " << name); |
2378 } | 2424 } |
2379 } | 2425 } |
2380 CheckGLError(); | 2426 CheckGLError(); |
2381 } | 2427 } |
2382 | 2428 |
| 2429 bool GLES2Implementation::GetActiveUniformBlockivHelper( |
| 2430 GLuint program, GLuint index, GLenum pname, GLint* params) { |
| 2431 typedef cmds::GetActiveUniformBlockiv::Result Result; |
| 2432 Result* result = GetResultAs<Result*>(); |
| 2433 if (!result) { |
| 2434 return false; |
| 2435 } |
| 2436 result->SetNumResults(0); |
| 2437 helper_->GetActiveUniformBlockiv( |
| 2438 program, index, pname, GetResultShmId(), GetResultShmOffset()); |
| 2439 WaitForCmd(); |
| 2440 if (result->GetNumResults() > 0) { |
| 2441 if (params) { |
| 2442 result->CopyResult(params); |
| 2443 } |
| 2444 GPU_CLIENT_LOG_CODE_BLOCK({ |
| 2445 for (int32_t i = 0; i < result->GetNumResults(); ++i) { |
| 2446 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); |
| 2447 } |
| 2448 }); |
| 2449 return true; |
| 2450 } |
| 2451 return false; |
| 2452 } |
| 2453 |
| 2454 void GLES2Implementation::GetActiveUniformBlockiv( |
| 2455 GLuint program, GLuint index, GLenum pname, GLint* params) { |
| 2456 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2457 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetActiveUniformBlockiv(" |
| 2458 << program << ", " << index << ", " |
| 2459 << GLES2Util::GetStringUniformBlockParameter(pname) << ", " |
| 2460 << static_cast<const void*>(params) << ")"); |
| 2461 TRACE_EVENT0("gpu", "GLES2::GetActiveUniformBlockiv"); |
| 2462 bool success = |
| 2463 share_group_->program_info_manager()->GetActiveUniformBlockiv( |
| 2464 this, program, index, pname, params); |
| 2465 if (success) { |
| 2466 if (params) { |
| 2467 // TODO(zmo): For GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, there will |
| 2468 // be more than one value returned in params. |
| 2469 GPU_CLIENT_LOG(" params: " << params[0]); |
| 2470 } |
| 2471 } |
| 2472 CheckGLError(); |
| 2473 } |
| 2474 |
| 2475 bool GLES2Implementation::GetActiveUniformsivHelper( |
| 2476 GLuint program, GLsizei count, const GLuint* indices, |
| 2477 GLenum pname, GLint* params) { |
| 2478 typedef cmds::GetActiveUniformsiv::Result Result; |
| 2479 Result* result = GetResultAs<Result*>(); |
| 2480 if (!result) { |
| 2481 return false; |
| 2482 } |
| 2483 result->SetNumResults(0); |
| 2484 base::CheckedNumeric<size_t> bytes = static_cast<size_t>(count); |
| 2485 bytes *= sizeof(GLuint); |
| 2486 if (!bytes.IsValid()) { |
| 2487 SetGLError(GL_INVALID_VALUE, "glGetActiveUniformsiv", "count overflow"); |
| 2488 return false; |
| 2489 } |
| 2490 SetBucketContents(kResultBucketId, indices, bytes.ValueOrDefault(0)); |
| 2491 helper_->GetActiveUniformsiv( |
| 2492 program, kResultBucketId, pname, GetResultShmId(), GetResultShmOffset()); |
| 2493 WaitForCmd(); |
| 2494 bool success = result->GetNumResults() == count; |
| 2495 if (success) { |
| 2496 if (params) { |
| 2497 result->CopyResult(params); |
| 2498 } |
| 2499 GPU_CLIENT_LOG_CODE_BLOCK({ |
| 2500 for (int32_t i = 0; i < result->GetNumResults(); ++i) { |
| 2501 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); |
| 2502 } |
| 2503 }); |
| 2504 } |
| 2505 helper_->SetBucketSize(kResultBucketId, 0); |
| 2506 return success; |
| 2507 } |
| 2508 |
| 2509 void GLES2Implementation::GetActiveUniformsiv( |
| 2510 GLuint program, GLsizei count, const GLuint* indices, |
| 2511 GLenum pname, GLint* params) { |
| 2512 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2513 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetActiveUniformsiv(" |
| 2514 << program << ", " << count << ", " |
| 2515 << static_cast<const void*>(indices) << ", " |
| 2516 << GLES2Util::GetStringUniformParameter(pname) << ", " |
| 2517 << static_cast<const void*>(params) << ")"); |
| 2518 TRACE_EVENT0("gpu", "GLES2::GetActiveUniformsiv"); |
| 2519 if (count < 0) { |
| 2520 SetGLError(GL_INVALID_VALUE, "glGetActiveUniformsiv", "count < 0"); |
| 2521 return; |
| 2522 } |
| 2523 bool success = share_group_->program_info_manager()->GetActiveUniformsiv( |
| 2524 this, program, count, indices, pname, params); |
| 2525 if (success) { |
| 2526 if (params) { |
| 2527 GPU_CLIENT_LOG_CODE_BLOCK({ |
| 2528 for (GLsizei ii = 0; ii < count; ++ii) { |
| 2529 GPU_CLIENT_LOG(" " << ii << ": " << params[ii]); |
| 2530 } |
| 2531 }); |
| 2532 } |
| 2533 } |
| 2534 CheckGLError(); |
| 2535 } |
| 2536 |
2383 void GLES2Implementation::GetAttachedShaders( | 2537 void GLES2Implementation::GetAttachedShaders( |
2384 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { | 2538 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { |
2385 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 2539 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
2386 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetAttachedShaders(" | 2540 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetAttachedShaders(" |
2387 << program << ", " << maxcount << ", " | 2541 << program << ", " << maxcount << ", " |
2388 << static_cast<const void*>(count) << ", " | 2542 << static_cast<const void*>(count) << ", " |
2389 << static_cast<const void*>(shaders) << ", "); | 2543 << static_cast<const void*>(shaders) << ", "); |
2390 if (maxcount < 0) { | 2544 if (maxcount < 0) { |
2391 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders", "maxcount < 0"); | 2545 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders", "maxcount < 0"); |
2392 return; | 2546 return; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2515 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 2669 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
2516 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetString(" | 2670 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetString(" |
2517 << GLES2Util::GetStringStringType(name) << ")"); | 2671 << GLES2Util::GetStringStringType(name) << ")"); |
2518 TRACE_EVENT0("gpu", "GLES2::GetString"); | 2672 TRACE_EVENT0("gpu", "GLES2::GetString"); |
2519 const GLubyte* result = GetStringHelper(name); | 2673 const GLubyte* result = GetStringHelper(name); |
2520 GPU_CLIENT_LOG(" returned " << reinterpret_cast<const char*>(result)); | 2674 GPU_CLIENT_LOG(" returned " << reinterpret_cast<const char*>(result)); |
2521 CheckGLError(); | 2675 CheckGLError(); |
2522 return result; | 2676 return result; |
2523 } | 2677 } |
2524 | 2678 |
| 2679 bool GLES2Implementation::GetTransformFeedbackVaryingHelper( |
| 2680 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, |
| 2681 GLenum* type, char* name) { |
| 2682 // Clear the bucket so if the command fails nothing will be in it. |
| 2683 helper_->SetBucketSize(kResultBucketId, 0); |
| 2684 typedef cmds::GetTransformFeedbackVarying::Result Result; |
| 2685 Result* result = GetResultAs<Result*>(); |
| 2686 if (!result) { |
| 2687 return false; |
| 2688 } |
| 2689 // Set as failed so if the command fails we'll recover. |
| 2690 result->success = false; |
| 2691 helper_->GetTransformFeedbackVarying( |
| 2692 program, index, kResultBucketId, GetResultShmId(), GetResultShmOffset()); |
| 2693 WaitForCmd(); |
| 2694 if (result->success) { |
| 2695 if (size) { |
| 2696 *size = result->size; |
| 2697 } |
| 2698 if (type) { |
| 2699 *type = result->type; |
| 2700 } |
| 2701 if (length || name) { |
| 2702 std::vector<int8> str; |
| 2703 GetBucketContents(kResultBucketId, &str); |
| 2704 GLsizei max_size = std::min(bufsize, static_cast<GLsizei>(str.size())); |
| 2705 if (max_size > 0) { |
| 2706 --max_size; |
| 2707 } |
| 2708 if (length) { |
| 2709 *length = max_size; |
| 2710 } |
| 2711 if (name) { |
| 2712 if (max_size > 0) { |
| 2713 memcpy(name, &str[0], max_size); |
| 2714 name[max_size] = '\0'; |
| 2715 } else if (bufsize > 0) { |
| 2716 name[0] = '\0'; |
| 2717 } |
| 2718 } |
| 2719 } |
| 2720 } |
| 2721 return result->success != 0; |
| 2722 } |
| 2723 |
| 2724 void GLES2Implementation::GetTransformFeedbackVarying( |
| 2725 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, |
| 2726 GLenum* type, char* name) { |
| 2727 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2728 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetTransformFeedbackVarying(" |
| 2729 << program << ", " << index << ", " << bufsize << ", " |
| 2730 << static_cast<const void*>(length) << ", " |
| 2731 << static_cast<const void*>(size) << ", " |
| 2732 << static_cast<const void*>(type) << ", " |
| 2733 << static_cast<const void*>(name) << ", "); |
| 2734 if (bufsize < 0) { |
| 2735 SetGLError(GL_INVALID_VALUE, "glGetTransformFeedbackVarying", |
| 2736 "bufsize < 0"); |
| 2737 return; |
| 2738 } |
| 2739 TRACE_EVENT0("gpu", "GLES2::GetTransformFeedbackVarying"); |
| 2740 bool success = |
| 2741 share_group_->program_info_manager()->GetTransformFeedbackVarying( |
| 2742 this, program, index, bufsize, length, size, type, name); |
| 2743 if (success) { |
| 2744 if (size) { |
| 2745 GPU_CLIENT_LOG(" size: " << *size); |
| 2746 } |
| 2747 if (type) { |
| 2748 GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type)); |
| 2749 } |
| 2750 if (name) { |
| 2751 GPU_CLIENT_LOG(" name: " << name); |
| 2752 } |
| 2753 } |
| 2754 CheckGLError(); |
| 2755 } |
| 2756 |
2525 void GLES2Implementation::GetUniformfv( | 2757 void GLES2Implementation::GetUniformfv( |
2526 GLuint program, GLint location, GLfloat* params) { | 2758 GLuint program, GLint location, GLfloat* params) { |
2527 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 2759 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
2528 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetUniformfv(" | 2760 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetUniformfv(" |
2529 << program << ", " << location << ", " | 2761 << program << ", " << location << ", " |
2530 << static_cast<const void*>(params) << ")"); | 2762 << static_cast<const void*>(params) << ")"); |
2531 TRACE_EVENT0("gpu", "GLES2::GetUniformfv"); | 2763 TRACE_EVENT0("gpu", "GLES2::GetUniformfv"); |
2532 typedef cmds::GetUniformfv::Result Result; | 2764 typedef cmds::GetUniformfv::Result Result; |
2533 Result* result = GetResultAs<Result*>(); | 2765 Result* result = GetResultAs<Result*>(); |
2534 if (!result) { | 2766 if (!result) { |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3621 helper_->SetBucketSize(kResultBucketId, 0); | 3853 helper_->SetBucketSize(kResultBucketId, 0); |
3622 helper_->GetUniformBlocksCHROMIUM(program, kResultBucketId); | 3854 helper_->GetUniformBlocksCHROMIUM(program, kResultBucketId); |
3623 GetBucketContents(kResultBucketId, result); | 3855 GetBucketContents(kResultBucketId, result); |
3624 } | 3856 } |
3625 | 3857 |
3626 void GLES2Implementation::GetUniformBlocksCHROMIUM( | 3858 void GLES2Implementation::GetUniformBlocksCHROMIUM( |
3627 GLuint program, GLsizei bufsize, GLsizei* size, void* info) { | 3859 GLuint program, GLsizei bufsize, GLsizei* size, void* info) { |
3628 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 3860 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
3629 if (bufsize < 0) { | 3861 if (bufsize < 0) { |
3630 SetGLError( | 3862 SetGLError( |
3631 GL_INVALID_VALUE, "glUniformBlocksCHROMIUM", "bufsize less than 0."); | 3863 GL_INVALID_VALUE, "glGetUniformBlocksCHROMIUM", "bufsize less than 0."); |
3632 return; | 3864 return; |
3633 } | 3865 } |
3634 if (size == NULL) { | 3866 if (size == NULL) { |
3635 SetGLError(GL_INVALID_VALUE, "glUniformBlocksCHROMIUM", "size is null."); | 3867 SetGLError(GL_INVALID_VALUE, "glGetUniformBlocksCHROMIUM", "size is null."); |
3636 return; | 3868 return; |
3637 } | 3869 } |
3638 // Make sure they've set size to 0 else the value will be undefined on | 3870 // Make sure they've set size to 0 else the value will be undefined on |
3639 // lost context. | 3871 // lost context. |
3640 DCHECK_EQ(0, *size); | 3872 DCHECK_EQ(0, *size); |
3641 std::vector<int8> result; | 3873 std::vector<int8> result; |
3642 GetUniformBlocksCHROMIUMHelper(program, &result); | 3874 GetUniformBlocksCHROMIUMHelper(program, &result); |
3643 if (result.empty()) { | 3875 if (result.empty()) { |
3644 return; | 3876 return; |
3645 } | 3877 } |
3646 *size = result.size(); | 3878 *size = result.size(); |
3647 if (!info) { | 3879 if (!info) { |
3648 return; | 3880 return; |
3649 } | 3881 } |
3650 if (static_cast<size_t>(bufsize) < result.size()) { | 3882 if (static_cast<size_t>(bufsize) < result.size()) { |
| 3883 SetGLError(GL_INVALID_OPERATION, "glGetUniformBlocksCHROMIUM", |
| 3884 "bufsize is too small for result."); |
| 3885 return; |
| 3886 } |
| 3887 memcpy(info, &result[0], result.size()); |
| 3888 } |
| 3889 |
| 3890 void GLES2Implementation::GetUniformsES3CHROMIUMHelper( |
| 3891 GLuint program, std::vector<int8>* result) { |
| 3892 DCHECK(result); |
| 3893 // Clear the bucket so if the command fails nothing will be in it. |
| 3894 helper_->SetBucketSize(kResultBucketId, 0); |
| 3895 helper_->GetUniformsES3CHROMIUM(program, kResultBucketId); |
| 3896 GetBucketContents(kResultBucketId, result); |
| 3897 } |
| 3898 |
| 3899 void GLES2Implementation::GetUniformsES3CHROMIUM( |
| 3900 GLuint program, GLsizei bufsize, GLsizei* size, void* info) { |
| 3901 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 3902 if (bufsize < 0) { |
| 3903 SetGLError( |
| 3904 GL_INVALID_VALUE, "glGetUniformsES3CHROMIUM", "bufsize less than 0."); |
| 3905 return; |
| 3906 } |
| 3907 if (size == NULL) { |
| 3908 SetGLError(GL_INVALID_VALUE, "glGetUniformsES3CHROMIUM", "size is null."); |
| 3909 return; |
| 3910 } |
| 3911 // Make sure they've set size to 0 else the value will be undefined on |
| 3912 // lost context. |
| 3913 DCHECK_EQ(0, *size); |
| 3914 std::vector<int8> result; |
| 3915 GetUniformsES3CHROMIUMHelper(program, &result); |
| 3916 if (result.empty()) { |
| 3917 return; |
| 3918 } |
| 3919 *size = result.size(); |
| 3920 if (!info) { |
| 3921 return; |
| 3922 } |
| 3923 if (static_cast<size_t>(bufsize) < result.size()) { |
3651 SetGLError(GL_INVALID_OPERATION, | 3924 SetGLError(GL_INVALID_OPERATION, |
3652 "glUniformBlocksCHROMIUM", "bufsize is too small for result."); | 3925 "glGetUniformsES3CHROMIUM", "bufsize is too small for result."); |
3653 return; | 3926 return; |
3654 } | 3927 } |
3655 memcpy(info, &result[0], result.size()); | 3928 memcpy(info, &result[0], result.size()); |
| 3929 } |
| 3930 |
| 3931 void GLES2Implementation::GetTransformFeedbackVaryingsCHROMIUMHelper( |
| 3932 GLuint program, std::vector<int8>* result) { |
| 3933 DCHECK(result); |
| 3934 // Clear the bucket so if the command fails nothing will be in it. |
| 3935 helper_->SetBucketSize(kResultBucketId, 0); |
| 3936 helper_->GetTransformFeedbackVaryingsCHROMIUM(program, kResultBucketId); |
| 3937 GetBucketContents(kResultBucketId, result); |
| 3938 } |
| 3939 |
| 3940 void GLES2Implementation::GetTransformFeedbackVaryingsCHROMIUM( |
| 3941 GLuint program, GLsizei bufsize, GLsizei* size, void* info) { |
| 3942 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 3943 if (bufsize < 0) { |
| 3944 SetGLError(GL_INVALID_VALUE, "glGetTransformFeedbackVaryingsCHROMIUM", |
| 3945 "bufsize less than 0."); |
| 3946 return; |
| 3947 } |
| 3948 if (size == NULL) { |
| 3949 SetGLError(GL_INVALID_VALUE, "glGetTransformFeedbackVaryingsCHROMIUM", |
| 3950 "size is null."); |
| 3951 return; |
| 3952 } |
| 3953 // Make sure they've set size to 0 else the value will be undefined on |
| 3954 // lost context. |
| 3955 DCHECK_EQ(0, *size); |
| 3956 std::vector<int8> result; |
| 3957 GetTransformFeedbackVaryingsCHROMIUMHelper(program, &result); |
| 3958 if (result.empty()) { |
| 3959 return; |
| 3960 } |
| 3961 *size = result.size(); |
| 3962 if (!info) { |
| 3963 return; |
| 3964 } |
| 3965 if (static_cast<size_t>(bufsize) < result.size()) { |
| 3966 SetGLError(GL_INVALID_OPERATION, "glGetTransformFeedbackVaryingsCHROMIUM", |
| 3967 "bufsize is too small for result."); |
| 3968 return; |
| 3969 } |
| 3970 memcpy(info, &result[0], result.size()); |
3656 } | 3971 } |
3657 | 3972 |
3658 GLuint GLES2Implementation::CreateStreamTextureCHROMIUM(GLuint texture) { | 3973 GLuint GLES2Implementation::CreateStreamTextureCHROMIUM(GLuint texture) { |
3659 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 3974 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
3660 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] CreateStreamTextureCHROMIUM(" | 3975 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] CreateStreamTextureCHROMIUM(" |
3661 << texture << ")"); | 3976 << texture << ")"); |
3662 TRACE_EVENT0("gpu", "GLES2::CreateStreamTextureCHROMIUM"); | 3977 TRACE_EVENT0("gpu", "GLES2::CreateStreamTextureCHROMIUM"); |
3663 helper_->CommandBufferHelper::Flush(); | 3978 helper_->CommandBufferHelper::Flush(); |
3664 return gpu_control_->CreateStreamTexture(texture); | 3979 return gpu_control_->CreateStreamTexture(texture); |
3665 } | 3980 } |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4521 // TODO(zmo): Implement client side caching. | 4836 // TODO(zmo): Implement client side caching. |
4522 return false; | 4837 return false; |
4523 } | 4838 } |
4524 | 4839 |
4525 bool GLES2Implementation::GetSamplerParameterivHelper( | 4840 bool GLES2Implementation::GetSamplerParameterivHelper( |
4526 GLuint /* sampler */, GLenum /* pname */, GLint* /* params */) { | 4841 GLuint /* sampler */, GLenum /* pname */, GLint* /* params */) { |
4527 // TODO(zmo): Implement client side caching. | 4842 // TODO(zmo): Implement client side caching. |
4528 return false; | 4843 return false; |
4529 } | 4844 } |
4530 | 4845 |
| 4846 bool GLES2Implementation::PackStringsToBucket(GLsizei count, |
| 4847 const char* const* str, |
| 4848 const GLint* length, |
| 4849 const char* func_name) { |
| 4850 DCHECK_LE(0, count); |
| 4851 // Compute the total size. |
| 4852 base::CheckedNumeric<size_t> total_size = count; |
| 4853 total_size += 1; |
| 4854 total_size *= sizeof(GLint); |
| 4855 if (!total_size.IsValid()) { |
| 4856 SetGLError(GL_INVALID_VALUE, func_name, "overflow"); |
| 4857 return false; |
| 4858 } |
| 4859 size_t header_size = total_size.ValueOrDefault(0); |
| 4860 std::vector<GLint> header(count + 1); |
| 4861 header[0] = static_cast<GLint>(count); |
| 4862 for (GLsizei ii = 0; ii < count; ++ii) { |
| 4863 GLint len = 0; |
| 4864 if (str[ii]) { |
| 4865 len = (length && length[ii] >= 0) |
| 4866 ? length[ii] |
| 4867 : base::checked_cast<GLint>(strlen(str[ii])); |
| 4868 } |
| 4869 total_size += len; |
| 4870 total_size += 1; // NULL at the end of each char array. |
| 4871 if (!total_size.IsValid()) { |
| 4872 SetGLError(GL_INVALID_VALUE, func_name, "overflow"); |
| 4873 return false; |
| 4874 } |
| 4875 header[ii + 1] = len; |
| 4876 } |
| 4877 // Pack data into a bucket on the service. |
| 4878 helper_->SetBucketSize(kResultBucketId, total_size.ValueOrDefault(0)); |
| 4879 size_t offset = 0; |
| 4880 for (GLsizei ii = 0; ii <= count; ++ii) { |
| 4881 const char* src = |
| 4882 (ii == 0) ? reinterpret_cast<const char*>(&header[0]) : str[ii - 1]; |
| 4883 base::CheckedNumeric<size_t> checked_size = |
| 4884 (ii == 0) ? header_size : static_cast<size_t>(header[ii]); |
| 4885 if (ii > 0) { |
| 4886 checked_size += 1; // NULL in the end. |
| 4887 } |
| 4888 if (!checked_size.IsValid()) { |
| 4889 SetGLError(GL_INVALID_VALUE, func_name, "overflow"); |
| 4890 return false; |
| 4891 } |
| 4892 size_t size = checked_size.ValueOrDefault(0); |
| 4893 while (size) { |
| 4894 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_); |
| 4895 if (!buffer.valid() || buffer.size() == 0) { |
| 4896 SetGLError(GL_OUT_OF_MEMORY, func_name, "too large"); |
| 4897 return false; |
| 4898 } |
| 4899 size_t copy_size = buffer.size(); |
| 4900 if (ii > 0 && buffer.size() == size) |
| 4901 --copy_size; |
| 4902 if (copy_size) |
| 4903 memcpy(buffer.address(), src, copy_size); |
| 4904 if (copy_size < buffer.size()) { |
| 4905 // Append NULL in the end. |
| 4906 DCHECK(copy_size + 1 == buffer.size()); |
| 4907 char* str = reinterpret_cast<char*>(buffer.address()); |
| 4908 str[copy_size] = 0; |
| 4909 } |
| 4910 helper_->SetBucketData(kResultBucketId, offset, buffer.size(), |
| 4911 buffer.shm_id(), buffer.offset()); |
| 4912 offset += buffer.size(); |
| 4913 src += buffer.size(); |
| 4914 size -= buffer.size(); |
| 4915 } |
| 4916 } |
| 4917 DCHECK_EQ(total_size.ValueOrDefault(0), offset); |
| 4918 return true; |
| 4919 } |
| 4920 |
| 4921 void GLES2Implementation::UniformBlockBinding(GLuint program, |
| 4922 GLuint index, |
| 4923 GLuint binding) { |
| 4924 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 4925 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUniformBlockBinding(" << program |
| 4926 << ", " << index << ", " << binding << ")"); |
| 4927 share_group_->program_info_manager()->UniformBlockBinding( |
| 4928 this, program, index, binding); |
| 4929 helper_->UniformBlockBinding(program, index, binding); |
| 4930 CheckGLError(); |
| 4931 } |
| 4932 |
| 4933 |
4531 // Include the auto-generated part of this file. We split this because it means | 4934 // Include the auto-generated part of this file. We split this because it means |
4532 // we can easily edit the non-auto generated parts right here in this file | 4935 // we can easily edit the non-auto generated parts right here in this file |
4533 // instead of having to edit some template or the code generator. | 4936 // instead of having to edit some template or the code generator. |
4534 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 4937 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
4535 | 4938 |
4536 } // namespace gles2 | 4939 } // namespace gles2 |
4537 } // namespace gpu | 4940 } // namespace gpu |
OLD | NEW |