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 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 GLES2Decoder::~GLES2Decoder() { | 559 GLES2Decoder::~GLES2Decoder() { |
560 } | 560 } |
561 | 561 |
562 void GLES2Decoder::BeginDecoding() {} | 562 void GLES2Decoder::BeginDecoding() {} |
563 | 563 |
564 void GLES2Decoder::EndDecoding() {} | 564 void GLES2Decoder::EndDecoding() {} |
565 | 565 |
566 // This class implements GLES2Decoder so we don't have to expose all the GLES2 | 566 // This class implements GLES2Decoder so we don't have to expose all the GLES2 |
567 // cmd stuff to outside this class. | 567 // cmd stuff to outside this class. |
568 class GLES2DecoderImpl : public GLES2Decoder, | 568 class GLES2DecoderImpl : public GLES2Decoder, |
569 public FramebufferManager::TextureDetachObserver, | 569 public FramebufferManager::TextureDetachObserver { |
570 public ErrorStateClient { | |
571 public: | 570 public: |
572 explicit GLES2DecoderImpl(ContextGroup* group); | 571 explicit GLES2DecoderImpl(ContextGroup* group); |
573 virtual ~GLES2DecoderImpl(); | 572 virtual ~GLES2DecoderImpl(); |
574 | 573 |
575 // Overridden from AsyncAPIInterface. | 574 // Overridden from AsyncAPIInterface. |
576 virtual Error DoCommand(unsigned int command, | 575 virtual Error DoCommand(unsigned int command, |
577 unsigned int arg_count, | 576 unsigned int arg_count, |
578 const void* args) OVERRIDE; | 577 const void* args) OVERRIDE; |
579 | 578 |
580 // Overridden from AsyncAPIInterface. | 579 // Overridden from AsyncAPIInterface. |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 bool BoundFramebufferHasColorAttachmentWithAlpha(bool all_draw_buffers); | 687 bool BoundFramebufferHasColorAttachmentWithAlpha(bool all_draw_buffers); |
689 bool BoundFramebufferHasDepthAttachment(); | 688 bool BoundFramebufferHasDepthAttachment(); |
690 bool BoundFramebufferHasStencilAttachment(); | 689 bool BoundFramebufferHasStencilAttachment(); |
691 | 690 |
692 virtual error::ContextLostReason GetContextLostReason() OVERRIDE; | 691 virtual error::ContextLostReason GetContextLostReason() OVERRIDE; |
693 | 692 |
694 // Overridden from FramebufferManager::TextureDetachObserver: | 693 // Overridden from FramebufferManager::TextureDetachObserver: |
695 virtual void OnTextureRefDetachedFromFramebuffer( | 694 virtual void OnTextureRefDetachedFromFramebuffer( |
696 TextureRef* texture) OVERRIDE; | 695 TextureRef* texture) OVERRIDE; |
697 | 696 |
698 // Overriden from ErrorStateClient. | |
699 virtual void OnOutOfMemoryError() OVERRIDE; | |
700 | |
701 // Helpers to facilitate calling into compatible extensions. | 697 // Helpers to facilitate calling into compatible extensions. |
702 static void RenderbufferStorageMultisampleHelper( | 698 static void RenderbufferStorageMultisampleHelper( |
703 const FeatureInfo* feature_info, | 699 const FeatureInfo* feature_info, |
704 GLenum target, | 700 GLenum target, |
705 GLsizei samples, | 701 GLsizei samples, |
706 GLenum internal_format, | 702 GLenum internal_format, |
707 GLsizei width, | 703 GLsizei width, |
708 GLsizei height); | 704 GLsizei height); |
709 | 705 |
710 void BlitFramebufferHelper(GLint srcX0, | 706 void BlitFramebufferHelper(GLint srcX0, |
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1749 // contexts, the assumptions on the availablity of extensions in WebGL | 1745 // contexts, the assumptions on the availablity of extensions in WebGL |
1750 // contexts may be broken. These flags override the shared state to preserve | 1746 // contexts may be broken. These flags override the shared state to preserve |
1751 // WebGL semantics. | 1747 // WebGL semantics. |
1752 bool force_webgl_glsl_validation_; | 1748 bool force_webgl_glsl_validation_; |
1753 bool derivatives_explicitly_enabled_; | 1749 bool derivatives_explicitly_enabled_; |
1754 bool frag_depth_explicitly_enabled_; | 1750 bool frag_depth_explicitly_enabled_; |
1755 bool draw_buffers_explicitly_enabled_; | 1751 bool draw_buffers_explicitly_enabled_; |
1756 | 1752 |
1757 bool compile_shader_always_succeeds_; | 1753 bool compile_shader_always_succeeds_; |
1758 | 1754 |
1759 // An optional behaviour to lose the context and group when OOM. | |
1760 bool lose_context_when_out_of_memory_; | |
1761 | |
1762 // Log extra info. | 1755 // Log extra info. |
1763 bool service_logging_; | 1756 bool service_logging_; |
1764 | 1757 |
1765 #if defined(OS_MACOSX) | 1758 #if defined(OS_MACOSX) |
1766 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap; | 1759 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap; |
1767 TextureToIOSurfaceMap texture_to_io_surface_map_; | 1760 TextureToIOSurfaceMap texture_to_io_surface_map_; |
1768 #endif | 1761 #endif |
1769 | 1762 |
1770 scoped_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; | 1763 scoped_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; |
1771 | 1764 |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2217 } | 2210 } |
2218 | 2211 |
2219 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { | 2212 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { |
2220 return new GLES2DecoderImpl(group); | 2213 return new GLES2DecoderImpl(group); |
2221 } | 2214 } |
2222 | 2215 |
2223 GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) | 2216 GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) |
2224 : GLES2Decoder(), | 2217 : GLES2Decoder(), |
2225 group_(group), | 2218 group_(group), |
2226 logger_(&debug_marker_manager_), | 2219 logger_(&debug_marker_manager_), |
2227 state_(group_->feature_info(), this, &logger_), | 2220 state_(group_->feature_info(), &logger_), |
2228 unpack_flip_y_(false), | 2221 unpack_flip_y_(false), |
2229 unpack_premultiply_alpha_(false), | 2222 unpack_premultiply_alpha_(false), |
2230 unpack_unpremultiply_alpha_(false), | 2223 unpack_unpremultiply_alpha_(false), |
2231 attrib_0_buffer_id_(0), | 2224 attrib_0_buffer_id_(0), |
2232 attrib_0_buffer_matches_value_(true), | 2225 attrib_0_buffer_matches_value_(true), |
2233 attrib_0_size_(0), | 2226 attrib_0_size_(0), |
2234 fixed_attrib_buffer_id_(0), | 2227 fixed_attrib_buffer_id_(0), |
2235 fixed_attrib_buffer_size_(0), | 2228 fixed_attrib_buffer_size_(0), |
2236 offscreen_target_color_format_(0), | 2229 offscreen_target_color_format_(0), |
2237 offscreen_target_depth_format_(0), | 2230 offscreen_target_depth_format_(0), |
(...skipping 12 matching lines...) Expand all Loading... |
2250 frame_number_(0), | 2243 frame_number_(0), |
2251 has_robustness_extension_(false), | 2244 has_robustness_extension_(false), |
2252 reset_status_(GL_NO_ERROR), | 2245 reset_status_(GL_NO_ERROR), |
2253 reset_by_robustness_extension_(false), | 2246 reset_by_robustness_extension_(false), |
2254 supports_post_sub_buffer_(false), | 2247 supports_post_sub_buffer_(false), |
2255 force_webgl_glsl_validation_(false), | 2248 force_webgl_glsl_validation_(false), |
2256 derivatives_explicitly_enabled_(false), | 2249 derivatives_explicitly_enabled_(false), |
2257 frag_depth_explicitly_enabled_(false), | 2250 frag_depth_explicitly_enabled_(false), |
2258 draw_buffers_explicitly_enabled_(false), | 2251 draw_buffers_explicitly_enabled_(false), |
2259 compile_shader_always_succeeds_(false), | 2252 compile_shader_always_succeeds_(false), |
2260 lose_context_when_out_of_memory_(false), | |
2261 service_logging_(CommandLine::ForCurrentProcess()->HasSwitch( | 2253 service_logging_(CommandLine::ForCurrentProcess()->HasSwitch( |
2262 switches::kEnableGPUServiceLoggingGPU)), | 2254 switches::kEnableGPUServiceLoggingGPU)), |
2263 viewport_max_width_(0), | 2255 viewport_max_width_(0), |
2264 viewport_max_height_(0), | 2256 viewport_max_height_(0), |
2265 texture_state_(group_->feature_info() | 2257 texture_state_(group_->feature_info() |
2266 ->workarounds() | 2258 ->workarounds() |
2267 .texsubimage2d_faster_than_teximage2d), | 2259 .texsubimage2d_faster_than_teximage2d), |
2268 validation_texture_(0), | 2260 validation_texture_(0), |
2269 validation_fbo_multisample_(0), | 2261 validation_fbo_multisample_(0), |
2270 validation_fbo_(0) { | 2262 validation_fbo_(0) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2324 | 2316 |
2325 // Take ownership of the context and surface. The surface can be replaced with | 2317 // Take ownership of the context and surface. The surface can be replaced with |
2326 // SetSurface. | 2318 // SetSurface. |
2327 context_ = context; | 2319 context_ = context; |
2328 surface_ = surface; | 2320 surface_ = surface; |
2329 | 2321 |
2330 ContextCreationAttribHelper attrib_parser; | 2322 ContextCreationAttribHelper attrib_parser; |
2331 if (!attrib_parser.Parse(attribs)) | 2323 if (!attrib_parser.Parse(attribs)) |
2332 return false; | 2324 return false; |
2333 | 2325 |
2334 // Save the loseContextWhenOutOfMemory context creation attribute. | |
2335 lose_context_when_out_of_memory_ = | |
2336 attrib_parser.lose_context_when_out_of_memory_; | |
2337 | |
2338 // If the failIfMajorPerformanceCaveat context creation attribute was true | 2326 // If the failIfMajorPerformanceCaveat context creation attribute was true |
2339 // and we are using a software renderer, fail. | 2327 // and we are using a software renderer, fail. |
2340 if (attrib_parser.fail_if_major_perf_caveat_ && | 2328 if (attrib_parser.fail_if_major_perf_caveat_ && |
2341 feature_info_->feature_flags().is_swiftshader) { | 2329 feature_info_->feature_flags().is_swiftshader) { |
2342 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. | 2330 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. |
2343 Destroy(true); | 2331 Destroy(true); |
2344 return false; | 2332 return false; |
2345 } | 2333 } |
2346 | 2334 |
2347 if (!group_->Initialize(this, disallowed_features)) { | 2335 if (!group_->Initialize(this, disallowed_features)) { |
(...skipping 8316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10664 ProcessFinishedAsyncTransfers(); | 10652 ProcessFinishedAsyncTransfers(); |
10665 return error::kNoError; | 10653 return error::kNoError; |
10666 } | 10654 } |
10667 | 10655 |
10668 void GLES2DecoderImpl::OnTextureRefDetachedFromFramebuffer( | 10656 void GLES2DecoderImpl::OnTextureRefDetachedFromFramebuffer( |
10669 TextureRef* texture_ref) { | 10657 TextureRef* texture_ref) { |
10670 Texture* texture = texture_ref->texture(); | 10658 Texture* texture = texture_ref->texture(); |
10671 DoDidUseTexImageIfNeeded(texture, texture->target()); | 10659 DoDidUseTexImageIfNeeded(texture, texture->target()); |
10672 } | 10660 } |
10673 | 10661 |
10674 void GLES2DecoderImpl::OnOutOfMemoryError() { | |
10675 if (lose_context_when_out_of_memory_) { | |
10676 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB); | |
10677 LoseContext(GL_GUILTY_CONTEXT_RESET_ARB); | |
10678 } | |
10679 } | |
10680 | |
10681 // Include the auto-generated part of this file. We split this because it means | 10662 // Include the auto-generated part of this file. We split this because it means |
10682 // we can easily edit the non-auto generated parts right here in this file | 10663 // we can easily edit the non-auto generated parts right here in this file |
10683 // instead of having to edit some template or the code generator. | 10664 // instead of having to edit some template or the code generator. |
10684 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10665 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
10685 | 10666 |
10686 } // namespace gles2 | 10667 } // namespace gles2 |
10687 } // namespace gpu | 10668 } // namespace gpu |
OLD | NEW |