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 2438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2449 return true; | 2449 return true; |
2450 } | 2450 } |
2451 return false; | 2451 return false; |
2452 } | 2452 } |
2453 | 2453 |
2454 void GLES2Implementation::GetActiveUniformBlockiv( | 2454 void GLES2Implementation::GetActiveUniformBlockiv( |
2455 GLuint program, GLuint index, GLenum pname, GLint* params) { | 2455 GLuint program, GLuint index, GLenum pname, GLint* params) { |
2456 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 2456 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
2457 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetActiveUniformBlockiv(" | 2457 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetActiveUniformBlockiv(" |
2458 << program << ", " << index << ", " | 2458 << program << ", " << index << ", " |
2459 << GLES2Util::GetStringProgramParameter(pname) << ", " | 2459 << GLES2Util::GetStringUniformBlockParameter(pname) << ", " |
2460 << static_cast<const void*>(params) << ")"); | 2460 << static_cast<const void*>(params) << ")"); |
2461 TRACE_EVENT0("gpu", "GLES2::GetActiveUniformBlockiv"); | 2461 TRACE_EVENT0("gpu", "GLES2::GetActiveUniformBlockiv"); |
2462 bool success = | 2462 bool success = |
2463 share_group_->program_info_manager()->GetActiveUniformBlockiv( | 2463 share_group_->program_info_manager()->GetActiveUniformBlockiv( |
2464 this, program, index, pname, params); | 2464 this, program, index, pname, params); |
2465 if (success) { | 2465 if (success) { |
2466 if (params) { | 2466 if (params) { |
2467 // TODO(zmo): For GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, there will | 2467 // TODO(zmo): For GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, there will |
2468 // be more than one value returned in params. | 2468 // be more than one value returned in params. |
2469 GPU_CLIENT_LOG(" params: " << params[0]); | 2469 GPU_CLIENT_LOG(" params: " << params[0]); |
2470 } | 2470 } |
2471 } | 2471 } |
2472 CheckGLError(); | 2472 CheckGLError(); |
2473 } | 2473 } |
2474 | 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 |
2475 void GLES2Implementation::GetAttachedShaders( | 2537 void GLES2Implementation::GetAttachedShaders( |
2476 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { | 2538 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { |
2477 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 2539 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
2478 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetAttachedShaders(" | 2540 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetAttachedShaders(" |
2479 << program << ", " << maxcount << ", " | 2541 << program << ", " << maxcount << ", " |
2480 << static_cast<const void*>(count) << ", " | 2542 << static_cast<const void*>(count) << ", " |
2481 << static_cast<const void*>(shaders) << ", "); | 2543 << static_cast<const void*>(shaders) << ", "); |
2482 if (maxcount < 0) { | 2544 if (maxcount < 0) { |
2483 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders", "maxcount < 0"); | 2545 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders", "maxcount < 0"); |
2484 return; | 2546 return; |
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3791 helper_->SetBucketSize(kResultBucketId, 0); | 3853 helper_->SetBucketSize(kResultBucketId, 0); |
3792 helper_->GetUniformBlocksCHROMIUM(program, kResultBucketId); | 3854 helper_->GetUniformBlocksCHROMIUM(program, kResultBucketId); |
3793 GetBucketContents(kResultBucketId, result); | 3855 GetBucketContents(kResultBucketId, result); |
3794 } | 3856 } |
3795 | 3857 |
3796 void GLES2Implementation::GetUniformBlocksCHROMIUM( | 3858 void GLES2Implementation::GetUniformBlocksCHROMIUM( |
3797 GLuint program, GLsizei bufsize, GLsizei* size, void* info) { | 3859 GLuint program, GLsizei bufsize, GLsizei* size, void* info) { |
3798 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 3860 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
3799 if (bufsize < 0) { | 3861 if (bufsize < 0) { |
3800 SetGLError( | 3862 SetGLError( |
3801 GL_INVALID_VALUE, "glUniformBlocksCHROMIUM", "bufsize less than 0."); | 3863 GL_INVALID_VALUE, "glGetUniformBlocksCHROMIUM", "bufsize less than 0."); |
3802 return; | 3864 return; |
3803 } | 3865 } |
3804 if (size == NULL) { | 3866 if (size == NULL) { |
3805 SetGLError(GL_INVALID_VALUE, "glUniformBlocksCHROMIUM", "size is null."); | 3867 SetGLError(GL_INVALID_VALUE, "glGetUniformBlocksCHROMIUM", "size is null."); |
3806 return; | 3868 return; |
3807 } | 3869 } |
3808 // 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 |
3809 // lost context. | 3871 // lost context. |
3810 DCHECK_EQ(0, *size); | 3872 DCHECK_EQ(0, *size); |
3811 std::vector<int8> result; | 3873 std::vector<int8> result; |
3812 GetUniformBlocksCHROMIUMHelper(program, &result); | 3874 GetUniformBlocksCHROMIUMHelper(program, &result); |
3813 if (result.empty()) { | 3875 if (result.empty()) { |
3814 return; | 3876 return; |
3815 } | 3877 } |
3816 *size = result.size(); | 3878 *size = result.size(); |
3817 if (!info) { | 3879 if (!info) { |
3818 return; | 3880 return; |
3819 } | 3881 } |
3820 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()) { |
3821 SetGLError(GL_INVALID_OPERATION, | 3924 SetGLError(GL_INVALID_OPERATION, |
3822 "glUniformBlocksCHROMIUM", "bufsize is too small for result."); | 3925 "glGetUniformsES3CHROMIUM", "bufsize is too small for result."); |
3823 return; | 3926 return; |
3824 } | 3927 } |
3825 memcpy(info, &result[0], result.size()); | 3928 memcpy(info, &result[0], result.size()); |
3826 } | 3929 } |
3827 | 3930 |
3828 void GLES2Implementation::GetTransformFeedbackVaryingsCHROMIUMHelper( | 3931 void GLES2Implementation::GetTransformFeedbackVaryingsCHROMIUMHelper( |
3829 GLuint program, std::vector<int8>* result) { | 3932 GLuint program, std::vector<int8>* result) { |
3830 DCHECK(result); | 3933 DCHECK(result); |
3831 // Clear the bucket so if the command fails nothing will be in it. | 3934 // Clear the bucket so if the command fails nothing will be in it. |
3832 helper_->SetBucketSize(kResultBucketId, 0); | 3935 helper_->SetBucketSize(kResultBucketId, 0); |
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4828 } | 4931 } |
4829 | 4932 |
4830 | 4933 |
4831 // 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 |
4832 // 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 |
4833 // instead of having to edit some template or the code generator. | 4936 // instead of having to edit some template or the code generator. |
4834 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 4937 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
4835 | 4938 |
4836 } // namespace gles2 | 4939 } // namespace gles2 |
4837 } // namespace gpu | 4940 } // namespace gpu |
OLD | NEW |