Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 315283002: Framebuffer clear() needs to consider the situation some draw buffers are disabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3055 matching lines...) Expand 10 before | Expand all | Expand 10 after
3066 if (!framebuffer) { 3066 if (!framebuffer) {
3067 if (backbuffer_needs_clear_bits_) { 3067 if (backbuffer_needs_clear_bits_) {
3068 glClearColor(0, 0, 0, (GLES2Util::GetChannelsForFormat( 3068 glClearColor(0, 0, 0, (GLES2Util::GetChannelsForFormat(
3069 offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1); 3069 offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1);
3070 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 3070 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
3071 glClearStencil(0); 3071 glClearStencil(0);
3072 glStencilMask(-1); 3072 glStencilMask(-1);
3073 glClearDepth(1.0f); 3073 glClearDepth(1.0f);
3074 state_.SetDeviceDepthMask(GL_TRUE); 3074 state_.SetDeviceDepthMask(GL_TRUE);
3075 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); 3075 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
3076 bool reset_draw_buffer = false;
3077 if ((backbuffer_needs_clear_bits_ | GL_COLOR_BUFFER_BIT) != 0 &&
3078 group_->draw_buffer() == GL_NONE) {
3079 reset_draw_buffer = true;
3080 GLenum buf = GL_BACK;
3081 if (GetBackbufferServiceId() != 0) // emulated backbuffer
3082 buf = GL_COLOR_ATTACHMENT0;
3083 glDrawBuffersARB(1, &buf);
3084 }
3076 glClear(backbuffer_needs_clear_bits_); 3085 glClear(backbuffer_needs_clear_bits_);
3086 if (reset_draw_buffer) {
3087 GLenum buf = GL_NONE;
3088 glDrawBuffersARB(1, &buf);
3089 }
3077 backbuffer_needs_clear_bits_ = 0; 3090 backbuffer_needs_clear_bits_ = 0;
3078 RestoreClearState(); 3091 RestoreClearState();
3079 } 3092 }
3080 return true; 3093 return true;
3081 } 3094 }
3082 3095
3083 if (framebuffer_manager()->IsComplete(framebuffer)) { 3096 if (framebuffer_manager()->IsComplete(framebuffer)) {
3084 return true; 3097 return true;
3085 } 3098 }
3086 3099
(...skipping 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after
5012 GLenum target, Framebuffer* framebuffer) { 5025 GLenum target, Framebuffer* framebuffer) {
5013 if (target == GL_READ_FRAMEBUFFER_EXT) { 5026 if (target == GL_READ_FRAMEBUFFER_EXT) {
5014 // bind this to the DRAW point, clear then bind back to READ 5027 // bind this to the DRAW point, clear then bind back to READ
5015 // TODO(gman): I don't think there is any guarantee that an FBO that 5028 // TODO(gman): I don't think there is any guarantee that an FBO that
5016 // is complete on the READ attachment will be complete as a DRAW 5029 // is complete on the READ attachment will be complete as a DRAW
5017 // attachment. 5030 // attachment.
5018 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); 5031 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0);
5019 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, framebuffer->service_id()); 5032 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, framebuffer->service_id());
5020 } 5033 }
5021 GLbitfield clear_bits = 0; 5034 GLbitfield clear_bits = 0;
5022 if (framebuffer->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)) { 5035 if (framebuffer->HasUnclearedColorAttachments()) {
5023 glClearColor( 5036 glClearColor(
5024 0.0f, 0.0f, 0.0f, 5037 0.0f, 0.0f, 0.0f,
5025 (GLES2Util::GetChannelsForFormat( 5038 (GLES2Util::GetChannelsForFormat(
5026 framebuffer->GetColorAttachmentFormat()) & 0x0008) != 0 ? 0.0f : 5039 framebuffer->GetColorAttachmentFormat()) & 0x0008) != 0 ? 0.0f :
5027 1.0f); 5040 1.0f);
5028 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 5041 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
5029 clear_bits |= GL_COLOR_BUFFER_BIT; 5042 clear_bits |= GL_COLOR_BUFFER_BIT;
5043 framebuffer->PrepareDrawBuffersForClear();
5030 } 5044 }
5031 5045
5032 if (framebuffer->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT) || 5046 if (framebuffer->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT) ||
5033 framebuffer->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)) { 5047 framebuffer->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)) {
5034 glClearStencil(0); 5048 glClearStencil(0);
5035 glStencilMask(-1); 5049 glStencilMask(-1);
5036 clear_bits |= GL_STENCIL_BUFFER_BIT; 5050 clear_bits |= GL_STENCIL_BUFFER_BIT;
5037 } 5051 }
5038 5052
5039 if (framebuffer->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT) || 5053 if (framebuffer->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT) ||
5040 framebuffer->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)) { 5054 framebuffer->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)) {
5041 glClearDepth(1.0f); 5055 glClearDepth(1.0f);
5042 state_.SetDeviceDepthMask(GL_TRUE); 5056 state_.SetDeviceDepthMask(GL_TRUE);
5043 clear_bits |= GL_DEPTH_BUFFER_BIT; 5057 clear_bits |= GL_DEPTH_BUFFER_BIT;
5044 } 5058 }
5045 5059
5046 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); 5060 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
5047 glClear(clear_bits); 5061 glClear(clear_bits);
5048 5062
5063 if ((clear_bits | GL_COLOR_BUFFER_BIT) != 0)
5064 framebuffer->RestoreDrawBuffersAfterClear();
5065
5049 framebuffer_manager()->MarkAttachmentsAsCleared( 5066 framebuffer_manager()->MarkAttachmentsAsCleared(
5050 framebuffer, renderbuffer_manager(), texture_manager()); 5067 framebuffer, renderbuffer_manager(), texture_manager());
5051 5068
5052 RestoreClearState(); 5069 RestoreClearState();
5053 5070
5054 if (target == GL_READ_FRAMEBUFFER_EXT) { 5071 if (target == GL_READ_FRAMEBUFFER_EXT) {
5055 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, framebuffer->service_id()); 5072 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, framebuffer->service_id());
5056 Framebuffer* draw_framebuffer = 5073 Framebuffer* draw_framebuffer =
5057 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); 5074 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
5058 GLuint service_id = draw_framebuffer ? draw_framebuffer->service_id() : 5075 GLuint service_id = draw_framebuffer ? draw_framebuffer->service_id() :
(...skipping 5713 matching lines...) Expand 10 before | Expand all | Expand 10 after
10772 } 10789 }
10773 } 10790 }
10774 10791
10775 // Include the auto-generated part of this file. We split this because it means 10792 // Include the auto-generated part of this file. We split this because it means
10776 // we can easily edit the non-auto generated parts right here in this file 10793 // we can easily edit the non-auto generated parts right here in this file
10777 // instead of having to edit some template or the code generator. 10794 // instead of having to edit some template or the code generator.
10778 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10795 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10779 10796
10780 } // namespace gles2 10797 } // namespace gles2
10781 } // namespace gpu 10798 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698