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 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2631 GLsizei /* n */, const GLuint* /* transformfeedbacks */) { | 2640 GLsizei /* n */, const GLuint* /* transformfeedbacks */) { |
2632 } | 2641 } |
2633 | 2642 |
2634 // NOTE #1: On old versions of OpenGL, calling glBindXXX with an unused id | 2643 // 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 | 2644 // 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 | 2645 // 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 | 2646 // 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 | 2647 // the old model but possibly not true in the new model if another context has |
2639 // deleted the resource. | 2648 // deleted the resource. |
2640 | 2649 |
| 2650 // NOTE #2: There is a bug in some BindXXXHelpers, that IDs might be marked as |
| 2651 // used even when Bind has failed. However, the bug is minor compared to the |
| 2652 // overhead & duplicated checking in client side. |
| 2653 |
2641 void GLES2Implementation::BindBufferHelper( | 2654 void GLES2Implementation::BindBufferHelper( |
2642 GLenum target, GLuint buffer_id) { | 2655 GLenum target, GLuint buffer_id) { |
2643 // TODO(gman): See note #1 above. | 2656 // TODO(gman): See note #1 above. |
2644 bool changed = false; | 2657 bool changed = false; |
2645 switch (target) { | 2658 switch (target) { |
2646 case GL_ARRAY_BUFFER: | 2659 case GL_ARRAY_BUFFER: |
2647 if (bound_array_buffer_id_ != buffer_id) { | 2660 if (bound_array_buffer_id_ != buffer_id) { |
2648 bound_array_buffer_id_ = buffer_id; | 2661 bound_array_buffer_id_ = buffer_id; |
2649 changed = true; | 2662 changed = true; |
2650 } | 2663 } |
2651 break; | 2664 break; |
2652 case GL_ELEMENT_ARRAY_BUFFER: | 2665 case GL_ELEMENT_ARRAY_BUFFER: |
2653 changed = vertex_array_object_manager_->BindElementArray(buffer_id); | 2666 changed = vertex_array_object_manager_->BindElementArray(buffer_id); |
2654 break; | 2667 break; |
2655 case GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM: | 2668 case GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM: |
2656 bound_pixel_pack_transfer_buffer_id_ = buffer_id; | 2669 bound_pixel_pack_transfer_buffer_id_ = buffer_id; |
2657 break; | 2670 break; |
2658 case GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM: | 2671 case GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM: |
2659 bound_pixel_unpack_transfer_buffer_id_ = buffer_id; | 2672 bound_pixel_unpack_transfer_buffer_id_ = buffer_id; |
2660 break; | 2673 break; |
2661 default: | 2674 default: |
2662 changed = true; | 2675 changed = true; |
2663 break; | 2676 break; |
2664 } | 2677 } |
2665 // TODO(gman): There's a bug here. If the target is invalid the ID will not be | 2678 // TODO(gman): See note #2 above. |
2666 // used even though it's marked it as used here. | |
2667 if (changed) { | 2679 if (changed) { |
2668 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind( | 2680 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind( |
2669 this, target, buffer_id, &GLES2Implementation::BindBufferStub); | 2681 this, target, buffer_id, &GLES2Implementation::BindBufferStub); |
2670 } | 2682 } |
2671 } | 2683 } |
2672 | 2684 |
2673 void GLES2Implementation::BindBufferStub(GLenum target, GLuint buffer) { | 2685 void GLES2Implementation::BindBufferStub(GLenum target, GLuint buffer) { |
2674 helper_->BindBuffer(target, buffer); | 2686 helper_->BindBuffer(target, buffer); |
2675 if (share_group_->bind_generates_resource()) | 2687 if (share_group_->bind_generates_resource()) |
2676 helper_->CommandBufferHelper::Flush(); | 2688 helper_->CommandBufferHelper::Flush(); |
2677 } | 2689 } |
2678 | 2690 |
2679 void GLES2Implementation::BindBufferBaseHelper( | 2691 void GLES2Implementation::BindBufferBaseHelper( |
2680 GLenum target, GLuint index, GLuint buffer_id) { | 2692 GLenum target, GLuint index, GLuint buffer_id) { |
2681 // TODO(zmo): See note #1 above. | 2693 // TODO(zmo): See note #1 above. |
2682 // TODO(zmo): There's a bug here. If the target or index is invalid the ID | 2694 // 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( | 2695 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind( |
2685 this, target, index, buffer_id, &GLES2Implementation::BindBufferBaseStub); | 2696 this, target, index, buffer_id, &GLES2Implementation::BindBufferBaseStub); |
2686 } | 2697 } |
2687 | 2698 |
2688 void GLES2Implementation::BindBufferBaseStub( | 2699 void GLES2Implementation::BindBufferBaseStub( |
2689 GLenum target, GLuint index, GLuint buffer) { | 2700 GLenum target, GLuint index, GLuint buffer) { |
2690 helper_->BindBufferBase(target, index, buffer); | 2701 helper_->BindBufferBase(target, index, buffer); |
2691 if (share_group_->bind_generates_resource()) | 2702 if (share_group_->bind_generates_resource()) |
2692 helper_->CommandBufferHelper::Flush(); | 2703 helper_->CommandBufferHelper::Flush(); |
2693 } | 2704 } |
2694 | 2705 |
2695 void GLES2Implementation::BindBufferRangeHelper( | 2706 void GLES2Implementation::BindBufferRangeHelper( |
2696 GLenum target, GLuint index, GLuint buffer_id, | 2707 GLenum target, GLuint index, GLuint buffer_id, |
2697 GLintptr offset, GLsizeiptr size) { | 2708 GLintptr offset, GLsizeiptr size) { |
2698 // TODO(zmo): See note #1 above. | 2709 // TODO(zmo): See note #1 above. |
2699 // TODO(zmo): There's a bug here. If an arguments is invalid the ID will not | 2710 // TODO(zmo): See note #2 above. |
2700 // be used even though it's marked it as used here. | |
2701 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind( | 2711 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind( |
2702 this, target, index, buffer_id, offset, size, | 2712 this, target, index, buffer_id, offset, size, |
2703 &GLES2Implementation::BindBufferRangeStub); | 2713 &GLES2Implementation::BindBufferRangeStub); |
2704 } | 2714 } |
2705 | 2715 |
2706 void GLES2Implementation::BindBufferRangeStub( | 2716 void GLES2Implementation::BindBufferRangeStub( |
2707 GLenum target, GLuint index, GLuint buffer, | 2717 GLenum target, GLuint index, GLuint buffer, |
2708 GLintptr offset, GLsizeiptr size) { | 2718 GLintptr offset, GLsizeiptr size) { |
2709 helper_->BindBufferRange(target, index, buffer, offset, size); | 2719 helper_->BindBufferRange(target, index, buffer, offset, size); |
2710 if (share_group_->bind_generates_resource()) | 2720 if (share_group_->bind_generates_resource()) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2770 case GL_RENDERBUFFER: | 2780 case GL_RENDERBUFFER: |
2771 if (bound_renderbuffer_ != renderbuffer) { | 2781 if (bound_renderbuffer_ != renderbuffer) { |
2772 bound_renderbuffer_ = renderbuffer; | 2782 bound_renderbuffer_ = renderbuffer; |
2773 changed = true; | 2783 changed = true; |
2774 } | 2784 } |
2775 break; | 2785 break; |
2776 default: | 2786 default: |
2777 changed = true; | 2787 changed = true; |
2778 break; | 2788 break; |
2779 } | 2789 } |
2780 // TODO(gman): There's a bug here. If the target is invalid the ID will not be | 2790 // TODO(zmo): See note #2 above. |
2781 // used even though it's marked it as used here. | |
2782 if (changed) { | 2791 if (changed) { |
2783 GetIdHandler(id_namespaces::kRenderbuffers)->MarkAsUsedForBind( | 2792 GetIdHandler(id_namespaces::kRenderbuffers)->MarkAsUsedForBind( |
2784 this, target, renderbuffer, | 2793 this, target, renderbuffer, |
2785 &GLES2Implementation::BindRenderbufferStub); | 2794 &GLES2Implementation::BindRenderbufferStub); |
2786 } | 2795 } |
2787 } | 2796 } |
2788 | 2797 |
2789 void GLES2Implementation::BindRenderbufferStub(GLenum target, | 2798 void GLES2Implementation::BindRenderbufferStub(GLenum target, |
2790 GLuint renderbuffer) { | 2799 GLuint renderbuffer) { |
2791 helper_->BindRenderbuffer(target, renderbuffer); | 2800 helper_->BindRenderbuffer(target, renderbuffer); |
(...skipping 28 matching lines...) Expand all Loading... |
2820 case GL_TEXTURE_EXTERNAL_OES: | 2829 case GL_TEXTURE_EXTERNAL_OES: |
2821 if (unit.bound_texture_external_oes != texture) { | 2830 if (unit.bound_texture_external_oes != texture) { |
2822 unit.bound_texture_external_oes = texture; | 2831 unit.bound_texture_external_oes = texture; |
2823 changed = true; | 2832 changed = true; |
2824 } | 2833 } |
2825 break; | 2834 break; |
2826 default: | 2835 default: |
2827 changed = true; | 2836 changed = true; |
2828 break; | 2837 break; |
2829 } | 2838 } |
2830 // TODO(gman): There's a bug here. If the target is invalid the ID will not be | 2839 // TODO(gman): See note #2 above. |
2831 // used. even though it's marked it as used here. | |
2832 if (changed) { | 2840 if (changed) { |
2833 GetIdHandler(id_namespaces::kTextures)->MarkAsUsedForBind( | 2841 GetIdHandler(id_namespaces::kTextures)->MarkAsUsedForBind( |
2834 this, target, texture, &GLES2Implementation::BindTextureStub); | 2842 this, target, texture, &GLES2Implementation::BindTextureStub); |
2835 } | 2843 } |
2836 } | 2844 } |
2837 | 2845 |
2838 void GLES2Implementation::BindTextureStub(GLenum target, GLuint texture) { | 2846 void GLES2Implementation::BindTextureStub(GLenum target, GLuint texture) { |
2839 helper_->BindTexture(target, texture); | 2847 helper_->BindTexture(target, texture); |
2840 if (share_group_->bind_generates_resource()) | 2848 if (share_group_->bind_generates_resource()) |
2841 helper_->CommandBufferHelper::Flush(); | 2849 helper_->CommandBufferHelper::Flush(); |
2842 } | 2850 } |
2843 | 2851 |
2844 void GLES2Implementation::BindTransformFeedbackHelper( | 2852 void GLES2Implementation::BindTransformFeedbackHelper( |
2845 GLenum target, GLuint transformfeedback) { | 2853 GLenum target, GLuint transformfeedback) { |
2846 helper_->BindTransformFeedback(target, transformfeedback); | 2854 helper_->BindTransformFeedback(target, transformfeedback); |
2847 } | 2855 } |
2848 | 2856 |
2849 void GLES2Implementation::BindVertexArrayOESHelper(GLuint array) { | 2857 void GLES2Implementation::BindVertexArrayOESHelper(GLuint array) { |
2850 // TODO(gman): See note #1 above. | |
2851 bool changed = false; | 2858 bool changed = false; |
2852 if (vertex_array_object_manager_->BindVertexArray(array, &changed)) { | 2859 if (vertex_array_object_manager_->BindVertexArray(array, &changed)) { |
2853 if (changed) { | 2860 if (changed) { |
2854 // Unlike other BindXXXHelpers we don't call MarkAsUsedForBind | 2861 // Unlike other BindXXXHelpers we don't call MarkAsUsedForBind |
2855 // because unlike other resources VertexArrayObject ids must | 2862 // because unlike other resources VertexArrayObject ids must |
2856 // be generated by GenVertexArrays. A random id to Bind will not | 2863 // be generated by GenVertexArrays. A random id to Bind will not |
2857 // generate a new object. | 2864 // generate a new object. |
2858 helper_->BindVertexArrayOES(array); | 2865 helper_->BindVertexArrayOES(array); |
2859 } | 2866 } |
2860 } else { | 2867 } else { |
(...skipping 10 matching lines...) Expand all Loading... |
2871 case GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM: | 2878 case GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM: |
2872 if (bound_valuebuffer_ != valuebuffer) { | 2879 if (bound_valuebuffer_ != valuebuffer) { |
2873 bound_valuebuffer_ = valuebuffer; | 2880 bound_valuebuffer_ = valuebuffer; |
2874 changed = true; | 2881 changed = true; |
2875 } | 2882 } |
2876 break; | 2883 break; |
2877 default: | 2884 default: |
2878 changed = true; | 2885 changed = true; |
2879 break; | 2886 break; |
2880 } | 2887 } |
2881 // TODO(gman): There's a bug here. If the target is invalid the ID will not be | 2888 // TODO(gman): See note #2 above. |
2882 // used even though it's marked it as used here. | |
2883 if (changed) { | 2889 if (changed) { |
2884 GetIdHandler(id_namespaces::kValuebuffers)->MarkAsUsedForBind( | 2890 GetIdHandler(id_namespaces::kValuebuffers)->MarkAsUsedForBind( |
2885 this, target, valuebuffer, | 2891 this, target, valuebuffer, |
2886 &GLES2Implementation::BindValuebufferCHROMIUMStub); | 2892 &GLES2Implementation::BindValuebufferCHROMIUMStub); |
2887 } | 2893 } |
2888 } | 2894 } |
2889 | 2895 |
2890 void GLES2Implementation::BindValuebufferCHROMIUMStub(GLenum target, | 2896 void GLES2Implementation::BindValuebufferCHROMIUMStub(GLenum target, |
2891 GLuint valuebuffer) { | 2897 GLuint valuebuffer) { |
2892 helper_->BindValuebufferCHROMIUM(target, valuebuffer); | 2898 helper_->BindValuebufferCHROMIUM(target, valuebuffer); |
(...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4382 return false; | 4388 return false; |
4383 } | 4389 } |
4384 | 4390 |
4385 // Include the auto-generated part of this file. We split this because it means | 4391 // 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 | 4392 // 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. | 4393 // instead of having to edit some template or the code generator. |
4388 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 4394 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
4389 | 4395 |
4390 } // namespace gles2 | 4396 } // namespace gles2 |
4391 } // namespace gpu | 4397 } // namespace gpu |
OLD | NEW |