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

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

Issue 592933003: Fix for surfaceless implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove debug code Created 6 years, 2 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 <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 1730 matching lines...) Expand 10 before | Expand all | Expand 10 after
1741 1741
1742 ShaderCacheCallback shader_cache_callback_; 1742 ShaderCacheCallback shader_cache_callback_;
1743 1743
1744 scoped_ptr<AsyncPixelTransferManager> async_pixel_transfer_manager_; 1744 scoped_ptr<AsyncPixelTransferManager> async_pixel_transfer_manager_;
1745 1745
1746 // The format of the back buffer_ 1746 // The format of the back buffer_
1747 GLenum back_buffer_color_format_; 1747 GLenum back_buffer_color_format_;
1748 bool back_buffer_has_depth_; 1748 bool back_buffer_has_depth_;
1749 bool back_buffer_has_stencil_; 1749 bool back_buffer_has_stencil_;
1750 1750
1751 bool surfaceless_;
1752
1751 // Backbuffer attachments that are currently undefined. 1753 // Backbuffer attachments that are currently undefined.
1752 uint32 backbuffer_needs_clear_bits_; 1754 uint32 backbuffer_needs_clear_bits_;
1753 1755
1754 // The current decoder error communicates the decoder error through command 1756 // The current decoder error communicates the decoder error through command
1755 // processing functions that do not return the error value. Should be set only 1757 // processing functions that do not return the error value. Should be set only
1756 // if not returning an error. 1758 // if not returning an error.
1757 error::Error current_decoder_error_; 1759 error::Error current_decoder_error_;
1758 1760
1759 bool use_shader_translator_; 1761 bool use_shader_translator_;
1760 scoped_refptr<ShaderTranslator> vertex_translator_; 1762 scoped_refptr<ShaderTranslator> vertex_translator_;
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
2297 fixed_attrib_buffer_size_(0), 2299 fixed_attrib_buffer_size_(0),
2298 offscreen_target_color_format_(0), 2300 offscreen_target_color_format_(0),
2299 offscreen_target_depth_format_(0), 2301 offscreen_target_depth_format_(0),
2300 offscreen_target_stencil_format_(0), 2302 offscreen_target_stencil_format_(0),
2301 offscreen_target_samples_(0), 2303 offscreen_target_samples_(0),
2302 offscreen_target_buffer_preserved_(true), 2304 offscreen_target_buffer_preserved_(true),
2303 offscreen_saved_color_format_(0), 2305 offscreen_saved_color_format_(0),
2304 back_buffer_color_format_(0), 2306 back_buffer_color_format_(0),
2305 back_buffer_has_depth_(false), 2307 back_buffer_has_depth_(false),
2306 back_buffer_has_stencil_(false), 2308 back_buffer_has_stencil_(false),
2309 surfaceless_(false),
2307 backbuffer_needs_clear_bits_(0), 2310 backbuffer_needs_clear_bits_(0),
2308 current_decoder_error_(error::kNoError), 2311 current_decoder_error_(error::kNoError),
2309 use_shader_translator_(true), 2312 use_shader_translator_(true),
2310 validators_(group_->feature_info()->validators()), 2313 validators_(group_->feature_info()->validators()),
2311 feature_info_(group_->feature_info()), 2314 feature_info_(group_->feature_info()),
2312 frame_number_(0), 2315 frame_number_(0),
2313 has_robustness_extension_(false), 2316 has_robustness_extension_(false),
2314 reset_status_(GL_NO_ERROR), 2317 reset_status_(GL_NO_ERROR),
2315 reset_by_robustness_extension_(false), 2318 reset_by_robustness_extension_(false),
2316 supports_post_sub_buffer_(false), 2319 supports_post_sub_buffer_(false),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2362 const scoped_refptr<gfx::GLSurface>& surface, 2365 const scoped_refptr<gfx::GLSurface>& surface,
2363 const scoped_refptr<gfx::GLContext>& context, 2366 const scoped_refptr<gfx::GLContext>& context,
2364 bool offscreen, 2367 bool offscreen,
2365 const gfx::Size& size, 2368 const gfx::Size& size,
2366 const DisallowedFeatures& disallowed_features, 2369 const DisallowedFeatures& disallowed_features,
2367 const std::vector<int32>& attribs) { 2370 const std::vector<int32>& attribs) {
2368 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); 2371 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize");
2369 DCHECK(context->IsCurrent(surface.get())); 2372 DCHECK(context->IsCurrent(surface.get()));
2370 DCHECK(!context_.get()); 2373 DCHECK(!context_.get());
2371 2374
2375 surfaceless_ = surface->IsSurfaceless();
2376
2372 set_initialized(); 2377 set_initialized();
2373 gpu_tracer_.reset(new GPUTracer(this)); 2378 gpu_tracer_.reset(new GPUTracer(this));
2374 gpu_state_tracer_ = GPUStateTracer::Create(&state_); 2379 gpu_state_tracer_ = GPUStateTracer::Create(&state_);
2375 2380
2376 if (CommandLine::ForCurrentProcess()->HasSwitch( 2381 if (CommandLine::ForCurrentProcess()->HasSwitch(
2377 switches::kEnableGPUDebugging)) { 2382 switches::kEnableGPUDebugging)) {
2378 set_debug(true); 2383 set_debug(true);
2379 } 2384 }
2380 2385
2381 if (CommandLine::ForCurrentProcess()->HasSwitch( 2386 if (CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
2619 DoBindFramebuffer(GL_FRAMEBUFFER, 0); 2624 DoBindFramebuffer(GL_FRAMEBUFFER, 0);
2620 } else { 2625 } else {
2621 glBindFramebufferEXT(GL_FRAMEBUFFER, GetBackbufferServiceId()); 2626 glBindFramebufferEXT(GL_FRAMEBUFFER, GetBackbufferServiceId());
2622 // These are NOT if the back buffer has these proprorties. They are 2627 // These are NOT if the back buffer has these proprorties. They are
2623 // if we want the command buffer to enforce them regardless of what 2628 // if we want the command buffer to enforce them regardless of what
2624 // the real backbuffer is assuming the real back buffer gives us more than 2629 // the real backbuffer is assuming the real back buffer gives us more than
2625 // we ask for. In other words, if we ask for RGB and we get RGBA then we'll 2630 // we ask for. In other words, if we ask for RGB and we get RGBA then we'll
2626 // make it appear RGB. If on the other hand we ask for RGBA nd get RGB we 2631 // make it appear RGB. If on the other hand we ask for RGBA nd get RGB we
2627 // can't do anything about that. 2632 // can't do anything about that.
2628 2633
2629 GLint v = 0; 2634 if (!surfaceless_) {
2630 glGetIntegerv(GL_ALPHA_BITS, &v); 2635 GLint v = 0;
2631 // This checks if the user requested RGBA and we have RGBA then RGBA. If the 2636 glGetIntegerv(GL_ALPHA_BITS, &v);
2632 // user requested RGB then RGB. If the user did not specify a preference 2637 // This checks if the user requested RGBA and we have RGBA then RGBA. If
2633 // than use whatever we were given. Same for DEPTH and STENCIL. 2638 // the user requested RGB then RGB. If the user did not specify a
2634 back_buffer_color_format_ = 2639 // preference than use whatever we were given. Same for DEPTH and STENCIL.
2635 (attrib_parser.alpha_size != 0 && v > 0) ? GL_RGBA : GL_RGB; 2640 back_buffer_color_format_ =
2636 glGetIntegerv(GL_DEPTH_BITS, &v); 2641 (attrib_parser.alpha_size != 0 && v > 0) ? GL_RGBA : GL_RGB;
2637 back_buffer_has_depth_ = attrib_parser.depth_size != 0 && v > 0; 2642 glGetIntegerv(GL_DEPTH_BITS, &v);
2638 glGetIntegerv(GL_STENCIL_BITS, &v); 2643 back_buffer_has_depth_ = attrib_parser.depth_size != 0 && v > 0;
2639 back_buffer_has_stencil_ = attrib_parser.stencil_size != 0 && v > 0; 2644 glGetIntegerv(GL_STENCIL_BITS, &v);
2645 back_buffer_has_stencil_ = attrib_parser.stencil_size != 0 && v > 0;
2646 }
2640 } 2647 }
2641 2648
2642 // OpenGL ES 2.0 implicitly enables the desktop GL capability 2649 // OpenGL ES 2.0 implicitly enables the desktop GL capability
2643 // VERTEX_PROGRAM_POINT_SIZE and doesn't expose this enum. This fact 2650 // VERTEX_PROGRAM_POINT_SIZE and doesn't expose this enum. This fact
2644 // isn't well documented; it was discovered in the Khronos OpenGL ES 2651 // isn't well documented; it was discovered in the Khronos OpenGL ES
2645 // mailing list archives. It also implicitly enables the desktop GL 2652 // mailing list archives. It also implicitly enables the desktop GL
2646 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord 2653 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord
2647 // variable in fragment shaders. 2654 // variable in fragment shaders.
2648 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { 2655 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
2649 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); 2656 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
(...skipping 22 matching lines...) Expand all
2672 // Set all the default state because some GL drivers get it wrong. 2679 // Set all the default state because some GL drivers get it wrong.
2673 state_.InitCapabilities(NULL); 2680 state_.InitCapabilities(NULL);
2674 state_.InitState(NULL); 2681 state_.InitState(NULL);
2675 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); 2682 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit);
2676 2683
2677 DoBindBuffer(GL_ARRAY_BUFFER, 0); 2684 DoBindBuffer(GL_ARRAY_BUFFER, 0);
2678 DoBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); 2685 DoBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
2679 DoBindFramebuffer(GL_FRAMEBUFFER, 0); 2686 DoBindFramebuffer(GL_FRAMEBUFFER, 0);
2680 DoBindRenderbuffer(GL_RENDERBUFFER, 0); 2687 DoBindRenderbuffer(GL_RENDERBUFFER, 0);
2681 2688
2682 bool call_gl_clear = true; 2689 bool call_gl_clear = !surfaceless_;
2683 #if defined(OS_ANDROID) 2690 #if defined(OS_ANDROID)
2684 // Temporary workaround for Android WebView because this clear ignores the 2691 // Temporary workaround for Android WebView because this clear ignores the
2685 // clip and corrupts that external UI of the App. Not calling glClear is ok 2692 // clip and corrupts that external UI of the App. Not calling glClear is ok
2686 // because the system already clears the buffer before each draw. Proper 2693 // because the system already clears the buffer before each draw. Proper
2687 // fix might be setting the scissor clip properly before initialize. See 2694 // fix might be setting the scissor clip properly before initialize. See
2688 // crbug.com/259023 for details. 2695 // crbug.com/259023 for details.
2689 call_gl_clear = surface_->GetHandle(); 2696 call_gl_clear = surface_->GetHandle();
2690 #endif 2697 #endif
2691 if (call_gl_clear) { 2698 if (call_gl_clear) {
2692 // Clear the backbuffer. 2699 // Clear the backbuffer.
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
3116 framebuffer_state_.bound_draw_framebuffer.get(), 3123 framebuffer_state_.bound_draw_framebuffer.get(),
3117 GetBackbufferServiceId()); 3124 GetBackbufferServiceId());
3118 } 3125 }
3119 OnFboChanged(); 3126 OnFboChanged();
3120 } 3127 }
3121 3128
3122 bool GLES2DecoderImpl::CheckFramebufferValid( 3129 bool GLES2DecoderImpl::CheckFramebufferValid(
3123 Framebuffer* framebuffer, 3130 Framebuffer* framebuffer,
3124 GLenum target, const char* func_name) { 3131 GLenum target, const char* func_name) {
3125 if (!framebuffer) { 3132 if (!framebuffer) {
3133 if (surfaceless_)
3134 return false;
3126 if (backbuffer_needs_clear_bits_) { 3135 if (backbuffer_needs_clear_bits_) {
3127 glClearColor(0, 0, 0, (GLES2Util::GetChannelsForFormat( 3136 glClearColor(0, 0, 0, (GLES2Util::GetChannelsForFormat(
3128 offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1); 3137 offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1);
3129 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 3138 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
3130 glClearStencil(0); 3139 glClearStencil(0);
3131 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); 3140 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask);
3132 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); 3141 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask);
3133 glClearDepth(1.0f); 3142 glClearDepth(1.0f);
3134 state_.SetDeviceDepthMask(GL_TRUE); 3143 state_.SetDeviceDepthMask(GL_TRUE);
3135 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); 3144 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
(...skipping 8139 matching lines...) Expand 10 before | Expand all | Expand 10 after
11275 } 11284 }
11276 } 11285 }
11277 11286
11278 // Include the auto-generated part of this file. We split this because it means 11287 // Include the auto-generated part of this file. We split this because it means
11279 // we can easily edit the non-auto generated parts right here in this file 11288 // we can easily edit the non-auto generated parts right here in this file
11280 // instead of having to edit some template or the code generator. 11289 // instead of having to edit some template or the code generator.
11281 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 11290 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
11282 11291
11283 } // namespace gles2 11292 } // namespace gles2
11284 } // namespace gpu 11293 } // namespace gpu
OLDNEW
« no previous file with comments | « content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_buffer.cc ('k') | ui/gl/gl_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698