| 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 <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 1833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1844 if (ShouldDeferReads()) | 1844 if (ShouldDeferReads()) |
| 1845 return error::kDeferCommandUntilLater; | 1845 return error::kDeferCommandUntilLater; |
| 1846 if (!offscreen_target_frame_buffer_.get() && | 1846 if (!offscreen_target_frame_buffer_.get() && |
| 1847 !framebuffer_state_.bound_read_framebuffer.get() && | 1847 !framebuffer_state_.bound_read_framebuffer.get() && |
| 1848 !surface_->SetBackbufferAllocation(true)) | 1848 !surface_->SetBackbufferAllocation(true)) |
| 1849 return error::kLostContext; | 1849 return error::kLostContext; |
| 1850 return error::kNoError; | 1850 return error::kNoError; |
| 1851 } | 1851 } |
| 1852 | 1852 |
| 1853 bool BackBufferHasAlpha() const { | 1853 bool BackBufferHasAlpha() const { |
| 1854 if (state_.emulating_rgb_with_rgba) |
| 1855 return false; |
| 1854 if (back_buffer_draw_buffer_ == GL_NONE) | 1856 if (back_buffer_draw_buffer_ == GL_NONE) |
| 1855 return false; | 1857 return false; |
| 1856 if (offscreen_target_frame_buffer_.get()) { | 1858 if (offscreen_target_frame_buffer_.get()) { |
| 1857 return (offscreen_target_color_format_ == GL_RGBA || | 1859 return (offscreen_target_color_format_ == GL_RGBA || |
| 1858 offscreen_target_color_format_ == GL_RGBA8); | 1860 offscreen_target_color_format_ == GL_RGBA8); |
| 1859 } | 1861 } |
| 1860 return (back_buffer_color_format_ == GL_RGBA || | 1862 return (back_buffer_color_format_ == GL_RGBA || |
| 1861 back_buffer_color_format_ == GL_RGBA8); | 1863 back_buffer_color_format_ == GL_RGBA8); |
| 1862 } | 1864 } |
| 1863 | 1865 |
| (...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2746 context_->HasExtension("GL_OES_rgb8_rgba8"); | 2748 context_->HasExtension("GL_OES_rgb8_rgba8"); |
| 2747 // The only available default render buffer formats in GLES2 have very | 2749 // The only available default render buffer formats in GLES2 have very |
| 2748 // little precision. Don't enable multisampling unless 8-bit render | 2750 // little precision. Don't enable multisampling unless 8-bit render |
| 2749 // buffer formats are available--instead fall back to 8-bit textures. | 2751 // buffer formats are available--instead fall back to 8-bit textures. |
| 2750 if (rgb8_supported && offscreen_target_samples_ > 1) { | 2752 if (rgb8_supported && offscreen_target_samples_ > 1) { |
| 2751 offscreen_target_color_format_ = attrib_parser.alpha_size > 0 ? | 2753 offscreen_target_color_format_ = attrib_parser.alpha_size > 0 ? |
| 2752 GL_RGBA8 : GL_RGB8; | 2754 GL_RGBA8 : GL_RGB8; |
| 2753 } else { | 2755 } else { |
| 2754 offscreen_target_samples_ = 1; | 2756 offscreen_target_samples_ = 1; |
| 2755 offscreen_target_color_format_ = | 2757 offscreen_target_color_format_ = |
| 2756 attrib_parser.alpha_size > 0 || workarounds().disable_gl_rgb_format | 2758 (attrib_parser.alpha_size > 0) ? GL_RGBA : GL_RGB; |
| 2757 ? GL_RGBA | 2759 if (offscreen_target_color_format_ == GL_RGB && |
| 2758 : GL_RGB; | 2760 workarounds().disable_gl_rgb_format) { |
| 2761 offscreen_target_color_format_ = GL_RGBA; |
| 2762 state_.emulating_rgb_with_rgba = true; |
| 2763 } |
| 2759 } | 2764 } |
| 2760 | 2765 |
| 2761 // ANGLE only supports packed depth/stencil formats, so use it if it is | 2766 // ANGLE only supports packed depth/stencil formats, so use it if it is |
| 2762 // available. | 2767 // available. |
| 2763 const bool depth24_stencil8_supported = | 2768 const bool depth24_stencil8_supported = |
| 2764 feature_info_->feature_flags().packed_depth24_stencil8; | 2769 feature_info_->feature_flags().packed_depth24_stencil8; |
| 2765 VLOG(1) << "GL_OES_packed_depth_stencil " | 2770 VLOG(1) << "GL_OES_packed_depth_stencil " |
| 2766 << (depth24_stencil8_supported ? "" : "not ") << "supported."; | 2771 << (depth24_stencil8_supported ? "" : "not ") << "supported."; |
| 2767 if ((attrib_parser.depth_size > 0 || attrib_parser.stencil_size > 0) && | 2772 if ((attrib_parser.depth_size > 0 || attrib_parser.stencil_size > 0) && |
| 2768 depth24_stencil8_supported) { | 2773 depth24_stencil8_supported) { |
| 2769 offscreen_target_depth_format_ = GL_DEPTH24_STENCIL8; | 2774 offscreen_target_depth_format_ = GL_DEPTH24_STENCIL8; |
| 2770 offscreen_target_stencil_format_ = 0; | 2775 offscreen_target_stencil_format_ = 0; |
| 2771 } else { | 2776 } else { |
| 2772 // It may be the case that this depth/stencil combination is not | 2777 // It may be the case that this depth/stencil combination is not |
| 2773 // supported, but this will be checked later by CheckFramebufferStatus. | 2778 // supported, but this will be checked later by CheckFramebufferStatus. |
| 2774 offscreen_target_depth_format_ = attrib_parser.depth_size > 0 ? | 2779 offscreen_target_depth_format_ = attrib_parser.depth_size > 0 ? |
| 2775 GL_DEPTH_COMPONENT16 : 0; | 2780 GL_DEPTH_COMPONENT16 : 0; |
| 2776 offscreen_target_stencil_format_ = attrib_parser.stencil_size > 0 ? | 2781 offscreen_target_stencil_format_ = attrib_parser.stencil_size > 0 ? |
| 2777 GL_STENCIL_INDEX8 : 0; | 2782 GL_STENCIL_INDEX8 : 0; |
| 2778 } | 2783 } |
| 2779 } else { | 2784 } else { |
| 2780 offscreen_target_color_format_ = | 2785 offscreen_target_color_format_ = |
| 2781 attrib_parser.alpha_size > 0 || workarounds().disable_gl_rgb_format | 2786 (attrib_parser.alpha_size > 0) ? GL_RGBA : GL_RGB; |
| 2782 ? GL_RGBA | 2787 if (offscreen_target_color_format_ == GL_RGB && |
| 2783 : GL_RGB; | 2788 workarounds().disable_gl_rgb_format) { |
| 2789 offscreen_target_color_format_ = GL_RGBA; |
| 2790 state_.emulating_rgb_with_rgba = true; |
| 2791 } |
| 2784 | 2792 |
| 2785 // If depth is requested at all, use the packed depth stencil format if | 2793 // If depth is requested at all, use the packed depth stencil format if |
| 2786 // it's available, as some desktop GL drivers don't support any non-packed | 2794 // it's available, as some desktop GL drivers don't support any non-packed |
| 2787 // formats for depth attachments. | 2795 // formats for depth attachments. |
| 2788 const bool depth24_stencil8_supported = | 2796 const bool depth24_stencil8_supported = |
| 2789 feature_info_->feature_flags().packed_depth24_stencil8; | 2797 feature_info_->feature_flags().packed_depth24_stencil8; |
| 2790 VLOG(1) << "GL_EXT_packed_depth_stencil " | 2798 VLOG(1) << "GL_EXT_packed_depth_stencil " |
| 2791 << (depth24_stencil8_supported ? "" : "not ") << "supported."; | 2799 << (depth24_stencil8_supported ? "" : "not ") << "supported."; |
| 2792 | 2800 |
| 2793 if ((attrib_parser.depth_size > 0 || attrib_parser.stencil_size > 0) && | 2801 if ((attrib_parser.depth_size > 0 || attrib_parser.stencil_size > 0) && |
| (...skipping 3344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6138 // is complete on the READ attachment will be complete as a DRAW | 6146 // is complete on the READ attachment will be complete as a DRAW |
| 6139 // attachment. | 6147 // attachment. |
| 6140 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); | 6148 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); |
| 6141 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, framebuffer->service_id()); | 6149 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, framebuffer->service_id()); |
| 6142 } | 6150 } |
| 6143 GLbitfield clear_bits = 0; | 6151 GLbitfield clear_bits = 0; |
| 6144 if (framebuffer->HasUnclearedColorAttachments()) { | 6152 if (framebuffer->HasUnclearedColorAttachments()) { |
| 6145 // We should always use alpha == 0 here, because 1) some draw buffers may | 6153 // We should always use alpha == 0 here, because 1) some draw buffers may |
| 6146 // have alpha and some may not; 2) we won't have the same situation as the | 6154 // have alpha and some may not; 2) we won't have the same situation as the |
| 6147 // back buffer where alpha channel exists but is not requested. | 6155 // back buffer where alpha channel exists but is not requested. |
| 6148 glClearColor(0.0f, 0.0f, 0.0f, 0.0f); | 6156 float clear_alpha = 0.0f; |
| 6157 if (workarounds().disable_gl_rgb_format && |
| 6158 (GLES2Util::GetChannelsForFormat( |
| 6159 framebuffer->GetColorAttachment0Format()) & |
| 6160 0x0008) == 0) { |
| 6161 clear_alpha = 1.0f; |
| 6162 } |
| 6163 glClearColor(0.0f, 0.0f, 0.0f, clear_alpha); |
| 6164 |
| 6149 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 6165 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
| 6150 clear_bits |= GL_COLOR_BUFFER_BIT; | 6166 clear_bits |= GL_COLOR_BUFFER_BIT; |
| 6151 if (feature_info_->feature_flags().ext_draw_buffers || | 6167 if (feature_info_->feature_flags().ext_draw_buffers || |
| 6152 feature_info_->IsES3Enabled()) { | 6168 feature_info_->IsES3Enabled()) { |
| 6153 framebuffer->PrepareDrawBuffersForClear(); | 6169 framebuffer->PrepareDrawBuffersForClear(); |
| 6154 } | 6170 } |
| 6155 } | 6171 } |
| 6156 | 6172 |
| 6157 if (framebuffer->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT) || | 6173 if (framebuffer->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT) || |
| 6158 framebuffer->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)) { | 6174 framebuffer->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)) { |
| (...skipping 9495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15654 } | 15670 } |
| 15655 | 15671 |
| 15656 // Include the auto-generated part of this file. We split this because it means | 15672 // Include the auto-generated part of this file. We split this because it means |
| 15657 // we can easily edit the non-auto generated parts right here in this file | 15673 // we can easily edit the non-auto generated parts right here in this file |
| 15658 // instead of having to edit some template or the code generator. | 15674 // instead of having to edit some template or the code generator. |
| 15659 #include "base/macros.h" | 15675 #include "base/macros.h" |
| 15660 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15676 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 15661 | 15677 |
| 15662 } // namespace gles2 | 15678 } // namespace gles2 |
| 15663 } // namespace gpu | 15679 } // namespace gpu |
| OLD | NEW |