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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1683 const char* filename, int line, const std::string& msg); | 1683 const char* filename, int line, const std::string& msg); |
1684 | 1684 |
1685 const FeatureInfo::FeatureFlags& features() const { | 1685 const FeatureInfo::FeatureFlags& features() const { |
1686 return feature_info_->feature_flags(); | 1686 return feature_info_->feature_flags(); |
1687 } | 1687 } |
1688 | 1688 |
1689 const FeatureInfo::Workarounds& workarounds() const { | 1689 const FeatureInfo::Workarounds& workarounds() const { |
1690 return feature_info_->workarounds(); | 1690 return feature_info_->workarounds(); |
1691 } | 1691 } |
1692 | 1692 |
1693 const gfx::GLVersionInfo& gl_version() const { | |
1694 return feature_info_->gl_version_info(); | |
1695 } | |
1696 | |
1697 bool ShouldDeferDraws() { | 1693 bool ShouldDeferDraws() { |
1698 return !offscreen_target_frame_buffer_.get() && | 1694 return !offscreen_target_frame_buffer_.get() && |
1699 framebuffer_state_.bound_draw_framebuffer.get() == NULL && | 1695 framebuffer_state_.bound_draw_framebuffer.get() == NULL && |
1700 surface_->DeferDraws(); | 1696 surface_->DeferDraws(); |
1701 } | 1697 } |
1702 | 1698 |
1703 bool ShouldDeferReads() { | 1699 bool ShouldDeferReads() { |
1704 return !offscreen_target_frame_buffer_.get() && | 1700 return !offscreen_target_frame_buffer_.get() && |
1705 framebuffer_state_.bound_read_framebuffer.get() == NULL && | 1701 framebuffer_state_.bound_read_framebuffer.get() == NULL && |
1706 surface_->DeferDraws(); | 1702 surface_->DeferDraws(); |
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2736 // make it appear RGB. If on the other hand we ask for RGBA nd get RGB we | 2732 // make it appear RGB. If on the other hand we ask for RGBA nd get RGB we |
2737 // can't do anything about that. | 2733 // can't do anything about that. |
2738 | 2734 |
2739 if (!surfaceless_) { | 2735 if (!surfaceless_) { |
2740 GLint alpha_bits = 0; | 2736 GLint alpha_bits = 0; |
2741 GLint depth_bits = 0; | 2737 GLint depth_bits = 0; |
2742 GLint stencil_bits = 0; | 2738 GLint stencil_bits = 0; |
2743 | 2739 |
2744 bool default_fb = (GetBackbufferServiceId() == 0); | 2740 bool default_fb = (GetBackbufferServiceId() == 0); |
2745 | 2741 |
2746 if (gl_version().is_desktop_core_profile) { | 2742 if (feature_info_->gl_version_info().is_desktop_core_profile) { |
2747 glGetFramebufferAttachmentParameterivEXT( | 2743 glGetFramebufferAttachmentParameterivEXT( |
2748 GL_FRAMEBUFFER, | 2744 GL_FRAMEBUFFER, |
2749 default_fb ? GL_BACK_LEFT : GL_COLOR_ATTACHMENT0, | 2745 default_fb ? GL_BACK_LEFT : GL_COLOR_ATTACHMENT0, |
2750 GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, &alpha_bits); | 2746 GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, &alpha_bits); |
2751 glGetFramebufferAttachmentParameterivEXT( | 2747 glGetFramebufferAttachmentParameterivEXT( |
2752 GL_FRAMEBUFFER, | 2748 GL_FRAMEBUFFER, |
2753 default_fb ? GL_DEPTH : GL_DEPTH_ATTACHMENT, | 2749 default_fb ? GL_DEPTH : GL_DEPTH_ATTACHMENT, |
2754 GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, &depth_bits); | 2750 GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, &depth_bits); |
2755 glGetFramebufferAttachmentParameterivEXT( | 2751 glGetFramebufferAttachmentParameterivEXT( |
2756 GL_FRAMEBUFFER, | 2752 GL_FRAMEBUFFER, |
(...skipping 18 matching lines...) Expand all Loading... |
2775 state_.viewport_width = surface->GetSize().width(); | 2771 state_.viewport_width = surface->GetSize().width(); |
2776 state_.viewport_height = surface->GetSize().height(); | 2772 state_.viewport_height = surface->GetSize().height(); |
2777 } | 2773 } |
2778 | 2774 |
2779 // OpenGL ES 2.0 implicitly enables the desktop GL capability | 2775 // OpenGL ES 2.0 implicitly enables the desktop GL capability |
2780 // VERTEX_PROGRAM_POINT_SIZE and doesn't expose this enum. This fact | 2776 // VERTEX_PROGRAM_POINT_SIZE and doesn't expose this enum. This fact |
2781 // isn't well documented; it was discovered in the Khronos OpenGL ES | 2777 // isn't well documented; it was discovered in the Khronos OpenGL ES |
2782 // mailing list archives. It also implicitly enables the desktop GL | 2778 // mailing list archives. It also implicitly enables the desktop GL |
2783 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord | 2779 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord |
2784 // variable in fragment shaders. | 2780 // variable in fragment shaders. |
2785 if (!gl_version().BehavesLikeGLES()) { | 2781 if (!feature_info_->gl_version_info().BehavesLikeGLES()) { |
2786 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); | 2782 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); |
2787 glEnable(GL_POINT_SPRITE); | 2783 glEnable(GL_POINT_SPRITE); |
2788 } | 2784 } |
2789 | 2785 |
2790 has_robustness_extension_ = | 2786 has_robustness_extension_ = |
2791 context->HasExtension("GL_ARB_robustness") || | 2787 context->HasExtension("GL_ARB_robustness") || |
2792 context->HasExtension("GL_KHR_robustness") || | 2788 context->HasExtension("GL_KHR_robustness") || |
2793 context->HasExtension("GL_EXT_robustness"); | 2789 context->HasExtension("GL_EXT_robustness"); |
2794 | 2790 |
2795 if (!InitializeShaderTranslator()) { | 2791 if (!InitializeShaderTranslator()) { |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3013 } else { | 3009 } else { |
3014 shader_spec = unsafe_es3_apis_enabled() ? SH_GLES3_SPEC : SH_GLES2_SPEC; | 3010 shader_spec = unsafe_es3_apis_enabled() ? SH_GLES3_SPEC : SH_GLES2_SPEC; |
3015 } | 3011 } |
3016 | 3012 |
3017 if ((shader_spec == SH_WEBGL_SPEC || shader_spec == SH_WEBGL2_SPEC) && | 3013 if ((shader_spec == SH_WEBGL_SPEC || shader_spec == SH_WEBGL2_SPEC) && |
3018 features().enable_shader_name_hashing) | 3014 features().enable_shader_name_hashing) |
3019 resources.HashFunction = &CityHash64; | 3015 resources.HashFunction = &CityHash64; |
3020 else | 3016 else |
3021 resources.HashFunction = NULL; | 3017 resources.HashFunction = NULL; |
3022 ShaderTranslatorInterface::GlslImplementationType implementation_type = | 3018 ShaderTranslatorInterface::GlslImplementationType implementation_type = |
3023 ShaderTranslatorInterface::kGlsl; | 3019 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 ? |
3024 if (gl_version().is_es) | 3020 ShaderTranslatorInterface::kGlslES : ShaderTranslatorInterface::kGlsl; |
3025 implementation_type = ShaderTranslatorInterface::kGlslES; | |
3026 else if (gl_version().is_desktop_core_profile) | |
3027 implementation_type = ShaderTranslatorInterface::kGlslCoreProfile; | |
3028 int driver_bug_workarounds = 0; | 3021 int driver_bug_workarounds = 0; |
3029 if (workarounds().needs_glsl_built_in_function_emulation) | 3022 if (workarounds().needs_glsl_built_in_function_emulation) |
3030 driver_bug_workarounds |= SH_EMULATE_BUILT_IN_FUNCTIONS; | 3023 driver_bug_workarounds |= SH_EMULATE_BUILT_IN_FUNCTIONS; |
3031 if (workarounds().init_gl_position_in_vertex_shader) | 3024 if (workarounds().init_gl_position_in_vertex_shader) |
3032 driver_bug_workarounds |= SH_INIT_GL_POSITION; | 3025 driver_bug_workarounds |= SH_INIT_GL_POSITION; |
3033 if (workarounds().unfold_short_circuit_as_ternary_operation) | 3026 if (workarounds().unfold_short_circuit_as_ternary_operation) |
3034 driver_bug_workarounds |= SH_UNFOLD_SHORT_CIRCUIT; | 3027 driver_bug_workarounds |= SH_UNFOLD_SHORT_CIRCUIT; |
3035 if (workarounds().init_varyings_without_static_use) | 3028 if (workarounds().init_varyings_without_static_use) |
3036 driver_bug_workarounds |= SH_INIT_VARYINGS_WITHOUT_STATIC_USE; | 3029 driver_bug_workarounds |= SH_INIT_VARYINGS_WITHOUT_STATIC_USE; |
3037 if (workarounds().unroll_for_loop_with_sampler_array_index) | 3030 if (workarounds().unroll_for_loop_with_sampler_array_index) |
(...skipping 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4589 break; | 4582 break; |
4590 default: | 4583 default: |
4591 NOTREACHED(); | 4584 NOTREACHED(); |
4592 return; | 4585 return; |
4593 } | 4586 } |
4594 } | 4587 } |
4595 translated_attachments[i] = attachment; | 4588 translated_attachments[i] = attachment; |
4596 } | 4589 } |
4597 | 4590 |
4598 ScopedRenderTo do_render(framebuffer); | 4591 ScopedRenderTo do_render(framebuffer); |
4599 if (gl_version().is_es3) { | 4592 if (feature_info_->gl_version_info().is_es3) { |
4600 glInvalidateFramebuffer( | 4593 glInvalidateFramebuffer( |
4601 target, numAttachments, translated_attachments.get()); | 4594 target, numAttachments, translated_attachments.get()); |
4602 } else { | 4595 } else { |
4603 glDiscardFramebufferEXT( | 4596 glDiscardFramebufferEXT( |
4604 target, numAttachments, translated_attachments.get()); | 4597 target, numAttachments, translated_attachments.get()); |
4605 } | 4598 } |
4606 } | 4599 } |
4607 | 4600 |
4608 void GLES2DecoderImpl::DoEnableVertexAttribArray(GLuint index) { | 4601 void GLES2DecoderImpl::DoEnableVertexAttribArray(GLuint index) { |
4609 if (state_.vertex_attrib_manager->Enable(index, true)) { | 4602 if (state_.vertex_attrib_manager->Enable(index, true)) { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4771 case GL_MAX_DRAW_BUFFERS_ARB: | 4764 case GL_MAX_DRAW_BUFFERS_ARB: |
4772 *num_written = 1; | 4765 *num_written = 1; |
4773 if (params) { | 4766 if (params) { |
4774 params[0] = group_->max_draw_buffers(); | 4767 params[0] = group_->max_draw_buffers(); |
4775 } | 4768 } |
4776 return true; | 4769 return true; |
4777 case GL_ALPHA_BITS: | 4770 case GL_ALPHA_BITS: |
4778 *num_written = 1; | 4771 *num_written = 1; |
4779 if (params) { | 4772 if (params) { |
4780 GLint v = 0; | 4773 GLint v = 0; |
4781 if (gl_version().is_desktop_core_profile) { | 4774 if (feature_info_->gl_version_info().is_desktop_core_profile) { |
4782 Framebuffer* framebuffer = | 4775 Framebuffer* framebuffer = |
4783 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); | 4776 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); |
4784 if (framebuffer) { | 4777 if (framebuffer) { |
4785 glGetFramebufferAttachmentParameterivEXT( | 4778 glGetFramebufferAttachmentParameterivEXT( |
4786 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 4779 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
4787 GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, &v); | 4780 GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, &v); |
4788 } else { | 4781 } else { |
4789 v = (back_buffer_color_format_ == GL_RGBA ? 8 : 0); | 4782 v = (back_buffer_color_format_ == GL_RGBA ? 8 : 0); |
4790 } | 4783 } |
4791 } else { | 4784 } else { |
4792 glGetIntegerv(GL_ALPHA_BITS, &v); | 4785 glGetIntegerv(GL_ALPHA_BITS, &v); |
4793 } | 4786 } |
4794 params[0] = | 4787 params[0] = |
4795 BoundFramebufferHasColorAttachmentWithAlpha(false) ? v : 0; | 4788 BoundFramebufferHasColorAttachmentWithAlpha(false) ? v : 0; |
4796 } | 4789 } |
4797 return true; | 4790 return true; |
4798 case GL_DEPTH_BITS: | 4791 case GL_DEPTH_BITS: |
4799 *num_written = 1; | 4792 *num_written = 1; |
4800 if (params) { | 4793 if (params) { |
4801 GLint v = 0; | 4794 GLint v = 0; |
4802 if (gl_version().is_desktop_core_profile) { | 4795 if (feature_info_->gl_version_info().is_desktop_core_profile) { |
4803 Framebuffer* framebuffer = | 4796 Framebuffer* framebuffer = |
4804 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); | 4797 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); |
4805 if (framebuffer) { | 4798 if (framebuffer) { |
4806 glGetFramebufferAttachmentParameterivEXT( | 4799 glGetFramebufferAttachmentParameterivEXT( |
4807 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, | 4800 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, |
4808 GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, &v); | 4801 GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, &v); |
4809 } else { | 4802 } else { |
4810 v = (back_buffer_has_depth_ ? 24 : 0); | 4803 v = (back_buffer_has_depth_ ? 24 : 0); |
4811 } | 4804 } |
4812 } else { | 4805 } else { |
4813 glGetIntegerv(GL_DEPTH_BITS, &v); | 4806 glGetIntegerv(GL_DEPTH_BITS, &v); |
4814 } | 4807 } |
4815 params[0] = BoundFramebufferHasDepthAttachment() ? v : 0; | 4808 params[0] = BoundFramebufferHasDepthAttachment() ? v : 0; |
4816 } | 4809 } |
4817 return true; | 4810 return true; |
4818 case GL_RED_BITS: | 4811 case GL_RED_BITS: |
4819 case GL_GREEN_BITS: | 4812 case GL_GREEN_BITS: |
4820 case GL_BLUE_BITS: | 4813 case GL_BLUE_BITS: |
4821 *num_written = 1; | 4814 *num_written = 1; |
4822 if (params) { | 4815 if (params) { |
4823 GLint v = 0; | 4816 GLint v = 0; |
4824 if (gl_version().is_desktop_core_profile) { | 4817 if (feature_info_->gl_version_info().is_desktop_core_profile) { |
4825 Framebuffer* framebuffer = | 4818 Framebuffer* framebuffer = |
4826 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); | 4819 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); |
4827 if (framebuffer) { | 4820 if (framebuffer) { |
4828 GLenum framebuffer_enum = 0; | 4821 GLenum framebuffer_enum = 0; |
4829 switch (pname) { | 4822 switch (pname) { |
4830 case GL_RED_BITS: | 4823 case GL_RED_BITS: |
4831 framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE; | 4824 framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE; |
4832 break; | 4825 break; |
4833 case GL_GREEN_BITS: | 4826 case GL_GREEN_BITS: |
4834 framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE; | 4827 framebuffer_enum = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE; |
(...skipping 10 matching lines...) Expand all Loading... |
4845 } else { | 4838 } else { |
4846 glGetIntegerv(pname, &v); | 4839 glGetIntegerv(pname, &v); |
4847 } | 4840 } |
4848 params[0] = v; | 4841 params[0] = v; |
4849 } | 4842 } |
4850 return true; | 4843 return true; |
4851 case GL_STENCIL_BITS: | 4844 case GL_STENCIL_BITS: |
4852 *num_written = 1; | 4845 *num_written = 1; |
4853 if (params) { | 4846 if (params) { |
4854 GLint v = 0; | 4847 GLint v = 0; |
4855 if (gl_version().is_desktop_core_profile) { | 4848 if (feature_info_->gl_version_info().is_desktop_core_profile) { |
4856 Framebuffer* framebuffer = | 4849 Framebuffer* framebuffer = |
4857 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); | 4850 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); |
4858 if (framebuffer) { | 4851 if (framebuffer) { |
4859 glGetFramebufferAttachmentParameterivEXT( | 4852 glGetFramebufferAttachmentParameterivEXT( |
4860 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, | 4853 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, |
4861 GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, &v); | 4854 GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, &v); |
4862 } else { | 4855 } else { |
4863 v = (back_buffer_has_stencil_ ? 8 : 0); | 4856 v = (back_buffer_has_stencil_ ? 8 : 0); |
4864 } | 4857 } |
4865 } else { | 4858 } else { |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5689 GLint srcX1, | 5682 GLint srcX1, |
5690 GLint srcY1, | 5683 GLint srcY1, |
5691 GLint dstX0, | 5684 GLint dstX0, |
5692 GLint dstY0, | 5685 GLint dstY0, |
5693 GLint dstX1, | 5686 GLint dstX1, |
5694 GLint dstY1, | 5687 GLint dstY1, |
5695 GLbitfield mask, | 5688 GLbitfield mask, |
5696 GLenum filter) { | 5689 GLenum filter) { |
5697 // TODO(sievers): This could be resolved at the GL binding level, but the | 5690 // TODO(sievers): This could be resolved at the GL binding level, but the |
5698 // binding process is currently a bit too 'brute force'. | 5691 // binding process is currently a bit too 'brute force'. |
5699 if (gl_version().is_angle) { | 5692 if (feature_info_->gl_version_info().is_angle) { |
5700 glBlitFramebufferANGLE( | 5693 glBlitFramebufferANGLE( |
5701 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); | 5694 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
5702 } else if (feature_info_->feature_flags().use_core_framebuffer_multisample) { | 5695 } else if (feature_info_->feature_flags().use_core_framebuffer_multisample) { |
5703 glBlitFramebuffer( | 5696 glBlitFramebuffer( |
5704 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); | 5697 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
5705 } else { | 5698 } else { |
5706 glBlitFramebufferEXT( | 5699 glBlitFramebufferEXT( |
5707 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); | 5700 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
5708 } | 5701 } |
5709 } | 5702 } |
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6704 max_vertex_accessed, | 6697 max_vertex_accessed, |
6705 instanced, | 6698 instanced, |
6706 primcount); | 6699 primcount); |
6707 } | 6700 } |
6708 | 6701 |
6709 bool GLES2DecoderImpl::SimulateAttrib0( | 6702 bool GLES2DecoderImpl::SimulateAttrib0( |
6710 const char* function_name, GLuint max_vertex_accessed, bool* simulated) { | 6703 const char* function_name, GLuint max_vertex_accessed, bool* simulated) { |
6711 DCHECK(simulated); | 6704 DCHECK(simulated); |
6712 *simulated = false; | 6705 *simulated = false; |
6713 | 6706 |
6714 if (gl_version().BehavesLikeGLES()) | 6707 if (feature_info_->gl_version_info().BehavesLikeGLES()) |
6715 return true; | 6708 return true; |
6716 | 6709 |
6717 const VertexAttrib* attrib = | 6710 const VertexAttrib* attrib = |
6718 state_.vertex_attrib_manager->GetVertexAttrib(0); | 6711 state_.vertex_attrib_manager->GetVertexAttrib(0); |
6719 // If it's enabled or it's not used then we don't need to do anything. | 6712 // If it's enabled or it's not used then we don't need to do anything. |
6720 bool attrib_0_used = | 6713 bool attrib_0_used = |
6721 state_.current_program->GetAttribInfoByLocation(0) != NULL; | 6714 state_.current_program->GetAttribInfoByLocation(0) != NULL; |
6722 if (attrib->enabled() && attrib_0_used) { | 6715 if (attrib->enabled() && attrib_0_used) { |
6723 return true; | 6716 return true; |
6724 } | 6717 } |
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8061 read_x, ry, read_width, 1, format, type, dst + dest_row_offset); | 8054 read_x, ry, read_width, 1, format, type, dst + dest_row_offset); |
8062 } | 8055 } |
8063 dst += padded_row_size; | 8056 dst += padded_row_size; |
8064 } | 8057 } |
8065 } else { | 8058 } else { |
8066 if (async && features().use_async_readpixels) { | 8059 if (async && features().use_async_readpixels) { |
8067 GLuint buffer = 0; | 8060 GLuint buffer = 0; |
8068 glGenBuffersARB(1, &buffer); | 8061 glGenBuffersARB(1, &buffer); |
8069 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, buffer); | 8062 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, buffer); |
8070 // For ANGLE client version 2, GL_STREAM_READ is not available. | 8063 // For ANGLE client version 2, GL_STREAM_READ is not available. |
8071 const GLenum usage_hint = gl_version().is_angle ? | 8064 const GLenum usage_hint = feature_info_->gl_version_info().is_angle ? |
8072 GL_STATIC_DRAW : GL_STREAM_READ; | 8065 GL_STATIC_DRAW : GL_STREAM_READ; |
8073 glBufferData(GL_PIXEL_PACK_BUFFER_ARB, pixels_size, NULL, usage_hint); | 8066 glBufferData(GL_PIXEL_PACK_BUFFER_ARB, pixels_size, NULL, usage_hint); |
8074 GLenum error = glGetError(); | 8067 GLenum error = glGetError(); |
8075 if (error == GL_NO_ERROR) { | 8068 if (error == GL_NO_ERROR) { |
8076 glReadPixels(x, y, width, height, format, type, 0); | 8069 glReadPixels(x, y, width, height, format, type, 0); |
8077 pending_readpixel_fences_.push(linked_ptr<FenceCallback>( | 8070 pending_readpixel_fences_.push(linked_ptr<FenceCallback>( |
8078 new FenceCallback())); | 8071 new FenceCallback())); |
8079 WaitForReadPixels(base::Bind( | 8072 WaitForReadPixels(base::Bind( |
8080 &GLES2DecoderImpl::FinishReadPixels, | 8073 &GLES2DecoderImpl::FinishReadPixels, |
8081 base::internal::SupportsWeakPtrBase::StaticAsWeakPtr | 8074 base::internal::SupportsWeakPtrBase::StaticAsWeakPtr |
(...skipping 2211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10293 SetServiceId(offscreen_target_color_texture_->id()); | 10286 SetServiceId(offscreen_target_color_texture_->id()); |
10294 | 10287 |
10295 offscreen_saved_color_texture_.swap(offscreen_target_color_texture_); | 10288 offscreen_saved_color_texture_.swap(offscreen_target_color_texture_); |
10296 offscreen_target_frame_buffer_->AttachRenderTexture( | 10289 offscreen_target_frame_buffer_->AttachRenderTexture( |
10297 offscreen_target_color_texture_.get()); | 10290 offscreen_target_color_texture_.get()); |
10298 } | 10291 } |
10299 | 10292 |
10300 // Ensure the side effects of the copy are visible to the parent | 10293 // Ensure the side effects of the copy are visible to the parent |
10301 // context. There is no need to do this for ANGLE because it uses a | 10294 // context. There is no need to do this for ANGLE because it uses a |
10302 // single D3D device for all contexts. | 10295 // single D3D device for all contexts. |
10303 if (!gl_version().is_angle) | 10296 if (!feature_info_->gl_version_info().is_angle) |
10304 glFlush(); | 10297 glFlush(); |
10305 } | 10298 } |
10306 } else { | 10299 } else { |
10307 if (!surface_->SwapBuffers()) { | 10300 if (!surface_->SwapBuffers()) { |
10308 LOG(ERROR) << "Context lost because SwapBuffers failed."; | 10301 LOG(ERROR) << "Context lost because SwapBuffers failed."; |
10309 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 10302 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); |
10310 } | 10303 } |
10311 } | 10304 } |
10312 | 10305 |
10313 // This may be a slow command. Exit command processing to allow for | 10306 // This may be a slow command. Exit command processing to allow for |
(...skipping 2229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12543 } | 12536 } |
12544 } | 12537 } |
12545 | 12538 |
12546 // Include the auto-generated part of this file. We split this because it means | 12539 // Include the auto-generated part of this file. We split this because it means |
12547 // we can easily edit the non-auto generated parts right here in this file | 12540 // we can easily edit the non-auto generated parts right here in this file |
12548 // instead of having to edit some template or the code generator. | 12541 // instead of having to edit some template or the code generator. |
12549 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 12542 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
12550 | 12543 |
12551 } // namespace gles2 | 12544 } // namespace gles2 |
12552 } // namespace gpu | 12545 } // namespace gpu |
OLD | NEW |