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

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

Issue 226423002: Merge 261120 "gpu: Lose context when BeginQueryEXT fails to allo..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1916/src/
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 unified diff | Download patch | Annotate | Revision Log
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 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 GLES2Decoder::~GLES2Decoder() { 534 GLES2Decoder::~GLES2Decoder() {
535 } 535 }
536 536
537 void GLES2Decoder::BeginDecoding() {} 537 void GLES2Decoder::BeginDecoding() {}
538 538
539 void GLES2Decoder::EndDecoding() {} 539 void GLES2Decoder::EndDecoding() {}
540 540
541 // This class implements GLES2Decoder so we don't have to expose all the GLES2 541 // This class implements GLES2Decoder so we don't have to expose all the GLES2
542 // cmd stuff to outside this class. 542 // cmd stuff to outside this class.
543 class GLES2DecoderImpl : public GLES2Decoder, 543 class GLES2DecoderImpl : public GLES2Decoder,
544 public FramebufferManager::TextureDetachObserver { 544 public FramebufferManager::TextureDetachObserver,
545 public ErrorStateClient {
545 public: 546 public:
546 explicit GLES2DecoderImpl(ContextGroup* group); 547 explicit GLES2DecoderImpl(ContextGroup* group);
547 virtual ~GLES2DecoderImpl(); 548 virtual ~GLES2DecoderImpl();
548 549
549 // Overridden from AsyncAPIInterface. 550 // Overridden from AsyncAPIInterface.
550 virtual Error DoCommand(unsigned int command, 551 virtual Error DoCommand(unsigned int command,
551 unsigned int arg_count, 552 unsigned int arg_count,
552 const void* args) OVERRIDE; 553 const void* args) OVERRIDE;
553 554
554 // Overridden from AsyncAPIInterface. 555 // Overridden from AsyncAPIInterface.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 bool BoundFramebufferHasColorAttachmentWithAlpha(bool all_draw_buffers); 663 bool BoundFramebufferHasColorAttachmentWithAlpha(bool all_draw_buffers);
663 bool BoundFramebufferHasDepthAttachment(); 664 bool BoundFramebufferHasDepthAttachment();
664 bool BoundFramebufferHasStencilAttachment(); 665 bool BoundFramebufferHasStencilAttachment();
665 666
666 virtual error::ContextLostReason GetContextLostReason() OVERRIDE; 667 virtual error::ContextLostReason GetContextLostReason() OVERRIDE;
667 668
668 // Overridden from FramebufferManager::TextureDetachObserver: 669 // Overridden from FramebufferManager::TextureDetachObserver:
669 virtual void OnTextureRefDetachedFromFramebuffer( 670 virtual void OnTextureRefDetachedFromFramebuffer(
670 TextureRef* texture) OVERRIDE; 671 TextureRef* texture) OVERRIDE;
671 672
673 // Overriden from ErrorStateClient.
674 virtual void OnOutOfMemoryError() OVERRIDE;
675
672 // Helpers to facilitate calling into compatible extensions. 676 // Helpers to facilitate calling into compatible extensions.
673 static void RenderbufferStorageMultisampleHelper( 677 static void RenderbufferStorageMultisampleHelper(
674 const FeatureInfo* feature_info, 678 const FeatureInfo* feature_info,
675 GLenum target, 679 GLenum target,
676 GLsizei samples, 680 GLsizei samples,
677 GLenum internal_format, 681 GLenum internal_format,
678 GLsizei width, 682 GLsizei width,
679 GLsizei height); 683 GLsizei height);
680 684
681 void BlitFramebufferHelper(GLint srcX0, 685 void BlitFramebufferHelper(GLint srcX0,
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 // contexts, the assumptions on the availablity of extensions in WebGL 1717 // contexts, the assumptions on the availablity of extensions in WebGL
1714 // contexts may be broken. These flags override the shared state to preserve 1718 // contexts may be broken. These flags override the shared state to preserve
1715 // WebGL semantics. 1719 // WebGL semantics.
1716 bool force_webgl_glsl_validation_; 1720 bool force_webgl_glsl_validation_;
1717 bool derivatives_explicitly_enabled_; 1721 bool derivatives_explicitly_enabled_;
1718 bool frag_depth_explicitly_enabled_; 1722 bool frag_depth_explicitly_enabled_;
1719 bool draw_buffers_explicitly_enabled_; 1723 bool draw_buffers_explicitly_enabled_;
1720 1724
1721 bool compile_shader_always_succeeds_; 1725 bool compile_shader_always_succeeds_;
1722 1726
1727 // An optional behaviour to lose the context and group when OOM.
1728 bool lose_context_when_out_of_memory_;
1729
1723 // Log extra info. 1730 // Log extra info.
1724 bool service_logging_; 1731 bool service_logging_;
1725 1732
1726 #if defined(OS_MACOSX) 1733 #if defined(OS_MACOSX)
1727 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap; 1734 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap;
1728 TextureToIOSurfaceMap texture_to_io_surface_map_; 1735 TextureToIOSurfaceMap texture_to_io_surface_map_;
1729 #endif 1736 #endif
1730 1737
1731 scoped_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; 1738 scoped_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_;
1732 1739
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
2178 } 2185 }
2179 2186
2180 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { 2187 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) {
2181 return new GLES2DecoderImpl(group); 2188 return new GLES2DecoderImpl(group);
2182 } 2189 }
2183 2190
2184 GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) 2191 GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group)
2185 : GLES2Decoder(), 2192 : GLES2Decoder(),
2186 group_(group), 2193 group_(group),
2187 logger_(&debug_marker_manager_), 2194 logger_(&debug_marker_manager_),
2188 state_(group_->feature_info(), &logger_), 2195 state_(group_->feature_info(), this, &logger_),
2189 unpack_flip_y_(false), 2196 unpack_flip_y_(false),
2190 unpack_premultiply_alpha_(false), 2197 unpack_premultiply_alpha_(false),
2191 unpack_unpremultiply_alpha_(false), 2198 unpack_unpremultiply_alpha_(false),
2192 attrib_0_buffer_id_(0), 2199 attrib_0_buffer_id_(0),
2193 attrib_0_buffer_matches_value_(true), 2200 attrib_0_buffer_matches_value_(true),
2194 attrib_0_size_(0), 2201 attrib_0_size_(0),
2195 fixed_attrib_buffer_id_(0), 2202 fixed_attrib_buffer_id_(0),
2196 fixed_attrib_buffer_size_(0), 2203 fixed_attrib_buffer_size_(0),
2197 offscreen_target_color_format_(0), 2204 offscreen_target_color_format_(0),
2198 offscreen_target_depth_format_(0), 2205 offscreen_target_depth_format_(0),
(...skipping 12 matching lines...) Expand all
2211 frame_number_(0), 2218 frame_number_(0),
2212 has_robustness_extension_(false), 2219 has_robustness_extension_(false),
2213 reset_status_(GL_NO_ERROR), 2220 reset_status_(GL_NO_ERROR),
2214 reset_by_robustness_extension_(false), 2221 reset_by_robustness_extension_(false),
2215 supports_post_sub_buffer_(false), 2222 supports_post_sub_buffer_(false),
2216 force_webgl_glsl_validation_(false), 2223 force_webgl_glsl_validation_(false),
2217 derivatives_explicitly_enabled_(false), 2224 derivatives_explicitly_enabled_(false),
2218 frag_depth_explicitly_enabled_(false), 2225 frag_depth_explicitly_enabled_(false),
2219 draw_buffers_explicitly_enabled_(false), 2226 draw_buffers_explicitly_enabled_(false),
2220 compile_shader_always_succeeds_(false), 2227 compile_shader_always_succeeds_(false),
2228 lose_context_when_out_of_memory_(false),
2221 service_logging_(CommandLine::ForCurrentProcess()->HasSwitch( 2229 service_logging_(CommandLine::ForCurrentProcess()->HasSwitch(
2222 switches::kEnableGPUServiceLoggingGPU)), 2230 switches::kEnableGPUServiceLoggingGPU)),
2223 viewport_max_width_(0), 2231 viewport_max_width_(0),
2224 viewport_max_height_(0), 2232 viewport_max_height_(0),
2225 texture_state_(group_->feature_info() 2233 texture_state_(group_->feature_info()
2226 ->workarounds() 2234 ->workarounds()
2227 .texsubimage2d_faster_than_teximage2d), 2235 .texsubimage2d_faster_than_teximage2d),
2228 validation_texture_(0), 2236 validation_texture_(0),
2229 validation_fbo_multisample_(0), 2237 validation_fbo_multisample_(0),
2230 validation_fbo_(0) { 2238 validation_fbo_(0) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2284 2292
2285 // Take ownership of the context and surface. The surface can be replaced with 2293 // Take ownership of the context and surface. The surface can be replaced with
2286 // SetSurface. 2294 // SetSurface.
2287 context_ = context; 2295 context_ = context;
2288 surface_ = surface; 2296 surface_ = surface;
2289 2297
2290 ContextCreationAttribHelper attrib_parser; 2298 ContextCreationAttribHelper attrib_parser;
2291 if (!attrib_parser.Parse(attribs)) 2299 if (!attrib_parser.Parse(attribs))
2292 return false; 2300 return false;
2293 2301
2302 // Save the loseContextWhenOutOfMemory context creation attribute.
2303 lose_context_when_out_of_memory_ =
2304 attrib_parser.lose_context_when_out_of_memory_;
2305
2294 // If the failIfMajorPerformanceCaveat context creation attribute was true 2306 // If the failIfMajorPerformanceCaveat context creation attribute was true
2295 // and we are using a software renderer, fail. 2307 // and we are using a software renderer, fail.
2296 if (attrib_parser.fail_if_major_perf_caveat_ && 2308 if (attrib_parser.fail_if_major_perf_caveat_ &&
2297 feature_info_->feature_flags().is_swiftshader) { 2309 feature_info_->feature_flags().is_swiftshader) {
2298 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. 2310 group_ = NULL; // Must not destroy ContextGroup if it is not initialized.
2299 Destroy(true); 2311 Destroy(true);
2300 return false; 2312 return false;
2301 } 2313 }
2302 2314
2303 if (!group_->Initialize(this, disallowed_features)) { 2315 if (!group_->Initialize(this, disallowed_features)) {
(...skipping 8254 matching lines...) Expand 10 before | Expand all | Expand 10 after
10558 ProcessFinishedAsyncTransfers(); 10570 ProcessFinishedAsyncTransfers();
10559 return error::kNoError; 10571 return error::kNoError;
10560 } 10572 }
10561 10573
10562 void GLES2DecoderImpl::OnTextureRefDetachedFromFramebuffer( 10574 void GLES2DecoderImpl::OnTextureRefDetachedFromFramebuffer(
10563 TextureRef* texture_ref) { 10575 TextureRef* texture_ref) {
10564 Texture* texture = texture_ref->texture(); 10576 Texture* texture = texture_ref->texture();
10565 DoDidUseTexImageIfNeeded(texture, texture->target()); 10577 DoDidUseTexImageIfNeeded(texture, texture->target());
10566 } 10578 }
10567 10579
10580 void GLES2DecoderImpl::OnOutOfMemoryError() {
10581 if (lose_context_when_out_of_memory_) {
10582 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB);
10583 LoseContext(GL_GUILTY_CONTEXT_RESET_ARB);
10584 }
10585 }
10586
10568 // Include the auto-generated part of this file. We split this because it means 10587 // Include the auto-generated part of this file. We split this because it means
10569 // we can easily edit the non-auto generated parts right here in this file 10588 // we can easily edit the non-auto generated parts right here in this file
10570 // instead of having to edit some template or the code generator. 10589 // instead of having to edit some template or the code generator.
10571 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10590 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10572 10591
10573 } // namespace gles2 10592 } // namespace gles2
10574 } // namespace gpu 10593 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/error_state.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698