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 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 *params = bound_read_framebuffer_; | 695 *params = bound_read_framebuffer_; |
696 return true; | 696 return true; |
697 } | 697 } |
698 return false; | 698 return false; |
699 case GL_RENDERBUFFER_BINDING: | 699 case GL_RENDERBUFFER_BINDING: |
700 if (share_group_->bind_generates_resource()) { | 700 if (share_group_->bind_generates_resource()) { |
701 *params = bound_renderbuffer_; | 701 *params = bound_renderbuffer_; |
702 return true; | 702 return true; |
703 } | 703 } |
704 return false; | 704 return false; |
| 705 case GL_MAX_UNIFORM_BUFFER_BINDINGS: |
| 706 *params = capabilities_.max_uniform_buffer_bindings; |
| 707 return true; |
| 708 case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: |
| 709 *params = capabilities_.max_transform_feedback_separate_attribs; |
| 710 return true; |
| 711 case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: |
| 712 *params = capabilities_.uniform_buffer_offset_alignment; |
| 713 return true; |
705 default: | 714 default: |
706 return false; | 715 return false; |
707 } | 716 } |
708 } | 717 } |
709 | 718 |
710 bool GLES2Implementation::GetBooleanvHelper(GLenum pname, GLboolean* params) { | 719 bool GLES2Implementation::GetBooleanvHelper(GLenum pname, GLboolean* params) { |
711 // TODO(gman): Make this handle pnames that return more than 1 value. | 720 // TODO(gman): Make this handle pnames that return more than 1 value. |
712 GLint value; | 721 GLint value; |
713 if (!GetHelper(pname, &value)) { | 722 if (!GetHelper(pname, &value)) { |
714 return false; | 723 return false; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 | 836 |
828 void GLES2Implementation::ShallowFlushCHROMIUM() { | 837 void GLES2Implementation::ShallowFlushCHROMIUM() { |
829 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 838 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
830 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glShallowFlushCHROMIUM()"); | 839 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glShallowFlushCHROMIUM()"); |
831 // Flush our command buffer | 840 // Flush our command buffer |
832 // (tell the service to execute up to the flush cmd.) | 841 // (tell the service to execute up to the flush cmd.) |
833 helper_->CommandBufferHelper::Flush(); | 842 helper_->CommandBufferHelper::Flush(); |
834 // TODO(piman): Add the FreeEverything() logic here. | 843 // TODO(piman): Add the FreeEverything() logic here. |
835 } | 844 } |
836 | 845 |
| 846 void GLES2Implementation::OrderingBarrierCHROMIUM() { |
| 847 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glOrderingBarrierCHROMIUM"); |
| 848 // Flush command buffer at the GPU channel level. May be implemented as |
| 849 // Flush(). |
| 850 helper_->CommandBufferHelper::OrderingBarrier(); |
| 851 } |
| 852 |
837 void GLES2Implementation::Finish() { | 853 void GLES2Implementation::Finish() { |
838 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 854 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
839 FinishHelper(); | 855 FinishHelper(); |
840 } | 856 } |
841 | 857 |
842 void GLES2Implementation::ShallowFinishCHROMIUM() { | 858 void GLES2Implementation::ShallowFinishCHROMIUM() { |
843 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 859 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
844 TRACE_EVENT0("gpu", "GLES2::ShallowFinishCHROMIUM"); | 860 TRACE_EVENT0("gpu", "GLES2::ShallowFinishCHROMIUM"); |
845 // Flush our command buffer (tell the service to execute up to the flush cmd | 861 // Flush our command buffer (tell the service to execute up to the flush cmd |
846 // and don't return until it completes). | 862 // and don't return until it completes). |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetFragDataLocation(" | 1100 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetFragDataLocation(" |
1085 << program << ", " << name << ")"); | 1101 << program << ", " << name << ")"); |
1086 TRACE_EVENT0("gpu", "GLES2::GetFragDataLocation"); | 1102 TRACE_EVENT0("gpu", "GLES2::GetFragDataLocation"); |
1087 GLint loc = share_group_->program_info_manager()->GetFragDataLocation( | 1103 GLint loc = share_group_->program_info_manager()->GetFragDataLocation( |
1088 this, program, name); | 1104 this, program, name); |
1089 GPU_CLIENT_LOG("returned " << loc); | 1105 GPU_CLIENT_LOG("returned " << loc); |
1090 CheckGLError(); | 1106 CheckGLError(); |
1091 return loc; | 1107 return loc; |
1092 } | 1108 } |
1093 | 1109 |
| 1110 GLuint GLES2Implementation::GetUniformBlockIndexHelper( |
| 1111 GLuint program, const char* name) { |
| 1112 typedef cmds::GetUniformBlockIndex::Result Result; |
| 1113 Result* result = GetResultAs<Result*>(); |
| 1114 if (!result) { |
| 1115 return GL_INVALID_INDEX; |
| 1116 } |
| 1117 *result = GL_INVALID_INDEX; |
| 1118 SetBucketAsCString(kResultBucketId, name); |
| 1119 helper_->GetUniformBlockIndex( |
| 1120 program, kResultBucketId, GetResultShmId(), GetResultShmOffset()); |
| 1121 WaitForCmd(); |
| 1122 helper_->SetBucketSize(kResultBucketId, 0); |
| 1123 return *result; |
| 1124 } |
| 1125 |
| 1126 GLuint GLES2Implementation::GetUniformBlockIndex( |
| 1127 GLuint program, const char* name) { |
| 1128 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1129 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetUniformBlockIndex(" |
| 1130 << program << ", " << name << ")"); |
| 1131 TRACE_EVENT0("gpu", "GLES2::GetUniformBlockIndex"); |
| 1132 GLuint index = share_group_->program_info_manager()->GetUniformBlockIndex( |
| 1133 this, program, name); |
| 1134 GPU_CLIENT_LOG("returned " << index); |
| 1135 CheckGLError(); |
| 1136 return index; |
| 1137 } |
| 1138 |
1094 void GLES2Implementation::LinkProgram(GLuint program) { | 1139 void GLES2Implementation::LinkProgram(GLuint program) { |
1095 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 1140 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
1096 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glLinkProgram(" << program << ")"); | 1141 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glLinkProgram(" << program << ")"); |
1097 helper_->LinkProgram(program); | 1142 helper_->LinkProgram(program); |
1098 share_group_->program_info_manager()->CreateInfo(program); | 1143 share_group_->program_info_manager()->CreateInfo(program); |
1099 CheckGLError(); | 1144 CheckGLError(); |
1100 } | 1145 } |
1101 | 1146 |
1102 void GLES2Implementation::ShaderBinary( | 1147 void GLES2Implementation::ShaderBinary( |
1103 GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, | 1148 GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, |
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2265 if (type) { | 2310 if (type) { |
2266 GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type)); | 2311 GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type)); |
2267 } | 2312 } |
2268 if (name) { | 2313 if (name) { |
2269 GPU_CLIENT_LOG(" name: " << name); | 2314 GPU_CLIENT_LOG(" name: " << name); |
2270 } | 2315 } |
2271 } | 2316 } |
2272 CheckGLError(); | 2317 CheckGLError(); |
2273 } | 2318 } |
2274 | 2319 |
| 2320 bool GLES2Implementation::GetActiveUniformBlockNameHelper( |
| 2321 GLuint program, GLuint index, GLsizei bufsize, |
| 2322 GLsizei* length, char* name) { |
| 2323 DCHECK_LE(0, bufsize); |
| 2324 // Clear the bucket so if the command fails nothing will be in it. |
| 2325 helper_->SetBucketSize(kResultBucketId, 0); |
| 2326 typedef cmds::GetActiveUniformBlockName::Result Result; |
| 2327 Result* result = GetResultAs<Result*>(); |
| 2328 if (!result) { |
| 2329 return false; |
| 2330 } |
| 2331 // Set as failed so if the command fails we'll recover. |
| 2332 *result = 0; |
| 2333 helper_->GetActiveUniformBlockName(program, index, kResultBucketId, |
| 2334 GetResultShmId(), GetResultShmOffset()); |
| 2335 WaitForCmd(); |
| 2336 if (*result) { |
| 2337 if (bufsize == 0) { |
| 2338 if (length) { |
| 2339 *length = 0; |
| 2340 } |
| 2341 } else if (length || name) { |
| 2342 std::vector<int8> str; |
| 2343 GetBucketContents(kResultBucketId, &str); |
| 2344 DCHECK(str.size() > 0); |
| 2345 GLsizei max_size = |
| 2346 std::min(bufsize, static_cast<GLsizei>(str.size())) - 1; |
| 2347 if (length) { |
| 2348 *length = max_size; |
| 2349 } |
| 2350 if (name) { |
| 2351 memcpy(name, &str[0], max_size); |
| 2352 name[max_size] = '\0'; |
| 2353 } |
| 2354 } |
| 2355 } |
| 2356 return *result != 0; |
| 2357 } |
| 2358 |
| 2359 void GLES2Implementation::GetActiveUniformBlockName( |
| 2360 GLuint program, GLuint index, GLsizei bufsize, |
| 2361 GLsizei* length, char* name) { |
| 2362 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2363 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetActiveUniformBlockName(" |
| 2364 << program << ", " << index << ", " << bufsize << ", " |
| 2365 << static_cast<const void*>(length) << ", " |
| 2366 << static_cast<const void*>(name) << ", "); |
| 2367 if (bufsize < 0) { |
| 2368 SetGLError(GL_INVALID_VALUE, "glGetActiveUniformBlockName", "bufsize < 0"); |
| 2369 return; |
| 2370 } |
| 2371 TRACE_EVENT0("gpu", "GLES2::GetActiveUniformBlockName"); |
| 2372 bool success = |
| 2373 share_group_->program_info_manager()->GetActiveUniformBlockName( |
| 2374 this, program, index, bufsize, length, name); |
| 2375 if (success) { |
| 2376 if (name) { |
| 2377 GPU_CLIENT_LOG(" name: " << name); |
| 2378 } |
| 2379 } |
| 2380 CheckGLError(); |
| 2381 } |
| 2382 |
2275 void GLES2Implementation::GetAttachedShaders( | 2383 void GLES2Implementation::GetAttachedShaders( |
2276 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { | 2384 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { |
2277 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 2385 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
2278 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetAttachedShaders(" | 2386 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetAttachedShaders(" |
2279 << program << ", " << maxcount << ", " | 2387 << program << ", " << maxcount << ", " |
2280 << static_cast<const void*>(count) << ", " | 2388 << static_cast<const void*>(count) << ", " |
2281 << static_cast<const void*>(shaders) << ", "); | 2389 << static_cast<const void*>(shaders) << ", "); |
2282 if (maxcount < 0) { | 2390 if (maxcount < 0) { |
2283 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders", "maxcount < 0"); | 2391 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders", "maxcount < 0"); |
2284 return; | 2392 return; |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2631 GLsizei /* n */, const GLuint* /* transformfeedbacks */) { | 2739 GLsizei /* n */, const GLuint* /* transformfeedbacks */) { |
2632 } | 2740 } |
2633 | 2741 |
2634 // NOTE #1: On old versions of OpenGL, calling glBindXXX with an unused id | 2742 // NOTE #1: On old versions of OpenGL, calling glBindXXX with an unused id |
2635 // generates a new resource. On newer versions of OpenGL they don't. The code | 2743 // generates a new resource. On newer versions of OpenGL they don't. The code |
2636 // related to binding below will need to change if we switch to the new OpenGL | 2744 // related to binding below will need to change if we switch to the new OpenGL |
2637 // model. Specifically it assumes a bind will succeed which is always true in | 2745 // model. Specifically it assumes a bind will succeed which is always true in |
2638 // the old model but possibly not true in the new model if another context has | 2746 // the old model but possibly not true in the new model if another context has |
2639 // deleted the resource. | 2747 // deleted the resource. |
2640 | 2748 |
| 2749 // NOTE #2: There is a bug in some BindXXXHelpers, that IDs might be marked as |
| 2750 // used even when Bind has failed. However, the bug is minor compared to the |
| 2751 // overhead & duplicated checking in client side. |
| 2752 |
2641 void GLES2Implementation::BindBufferHelper( | 2753 void GLES2Implementation::BindBufferHelper( |
2642 GLenum target, GLuint buffer_id) { | 2754 GLenum target, GLuint buffer_id) { |
2643 // TODO(gman): See note #1 above. | 2755 // TODO(gman): See note #1 above. |
2644 bool changed = false; | 2756 bool changed = false; |
2645 switch (target) { | 2757 switch (target) { |
2646 case GL_ARRAY_BUFFER: | 2758 case GL_ARRAY_BUFFER: |
2647 if (bound_array_buffer_id_ != buffer_id) { | 2759 if (bound_array_buffer_id_ != buffer_id) { |
2648 bound_array_buffer_id_ = buffer_id; | 2760 bound_array_buffer_id_ = buffer_id; |
2649 changed = true; | 2761 changed = true; |
2650 } | 2762 } |
2651 break; | 2763 break; |
2652 case GL_ELEMENT_ARRAY_BUFFER: | 2764 case GL_ELEMENT_ARRAY_BUFFER: |
2653 changed = vertex_array_object_manager_->BindElementArray(buffer_id); | 2765 changed = vertex_array_object_manager_->BindElementArray(buffer_id); |
2654 break; | 2766 break; |
2655 case GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM: | 2767 case GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM: |
2656 bound_pixel_pack_transfer_buffer_id_ = buffer_id; | 2768 bound_pixel_pack_transfer_buffer_id_ = buffer_id; |
2657 break; | 2769 break; |
2658 case GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM: | 2770 case GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM: |
2659 bound_pixel_unpack_transfer_buffer_id_ = buffer_id; | 2771 bound_pixel_unpack_transfer_buffer_id_ = buffer_id; |
2660 break; | 2772 break; |
2661 default: | 2773 default: |
2662 changed = true; | 2774 changed = true; |
2663 break; | 2775 break; |
2664 } | 2776 } |
2665 // TODO(gman): There's a bug here. If the target is invalid the ID will not be | 2777 // TODO(gman): See note #2 above. |
2666 // used even though it's marked it as used here. | |
2667 if (changed) { | 2778 if (changed) { |
2668 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind( | 2779 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind( |
2669 this, target, buffer_id, &GLES2Implementation::BindBufferStub); | 2780 this, target, buffer_id, &GLES2Implementation::BindBufferStub); |
2670 } | 2781 } |
2671 } | 2782 } |
2672 | 2783 |
2673 void GLES2Implementation::BindBufferStub(GLenum target, GLuint buffer) { | 2784 void GLES2Implementation::BindBufferStub(GLenum target, GLuint buffer) { |
2674 helper_->BindBuffer(target, buffer); | 2785 helper_->BindBuffer(target, buffer); |
2675 if (share_group_->bind_generates_resource()) | 2786 if (share_group_->bind_generates_resource()) |
2676 helper_->CommandBufferHelper::Flush(); | 2787 helper_->CommandBufferHelper::Flush(); |
2677 } | 2788 } |
2678 | 2789 |
2679 void GLES2Implementation::BindBufferBaseHelper( | 2790 void GLES2Implementation::BindBufferBaseHelper( |
2680 GLenum target, GLuint index, GLuint buffer_id) { | 2791 GLenum target, GLuint index, GLuint buffer_id) { |
2681 // TODO(zmo): See note #1 above. | 2792 // TODO(zmo): See note #1 above. |
2682 // TODO(zmo): There's a bug here. If the target or index is invalid the ID | 2793 // TODO(zmo): See note #2 above. |
2683 // will not be used even though it's marked it as used here. | |
2684 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind( | 2794 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind( |
2685 this, target, index, buffer_id, &GLES2Implementation::BindBufferBaseStub); | 2795 this, target, index, buffer_id, &GLES2Implementation::BindBufferBaseStub); |
2686 } | 2796 } |
2687 | 2797 |
2688 void GLES2Implementation::BindBufferBaseStub( | 2798 void GLES2Implementation::BindBufferBaseStub( |
2689 GLenum target, GLuint index, GLuint buffer) { | 2799 GLenum target, GLuint index, GLuint buffer) { |
2690 helper_->BindBufferBase(target, index, buffer); | 2800 helper_->BindBufferBase(target, index, buffer); |
2691 if (share_group_->bind_generates_resource()) | 2801 if (share_group_->bind_generates_resource()) |
2692 helper_->CommandBufferHelper::Flush(); | 2802 helper_->CommandBufferHelper::Flush(); |
2693 } | 2803 } |
2694 | 2804 |
2695 void GLES2Implementation::BindBufferRangeHelper( | 2805 void GLES2Implementation::BindBufferRangeHelper( |
2696 GLenum target, GLuint index, GLuint buffer_id, | 2806 GLenum target, GLuint index, GLuint buffer_id, |
2697 GLintptr offset, GLsizeiptr size) { | 2807 GLintptr offset, GLsizeiptr size) { |
2698 // TODO(zmo): See note #1 above. | 2808 // TODO(zmo): See note #1 above. |
2699 // TODO(zmo): There's a bug here. If an arguments is invalid the ID will not | 2809 // TODO(zmo): See note #2 above. |
2700 // be used even though it's marked it as used here. | |
2701 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind( | 2810 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind( |
2702 this, target, index, buffer_id, offset, size, | 2811 this, target, index, buffer_id, offset, size, |
2703 &GLES2Implementation::BindBufferRangeStub); | 2812 &GLES2Implementation::BindBufferRangeStub); |
2704 } | 2813 } |
2705 | 2814 |
2706 void GLES2Implementation::BindBufferRangeStub( | 2815 void GLES2Implementation::BindBufferRangeStub( |
2707 GLenum target, GLuint index, GLuint buffer, | 2816 GLenum target, GLuint index, GLuint buffer, |
2708 GLintptr offset, GLsizeiptr size) { | 2817 GLintptr offset, GLsizeiptr size) { |
2709 helper_->BindBufferRange(target, index, buffer, offset, size); | 2818 helper_->BindBufferRange(target, index, buffer, offset, size); |
2710 if (share_group_->bind_generates_resource()) | 2819 if (share_group_->bind_generates_resource()) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2770 case GL_RENDERBUFFER: | 2879 case GL_RENDERBUFFER: |
2771 if (bound_renderbuffer_ != renderbuffer) { | 2880 if (bound_renderbuffer_ != renderbuffer) { |
2772 bound_renderbuffer_ = renderbuffer; | 2881 bound_renderbuffer_ = renderbuffer; |
2773 changed = true; | 2882 changed = true; |
2774 } | 2883 } |
2775 break; | 2884 break; |
2776 default: | 2885 default: |
2777 changed = true; | 2886 changed = true; |
2778 break; | 2887 break; |
2779 } | 2888 } |
2780 // TODO(gman): There's a bug here. If the target is invalid the ID will not be | 2889 // TODO(zmo): See note #2 above. |
2781 // used even though it's marked it as used here. | |
2782 if (changed) { | 2890 if (changed) { |
2783 GetIdHandler(id_namespaces::kRenderbuffers)->MarkAsUsedForBind( | 2891 GetIdHandler(id_namespaces::kRenderbuffers)->MarkAsUsedForBind( |
2784 this, target, renderbuffer, | 2892 this, target, renderbuffer, |
2785 &GLES2Implementation::BindRenderbufferStub); | 2893 &GLES2Implementation::BindRenderbufferStub); |
2786 } | 2894 } |
2787 } | 2895 } |
2788 | 2896 |
2789 void GLES2Implementation::BindRenderbufferStub(GLenum target, | 2897 void GLES2Implementation::BindRenderbufferStub(GLenum target, |
2790 GLuint renderbuffer) { | 2898 GLuint renderbuffer) { |
2791 helper_->BindRenderbuffer(target, renderbuffer); | 2899 helper_->BindRenderbuffer(target, renderbuffer); |
(...skipping 28 matching lines...) Expand all Loading... |
2820 case GL_TEXTURE_EXTERNAL_OES: | 2928 case GL_TEXTURE_EXTERNAL_OES: |
2821 if (unit.bound_texture_external_oes != texture) { | 2929 if (unit.bound_texture_external_oes != texture) { |
2822 unit.bound_texture_external_oes = texture; | 2930 unit.bound_texture_external_oes = texture; |
2823 changed = true; | 2931 changed = true; |
2824 } | 2932 } |
2825 break; | 2933 break; |
2826 default: | 2934 default: |
2827 changed = true; | 2935 changed = true; |
2828 break; | 2936 break; |
2829 } | 2937 } |
2830 // TODO(gman): There's a bug here. If the target is invalid the ID will not be | 2938 // TODO(gman): See note #2 above. |
2831 // used. even though it's marked it as used here. | |
2832 if (changed) { | 2939 if (changed) { |
2833 GetIdHandler(id_namespaces::kTextures)->MarkAsUsedForBind( | 2940 GetIdHandler(id_namespaces::kTextures)->MarkAsUsedForBind( |
2834 this, target, texture, &GLES2Implementation::BindTextureStub); | 2941 this, target, texture, &GLES2Implementation::BindTextureStub); |
2835 } | 2942 } |
2836 } | 2943 } |
2837 | 2944 |
2838 void GLES2Implementation::BindTextureStub(GLenum target, GLuint texture) { | 2945 void GLES2Implementation::BindTextureStub(GLenum target, GLuint texture) { |
2839 helper_->BindTexture(target, texture); | 2946 helper_->BindTexture(target, texture); |
2840 if (share_group_->bind_generates_resource()) | 2947 if (share_group_->bind_generates_resource()) |
2841 helper_->CommandBufferHelper::Flush(); | 2948 helper_->CommandBufferHelper::Flush(); |
2842 } | 2949 } |
2843 | 2950 |
2844 void GLES2Implementation::BindTransformFeedbackHelper( | 2951 void GLES2Implementation::BindTransformFeedbackHelper( |
2845 GLenum target, GLuint transformfeedback) { | 2952 GLenum target, GLuint transformfeedback) { |
2846 helper_->BindTransformFeedback(target, transformfeedback); | 2953 helper_->BindTransformFeedback(target, transformfeedback); |
2847 } | 2954 } |
2848 | 2955 |
2849 void GLES2Implementation::BindVertexArrayOESHelper(GLuint array) { | 2956 void GLES2Implementation::BindVertexArrayOESHelper(GLuint array) { |
2850 // TODO(gman): See note #1 above. | |
2851 bool changed = false; | 2957 bool changed = false; |
2852 if (vertex_array_object_manager_->BindVertexArray(array, &changed)) { | 2958 if (vertex_array_object_manager_->BindVertexArray(array, &changed)) { |
2853 if (changed) { | 2959 if (changed) { |
2854 // Unlike other BindXXXHelpers we don't call MarkAsUsedForBind | 2960 // Unlike other BindXXXHelpers we don't call MarkAsUsedForBind |
2855 // because unlike other resources VertexArrayObject ids must | 2961 // because unlike other resources VertexArrayObject ids must |
2856 // be generated by GenVertexArrays. A random id to Bind will not | 2962 // be generated by GenVertexArrays. A random id to Bind will not |
2857 // generate a new object. | 2963 // generate a new object. |
2858 helper_->BindVertexArrayOES(array); | 2964 helper_->BindVertexArrayOES(array); |
2859 } | 2965 } |
2860 } else { | 2966 } else { |
(...skipping 10 matching lines...) Expand all Loading... |
2871 case GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM: | 2977 case GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM: |
2872 if (bound_valuebuffer_ != valuebuffer) { | 2978 if (bound_valuebuffer_ != valuebuffer) { |
2873 bound_valuebuffer_ = valuebuffer; | 2979 bound_valuebuffer_ = valuebuffer; |
2874 changed = true; | 2980 changed = true; |
2875 } | 2981 } |
2876 break; | 2982 break; |
2877 default: | 2983 default: |
2878 changed = true; | 2984 changed = true; |
2879 break; | 2985 break; |
2880 } | 2986 } |
2881 // TODO(gman): There's a bug here. If the target is invalid the ID will not be | 2987 // TODO(gman): See note #2 above. |
2882 // used even though it's marked it as used here. | |
2883 if (changed) { | 2988 if (changed) { |
2884 GetIdHandler(id_namespaces::kValuebuffers)->MarkAsUsedForBind( | 2989 GetIdHandler(id_namespaces::kValuebuffers)->MarkAsUsedForBind( |
2885 this, target, valuebuffer, | 2990 this, target, valuebuffer, |
2886 &GLES2Implementation::BindValuebufferCHROMIUMStub); | 2991 &GLES2Implementation::BindValuebufferCHROMIUMStub); |
2887 } | 2992 } |
2888 } | 2993 } |
2889 | 2994 |
2890 void GLES2Implementation::BindValuebufferCHROMIUMStub(GLenum target, | 2995 void GLES2Implementation::BindValuebufferCHROMIUMStub(GLenum target, |
2891 GLuint valuebuffer) { | 2996 GLuint valuebuffer) { |
2892 helper_->BindValuebufferCHROMIUM(target, valuebuffer); | 2997 helper_->BindValuebufferCHROMIUM(target, valuebuffer); |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3502 return; | 3607 return; |
3503 } | 3608 } |
3504 if (static_cast<size_t>(bufsize) < result.size()) { | 3609 if (static_cast<size_t>(bufsize) < result.size()) { |
3505 SetGLError(GL_INVALID_OPERATION, | 3610 SetGLError(GL_INVALID_OPERATION, |
3506 "glProgramInfoCHROMIUM", "bufsize is too small for result."); | 3611 "glProgramInfoCHROMIUM", "bufsize is too small for result."); |
3507 return; | 3612 return; |
3508 } | 3613 } |
3509 memcpy(info, &result[0], result.size()); | 3614 memcpy(info, &result[0], result.size()); |
3510 } | 3615 } |
3511 | 3616 |
| 3617 void GLES2Implementation::GetUniformBlocksCHROMIUMHelper( |
| 3618 GLuint program, std::vector<int8>* result) { |
| 3619 DCHECK(result); |
| 3620 // Clear the bucket so if the command fails nothing will be in it. |
| 3621 helper_->SetBucketSize(kResultBucketId, 0); |
| 3622 helper_->GetUniformBlocksCHROMIUM(program, kResultBucketId); |
| 3623 GetBucketContents(kResultBucketId, result); |
| 3624 } |
| 3625 |
| 3626 void GLES2Implementation::GetUniformBlocksCHROMIUM( |
| 3627 GLuint program, GLsizei bufsize, GLsizei* size, void* info) { |
| 3628 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 3629 if (bufsize < 0) { |
| 3630 SetGLError( |
| 3631 GL_INVALID_VALUE, "glUniformBlocksCHROMIUM", "bufsize less than 0."); |
| 3632 return; |
| 3633 } |
| 3634 if (size == NULL) { |
| 3635 SetGLError(GL_INVALID_VALUE, "glUniformBlocksCHROMIUM", "size is null."); |
| 3636 return; |
| 3637 } |
| 3638 // Make sure they've set size to 0 else the value will be undefined on |
| 3639 // lost context. |
| 3640 DCHECK_EQ(0, *size); |
| 3641 std::vector<int8> result; |
| 3642 GetUniformBlocksCHROMIUMHelper(program, &result); |
| 3643 if (result.empty()) { |
| 3644 return; |
| 3645 } |
| 3646 *size = result.size(); |
| 3647 if (!info) { |
| 3648 return; |
| 3649 } |
| 3650 if (static_cast<size_t>(bufsize) < result.size()) { |
| 3651 SetGLError(GL_INVALID_OPERATION, |
| 3652 "glUniformBlocksCHROMIUM", "bufsize is too small for result."); |
| 3653 return; |
| 3654 } |
| 3655 memcpy(info, &result[0], result.size()); |
| 3656 } |
| 3657 |
3512 GLuint GLES2Implementation::CreateStreamTextureCHROMIUM(GLuint texture) { | 3658 GLuint GLES2Implementation::CreateStreamTextureCHROMIUM(GLuint texture) { |
3513 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 3659 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
3514 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] CreateStreamTextureCHROMIUM(" | 3660 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] CreateStreamTextureCHROMIUM(" |
3515 << texture << ")"); | 3661 << texture << ")"); |
3516 TRACE_EVENT0("gpu", "GLES2::CreateStreamTextureCHROMIUM"); | 3662 TRACE_EVENT0("gpu", "GLES2::CreateStreamTextureCHROMIUM"); |
3517 helper_->CommandBufferHelper::Flush(); | 3663 helper_->CommandBufferHelper::Flush(); |
3518 return gpu_control_->CreateStreamTexture(texture); | 3664 return gpu_control_->CreateStreamTexture(texture); |
3519 } | 3665 } |
3520 | 3666 |
3521 void GLES2Implementation::PostSubBufferCHROMIUM( | 3667 void GLES2Implementation::PostSubBufferCHROMIUM( |
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4382 return false; | 4528 return false; |
4383 } | 4529 } |
4384 | 4530 |
4385 // Include the auto-generated part of this file. We split this because it means | 4531 // Include the auto-generated part of this file. We split this because it means |
4386 // we can easily edit the non-auto generated parts right here in this file | 4532 // we can easily edit the non-auto generated parts right here in this file |
4387 // instead of having to edit some template or the code generator. | 4533 // instead of having to edit some template or the code generator. |
4388 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 4534 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
4389 | 4535 |
4390 } // namespace gles2 | 4536 } // namespace gles2 |
4391 } // namespace gpu | 4537 } // namespace gpu |
OLD | NEW |