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

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

Issue 2128753002: Add workaround for multisampling color masks for the command buffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@temp17_gmb_workaround
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | 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 <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 2352 matching lines...) Expand 10 before | Expand all | Expand 10 after
2363 ScopedResolvedFrameBufferBinder::ScopedResolvedFrameBufferBinder( 2363 ScopedResolvedFrameBufferBinder::ScopedResolvedFrameBufferBinder(
2364 GLES2DecoderImpl* decoder, bool enforce_internal_framebuffer, bool internal) 2364 GLES2DecoderImpl* decoder, bool enforce_internal_framebuffer, bool internal)
2365 : decoder_(decoder) { 2365 : decoder_(decoder) {
2366 resolve_and_bind_ = ( 2366 resolve_and_bind_ = (
2367 decoder_->offscreen_target_frame_buffer_.get() && 2367 decoder_->offscreen_target_frame_buffer_.get() &&
2368 decoder_->IsOffscreenBufferMultisampled() && 2368 decoder_->IsOffscreenBufferMultisampled() &&
2369 (!decoder_->framebuffer_state_.bound_read_framebuffer.get() || 2369 (!decoder_->framebuffer_state_.bound_read_framebuffer.get() ||
2370 enforce_internal_framebuffer)); 2370 enforce_internal_framebuffer));
2371 if (!resolve_and_bind_) 2371 if (!resolve_and_bind_)
2372 return; 2372 return;
2373
2374 // TODO(erikchen): On old AMD GPUs on macOS, glColorMask doesn't work
2375 // correctly for multisampled renderbuffers and the alpha channel can be
2376 // overwritten. Add a workaround to clear the alpha channel before resolving.
2377 // https://crbug.com/602484.
2378 ScopedGLErrorSuppressor suppressor( 2373 ScopedGLErrorSuppressor suppressor(
2379 "ScopedResolvedFrameBufferBinder::ctor", decoder_->GetErrorState()); 2374 "ScopedResolvedFrameBufferBinder::ctor", decoder_->GetErrorState());
2375
2376 // On old AMD GPUs on macOS, glColorMask doesn't work correctly for
2377 // multisampled renderbuffers and the alpha channel can be overwritten. This
2378 // workaround clears the alpha channel before resolving.
2379 bool alpha_channel_needs_clear =
2380 decoder_->should_use_native_gmb_for_backbuffer_ &&
2381 !decoder_->offscreen_buffer_should_have_alpha_ &&
2382 decoder_->ChromiumImageNeedsRGBEmulation() &&
2383 decoder_->feature_info_->workarounds()
2384 .disable_multisampling_color_mask_usage;
2385 if (alpha_channel_needs_clear) {
2386 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT,
2387 decoder_->offscreen_target_frame_buffer_->id());
2388 decoder_->state_.SetDeviceColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
2389 decoder->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
2390 glClearColor(0, 0, 0, 1);
2391 glClear(GL_COLOR_BUFFER_BIT);
2392 decoder_->RestoreClearState();
2393 }
2394
2380 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 2395 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT,
2381 decoder_->offscreen_target_frame_buffer_->id()); 2396 decoder_->offscreen_target_frame_buffer_->id());
2382 GLuint targetid; 2397 GLuint targetid;
2383 if (internal) { 2398 if (internal) {
2384 if (!decoder_->offscreen_resolved_frame_buffer_.get()) { 2399 if (!decoder_->offscreen_resolved_frame_buffer_.get()) {
2385 decoder_->offscreen_resolved_frame_buffer_.reset( 2400 decoder_->offscreen_resolved_frame_buffer_.reset(
2386 new BackFramebuffer(decoder_)); 2401 new BackFramebuffer(decoder_));
2387 decoder_->offscreen_resolved_frame_buffer_->Create(); 2402 decoder_->offscreen_resolved_frame_buffer_->Create();
2388 decoder_->offscreen_resolved_color_texture_.reset( 2403 decoder_->offscreen_resolved_color_texture_.reset(
2389 new BackTexture(decoder)); 2404 new BackTexture(decoder));
(...skipping 14698 matching lines...) Expand 10 before | Expand all | Expand 10 after
17088 } 17103 }
17089 17104
17090 // Include the auto-generated part of this file. We split this because it means 17105 // Include the auto-generated part of this file. We split this because it means
17091 // we can easily edit the non-auto generated parts right here in this file 17106 // we can easily edit the non-auto generated parts right here in this file
17092 // instead of having to edit some template or the code generator. 17107 // instead of having to edit some template or the code generator.
17093 #include "base/macros.h" 17108 #include "base/macros.h"
17094 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 17109 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
17095 17110
17096 } // namespace gles2 17111 } // namespace gles2
17097 } // namespace gpu 17112 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698