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

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

Issue 2934733002: Workaround for Intel 6xxx clear to 0/1 bug (Closed)
Patch Set: fix try-bot error Created 3 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
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 <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 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 1454
1455 // Wrapper for glBufferSubData. 1455 // Wrapper for glBufferSubData.
1456 void DoBufferSubData( 1456 void DoBufferSubData(
1457 GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data); 1457 GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data);
1458 1458
1459 // Wrapper for glCheckFramebufferStatus 1459 // Wrapper for glCheckFramebufferStatus
1460 GLenum DoCheckFramebufferStatus(GLenum target); 1460 GLenum DoCheckFramebufferStatus(GLenum target);
1461 1461
1462 // Wrapper for glClear*() 1462 // Wrapper for glClear*()
1463 error::Error DoClear(GLbitfield mask); 1463 error::Error DoClear(GLbitfield mask);
1464 void DoClearColor(GLclampf red,
1465 GLclampf green,
1466 GLclampf blue,
1467 GLclampf alpha);
1464 void DoClearBufferiv(GLenum buffer, 1468 void DoClearBufferiv(GLenum buffer,
1465 GLint drawbuffer, 1469 GLint drawbuffer,
1466 const volatile GLint* value); 1470 const volatile GLint* value);
1467 void DoClearBufferuiv(GLenum buffer, 1471 void DoClearBufferuiv(GLenum buffer,
1468 GLint drawbuffer, 1472 GLint drawbuffer,
1469 const volatile GLuint* value); 1473 const volatile GLuint* value);
1470 void DoClearBufferfv(GLenum buffer, 1474 void DoClearBufferfv(GLenum buffer,
1471 GLint drawbuffer, 1475 GLint drawbuffer,
1472 const volatile GLfloat* value); 1476 const volatile GLfloat* value);
1473 void DoClearBufferfi( 1477 void DoClearBufferfi(
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2601 decoder_->should_use_native_gmb_for_backbuffer_ && 2605 decoder_->should_use_native_gmb_for_backbuffer_ &&
2602 !decoder_->offscreen_buffer_should_have_alpha_ && 2606 !decoder_->offscreen_buffer_should_have_alpha_ &&
2603 decoder_->ChromiumImageNeedsRGBEmulation() && 2607 decoder_->ChromiumImageNeedsRGBEmulation() &&
2604 decoder_->workarounds() 2608 decoder_->workarounds()
2605 .disable_multisampling_color_mask_usage; 2609 .disable_multisampling_color_mask_usage;
2606 if (alpha_channel_needs_clear) { 2610 if (alpha_channel_needs_clear) {
2607 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 2611 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT,
2608 decoder_->offscreen_target_frame_buffer_->id()); 2612 decoder_->offscreen_target_frame_buffer_->id());
2609 decoder_->state_.SetDeviceColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); 2613 decoder_->state_.SetDeviceColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
2610 decoder->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); 2614 decoder->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
2611 glClearColor(0, 0, 0, 1); 2615 decoder_->DoClearColor(0, 0, 0, 1);
2612 glClear(GL_COLOR_BUFFER_BIT); 2616 glClear(GL_COLOR_BUFFER_BIT);
2613 decoder_->RestoreClearState(); 2617 decoder_->RestoreClearState();
2614 } 2618 }
2615 2619
2616 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 2620 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT,
2617 decoder_->offscreen_target_frame_buffer_->id()); 2621 decoder_->offscreen_target_frame_buffer_->id());
2618 GLuint targetid; 2622 GLuint targetid;
2619 if (internal) { 2623 if (internal) {
2620 if (!decoder_->offscreen_resolved_frame_buffer_.get()) { 2624 if (!decoder_->offscreen_resolved_frame_buffer_.get()) {
2621 decoder_->offscreen_resolved_frame_buffer_.reset( 2625 decoder_->offscreen_resolved_frame_buffer_.reset(
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2853 bool needs_clear_for_rgb_emulation = 2857 bool needs_clear_for_rgb_emulation =
2854 !decoder_->offscreen_buffer_should_have_alpha_ && 2858 !decoder_->offscreen_buffer_should_have_alpha_ &&
2855 decoder_->ChromiumImageNeedsRGBEmulation(); 2859 decoder_->ChromiumImageNeedsRGBEmulation();
2856 if (zero || needs_clear_for_rgb_emulation) { 2860 if (zero || needs_clear_for_rgb_emulation) {
2857 GLuint fbo; 2861 GLuint fbo;
2858 glGenFramebuffersEXT(1, &fbo); 2862 glGenFramebuffersEXT(1, &fbo);
2859 { 2863 {
2860 ScopedFramebufferBinder binder(decoder_, fbo); 2864 ScopedFramebufferBinder binder(decoder_, fbo);
2861 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, Target(), 2865 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, Target(),
2862 id(), 0); 2866 id(), 0);
2863 glClearColor(0, 0, 0, decoder_->BackBufferAlphaClearColor()); 2867 decoder_->DoClearColor(0, 0, 0, decoder_->BackBufferAlphaClearColor());
2864 decoder_->state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 2868 decoder_->state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
2865 decoder_->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); 2869 decoder_->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
2866 glClear(GL_COLOR_BUFFER_BIT); 2870 glClear(GL_COLOR_BUFFER_BIT);
2867 decoder_->RestoreClearState(); 2871 decoder_->RestoreClearState();
2868 } 2872 }
2869 glDeleteFramebuffersEXT(1, &fbo); 2873 glDeleteFramebuffersEXT(1, &fbo);
2870 } 2874 }
2871 return true; 2875 return true;
2872 } 2876 }
2873 2877
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2946 bool alpha_channel_needs_clear = 2950 bool alpha_channel_needs_clear =
2947 (format == GL_RGBA || format == GL_RGBA8) && 2951 (format == GL_RGBA || format == GL_RGBA8) &&
2948 !decoder_->offscreen_buffer_should_have_alpha_; 2952 !decoder_->offscreen_buffer_should_have_alpha_;
2949 if (alpha_channel_needs_clear) { 2953 if (alpha_channel_needs_clear) {
2950 GLuint fbo; 2954 GLuint fbo;
2951 glGenFramebuffersEXT(1, &fbo); 2955 glGenFramebuffersEXT(1, &fbo);
2952 { 2956 {
2953 ScopedFramebufferBinder binder(decoder_, fbo); 2957 ScopedFramebufferBinder binder(decoder_, fbo);
2954 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 2958 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
2955 GL_RENDERBUFFER, id_); 2959 GL_RENDERBUFFER, id_);
2956 glClearColor(0, 0, 0, decoder_->BackBufferAlphaClearColor()); 2960 decoder_->DoClearColor(0, 0, 0, decoder_->BackBufferAlphaClearColor());
2957 decoder_->state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 2961 decoder_->state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
2958 decoder_->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); 2962 decoder_->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
2959 glClear(GL_COLOR_BUFFER_BIT); 2963 glClear(GL_COLOR_BUFFER_BIT);
2960 decoder_->RestoreClearState(); 2964 decoder_->RestoreClearState();
2961 } 2965 }
2962 glDeleteFramebuffersEXT(1, &fbo); 2966 glDeleteFramebuffersEXT(1, &fbo);
2963 } 2967 }
2964 2968
2965 bool success = glGetError() == GL_NO_ERROR; 2969 bool success = glGetError() == GL_NO_ERROR;
2966 if (success) { 2970 if (success) {
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
3596 // because the system already clears the buffer before each draw. Proper 3600 // because the system already clears the buffer before each draw. Proper
3597 // fix might be setting the scissor clip properly before initialize. See 3601 // fix might be setting the scissor clip properly before initialize. See
3598 // crbug.com/259023 for details. 3602 // crbug.com/259023 for details.
3599 call_gl_clear = surface_->GetHandle(); 3603 call_gl_clear = surface_->GetHandle();
3600 #endif 3604 #endif
3601 if (call_gl_clear) { 3605 if (call_gl_clear) {
3602 // On configs where we report no alpha, if the underlying surface has 3606 // On configs where we report no alpha, if the underlying surface has
3603 // alpha, clear the surface alpha to 1.0 to be correct on ReadPixels/etc. 3607 // alpha, clear the surface alpha to 1.0 to be correct on ReadPixels/etc.
3604 bool clear_alpha = back_buffer_color_format_ == GL_RGB && alpha_bits > 0; 3608 bool clear_alpha = back_buffer_color_format_ == GL_RGB && alpha_bits > 0;
3605 if (clear_alpha) { 3609 if (clear_alpha) {
3606 glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 3610 DoClearColor(0.0f, 0.0f, 0.0f, 1.0f);
3607 } 3611 }
3608 3612
3609 // Clear the backbuffer. 3613 // Clear the backbuffer.
3610 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 3614 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
3611 3615
3612 // Restore alpha clear value if we changed it. 3616 // Restore alpha clear value if we changed it.
3613 if (clear_alpha) { 3617 if (clear_alpha) {
3614 glClearColor(0.0f, 0.0f, 0.0f, 0.0f); 3618 DoClearColor(0.0f, 0.0f, 0.0f, 0.0f);
3615 } 3619 }
3616 } 3620 }
3617 3621
3618 supports_post_sub_buffer_ = surface->SupportsPostSubBuffer(); 3622 supports_post_sub_buffer_ = surface->SupportsPostSubBuffer();
3619 if (workarounds() 3623 if (workarounds()
3620 .disable_post_sub_buffers_for_onscreen_surfaces && 3624 .disable_post_sub_buffers_for_onscreen_surfaces &&
3621 !surface->IsOffscreen()) 3625 !surface->IsOffscreen())
3622 supports_post_sub_buffer_ = false; 3626 supports_post_sub_buffer_ = false;
3623 3627
3624 supports_swap_buffers_with_bounds_ = surface->SupportsSwapBuffersWithBounds(); 3628 supports_swap_buffers_with_bounds_ = surface->SupportsSwapBuffersWithBounds();
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
4353 4357
4354 bool GLES2DecoderImpl::CheckFramebufferValid( 4358 bool GLES2DecoderImpl::CheckFramebufferValid(
4355 Framebuffer* framebuffer, 4359 Framebuffer* framebuffer,
4356 GLenum target, 4360 GLenum target,
4357 GLenum gl_error, 4361 GLenum gl_error,
4358 const char* func_name) { 4362 const char* func_name) {
4359 if (!framebuffer) { 4363 if (!framebuffer) {
4360 if (surfaceless_) 4364 if (surfaceless_)
4361 return false; 4365 return false;
4362 if (backbuffer_needs_clear_bits_) { 4366 if (backbuffer_needs_clear_bits_) {
4363 glClearColor(0, 0, 0, BackBufferAlphaClearColor()); 4367 DoClearColor(0, 0, 0, BackBufferAlphaClearColor());
4364 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 4368 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
4365 glClearStencil(0); 4369 glClearStencil(0);
4366 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); 4370 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask);
4367 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); 4371 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask);
4368 glClearDepth(1.0f); 4372 glClearDepth(1.0f);
4369 state_.SetDeviceDepthMask(GL_TRUE); 4373 state_.SetDeviceDepthMask(GL_TRUE);
4370 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); 4374 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
4371 bool reset_draw_buffer = false; 4375 bool reset_draw_buffer = false;
4372 if ((backbuffer_needs_clear_bits_ & GL_COLOR_BUFFER_BIT) != 0 && 4376 if ((backbuffer_needs_clear_bits_ & GL_COLOR_BUFFER_BIT) != 0 &&
4373 back_buffer_draw_buffer_ == GL_NONE) { 4377 back_buffer_draw_buffer_ == GL_NONE) {
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
5101 if (offscreen_target_frame_buffer_->CheckStatus() != 5105 if (offscreen_target_frame_buffer_->CheckStatus() !=
5102 GL_FRAMEBUFFER_COMPLETE) { 5106 GL_FRAMEBUFFER_COMPLETE) {
5103 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFramebuffer failed " 5107 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFramebuffer failed "
5104 << "because offscreen FBO was incomplete."; 5108 << "because offscreen FBO was incomplete.";
5105 return false; 5109 return false;
5106 } 5110 }
5107 5111
5108 // Clear the target frame buffer. 5112 // Clear the target frame buffer.
5109 { 5113 {
5110 ScopedFramebufferBinder binder(this, offscreen_target_frame_buffer_->id()); 5114 ScopedFramebufferBinder binder(this, offscreen_target_frame_buffer_->id());
5111 glClearColor(0, 0, 0, BackBufferAlphaClearColor()); 5115 DoClearColor(0, 0, 0, BackBufferAlphaClearColor());
5112 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 5116 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
5113 glClearStencil(0); 5117 glClearStencil(0);
5114 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); 5118 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask);
5115 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); 5119 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask);
5116 glClearDepth(0); 5120 glClearDepth(0);
5117 state_.SetDeviceDepthMask(GL_TRUE); 5121 state_.SetDeviceDepthMask(GL_TRUE);
5118 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); 5122 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
5119 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 5123 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
5120 RestoreClearState(); 5124 RestoreClearState();
5121 } 5125 }
(...skipping 2250 matching lines...) Expand 10 before | Expand all | Expand 10 after
7372 "can't be called on integer buffers"); 7376 "can't be called on integer buffers");
7373 return error::kNoError; 7377 return error::kNoError;
7374 } 7378 }
7375 } 7379 }
7376 AdjustDrawBuffers(); 7380 AdjustDrawBuffers();
7377 glClear(mask); 7381 glClear(mask);
7378 } 7382 }
7379 return error::kNoError; 7383 return error::kNoError;
7380 } 7384 }
7381 7385
7386 void GLES2DecoderImpl::DoClearColor(GLclampf red,
7387 GLclampf green,
7388 GLclampf blue,
7389 GLclampf alpha) {
7390 if (workarounds().clear_to_boundary_values_is_broken &&
7391 (1 == red || 0 == red) && (1 == green || 0 == green) &&
7392 (1 == blue || 0 == blue) && (1 == alpha || 0 == alpha)) {
7393 if (1 == alpha)
7394 alpha = 2;
7395 else
7396 alpha = -1;
7397 }
7398 glClearColor(red, green, blue, alpha);
7399 }
7400
7382 void GLES2DecoderImpl::DoClearBufferiv(GLenum buffer, 7401 void GLES2DecoderImpl::DoClearBufferiv(GLenum buffer,
7383 GLint drawbuffer, 7402 GLint drawbuffer,
7384 const volatile GLint* value) { 7403 const volatile GLint* value) {
7385 const char* func_name = "glClearBufferiv"; 7404 const char* func_name = "glClearBufferiv";
7386 if (!CheckBoundDrawFramebufferValid(func_name)) 7405 if (!CheckBoundDrawFramebufferValid(func_name))
7387 return; 7406 return;
7388 ApplyDirtyState(); 7407 ApplyDirtyState();
7389 7408
7390 if (buffer == GL_COLOR) { 7409 if (buffer == GL_COLOR) {
7391 if (drawbuffer < 0 || 7410 if (drawbuffer < 0 ||
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
7610 7629
7611 cleared_int_renderbuffers = true; 7630 cleared_int_renderbuffers = true;
7612 } 7631 }
7613 7632
7614 GLbitfield clear_bits = 0; 7633 GLbitfield clear_bits = 0;
7615 bool reset_draw_buffers = false; 7634 bool reset_draw_buffers = false;
7616 if (framebuffer->HasUnclearedColorAttachments()) { 7635 if (framebuffer->HasUnclearedColorAttachments()) {
7617 // We should always use alpha == 0 here, because 1) some draw buffers may 7636 // We should always use alpha == 0 here, because 1) some draw buffers may
7618 // have alpha and some may not; 2) we won't have the same situation as the 7637 // have alpha and some may not; 2) we won't have the same situation as the
7619 // back buffer where alpha channel exists but is not requested. 7638 // back buffer where alpha channel exists but is not requested.
7620 glClearColor(0.0f, 0.0f, 0.0f, 0.0f); 7639 DoClearColor(0.0f, 0.0f, 0.0f, 0.0f);
7621 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 7640 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
7622 clear_bits |= GL_COLOR_BUFFER_BIT; 7641 clear_bits |= GL_COLOR_BUFFER_BIT;
7623 7642
7624 if (SupportsDrawBuffers()) { 7643 if (SupportsDrawBuffers()) {
7625 reset_draw_buffers = 7644 reset_draw_buffers =
7626 framebuffer->PrepareDrawBuffersForClearingUninitializedAttachments(); 7645 framebuffer->PrepareDrawBuffersForClearingUninitializedAttachments();
7627 } 7646 }
7628 } 7647 }
7629 7648
7630 if (framebuffer->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)) { 7649 if (framebuffer->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
7665 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, service_id); 7684 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, service_id);
7666 } 7685 }
7667 } 7686 }
7668 7687
7669 framebuffer_manager()->MarkAttachmentsAsCleared( 7688 framebuffer_manager()->MarkAttachmentsAsCleared(
7670 framebuffer, renderbuffer_manager(), texture_manager()); 7689 framebuffer, renderbuffer_manager(), texture_manager());
7671 } 7690 }
7672 7691
7673 void GLES2DecoderImpl::RestoreClearState() { 7692 void GLES2DecoderImpl::RestoreClearState() {
7674 framebuffer_state_.clear_state_dirty = true; 7693 framebuffer_state_.clear_state_dirty = true;
7675 glClearColor( 7694 DoClearColor(state_.color_clear_red, state_.color_clear_green,
7676 state_.color_clear_red, state_.color_clear_green, state_.color_clear_blue, 7695 state_.color_clear_blue, state_.color_clear_alpha);
7677 state_.color_clear_alpha);
7678 glClearStencil(state_.stencil_clear); 7696 glClearStencil(state_.stencil_clear);
7679 glClearDepth(state_.depth_clear); 7697 glClearDepth(state_.depth_clear);
7680 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, 7698 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST,
7681 state_.enable_flags.scissor_test); 7699 state_.enable_flags.scissor_test);
7682 gfx::Vector2d scissor_offset = GetBoundFramebufferDrawOffset(); 7700 gfx::Vector2d scissor_offset = GetBoundFramebufferDrawOffset();
7683 glScissor(state_.scissor_x + scissor_offset.x(), 7701 glScissor(state_.scissor_x + scissor_offset.x(),
7684 state_.scissor_y + scissor_offset.y(), state_.scissor_width, 7702 state_.scissor_y + scissor_offset.y(), state_.scissor_width,
7685 state_.scissor_height); 7703 state_.scissor_height);
7686 } 7704 }
7687 7705
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
8626 glGetBooleanv(GL_SCISSOR_TEST, &scissor_enabled); 8644 glGetBooleanv(GL_SCISSOR_TEST, &scissor_enabled);
8627 if (scissor_enabled) 8645 if (scissor_enabled)
8628 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); 8646 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
8629 8647
8630 GLboolean color_mask[4] = {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE}; 8648 GLboolean color_mask[4] = {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE};
8631 glGetBooleanv(GL_COLOR_WRITEMASK, color_mask); 8649 glGetBooleanv(GL_COLOR_WRITEMASK, color_mask);
8632 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 8650 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
8633 8651
8634 GLfloat clear_color[4] = {0.0f, 0.0f, 0.0f, 0.0f}; 8652 GLfloat clear_color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
8635 glGetFloatv(GL_COLOR_CLEAR_VALUE, clear_color); 8653 glGetFloatv(GL_COLOR_CLEAR_VALUE, clear_color);
8636 glClearColor(1.0f, 0.0f, 1.0f, 1.0f); 8654 DoClearColor(1.0f, 0.0f, 1.0f, 1.0f);
8637 8655
8638 // Clear the buffer to the desired key color. 8656 // Clear the buffer to the desired key color.
8639 glClear(GL_COLOR_BUFFER_BIT); 8657 glClear(GL_COLOR_BUFFER_BIT);
8640 8658
8641 // Blit from the multisample buffer to a standard texture. 8659 // Blit from the multisample buffer to a standard texture.
8642 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, validation_fbo_multisample_); 8660 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, validation_fbo_multisample_);
8643 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, validation_fbo_); 8661 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, validation_fbo_);
8644 8662
8645 BlitFramebufferHelper( 8663 BlitFramebufferHelper(
8646 0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_NEAREST); 8664 0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_NEAREST);
8647 8665
8648 // Read a pixel from the buffer. 8666 // Read a pixel from the buffer.
8649 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_); 8667 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_);
8650 8668
8651 unsigned char pixel[3] = {0, 0, 0}; 8669 unsigned char pixel[3] = {0, 0, 0};
8652 glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pixel); 8670 glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pixel);
8653 8671
8654 // Detach the renderbuffer. 8672 // Detach the renderbuffer.
8655 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_multisample_); 8673 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_multisample_);
8656 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 8674 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
8657 GL_RENDERBUFFER, 0); 8675 GL_RENDERBUFFER, 0);
8658 8676
8659 // Restore cached state. 8677 // Restore cached state.
8660 if (scissor_enabled) 8678 if (scissor_enabled)
8661 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, true); 8679 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, true);
8662 8680
8663 state_.SetDeviceColorMask( 8681 state_.SetDeviceColorMask(
8664 color_mask[0], color_mask[1], color_mask[2], color_mask[3]); 8682 color_mask[0], color_mask[1], color_mask[2], color_mask[3]);
8665 glClearColor(clear_color[0], clear_color[1], clear_color[2], clear_color[3]); 8683 DoClearColor(clear_color[0], clear_color[1], clear_color[2], clear_color[3]);
8666 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, draw_framebuffer); 8684 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, draw_framebuffer);
8667 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, read_framebuffer); 8685 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, read_framebuffer);
8668 8686
8669 // Return true if the pixel matched the desired key color. 8687 // Return true if the pixel matched the desired key color.
8670 return (pixel[0] == 0xFF && 8688 return (pixel[0] == 0xFF &&
8671 pixel[1] == 0x00 && 8689 pixel[1] == 0x00 &&
8672 pixel[2] == 0xFF); 8690 pixel[2] == 0xFF);
8673 } 8691 }
8674 8692
8675 void GLES2DecoderImpl::DoRenderbufferStorage( 8693 void GLES2DecoderImpl::DoRenderbufferStorage(
(...skipping 6882 matching lines...) Expand 10 before | Expand all | Expand 10 after
15558 MarkContextLost(error::kUnknown); 15576 MarkContextLost(error::kUnknown);
15559 group_->LoseContexts(error::kUnknown); 15577 group_->LoseContexts(error::kUnknown);
15560 return; 15578 return;
15561 } 15579 }
15562 15580
15563 // Clear the offscreen color texture. 15581 // Clear the offscreen color texture.
15564 // TODO(piman): Is this still necessary? 15582 // TODO(piman): Is this still necessary?
15565 { 15583 {
15566 ScopedFramebufferBinder binder(this, 15584 ScopedFramebufferBinder binder(this,
15567 offscreen_saved_frame_buffer_->id()); 15585 offscreen_saved_frame_buffer_->id());
15568 glClearColor(0, 0, 0, BackBufferAlphaClearColor()); 15586 DoClearColor(0, 0, 0, BackBufferAlphaClearColor());
15569 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 15587 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
15570 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); 15588 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
15571 glClear(GL_COLOR_BUFFER_BIT); 15589 glClear(GL_COLOR_BUFFER_BIT);
15572 RestoreClearState(); 15590 RestoreClearState();
15573 } 15591 }
15574 } 15592 }
15575 } 15593 }
15576 15594
15577 if (offscreen_size_.width() == 0 || offscreen_size_.height() == 0) 15595 if (offscreen_size_.width() == 0 || offscreen_size_.height() == 0)
15578 return; 15596 return;
(...skipping 4137 matching lines...) Expand 10 before | Expand all | Expand 10 after
19716 } 19734 }
19717 19735
19718 // Include the auto-generated part of this file. We split this because it means 19736 // Include the auto-generated part of this file. We split this because it means
19719 // we can easily edit the non-auto generated parts right here in this file 19737 // we can easily edit the non-auto generated parts right here in this file
19720 // instead of having to edit some template or the code generator. 19738 // instead of having to edit some template or the code generator.
19721 #include "base/macros.h" 19739 #include "base/macros.h"
19722 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 19740 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
19723 19741
19724 } // namespace gles2 19742 } // namespace gles2
19725 } // namespace gpu 19743 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698