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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 explicit BackRenderbuffer( | 400 explicit BackRenderbuffer( |
401 RenderbufferManager* renderbuffer_manager, | 401 RenderbufferManager* renderbuffer_manager, |
402 MemoryTracker* memory_tracker, | 402 MemoryTracker* memory_tracker, |
403 ContextState* state); | 403 ContextState* state); |
404 ~BackRenderbuffer(); | 404 ~BackRenderbuffer(); |
405 | 405 |
406 // Create a new render buffer. | 406 // Create a new render buffer. |
407 void Create(); | 407 void Create(); |
408 | 408 |
409 // Set the initial size and format of a render buffer or resize it. | 409 // Set the initial size and format of a render buffer or resize it. |
410 bool AllocateStorage(const gfx::Size& size, GLenum format, GLsizei samples); | 410 bool AllocateStorage(const FeatureInfo* feature_info, |
| 411 const gfx::Size& size, |
| 412 GLenum format, |
| 413 GLsizei samples); |
411 | 414 |
412 // Destroy the render buffer. This must be explicitly called before destroying | 415 // Destroy the render buffer. This must be explicitly called before destroying |
413 // this object. | 416 // this object. |
414 void Destroy(); | 417 void Destroy(); |
415 | 418 |
416 // Invalidate the render buffer. This can be used when a context is lost and | 419 // Invalidate the render buffer. This can be used when a context is lost and |
417 // it is not possible to make it current in order to free the resource. | 420 // it is not possible to make it current in order to free the resource. |
418 void Invalidate(); | 421 void Invalidate(); |
419 | 422 |
420 GLuint id() const { | 423 GLuint id() const { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 bool BoundFramebufferHasColorAttachmentWithAlpha(bool all_draw_buffers); | 623 bool BoundFramebufferHasColorAttachmentWithAlpha(bool all_draw_buffers); |
621 bool BoundFramebufferHasDepthAttachment(); | 624 bool BoundFramebufferHasDepthAttachment(); |
622 bool BoundFramebufferHasStencilAttachment(); | 625 bool BoundFramebufferHasStencilAttachment(); |
623 | 626 |
624 virtual error::ContextLostReason GetContextLostReason() OVERRIDE; | 627 virtual error::ContextLostReason GetContextLostReason() OVERRIDE; |
625 | 628 |
626 // Overridden from FramebufferManager::TextureDetachObserver: | 629 // Overridden from FramebufferManager::TextureDetachObserver: |
627 virtual void OnTextureRefDetachedFromFramebuffer( | 630 virtual void OnTextureRefDetachedFromFramebuffer( |
628 TextureRef* texture) OVERRIDE; | 631 TextureRef* texture) OVERRIDE; |
629 | 632 |
630 static bool IsAngle(); | 633 // Helpers to facilitate calling into compatible extensions. |
| 634 static void RenderbufferStorageMultisampleHelper( |
| 635 const FeatureInfo* feature_info, |
| 636 GLenum target, |
| 637 GLsizei samples, |
| 638 GLenum internal_format, |
| 639 GLsizei width, |
| 640 GLsizei height); |
| 641 |
| 642 void BlitFramebufferHelper(GLint srcX0, |
| 643 GLint srcY0, |
| 644 GLint srcX1, |
| 645 GLint srcY1, |
| 646 GLint dstX0, |
| 647 GLint dstY0, |
| 648 GLint dstX1, |
| 649 GLint dstY1, |
| 650 GLbitfield mask, |
| 651 GLenum filter); |
631 | 652 |
632 private: | 653 private: |
633 friend class ScopedFrameBufferBinder; | 654 friend class ScopedFrameBufferBinder; |
634 friend class ScopedResolvedFrameBufferBinder; | 655 friend class ScopedResolvedFrameBufferBinder; |
635 friend class BackFramebuffer; | 656 friend class BackFramebuffer; |
636 | 657 |
637 // Initialize or re-initialize the shader translator. | 658 // Initialize or re-initialize the shader translator. |
638 bool InitializeShaderTranslator(); | 659 bool InitializeShaderTranslator(); |
639 | 660 |
640 void UpdateCapabilities(); | 661 void UpdateCapabilities(); |
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 } | 1818 } |
1798 } | 1819 } |
1799 targetid = decoder_->offscreen_resolved_frame_buffer_->id(); | 1820 targetid = decoder_->offscreen_resolved_frame_buffer_->id(); |
1800 } else { | 1821 } else { |
1801 targetid = decoder_->offscreen_saved_frame_buffer_->id(); | 1822 targetid = decoder_->offscreen_saved_frame_buffer_->id(); |
1802 } | 1823 } |
1803 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, targetid); | 1824 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, targetid); |
1804 const int width = decoder_->offscreen_size_.width(); | 1825 const int width = decoder_->offscreen_size_.width(); |
1805 const int height = decoder_->offscreen_size_.height(); | 1826 const int height = decoder_->offscreen_size_.height(); |
1806 glDisable(GL_SCISSOR_TEST); | 1827 glDisable(GL_SCISSOR_TEST); |
1807 if (GLES2DecoderImpl::IsAngle()) { | 1828 decoder->BlitFramebufferHelper(0, |
1808 glBlitFramebufferANGLE(0, 0, width, height, 0, 0, width, height, | 1829 0, |
1809 GL_COLOR_BUFFER_BIT, GL_NEAREST); | 1830 width, |
1810 } else { | 1831 height, |
1811 glBlitFramebufferEXT(0, 0, width, height, 0, 0, width, height, | 1832 0, |
1812 GL_COLOR_BUFFER_BIT, GL_NEAREST); | 1833 0, |
1813 } | 1834 width, |
| 1835 height, |
| 1836 GL_COLOR_BUFFER_BIT, |
| 1837 GL_NEAREST); |
1814 glBindFramebufferEXT(GL_FRAMEBUFFER, targetid); | 1838 glBindFramebufferEXT(GL_FRAMEBUFFER, targetid); |
1815 } | 1839 } |
1816 | 1840 |
1817 ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() { | 1841 ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() { |
1818 if (!resolve_and_bind_) | 1842 if (!resolve_and_bind_) |
1819 return; | 1843 return; |
1820 | 1844 |
1821 ScopedGLErrorSuppressor suppressor( | 1845 ScopedGLErrorSuppressor suppressor( |
1822 "ScopedResolvedFrameBufferBinder::dtor", decoder_->GetErrorState()); | 1846 "ScopedResolvedFrameBufferBinder::dtor", decoder_->GetErrorState()); |
1823 decoder_->RestoreCurrentFramebufferBindings(); | 1847 decoder_->RestoreCurrentFramebufferBindings(); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1955 DCHECK_EQ(id_, 0u); | 1979 DCHECK_EQ(id_, 0u); |
1956 } | 1980 } |
1957 | 1981 |
1958 void BackRenderbuffer::Create() { | 1982 void BackRenderbuffer::Create() { |
1959 ScopedGLErrorSuppressor suppressor("BackRenderbuffer::Create", | 1983 ScopedGLErrorSuppressor suppressor("BackRenderbuffer::Create", |
1960 state_->GetErrorState()); | 1984 state_->GetErrorState()); |
1961 Destroy(); | 1985 Destroy(); |
1962 glGenRenderbuffersEXT(1, &id_); | 1986 glGenRenderbuffersEXT(1, &id_); |
1963 } | 1987 } |
1964 | 1988 |
1965 bool BackRenderbuffer::AllocateStorage(const gfx::Size& size, GLenum format, | 1989 bool BackRenderbuffer::AllocateStorage(const FeatureInfo* feature_info, |
| 1990 const gfx::Size& size, |
| 1991 GLenum format, |
1966 GLsizei samples) { | 1992 GLsizei samples) { |
1967 ScopedGLErrorSuppressor suppressor( | 1993 ScopedGLErrorSuppressor suppressor( |
1968 "BackRenderbuffer::AllocateStorage", state_->GetErrorState()); | 1994 "BackRenderbuffer::AllocateStorage", state_->GetErrorState()); |
1969 ScopedRenderBufferBinder binder(state_, id_); | 1995 ScopedRenderBufferBinder binder(state_, id_); |
1970 | 1996 |
1971 uint32 estimated_size = 0; | 1997 uint32 estimated_size = 0; |
1972 if (!renderbuffer_manager_->ComputeEstimatedRenderbufferSize( | 1998 if (!renderbuffer_manager_->ComputeEstimatedRenderbufferSize( |
1973 size.width(), size.height(), samples, format, &estimated_size)) { | 1999 size.width(), size.height(), samples, format, &estimated_size)) { |
1974 return false; | 2000 return false; |
1975 } | 2001 } |
1976 | 2002 |
1977 if (!memory_tracker_.EnsureGPUMemoryAvailable(estimated_size)) { | 2003 if (!memory_tracker_.EnsureGPUMemoryAvailable(estimated_size)) { |
1978 return false; | 2004 return false; |
1979 } | 2005 } |
1980 | 2006 |
1981 if (samples <= 1) { | 2007 if (samples <= 1) { |
1982 glRenderbufferStorageEXT(GL_RENDERBUFFER, | 2008 glRenderbufferStorageEXT(GL_RENDERBUFFER, |
1983 format, | 2009 format, |
1984 size.width(), | 2010 size.width(), |
1985 size.height()); | 2011 size.height()); |
1986 } else { | 2012 } else { |
1987 if (GLES2DecoderImpl::IsAngle()) { | 2013 GLES2DecoderImpl::RenderbufferStorageMultisampleHelper(feature_info, |
1988 glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, | 2014 GL_RENDERBUFFER, |
1989 samples, | 2015 samples, |
1990 format, | 2016 format, |
1991 size.width(), | 2017 size.width(), |
1992 size.height()); | 2018 size.height()); |
1993 } else { | |
1994 glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, | |
1995 samples, | |
1996 format, | |
1997 size.width(), | |
1998 size.height()); | |
1999 } | |
2000 } | 2019 } |
2001 bool success = glGetError() == GL_NO_ERROR; | 2020 bool success = glGetError() == GL_NO_ERROR; |
2002 if (success) { | 2021 if (success) { |
2003 // Mark the previously allocated bytes as free. | 2022 // Mark the previously allocated bytes as free. |
2004 memory_tracker_.TrackMemFree(bytes_allocated_); | 2023 memory_tracker_.TrackMemFree(bytes_allocated_); |
2005 bytes_allocated_ = estimated_size; | 2024 bytes_allocated_ = estimated_size; |
2006 // Track the newly allocated bytes. | 2025 // Track the newly allocated bytes. |
2007 memory_tracker_.TrackMemAlloc(bytes_allocated_); | 2026 memory_tracker_.TrackMemAlloc(bytes_allocated_); |
2008 } | 2027 } |
2009 return success; | 2028 return success; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2087 ScopedGLErrorSuppressor suppressor("BackFramebuffer::CheckStatus", | 2106 ScopedGLErrorSuppressor suppressor("BackFramebuffer::CheckStatus", |
2088 decoder_->GetErrorState()); | 2107 decoder_->GetErrorState()); |
2089 ScopedFrameBufferBinder binder(decoder_, id_); | 2108 ScopedFrameBufferBinder binder(decoder_, id_); |
2090 return glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); | 2109 return glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); |
2091 } | 2110 } |
2092 | 2111 |
2093 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { | 2112 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { |
2094 return new GLES2DecoderImpl(group); | 2113 return new GLES2DecoderImpl(group); |
2095 } | 2114 } |
2096 | 2115 |
2097 bool GLES2DecoderImpl::IsAngle() { | |
2098 #if defined(OS_WIN) | |
2099 return gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2; | |
2100 #else | |
2101 return false; | |
2102 #endif | |
2103 } | |
2104 | |
2105 GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) | 2116 GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) |
2106 : GLES2Decoder(), | 2117 : GLES2Decoder(), |
2107 group_(group), | 2118 group_(group), |
2108 logger_(&debug_marker_manager_), | 2119 logger_(&debug_marker_manager_), |
2109 state_(group_->feature_info(), &logger_), | 2120 state_(group_->feature_info(), &logger_), |
2110 unpack_flip_y_(false), | 2121 unpack_flip_y_(false), |
2111 unpack_premultiply_alpha_(false), | 2122 unpack_premultiply_alpha_(false), |
2112 unpack_unpremultiply_alpha_(false), | 2123 unpack_unpremultiply_alpha_(false), |
2113 attrib_0_buffer_id_(0), | 2124 attrib_0_buffer_id_(0), |
2114 attrib_0_buffer_matches_value_(true), | 2125 attrib_0_buffer_matches_value_(true), |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2296 GL_RGBA8 : GL_RGB8; | 2307 GL_RGBA8 : GL_RGB8; |
2297 } else { | 2308 } else { |
2298 offscreen_target_samples_ = 1; | 2309 offscreen_target_samples_ = 1; |
2299 offscreen_target_color_format_ = attrib_parser.alpha_size_ > 0 ? | 2310 offscreen_target_color_format_ = attrib_parser.alpha_size_ > 0 ? |
2300 GL_RGBA : GL_RGB; | 2311 GL_RGBA : GL_RGB; |
2301 } | 2312 } |
2302 | 2313 |
2303 // ANGLE only supports packed depth/stencil formats, so use it if it is | 2314 // ANGLE only supports packed depth/stencil formats, so use it if it is |
2304 // available. | 2315 // available. |
2305 const bool depth24_stencil8_supported = | 2316 const bool depth24_stencil8_supported = |
2306 context_->HasExtension("GL_OES_packed_depth_stencil"); | 2317 feature_info_->feature_flags().packed_depth24_stencil8; |
2307 VLOG(1) << "GL_OES_packed_depth_stencil " | 2318 VLOG(1) << "GL_OES_packed_depth_stencil " |
2308 << (depth24_stencil8_supported ? "" : "not ") << "supported."; | 2319 << (depth24_stencil8_supported ? "" : "not ") << "supported."; |
2309 if ((attrib_parser.depth_size_ > 0 || attrib_parser.stencil_size_ > 0) && | 2320 if ((attrib_parser.depth_size_ > 0 || attrib_parser.stencil_size_ > 0) && |
2310 depth24_stencil8_supported) { | 2321 depth24_stencil8_supported) { |
2311 offscreen_target_depth_format_ = GL_DEPTH24_STENCIL8; | 2322 offscreen_target_depth_format_ = GL_DEPTH24_STENCIL8; |
2312 offscreen_target_stencil_format_ = 0; | 2323 offscreen_target_stencil_format_ = 0; |
2313 } else { | 2324 } else { |
2314 // It may be the case that this depth/stencil combination is not | 2325 // It may be the case that this depth/stencil combination is not |
2315 // supported, but this will be checked later by CheckFramebufferStatus. | 2326 // supported, but this will be checked later by CheckFramebufferStatus. |
2316 offscreen_target_depth_format_ = attrib_parser.depth_size_ > 0 ? | 2327 offscreen_target_depth_format_ = attrib_parser.depth_size_ > 0 ? |
2317 GL_DEPTH_COMPONENT16 : 0; | 2328 GL_DEPTH_COMPONENT16 : 0; |
2318 offscreen_target_stencil_format_ = attrib_parser.stencil_size_ > 0 ? | 2329 offscreen_target_stencil_format_ = attrib_parser.stencil_size_ > 0 ? |
2319 GL_STENCIL_INDEX8 : 0; | 2330 GL_STENCIL_INDEX8 : 0; |
2320 } | 2331 } |
2321 } else { | 2332 } else { |
2322 offscreen_target_color_format_ = attrib_parser.alpha_size_ > 0 ? | 2333 offscreen_target_color_format_ = attrib_parser.alpha_size_ > 0 ? |
2323 GL_RGBA : GL_RGB; | 2334 GL_RGBA : GL_RGB; |
2324 | 2335 |
2325 // If depth is requested at all, use the packed depth stencil format if | 2336 // If depth is requested at all, use the packed depth stencil format if |
2326 // it's available, as some desktop GL drivers don't support any non-packed | 2337 // it's available, as some desktop GL drivers don't support any non-packed |
2327 // formats for depth attachments. | 2338 // formats for depth attachments. |
2328 const bool depth24_stencil8_supported = | 2339 const bool depth24_stencil8_supported = |
2329 context_->HasExtension("GL_EXT_packed_depth_stencil"); | 2340 feature_info_->feature_flags().packed_depth24_stencil8; |
2330 VLOG(1) << "GL_EXT_packed_depth_stencil " | 2341 VLOG(1) << "GL_EXT_packed_depth_stencil " |
2331 << (depth24_stencil8_supported ? "" : "not ") << "supported."; | 2342 << (depth24_stencil8_supported ? "" : "not ") << "supported."; |
2332 | 2343 |
2333 if ((attrib_parser.depth_size_ > 0 || attrib_parser.stencil_size_ > 0) && | 2344 if ((attrib_parser.depth_size_ > 0 || attrib_parser.stencil_size_ > 0) && |
2334 depth24_stencil8_supported) { | 2345 depth24_stencil8_supported) { |
2335 offscreen_target_depth_format_ = GL_DEPTH24_STENCIL8; | 2346 offscreen_target_depth_format_ = GL_DEPTH24_STENCIL8; |
2336 offscreen_target_stencil_format_ = 0; | 2347 offscreen_target_stencil_format_ = 0; |
2337 } else { | 2348 } else { |
2338 offscreen_target_depth_format_ = attrib_parser.depth_size_ > 0 ? | 2349 offscreen_target_depth_format_ = attrib_parser.depth_size_ > 0 ? |
2339 GL_DEPTH_COMPONENT : 0; | 2350 GL_DEPTH_COMPONENT : 0; |
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3314 if (w < 0 || h < 0 || h >= (INT_MAX / 4) / (w ? w : 1)) { | 3325 if (w < 0 || h < 0 || h >= (INT_MAX / 4) / (w ? w : 1)) { |
3315 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | 3326 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " |
3316 << "to allocate storage due to excessive dimensions."; | 3327 << "to allocate storage due to excessive dimensions."; |
3317 return false; | 3328 return false; |
3318 } | 3329 } |
3319 | 3330 |
3320 // Reallocate the offscreen target buffers. | 3331 // Reallocate the offscreen target buffers. |
3321 DCHECK(offscreen_target_color_format_); | 3332 DCHECK(offscreen_target_color_format_); |
3322 if (IsOffscreenBufferMultisampled()) { | 3333 if (IsOffscreenBufferMultisampled()) { |
3323 if (!offscreen_target_color_render_buffer_->AllocateStorage( | 3334 if (!offscreen_target_color_render_buffer_->AllocateStorage( |
3324 offscreen_size_, offscreen_target_color_format_, | 3335 feature_info_, offscreen_size_, offscreen_target_color_format_, |
3325 offscreen_target_samples_)) { | 3336 offscreen_target_samples_)) { |
3326 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | 3337 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " |
3327 << "to allocate storage for offscreen target color buffer."; | 3338 << "to allocate storage for offscreen target color buffer."; |
3328 return false; | 3339 return false; |
3329 } | 3340 } |
3330 } else { | 3341 } else { |
3331 if (!offscreen_target_color_texture_->AllocateStorage( | 3342 if (!offscreen_target_color_texture_->AllocateStorage( |
3332 offscreen_size_, offscreen_target_color_format_, false)) { | 3343 offscreen_size_, offscreen_target_color_format_, false)) { |
3333 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | 3344 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " |
3334 << "to allocate storage for offscreen target color texture."; | 3345 << "to allocate storage for offscreen target color texture."; |
3335 return false; | 3346 return false; |
3336 } | 3347 } |
3337 } | 3348 } |
3338 if (offscreen_target_depth_format_ && | 3349 if (offscreen_target_depth_format_ && |
3339 !offscreen_target_depth_render_buffer_->AllocateStorage( | 3350 !offscreen_target_depth_render_buffer_->AllocateStorage( |
3340 offscreen_size_, offscreen_target_depth_format_, | 3351 feature_info_, offscreen_size_, offscreen_target_depth_format_, |
3341 offscreen_target_samples_)) { | 3352 offscreen_target_samples_)) { |
3342 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | 3353 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " |
3343 << "to allocate storage for offscreen target depth buffer."; | 3354 << "to allocate storage for offscreen target depth buffer."; |
3344 return false; | 3355 return false; |
3345 } | 3356 } |
3346 if (offscreen_target_stencil_format_ && | 3357 if (offscreen_target_stencil_format_ && |
3347 !offscreen_target_stencil_render_buffer_->AllocateStorage( | 3358 !offscreen_target_stencil_render_buffer_->AllocateStorage( |
3348 offscreen_size_, offscreen_target_stencil_format_, | 3359 feature_info_, offscreen_size_, offscreen_target_stencil_format_, |
3349 offscreen_target_samples_)) { | 3360 offscreen_target_samples_)) { |
3350 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | 3361 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " |
3351 << "to allocate storage for offscreen target stencil buffer."; | 3362 << "to allocate storage for offscreen target stencil buffer."; |
3352 return false; | 3363 return false; |
3353 } | 3364 } |
3354 | 3365 |
3355 // Attach the offscreen target buffers to the target frame buffer. | 3366 // Attach the offscreen target buffers to the target frame buffer. |
3356 if (IsOffscreenBufferMultisampled()) { | 3367 if (IsOffscreenBufferMultisampled()) { |
3357 offscreen_target_frame_buffer_->AttachRenderBuffer( | 3368 offscreen_target_frame_buffer_->AttachRenderBuffer( |
3358 GL_COLOR_ATTACHMENT0, | 3369 GL_COLOR_ATTACHMENT0, |
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4990 GL_INVALID_OPERATION, | 5001 GL_INVALID_OPERATION, |
4991 "glBlitFramebufferCHROMIUM", "function not available"); | 5002 "glBlitFramebufferCHROMIUM", "function not available"); |
4992 return; | 5003 return; |
4993 } | 5004 } |
4994 | 5005 |
4995 if (!CheckBoundFramebuffersValid("glBlitFramebufferCHROMIUM")) { | 5006 if (!CheckBoundFramebuffersValid("glBlitFramebufferCHROMIUM")) { |
4996 return; | 5007 return; |
4997 } | 5008 } |
4998 | 5009 |
4999 glDisable(GL_SCISSOR_TEST); | 5010 glDisable(GL_SCISSOR_TEST); |
5000 if (IsAngle()) { | 5011 BlitFramebufferHelper( |
| 5012 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 5013 EnableDisable(GL_SCISSOR_TEST, state_.enable_flags.scissor_test); |
| 5014 } |
| 5015 |
| 5016 void GLES2DecoderImpl::RenderbufferStorageMultisampleHelper( |
| 5017 const FeatureInfo* feature_info, |
| 5018 GLenum target, |
| 5019 GLsizei samples, |
| 5020 GLenum internal_format, |
| 5021 GLsizei width, |
| 5022 GLsizei height) { |
| 5023 // TODO(sievers): This could be resolved at the GL binding level, but the |
| 5024 // binding process is currently a bit too 'brute force'. |
| 5025 if (feature_info->feature_flags().is_angle) { |
| 5026 glRenderbufferStorageMultisampleANGLE( |
| 5027 target, samples, internal_format, width, height); |
| 5028 } else if (feature_info->feature_flags().use_core_framebuffer_multisample) { |
| 5029 glRenderbufferStorageMultisample( |
| 5030 target, samples, internal_format, width, height); |
| 5031 } else { |
| 5032 glRenderbufferStorageMultisampleEXT( |
| 5033 target, samples, internal_format, width, height); |
| 5034 } |
| 5035 } |
| 5036 |
| 5037 void GLES2DecoderImpl::BlitFramebufferHelper(GLint srcX0, |
| 5038 GLint srcY0, |
| 5039 GLint srcX1, |
| 5040 GLint srcY1, |
| 5041 GLint dstX0, |
| 5042 GLint dstY0, |
| 5043 GLint dstX1, |
| 5044 GLint dstY1, |
| 5045 GLbitfield mask, |
| 5046 GLenum filter) { |
| 5047 // TODO(sievers): This could be resolved at the GL binding level, but the |
| 5048 // binding process is currently a bit too 'brute force'. |
| 5049 if (feature_info_->feature_flags().is_angle) { |
5001 glBlitFramebufferANGLE( | 5050 glBlitFramebufferANGLE( |
5002 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); | 5051 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 5052 } else if (feature_info_->feature_flags().use_core_framebuffer_multisample) { |
| 5053 glBlitFramebuffer( |
| 5054 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
5003 } else { | 5055 } else { |
5004 glBlitFramebufferEXT( | 5056 glBlitFramebufferEXT( |
5005 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); | 5057 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
5006 } | 5058 } |
5007 EnableDisable(GL_SCISSOR_TEST, state_.enable_flags.scissor_test); | |
5008 } | 5059 } |
5009 | 5060 |
5010 bool GLES2DecoderImpl::ValidateRenderbufferStorageMultisample( | 5061 bool GLES2DecoderImpl::ValidateRenderbufferStorageMultisample( |
5011 GLsizei samples, | 5062 GLsizei samples, |
5012 GLenum internalformat, | 5063 GLenum internalformat, |
5013 GLsizei width, | 5064 GLsizei width, |
5014 GLsizei height) { | 5065 GLsizei height) { |
5015 if (samples > renderbuffer_manager()->max_samples()) { | 5066 if (samples > renderbuffer_manager()->max_samples()) { |
5016 LOCAL_SET_GL_ERROR( | 5067 LOCAL_SET_GL_ERROR( |
5017 GL_INVALID_VALUE, | 5068 GL_INVALID_VALUE, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5067 if (!ValidateRenderbufferStorageMultisample( | 5118 if (!ValidateRenderbufferStorageMultisample( |
5068 samples, internalformat, width, height)) { | 5119 samples, internalformat, width, height)) { |
5069 return; | 5120 return; |
5070 } | 5121 } |
5071 | 5122 |
5072 GLenum impl_format = | 5123 GLenum impl_format = |
5073 renderbuffer_manager()->InternalRenderbufferFormatToImplFormat( | 5124 renderbuffer_manager()->InternalRenderbufferFormatToImplFormat( |
5074 internalformat); | 5125 internalformat); |
5075 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER( | 5126 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER( |
5076 "glRenderbufferStorageMultisampleCHROMIUM"); | 5127 "glRenderbufferStorageMultisampleCHROMIUM"); |
5077 if (IsAngle()) { | 5128 RenderbufferStorageMultisampleHelper( |
5078 glRenderbufferStorageMultisampleANGLE( | 5129 feature_info_, target, samples, impl_format, width, height); |
5079 target, samples, impl_format, width, height); | |
5080 } else { | |
5081 glRenderbufferStorageMultisampleEXT( | |
5082 target, samples, impl_format, width, height); | |
5083 } | |
5084 GLenum error = | 5130 GLenum error = |
5085 LOCAL_PEEK_GL_ERROR("glRenderbufferStorageMultisampleCHROMIUM"); | 5131 LOCAL_PEEK_GL_ERROR("glRenderbufferStorageMultisampleCHROMIUM"); |
5086 if (error == GL_NO_ERROR) { | 5132 if (error == GL_NO_ERROR) { |
5087 | 5133 |
5088 if (workarounds().validate_multisample_buffer_allocation) { | 5134 if (workarounds().validate_multisample_buffer_allocation) { |
5089 if (!VerifyMultisampleRenderbufferIntegrity( | 5135 if (!VerifyMultisampleRenderbufferIntegrity( |
5090 renderbuffer->service_id(), impl_format)) { | 5136 renderbuffer->service_id(), impl_format)) { |
5091 LOCAL_SET_GL_ERROR( | 5137 LOCAL_SET_GL_ERROR( |
5092 GL_OUT_OF_MEMORY, | 5138 GL_OUT_OF_MEMORY, |
5093 "glRenderbufferStorageMultisampleCHROMIUM", "out of memory"); | 5139 "glRenderbufferStorageMultisampleCHROMIUM", "out of memory"); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5213 glGetFloatv(GL_COLOR_CLEAR_VALUE, clear_color); | 5259 glGetFloatv(GL_COLOR_CLEAR_VALUE, clear_color); |
5214 glClearColor(1.0f, 0.0f, 1.0f, 1.0f); | 5260 glClearColor(1.0f, 0.0f, 1.0f, 1.0f); |
5215 | 5261 |
5216 // Clear the buffer to the desired key color. | 5262 // Clear the buffer to the desired key color. |
5217 glClear(GL_COLOR_BUFFER_BIT); | 5263 glClear(GL_COLOR_BUFFER_BIT); |
5218 | 5264 |
5219 // Blit from the multisample buffer to a standard texture. | 5265 // Blit from the multisample buffer to a standard texture. |
5220 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, validation_fbo_multisample_); | 5266 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, validation_fbo_multisample_); |
5221 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, validation_fbo_); | 5267 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, validation_fbo_); |
5222 | 5268 |
5223 glBlitFramebufferEXT(0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_NEAREST); | 5269 BlitFramebufferHelper( |
| 5270 0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_NEAREST); |
5224 | 5271 |
5225 // Read a pixel from the buffer. | 5272 // Read a pixel from the buffer. |
5226 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_); | 5273 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_); |
5227 | 5274 |
5228 unsigned char pixel[3] = {0, 0, 0}; | 5275 unsigned char pixel[3] = {0, 0, 0}; |
5229 glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pixel); | 5276 glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pixel); |
5230 | 5277 |
5231 // Detach the renderbuffer. | 5278 // Detach the renderbuffer. |
5232 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_multisample_); | 5279 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_multisample_); |
5233 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 5280 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
(...skipping 3610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8844 SetServiceId(offscreen_target_color_texture_->id()); | 8891 SetServiceId(offscreen_target_color_texture_->id()); |
8845 | 8892 |
8846 offscreen_saved_color_texture_.swap(offscreen_target_color_texture_); | 8893 offscreen_saved_color_texture_.swap(offscreen_target_color_texture_); |
8847 offscreen_target_frame_buffer_->AttachRenderTexture( | 8894 offscreen_target_frame_buffer_->AttachRenderTexture( |
8848 offscreen_target_color_texture_.get()); | 8895 offscreen_target_color_texture_.get()); |
8849 } | 8896 } |
8850 | 8897 |
8851 // Ensure the side effects of the copy are visible to the parent | 8898 // Ensure the side effects of the copy are visible to the parent |
8852 // context. There is no need to do this for ANGLE because it uses a | 8899 // context. There is no need to do this for ANGLE because it uses a |
8853 // single D3D device for all contexts. | 8900 // single D3D device for all contexts. |
8854 if (!IsAngle()) | 8901 if (!feature_info_->feature_flags().is_angle) |
8855 glFlush(); | 8902 glFlush(); |
8856 } | 8903 } |
8857 } else { | 8904 } else { |
8858 TRACE_EVENT2("gpu", "Onscreen", | 8905 TRACE_EVENT2("gpu", "Onscreen", |
8859 "width", surface_->GetSize().width(), | 8906 "width", surface_->GetSize().width(), |
8860 "height", surface_->GetSize().height()); | 8907 "height", surface_->GetSize().height()); |
8861 if (!surface_->SwapBuffers()) { | 8908 if (!surface_->SwapBuffers()) { |
8862 LOG(ERROR) << "Context lost because SwapBuffers failed."; | 8909 LOG(ERROR) << "Context lost because SwapBuffers failed."; |
8863 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 8910 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); |
8864 } | 8911 } |
(...skipping 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10464 DoDidUseTexImageIfNeeded(texture, texture->target()); | 10511 DoDidUseTexImageIfNeeded(texture, texture->target()); |
10465 } | 10512 } |
10466 | 10513 |
10467 // Include the auto-generated part of this file. We split this because it means | 10514 // Include the auto-generated part of this file. We split this because it means |
10468 // we can easily edit the non-auto generated parts right here in this file | 10515 // we can easily edit the non-auto generated parts right here in this file |
10469 // instead of having to edit some template or the code generator. | 10516 // instead of having to edit some template or the code generator. |
10470 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10517 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
10471 | 10518 |
10472 } // namespace gles2 | 10519 } // namespace gles2 |
10473 } // namespace gpu | 10520 } // namespace gpu |
OLD | NEW |