Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 658 bool BoundFramebufferHasColorAttachmentWithAlpha(bool all_draw_buffers); | 659 bool BoundFramebufferHasColorAttachmentWithAlpha(bool all_draw_buffers); |
| 659 bool BoundFramebufferHasDepthAttachment(); | 660 bool BoundFramebufferHasDepthAttachment(); |
| 660 bool BoundFramebufferHasStencilAttachment(); | 661 bool BoundFramebufferHasStencilAttachment(); |
| 661 | 662 |
| 662 virtual error::ContextLostReason GetContextLostReason() OVERRIDE; | 663 virtual error::ContextLostReason GetContextLostReason() OVERRIDE; |
| 663 | 664 |
| 664 // Overridden from FramebufferManager::TextureDetachObserver: | 665 // Overridden from FramebufferManager::TextureDetachObserver: |
| 665 virtual void OnTextureRefDetachedFromFramebuffer( | 666 virtual void OnTextureRefDetachedFromFramebuffer( |
| 666 TextureRef* texture) OVERRIDE; | 667 TextureRef* texture) OVERRIDE; |
| 667 | 668 |
| 669 // Overriden from ErrorStateClient. | |
| 670 virtual void OnOutOfMemoryError() OVERRIDE; | |
| 671 | |
| 668 // Helpers to facilitate calling into compatible extensions. | 672 // Helpers to facilitate calling into compatible extensions. |
| 669 static void RenderbufferStorageMultisampleHelper( | 673 static void RenderbufferStorageMultisampleHelper( |
| 670 const FeatureInfo* feature_info, | 674 const FeatureInfo* feature_info, |
| 671 GLenum target, | 675 GLenum target, |
| 672 GLsizei samples, | 676 GLsizei samples, |
| 673 GLenum internal_format, | 677 GLenum internal_format, |
| 674 GLsizei width, | 678 GLsizei width, |
| 675 GLsizei height); | 679 GLsizei height); |
| 676 | 680 |
| 677 void BlitFramebufferHelper(GLint srcX0, | 681 void BlitFramebufferHelper(GLint srcX0, |
| (...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1708 // contexts, the assumptions on the availablity of extensions in WebGL | 1712 // contexts, the assumptions on the availablity of extensions in WebGL |
| 1709 // contexts may be broken. These flags override the shared state to preserve | 1713 // contexts may be broken. These flags override the shared state to preserve |
| 1710 // WebGL semantics. | 1714 // WebGL semantics. |
| 1711 bool force_webgl_glsl_validation_; | 1715 bool force_webgl_glsl_validation_; |
| 1712 bool derivatives_explicitly_enabled_; | 1716 bool derivatives_explicitly_enabled_; |
| 1713 bool frag_depth_explicitly_enabled_; | 1717 bool frag_depth_explicitly_enabled_; |
| 1714 bool draw_buffers_explicitly_enabled_; | 1718 bool draw_buffers_explicitly_enabled_; |
| 1715 | 1719 |
| 1716 bool compile_shader_always_succeeds_; | 1720 bool compile_shader_always_succeeds_; |
| 1717 | 1721 |
| 1722 // An optional behaviour to lose the context and group when OOM. | |
| 1723 bool lose_context_when_out_of_memory_; | |
| 1724 | |
| 1718 // Log extra info. | 1725 // Log extra info. |
| 1719 bool service_logging_; | 1726 bool service_logging_; |
| 1720 | 1727 |
| 1721 #if defined(OS_MACOSX) | 1728 #if defined(OS_MACOSX) |
| 1722 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap; | 1729 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap; |
| 1723 TextureToIOSurfaceMap texture_to_io_surface_map_; | 1730 TextureToIOSurfaceMap texture_to_io_surface_map_; |
| 1724 #endif | 1731 #endif |
| 1725 | 1732 |
| 1726 scoped_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; | 1733 scoped_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; |
| 1727 | 1734 |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2173 } | 2180 } |
| 2174 | 2181 |
| 2175 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { | 2182 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { |
| 2176 return new GLES2DecoderImpl(group); | 2183 return new GLES2DecoderImpl(group); |
| 2177 } | 2184 } |
| 2178 | 2185 |
| 2179 GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) | 2186 GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) |
| 2180 : GLES2Decoder(), | 2187 : GLES2Decoder(), |
| 2181 group_(group), | 2188 group_(group), |
| 2182 logger_(&debug_marker_manager_), | 2189 logger_(&debug_marker_manager_), |
| 2183 state_(group_->feature_info(), &logger_), | 2190 state_(group_->feature_info(), this, &logger_), |
| 2184 unpack_flip_y_(false), | 2191 unpack_flip_y_(false), |
| 2185 unpack_premultiply_alpha_(false), | 2192 unpack_premultiply_alpha_(false), |
| 2186 unpack_unpremultiply_alpha_(false), | 2193 unpack_unpremultiply_alpha_(false), |
| 2187 attrib_0_buffer_id_(0), | 2194 attrib_0_buffer_id_(0), |
| 2188 attrib_0_buffer_matches_value_(true), | 2195 attrib_0_buffer_matches_value_(true), |
| 2189 attrib_0_size_(0), | 2196 attrib_0_size_(0), |
| 2190 fixed_attrib_buffer_id_(0), | 2197 fixed_attrib_buffer_id_(0), |
| 2191 fixed_attrib_buffer_size_(0), | 2198 fixed_attrib_buffer_size_(0), |
| 2192 offscreen_target_color_format_(0), | 2199 offscreen_target_color_format_(0), |
| 2193 offscreen_target_depth_format_(0), | 2200 offscreen_target_depth_format_(0), |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 2205 feature_info_(group_->feature_info()), | 2212 feature_info_(group_->feature_info()), |
| 2206 frame_number_(0), | 2213 frame_number_(0), |
| 2207 has_robustness_extension_(false), | 2214 has_robustness_extension_(false), |
| 2208 reset_status_(GL_NO_ERROR), | 2215 reset_status_(GL_NO_ERROR), |
| 2209 reset_by_robustness_extension_(false), | 2216 reset_by_robustness_extension_(false), |
| 2210 force_webgl_glsl_validation_(false), | 2217 force_webgl_glsl_validation_(false), |
| 2211 derivatives_explicitly_enabled_(false), | 2218 derivatives_explicitly_enabled_(false), |
| 2212 frag_depth_explicitly_enabled_(false), | 2219 frag_depth_explicitly_enabled_(false), |
| 2213 draw_buffers_explicitly_enabled_(false), | 2220 draw_buffers_explicitly_enabled_(false), |
| 2214 compile_shader_always_succeeds_(false), | 2221 compile_shader_always_succeeds_(false), |
| 2222 lose_context_when_out_of_memory_(false), | |
| 2215 service_logging_(CommandLine::ForCurrentProcess()->HasSwitch( | 2223 service_logging_(CommandLine::ForCurrentProcess()->HasSwitch( |
| 2216 switches::kEnableGPUServiceLoggingGPU)), | 2224 switches::kEnableGPUServiceLoggingGPU)), |
| 2217 viewport_max_width_(0), | 2225 viewport_max_width_(0), |
| 2218 viewport_max_height_(0), | 2226 viewport_max_height_(0), |
| 2219 texture_state_(group_->feature_info() | 2227 texture_state_(group_->feature_info() |
| 2220 ->workarounds() | 2228 ->workarounds() |
| 2221 .texsubimage2d_faster_than_teximage2d), | 2229 .texsubimage2d_faster_than_teximage2d), |
| 2222 validation_texture_(0), | 2230 validation_texture_(0), |
| 2223 validation_fbo_multisample_(0), | 2231 validation_fbo_multisample_(0), |
| 2224 validation_fbo_(0) { | 2232 validation_fbo_(0) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2278 | 2286 |
| 2279 // Take ownership of the context and surface. The surface can be replaced with | 2287 // Take ownership of the context and surface. The surface can be replaced with |
| 2280 // SetSurface. | 2288 // SetSurface. |
| 2281 context_ = context; | 2289 context_ = context; |
| 2282 surface_ = surface; | 2290 surface_ = surface; |
| 2283 | 2291 |
| 2284 ContextCreationAttribHelper attrib_parser; | 2292 ContextCreationAttribHelper attrib_parser; |
| 2285 if (!attrib_parser.Parse(attribs)) | 2293 if (!attrib_parser.Parse(attribs)) |
| 2286 return false; | 2294 return false; |
| 2287 | 2295 |
| 2296 // Save the loseContextWhenOutOfMemory context creation attribute. | |
| 2297 lose_context_when_out_of_memory_ = | |
| 2298 attrib_parser.lose_context_when_out_of_memory_ > 0; | |
| 2299 | |
| 2288 // If the failIfMajorPerformanceCaveat context creation attribute was true | 2300 // If the failIfMajorPerformanceCaveat context creation attribute was true |
| 2289 // and we are using a software renderer, fail. | 2301 // and we are using a software renderer, fail. |
| 2290 if (attrib_parser.fail_if_major_perf_caveat_ && | 2302 if (attrib_parser.fail_if_major_perf_caveat_ && |
| 2291 feature_info_->feature_flags().is_swiftshader) { | 2303 feature_info_->feature_flags().is_swiftshader) { |
| 2292 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. | 2304 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. |
| 2293 Destroy(true); | 2305 Destroy(true); |
| 2294 return false; | 2306 return false; |
| 2295 } | 2307 } |
| 2296 | 2308 |
| 2297 if (!group_->Initialize(this, disallowed_features)) { | 2309 if (!group_->Initialize(this, disallowed_features)) { |
| (...skipping 8248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10546 ProcessFinishedAsyncTransfers(); | 10558 ProcessFinishedAsyncTransfers(); |
| 10547 return error::kNoError; | 10559 return error::kNoError; |
| 10548 } | 10560 } |
| 10549 | 10561 |
| 10550 void GLES2DecoderImpl::OnTextureRefDetachedFromFramebuffer( | 10562 void GLES2DecoderImpl::OnTextureRefDetachedFromFramebuffer( |
| 10551 TextureRef* texture_ref) { | 10563 TextureRef* texture_ref) { |
| 10552 Texture* texture = texture_ref->texture(); | 10564 Texture* texture = texture_ref->texture(); |
| 10553 DoDidUseTexImageIfNeeded(texture, texture->target()); | 10565 DoDidUseTexImageIfNeeded(texture, texture->target()); |
| 10554 } | 10566 } |
| 10555 | 10567 |
| 10568 void GLES2DecoderImpl::OnOutOfMemoryError() { | |
| 10569 if (lose_context_when_out_of_memory_) { | |
| 10570 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB); | |
| 10571 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | |
|
piman
2014/03/21 21:34:48
nit: we're guilty.
danakj
2014/03/21 22:53:50
Done.
| |
| 10572 } | |
| 10573 } | |
| 10574 | |
| 10556 // Include the auto-generated part of this file. We split this because it means | 10575 // Include the auto-generated part of this file. We split this because it means |
| 10557 // we can easily edit the non-auto generated parts right here in this file | 10576 // we can easily edit the non-auto generated parts right here in this file |
| 10558 // instead of having to edit some template or the code generator. | 10577 // instead of having to edit some template or the code generator. |
| 10559 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10578 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 10560 | 10579 |
| 10561 } // namespace gles2 | 10580 } // namespace gles2 |
| 10562 } // namespace gpu | 10581 } // namespace gpu |
| OLD | NEW |