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

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 262793002: Revert of Optimize GLES2DecoderImpl::ApplyDirtyState. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/gles2_cmd_decoder.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 605ec14569e6cee22d9f43b4cfb51183d677ac1f..4b75c2e1eb480c1ec4e55c6956e89324ffd78b84 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -278,6 +278,15 @@
return true;
}
+// Wrapper for glEnable/glDisable that doesn't suck.
+static void EnableDisable(GLenum pname, bool enable) {
+ if (enable) {
+ glEnable(pname);
+ } else {
+ glDisable(pname);
+ }
+}
+
// This class prevents any GL errors that occur when it is in scope from
// being reported to the client.
class ScopedGLErrorSuppressor {
@@ -652,7 +661,6 @@
virtual void ResetAsyncPixelTransferManagerForTest() OVERRIDE;
virtual void SetAsyncPixelTransferManagerForTest(
AsyncPixelTransferManager* manager) OVERRIDE;
- virtual void SetIgnoreCachedStateForTest(bool ignore) OVERRIDE;
void ProcessFinishedAsyncTransfers();
virtual bool GetServiceTextureId(uint32 client_texture_id,
@@ -1924,7 +1932,7 @@
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, targetid);
const int width = decoder_->offscreen_size_.width();
const int height = decoder_->offscreen_size_.height();
- decoder->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
+ glDisable(GL_SCISSOR_TEST);
decoder->BlitFramebufferHelper(0,
0,
width,
@@ -1946,7 +1954,7 @@
"ScopedResolvedFrameBufferBinder::dtor", decoder_->GetErrorState());
decoder_->RestoreCurrentFramebufferBindings();
if (decoder_->state_.enable_flags.scissor_test) {
- decoder_->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, true);
+ glEnable(GL_SCISSOR_TEST);
}
}
@@ -3062,12 +3070,12 @@
if (backbuffer_needs_clear_bits_) {
glClearColor(0, 0, 0, (GLES2Util::GetChannelsForFormat(
offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1);
- state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glClearStencil(0);
glStencilMask(-1);
glClearDepth(1.0f);
- state_.SetDeviceDepthMask(GL_TRUE);
- state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
+ glDepthMask(true);
+ glDisable(GL_SCISSOR_TEST);
glClear(backbuffer_needs_clear_bits_);
backbuffer_needs_clear_bits_ = 0;
RestoreClearState();
@@ -3570,13 +3578,13 @@
ScopedFrameBufferBinder binder(this, offscreen_target_frame_buffer_->id());
glClearColor(0, 0, 0, (GLES2Util::GetChannelsForFormat(
offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1);
- state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glClearStencil(0);
- state_.SetDeviceStencilMaskSeparate(GL_FRONT, -1);
- state_.SetDeviceStencilMaskSeparate(GL_BACK, -1);
+ glStencilMaskSeparate(GL_FRONT, -1);
+ glStencilMaskSeparate(GL_BACK, -1);
glClearDepth(0);
- state_.SetDeviceDepthMask(GL_TRUE);
- state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
+ glDepthMask(GL_TRUE);
+ glDisable(GL_SCISSOR_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
RestoreClearState();
}
@@ -3839,25 +3847,23 @@
void GLES2DecoderImpl::ApplyDirtyState() {
if (framebuffer_state_.clear_state_dirty) {
- bool have_alpha = BoundFramebufferHasColorAttachmentWithAlpha(true);
- state_.SetDeviceColorMask(state_.color_mask_red,
- state_.color_mask_green,
- state_.color_mask_blue,
- state_.color_mask_alpha && have_alpha);
-
+ glColorMask(
+ state_.color_mask_red, state_.color_mask_green, state_.color_mask_blue,
+ state_.color_mask_alpha &&
+ BoundFramebufferHasColorAttachmentWithAlpha(true));
bool have_depth = BoundFramebufferHasDepthAttachment();
- state_.SetDeviceDepthMask(state_.depth_mask && have_depth);
-
+ glDepthMask(state_.depth_mask && have_depth);
+ EnableDisable(GL_DEPTH_TEST, state_.enable_flags.depth_test && have_depth);
bool have_stencil = BoundFramebufferHasStencilAttachment();
- state_.SetDeviceStencilMaskSeparate(
+ glStencilMaskSeparate(
GL_FRONT, have_stencil ? state_.stencil_front_writemask : 0);
- state_.SetDeviceStencilMaskSeparate(
+ glStencilMaskSeparate(
GL_BACK, have_stencil ? state_.stencil_back_writemask : 0);
-
- state_.SetDeviceCapabilityState(
- GL_DEPTH_TEST, state_.enable_flags.depth_test && have_depth);
- state_.SetDeviceCapabilityState(
+ EnableDisable(
GL_STENCIL_TEST, state_.enable_flags.stencil_test && have_stencil);
+ EnableDisable(GL_CULL_FACE, state_.enable_flags.cull_face);
+ EnableDisable(GL_SCISSOR_TEST, state_.enable_flags.scissor_test);
+ EnableDisable(GL_BLEND, state_.enable_flags.blend);
framebuffer_state_.clear_state_dirty = false;
}
}
@@ -3928,10 +3934,6 @@
void GLES2DecoderImpl::RestoreAllAttributes() const {
state_.RestoreVertexAttribs();
-}
-
-void GLES2DecoderImpl::SetIgnoreCachedStateForTest(bool ignore) {
- state_.SetIgnoreCachedStateForTest(ignore);
}
void GLES2DecoderImpl::OnFboChanged() const {
@@ -5027,7 +5029,7 @@
(GLES2Util::GetChannelsForFormat(
framebuffer->GetColorAttachmentFormat()) & 0x0008) != 0 ? 0.0f :
1.0f);
- state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+ glColorMask(true, true, true, true);
clear_bits |= GL_COLOR_BUFFER_BIT;
}
@@ -5041,11 +5043,11 @@
if (framebuffer->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT) ||
framebuffer->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)) {
glClearDepth(1.0f);
- state_.SetDeviceDepthMask(GL_TRUE);
+ glDepthMask(true);
clear_bits |= GL_DEPTH_BUFFER_BIT;
}
- state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
+ glDisable(GL_SCISSOR_TEST);
glClear(clear_bits);
framebuffer_manager()->MarkAttachmentsAsCleared(
@@ -5071,7 +5073,7 @@
glClearStencil(state_.stencil_clear);
glClearDepth(state_.depth_clear);
if (state_.enable_flags.scissor_test) {
- state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, true);
+ glEnable(GL_SCISSOR_TEST);
}
}
@@ -5248,11 +5250,10 @@
return;
}
- state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
+ glDisable(GL_SCISSOR_TEST);
BlitFramebufferHelper(
srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
- state_.SetDeviceCapabilityState(GL_SCISSOR_TEST,
- state_.enable_flags.scissor_test);
+ EnableDisable(GL_SCISSOR_TEST, state_.enable_flags.scissor_test);
}
void GLES2DecoderImpl::RenderbufferStorageMultisampleHelper(
@@ -5491,11 +5492,11 @@
GLboolean scissor_enabled = false;
glGetBooleanv(GL_SCISSOR_TEST, &scissor_enabled);
if (scissor_enabled)
- state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
-
- GLboolean color_mask[4] = {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE};
+ glDisable(GL_SCISSOR_TEST);
+
+ GLboolean color_mask[4] = {true, true, true, true};
glGetBooleanv(GL_COLOR_WRITEMASK, color_mask);
- state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+ glColorMask(true, true, true, true);
GLfloat clear_color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
glGetFloatv(GL_COLOR_CLEAR_VALUE, clear_color);
@@ -5524,10 +5525,9 @@
// Restore cached state.
if (scissor_enabled)
- state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, true);
-
- state_.SetDeviceColorMask(
- color_mask[0], color_mask[1], color_mask[2], color_mask[3]);
+ glEnable(GL_SCISSOR_TEST);
+
+ glColorMask(color_mask[0], color_mask[1], color_mask[2], color_mask[3]);
glClearColor(clear_color[0], clear_color[1], clear_color[2], clear_color[3]);
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, draw_framebuffer);
glBindFramebufferEXT(GL_READ_FRAMEBUFFER, read_framebuffer);
@@ -7843,8 +7843,8 @@
glClearStencil(0);
glStencilMask(-1);
glClearDepth(1.0f);
- state_.SetDeviceDepthMask(GL_TRUE);
- state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
+ glDepthMask(true);
+ glDisable(GL_SCISSOR_TEST);
glClear(GL_DEPTH_BUFFER_BIT | (have_stencil ? GL_STENCIL_BUFFER_BIT : 0));
RestoreClearState();
@@ -9170,8 +9170,8 @@
ScopedFrameBufferBinder binder(this,
offscreen_saved_frame_buffer_->id());
glClearColor(0, 0, 0, 0);
- state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+ glDisable(GL_SCISSOR_TEST);
glClear(GL_COLOR_BUFFER_BIT);
RestoreClearState();
}
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698