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 2595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2606 const bool rgb8_supported = | 2606 const bool rgb8_supported = |
2607 context_->HasExtension("GL_OES_rgb8_rgba8"); | 2607 context_->HasExtension("GL_OES_rgb8_rgba8"); |
2608 // The only available default render buffer formats in GLES2 have very | 2608 // The only available default render buffer formats in GLES2 have very |
2609 // little precision. Don't enable multisampling unless 8-bit render | 2609 // little precision. Don't enable multisampling unless 8-bit render |
2610 // buffer formats are available--instead fall back to 8-bit textures. | 2610 // buffer formats are available--instead fall back to 8-bit textures. |
2611 if (rgb8_supported && offscreen_target_samples_ > 1) { | 2611 if (rgb8_supported && offscreen_target_samples_ > 1) { |
2612 offscreen_target_color_format_ = attrib_parser.alpha_size > 0 ? | 2612 offscreen_target_color_format_ = attrib_parser.alpha_size > 0 ? |
2613 GL_RGBA8 : GL_RGB8; | 2613 GL_RGBA8 : GL_RGB8; |
2614 } else { | 2614 } else { |
2615 offscreen_target_samples_ = 1; | 2615 offscreen_target_samples_ = 1; |
2616 offscreen_target_color_format_ = attrib_parser.alpha_size > 0 ? | 2616 offscreen_target_color_format_ = attrib_parser.alpha_size > 0 || |
2617 GL_RGBA : GL_RGB; | 2617 workarounds().disable_gl_rgb_format ? GL_RGBA : GL_RGB; |
piman
2015/03/31 04:06:30
nit: can you fix indenting? e.g. by running git cl
| |
2618 } | 2618 } |
2619 | 2619 |
2620 // ANGLE only supports packed depth/stencil formats, so use it if it is | 2620 // ANGLE only supports packed depth/stencil formats, so use it if it is |
2621 // available. | 2621 // available. |
2622 const bool depth24_stencil8_supported = | 2622 const bool depth24_stencil8_supported = |
2623 feature_info_->feature_flags().packed_depth24_stencil8; | 2623 feature_info_->feature_flags().packed_depth24_stencil8; |
2624 VLOG(1) << "GL_OES_packed_depth_stencil " | 2624 VLOG(1) << "GL_OES_packed_depth_stencil " |
2625 << (depth24_stencil8_supported ? "" : "not ") << "supported."; | 2625 << (depth24_stencil8_supported ? "" : "not ") << "supported."; |
2626 if ((attrib_parser.depth_size > 0 || attrib_parser.stencil_size > 0) && | 2626 if ((attrib_parser.depth_size > 0 || attrib_parser.stencil_size > 0) && |
2627 depth24_stencil8_supported) { | 2627 depth24_stencil8_supported) { |
2628 offscreen_target_depth_format_ = GL_DEPTH24_STENCIL8; | 2628 offscreen_target_depth_format_ = GL_DEPTH24_STENCIL8; |
2629 offscreen_target_stencil_format_ = 0; | 2629 offscreen_target_stencil_format_ = 0; |
2630 } else { | 2630 } else { |
2631 // It may be the case that this depth/stencil combination is not | 2631 // It may be the case that this depth/stencil combination is not |
2632 // supported, but this will be checked later by CheckFramebufferStatus. | 2632 // supported, but this will be checked later by CheckFramebufferStatus. |
2633 offscreen_target_depth_format_ = attrib_parser.depth_size > 0 ? | 2633 offscreen_target_depth_format_ = attrib_parser.depth_size > 0 ? |
2634 GL_DEPTH_COMPONENT16 : 0; | 2634 GL_DEPTH_COMPONENT16 : 0; |
2635 offscreen_target_stencil_format_ = attrib_parser.stencil_size > 0 ? | 2635 offscreen_target_stencil_format_ = attrib_parser.stencil_size > 0 ? |
2636 GL_STENCIL_INDEX8 : 0; | 2636 GL_STENCIL_INDEX8 : 0; |
2637 } | 2637 } |
2638 } else { | 2638 } else { |
2639 offscreen_target_color_format_ = attrib_parser.alpha_size > 0 ? | 2639 offscreen_target_color_format_ = attrib_parser.alpha_size > 0 || |
2640 GL_RGBA : GL_RGB; | 2640 workarounds().disable_gl_rgb_format ? GL_RGBA : GL_RGB; |
2641 | 2641 |
2642 // If depth is requested at all, use the packed depth stencil format if | 2642 // If depth is requested at all, use the packed depth stencil format if |
2643 // it's available, as some desktop GL drivers don't support any non-packed | 2643 // it's available, as some desktop GL drivers don't support any non-packed |
2644 // formats for depth attachments. | 2644 // formats for depth attachments. |
2645 const bool depth24_stencil8_supported = | 2645 const bool depth24_stencil8_supported = |
2646 feature_info_->feature_flags().packed_depth24_stencil8; | 2646 feature_info_->feature_flags().packed_depth24_stencil8; |
2647 VLOG(1) << "GL_EXT_packed_depth_stencil " | 2647 VLOG(1) << "GL_EXT_packed_depth_stencil " |
2648 << (depth24_stencil8_supported ? "" : "not ") << "supported."; | 2648 << (depth24_stencil8_supported ? "" : "not ") << "supported."; |
2649 | 2649 |
2650 if ((attrib_parser.depth_size > 0 || attrib_parser.stencil_size > 0) && | 2650 if ((attrib_parser.depth_size > 0 || attrib_parser.stencil_size > 0) && |
2651 depth24_stencil8_supported) { | 2651 depth24_stencil8_supported) { |
2652 offscreen_target_depth_format_ = GL_DEPTH24_STENCIL8; | 2652 offscreen_target_depth_format_ = GL_DEPTH24_STENCIL8; |
2653 offscreen_target_stencil_format_ = 0; | 2653 offscreen_target_stencil_format_ = 0; |
2654 } else { | 2654 } else { |
2655 offscreen_target_depth_format_ = attrib_parser.depth_size > 0 ? | 2655 offscreen_target_depth_format_ = attrib_parser.depth_size > 0 ? |
2656 GL_DEPTH_COMPONENT : 0; | 2656 GL_DEPTH_COMPONENT : 0; |
2657 offscreen_target_stencil_format_ = attrib_parser.stencil_size > 0 ? | 2657 offscreen_target_stencil_format_ = attrib_parser.stencil_size > 0 ? |
2658 GL_STENCIL_INDEX : 0; | 2658 GL_STENCIL_INDEX : 0; |
2659 } | 2659 } |
2660 } | 2660 } |
2661 | 2661 |
2662 offscreen_saved_color_format_ = attrib_parser.alpha_size > 0 ? | 2662 offscreen_saved_color_format_ = attrib_parser.alpha_size > 0 || |
2663 GL_RGBA : GL_RGB; | 2663 workarounds().disable_gl_rgb_format ? GL_RGBA : GL_RGB; |
2664 | 2664 |
2665 // Create the target frame buffer. This is the one that the client renders | 2665 // Create the target frame buffer. This is the one that the client renders |
2666 // directly to. | 2666 // directly to. |
2667 offscreen_target_frame_buffer_.reset(new BackFramebuffer(this)); | 2667 offscreen_target_frame_buffer_.reset(new BackFramebuffer(this)); |
2668 offscreen_target_frame_buffer_->Create(); | 2668 offscreen_target_frame_buffer_->Create(); |
2669 // Due to GLES2 format limitations, either the color texture (for | 2669 // Due to GLES2 format limitations, either the color texture (for |
2670 // non-multisampling) or the color render buffer (for multisampling) will be | 2670 // non-multisampling) or the color render buffer (for multisampling) will be |
2671 // attached to the offscreen frame buffer. The render buffer has more | 2671 // attached to the offscreen frame buffer. The render buffer has more |
2672 // limited formats available to it, but the texture can't do multisampling. | 2672 // limited formats available to it, but the texture can't do multisampling. |
2673 if (IsOffscreenBufferMultisampled()) { | 2673 if (IsOffscreenBufferMultisampled()) { |
(...skipping 9757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12431 } | 12431 } |
12432 } | 12432 } |
12433 | 12433 |
12434 // Include the auto-generated part of this file. We split this because it means | 12434 // Include the auto-generated part of this file. We split this because it means |
12435 // we can easily edit the non-auto generated parts right here in this file | 12435 // we can easily edit the non-auto generated parts right here in this file |
12436 // instead of having to edit some template or the code generator. | 12436 // instead of having to edit some template or the code generator. |
12437 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 12437 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
12438 | 12438 |
12439 } // namespace gles2 | 12439 } // namespace gles2 |
12440 } // namespace gpu | 12440 } // namespace gpu |
OLD | NEW |