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

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

Issue 72173002: gpu: Support ES3 msaa and depth/stencil formats (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 7 years, 1 month 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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(GLES2DecoderImpl* decoder,
piman 2013/11/15 16:58:50 nit: kloveless@ tried to decouple these from the d
no sievers 2013/11/15 19:41:48 Done.
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
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 void RenderbufferStorageMultisampleHelper(GLenum target,
635 GLsizei samples,
636 GLenum internal_format,
637 GLsizei width,
638 GLsizei height);
639 void BlitFramebufferHelper(GLint srcX0,
640 GLint srcY0,
641 GLint srcX1,
642 GLint srcY1,
643 GLint dstX0,
644 GLint dstY0,
645 GLint dstX1,
646 GLint dstY1,
647 GLbitfield mask,
648 GLenum filter);
631 649
632 private: 650 private:
633 friend class ScopedFrameBufferBinder; 651 friend class ScopedFrameBufferBinder;
634 friend class ScopedResolvedFrameBufferBinder; 652 friend class ScopedResolvedFrameBufferBinder;
635 friend class BackFramebuffer; 653 friend class BackFramebuffer;
636 654
637 // Initialize or re-initialize the shader translator. 655 // Initialize or re-initialize the shader translator.
638 bool InitializeShaderTranslator(); 656 bool InitializeShaderTranslator();
639 657
640 void UpdateCapabilities(); 658 void UpdateCapabilities();
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1797 } 1815 }
1798 } 1816 }
1799 targetid = decoder_->offscreen_resolved_frame_buffer_->id(); 1817 targetid = decoder_->offscreen_resolved_frame_buffer_->id();
1800 } else { 1818 } else {
1801 targetid = decoder_->offscreen_saved_frame_buffer_->id(); 1819 targetid = decoder_->offscreen_saved_frame_buffer_->id();
1802 } 1820 }
1803 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, targetid); 1821 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, targetid);
1804 const int width = decoder_->offscreen_size_.width(); 1822 const int width = decoder_->offscreen_size_.width();
1805 const int height = decoder_->offscreen_size_.height(); 1823 const int height = decoder_->offscreen_size_.height();
1806 glDisable(GL_SCISSOR_TEST); 1824 glDisable(GL_SCISSOR_TEST);
1807 if (GLES2DecoderImpl::IsAngle()) { 1825 decoder->BlitFramebufferHelper(0,
1808 glBlitFramebufferANGLE(0, 0, width, height, 0, 0, width, height, 1826 0,
1809 GL_COLOR_BUFFER_BIT, GL_NEAREST); 1827 width,
1810 } else { 1828 height,
1811 glBlitFramebufferEXT(0, 0, width, height, 0, 0, width, height, 1829 0,
1812 GL_COLOR_BUFFER_BIT, GL_NEAREST); 1830 0,
1813 } 1831 width,
1832 height,
1833 GL_COLOR_BUFFER_BIT,
1834 GL_NEAREST);
1814 glBindFramebufferEXT(GL_FRAMEBUFFER, targetid); 1835 glBindFramebufferEXT(GL_FRAMEBUFFER, targetid);
1815 } 1836 }
1816 1837
1817 ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() { 1838 ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() {
1818 if (!resolve_and_bind_) 1839 if (!resolve_and_bind_)
1819 return; 1840 return;
1820 1841
1821 ScopedGLErrorSuppressor suppressor( 1842 ScopedGLErrorSuppressor suppressor(
1822 "ScopedResolvedFrameBufferBinder::dtor", decoder_->GetErrorState()); 1843 "ScopedResolvedFrameBufferBinder::dtor", decoder_->GetErrorState());
1823 decoder_->RestoreCurrentFramebufferBindings(); 1844 decoder_->RestoreCurrentFramebufferBindings();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 DCHECK_EQ(id_, 0u); 1976 DCHECK_EQ(id_, 0u);
1956 } 1977 }
1957 1978
1958 void BackRenderbuffer::Create() { 1979 void BackRenderbuffer::Create() {
1959 ScopedGLErrorSuppressor suppressor("BackRenderbuffer::Create", 1980 ScopedGLErrorSuppressor suppressor("BackRenderbuffer::Create",
1960 state_->GetErrorState()); 1981 state_->GetErrorState());
1961 Destroy(); 1982 Destroy();
1962 glGenRenderbuffersEXT(1, &id_); 1983 glGenRenderbuffersEXT(1, &id_);
1963 } 1984 }
1964 1985
1965 bool BackRenderbuffer::AllocateStorage(const gfx::Size& size, GLenum format, 1986 bool BackRenderbuffer::AllocateStorage(GLES2DecoderImpl* decoder,
1987 const gfx::Size& size,
1988 GLenum format,
1966 GLsizei samples) { 1989 GLsizei samples) {
1967 ScopedGLErrorSuppressor suppressor( 1990 ScopedGLErrorSuppressor suppressor(
1968 "BackRenderbuffer::AllocateStorage", state_->GetErrorState()); 1991 "BackRenderbuffer::AllocateStorage", state_->GetErrorState());
1969 ScopedRenderBufferBinder binder(state_, id_); 1992 ScopedRenderBufferBinder binder(state_, id_);
1970 1993
1971 uint32 estimated_size = 0; 1994 uint32 estimated_size = 0;
1972 if (!renderbuffer_manager_->ComputeEstimatedRenderbufferSize( 1995 if (!renderbuffer_manager_->ComputeEstimatedRenderbufferSize(
1973 size.width(), size.height(), samples, format, &estimated_size)) { 1996 size.width(), size.height(), samples, format, &estimated_size)) {
1974 return false; 1997 return false;
1975 } 1998 }
1976 1999
1977 if (!memory_tracker_.EnsureGPUMemoryAvailable(estimated_size)) { 2000 if (!memory_tracker_.EnsureGPUMemoryAvailable(estimated_size)) {
1978 return false; 2001 return false;
1979 } 2002 }
1980 2003
1981 if (samples <= 1) { 2004 if (samples <= 1) {
1982 glRenderbufferStorageEXT(GL_RENDERBUFFER, 2005 glRenderbufferStorageEXT(GL_RENDERBUFFER,
1983 format, 2006 format,
1984 size.width(), 2007 size.width(),
1985 size.height()); 2008 size.height());
1986 } else { 2009 } else {
1987 if (GLES2DecoderImpl::IsAngle()) { 2010 decoder->RenderbufferStorageMultisampleHelper(
1988 glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, 2011 GL_RENDERBUFFER, samples, format, size.width(), size.height());
1989 samples,
1990 format,
1991 size.width(),
1992 size.height());
1993 } else {
1994 glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER,
1995 samples,
1996 format,
1997 size.width(),
1998 size.height());
1999 }
2000 } 2012 }
2001 bool success = glGetError() == GL_NO_ERROR; 2013 bool success = glGetError() == GL_NO_ERROR;
2002 if (success) { 2014 if (success) {
2003 // Mark the previously allocated bytes as free. 2015 // Mark the previously allocated bytes as free.
2004 memory_tracker_.TrackMemFree(bytes_allocated_); 2016 memory_tracker_.TrackMemFree(bytes_allocated_);
2005 bytes_allocated_ = estimated_size; 2017 bytes_allocated_ = estimated_size;
2006 // Track the newly allocated bytes. 2018 // Track the newly allocated bytes.
2007 memory_tracker_.TrackMemAlloc(bytes_allocated_); 2019 memory_tracker_.TrackMemAlloc(bytes_allocated_);
2008 } 2020 }
2009 return success; 2021 return success;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 ScopedGLErrorSuppressor suppressor("BackFramebuffer::CheckStatus", 2099 ScopedGLErrorSuppressor suppressor("BackFramebuffer::CheckStatus",
2088 decoder_->GetErrorState()); 2100 decoder_->GetErrorState());
2089 ScopedFrameBufferBinder binder(decoder_, id_); 2101 ScopedFrameBufferBinder binder(decoder_, id_);
2090 return glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); 2102 return glCheckFramebufferStatusEXT(GL_FRAMEBUFFER);
2091 } 2103 }
2092 2104
2093 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { 2105 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) {
2094 return new GLES2DecoderImpl(group); 2106 return new GLES2DecoderImpl(group);
2095 } 2107 }
2096 2108
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) 2109 GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group)
2106 : GLES2Decoder(), 2110 : GLES2Decoder(),
2107 group_(group), 2111 group_(group),
2108 logger_(&debug_marker_manager_), 2112 logger_(&debug_marker_manager_),
2109 state_(group_->feature_info(), &logger_), 2113 state_(group_->feature_info(), &logger_),
2110 unpack_flip_y_(false), 2114 unpack_flip_y_(false),
2111 unpack_premultiply_alpha_(false), 2115 unpack_premultiply_alpha_(false),
2112 unpack_unpremultiply_alpha_(false), 2116 unpack_unpremultiply_alpha_(false),
2113 attrib_0_buffer_id_(0), 2117 attrib_0_buffer_id_(0),
2114 attrib_0_buffer_matches_value_(true), 2118 attrib_0_buffer_matches_value_(true),
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2296 GL_RGBA8 : GL_RGB8; 2300 GL_RGBA8 : GL_RGB8;
2297 } else { 2301 } else {
2298 offscreen_target_samples_ = 1; 2302 offscreen_target_samples_ = 1;
2299 offscreen_target_color_format_ = attrib_parser.alpha_size_ > 0 ? 2303 offscreen_target_color_format_ = attrib_parser.alpha_size_ > 0 ?
2300 GL_RGBA : GL_RGB; 2304 GL_RGBA : GL_RGB;
2301 } 2305 }
2302 2306
2303 // ANGLE only supports packed depth/stencil formats, so use it if it is 2307 // ANGLE only supports packed depth/stencil formats, so use it if it is
2304 // available. 2308 // available.
2305 const bool depth24_stencil8_supported = 2309 const bool depth24_stencil8_supported =
2306 context_->HasExtension("GL_OES_packed_depth_stencil"); 2310 feature_info_->feature_flags().packed_depth24_stencil8;
2307 VLOG(1) << "GL_OES_packed_depth_stencil " 2311 VLOG(1) << "GL_OES_packed_depth_stencil "
2308 << (depth24_stencil8_supported ? "" : "not ") << "supported."; 2312 << (depth24_stencil8_supported ? "" : "not ") << "supported.";
2309 if ((attrib_parser.depth_size_ > 0 || attrib_parser.stencil_size_ > 0) && 2313 if ((attrib_parser.depth_size_ > 0 || attrib_parser.stencil_size_ > 0) &&
2310 depth24_stencil8_supported) { 2314 depth24_stencil8_supported) {
2311 offscreen_target_depth_format_ = GL_DEPTH24_STENCIL8; 2315 offscreen_target_depth_format_ = GL_DEPTH24_STENCIL8;
2312 offscreen_target_stencil_format_ = 0; 2316 offscreen_target_stencil_format_ = 0;
2313 } else { 2317 } else {
2314 // It may be the case that this depth/stencil combination is not 2318 // It may be the case that this depth/stencil combination is not
2315 // supported, but this will be checked later by CheckFramebufferStatus. 2319 // supported, but this will be checked later by CheckFramebufferStatus.
2316 offscreen_target_depth_format_ = attrib_parser.depth_size_ > 0 ? 2320 offscreen_target_depth_format_ = attrib_parser.depth_size_ > 0 ?
2317 GL_DEPTH_COMPONENT16 : 0; 2321 GL_DEPTH_COMPONENT16 : 0;
2318 offscreen_target_stencil_format_ = attrib_parser.stencil_size_ > 0 ? 2322 offscreen_target_stencil_format_ = attrib_parser.stencil_size_ > 0 ?
2319 GL_STENCIL_INDEX8 : 0; 2323 GL_STENCIL_INDEX8 : 0;
2320 } 2324 }
2321 } else { 2325 } else {
2322 offscreen_target_color_format_ = attrib_parser.alpha_size_ > 0 ? 2326 offscreen_target_color_format_ = attrib_parser.alpha_size_ > 0 ?
2323 GL_RGBA : GL_RGB; 2327 GL_RGBA : GL_RGB;
2324 2328
2325 // If depth is requested at all, use the packed depth stencil format if 2329 // 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 2330 // it's available, as some desktop GL drivers don't support any non-packed
2327 // formats for depth attachments. 2331 // formats for depth attachments.
2328 const bool depth24_stencil8_supported = 2332 const bool depth24_stencil8_supported =
2329 context_->HasExtension("GL_EXT_packed_depth_stencil"); 2333 feature_info_->feature_flags().packed_depth24_stencil8;
2330 VLOG(1) << "GL_EXT_packed_depth_stencil " 2334 VLOG(1) << "GL_EXT_packed_depth_stencil "
2331 << (depth24_stencil8_supported ? "" : "not ") << "supported."; 2335 << (depth24_stencil8_supported ? "" : "not ") << "supported.";
2332 2336
2333 if ((attrib_parser.depth_size_ > 0 || attrib_parser.stencil_size_ > 0) && 2337 if ((attrib_parser.depth_size_ > 0 || attrib_parser.stencil_size_ > 0) &&
2334 depth24_stencil8_supported) { 2338 depth24_stencil8_supported) {
2335 offscreen_target_depth_format_ = GL_DEPTH24_STENCIL8; 2339 offscreen_target_depth_format_ = GL_DEPTH24_STENCIL8;
2336 offscreen_target_stencil_format_ = 0; 2340 offscreen_target_stencil_format_ = 0;
2337 } else { 2341 } else {
2338 offscreen_target_depth_format_ = attrib_parser.depth_size_ > 0 ? 2342 offscreen_target_depth_format_ = attrib_parser.depth_size_ > 0 ?
2339 GL_DEPTH_COMPONENT : 0; 2343 GL_DEPTH_COMPONENT : 0;
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
3314 if (w < 0 || h < 0 || h >= (INT_MAX / 4) / (w ? w : 1)) { 3318 if (w < 0 || h < 0 || h >= (INT_MAX / 4) / (w ? w : 1)) {
3315 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " 3319 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed "
3316 << "to allocate storage due to excessive dimensions."; 3320 << "to allocate storage due to excessive dimensions.";
3317 return false; 3321 return false;
3318 } 3322 }
3319 3323
3320 // Reallocate the offscreen target buffers. 3324 // Reallocate the offscreen target buffers.
3321 DCHECK(offscreen_target_color_format_); 3325 DCHECK(offscreen_target_color_format_);
3322 if (IsOffscreenBufferMultisampled()) { 3326 if (IsOffscreenBufferMultisampled()) {
3323 if (!offscreen_target_color_render_buffer_->AllocateStorage( 3327 if (!offscreen_target_color_render_buffer_->AllocateStorage(
3324 offscreen_size_, offscreen_target_color_format_, 3328 this, offscreen_size_, offscreen_target_color_format_,
3325 offscreen_target_samples_)) { 3329 offscreen_target_samples_)) {
3326 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " 3330 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed "
3327 << "to allocate storage for offscreen target color buffer."; 3331 << "to allocate storage for offscreen target color buffer.";
3328 return false; 3332 return false;
3329 } 3333 }
3330 } else { 3334 } else {
3331 if (!offscreen_target_color_texture_->AllocateStorage( 3335 if (!offscreen_target_color_texture_->AllocateStorage(
3332 offscreen_size_, offscreen_target_color_format_, false)) { 3336 offscreen_size_, offscreen_target_color_format_, false)) {
3333 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " 3337 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed "
3334 << "to allocate storage for offscreen target color texture."; 3338 << "to allocate storage for offscreen target color texture.";
3335 return false; 3339 return false;
3336 } 3340 }
3337 } 3341 }
3338 if (offscreen_target_depth_format_ && 3342 if (offscreen_target_depth_format_ &&
3339 !offscreen_target_depth_render_buffer_->AllocateStorage( 3343 !offscreen_target_depth_render_buffer_->AllocateStorage(
3340 offscreen_size_, offscreen_target_depth_format_, 3344 this, offscreen_size_, offscreen_target_depth_format_,
3341 offscreen_target_samples_)) { 3345 offscreen_target_samples_)) {
3342 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " 3346 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed "
3343 << "to allocate storage for offscreen target depth buffer."; 3347 << "to allocate storage for offscreen target depth buffer.";
3344 return false; 3348 return false;
3345 } 3349 }
3346 if (offscreen_target_stencil_format_ && 3350 if (offscreen_target_stencil_format_ &&
3347 !offscreen_target_stencil_render_buffer_->AllocateStorage( 3351 !offscreen_target_stencil_render_buffer_->AllocateStorage(
3348 offscreen_size_, offscreen_target_stencil_format_, 3352 this, offscreen_size_, offscreen_target_stencil_format_,
3349 offscreen_target_samples_)) { 3353 offscreen_target_samples_)) {
3350 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " 3354 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed "
3351 << "to allocate storage for offscreen target stencil buffer."; 3355 << "to allocate storage for offscreen target stencil buffer.";
3352 return false; 3356 return false;
3353 } 3357 }
3354 3358
3355 // Attach the offscreen target buffers to the target frame buffer. 3359 // Attach the offscreen target buffers to the target frame buffer.
3356 if (IsOffscreenBufferMultisampled()) { 3360 if (IsOffscreenBufferMultisampled()) {
3357 offscreen_target_frame_buffer_->AttachRenderBuffer( 3361 offscreen_target_frame_buffer_->AttachRenderBuffer(
3358 GL_COLOR_ATTACHMENT0, 3362 GL_COLOR_ATTACHMENT0,
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after
4990 GL_INVALID_OPERATION, 4994 GL_INVALID_OPERATION,
4991 "glBlitFramebufferCHROMIUM", "function not available"); 4995 "glBlitFramebufferCHROMIUM", "function not available");
4992 return; 4996 return;
4993 } 4997 }
4994 4998
4995 if (!CheckBoundFramebuffersValid("glBlitFramebufferCHROMIUM")) { 4999 if (!CheckBoundFramebuffersValid("glBlitFramebufferCHROMIUM")) {
4996 return; 5000 return;
4997 } 5001 }
4998 5002
4999 glDisable(GL_SCISSOR_TEST); 5003 glDisable(GL_SCISSOR_TEST);
5000 if (IsAngle()) { 5004 BlitFramebufferHelper(
5005 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
5006 EnableDisable(GL_SCISSOR_TEST, state_.enable_flags.scissor_test);
5007 }
5008
5009 void GLES2DecoderImpl::RenderbufferStorageMultisampleHelper(
5010 GLenum target,
5011 GLsizei samples,
5012 GLenum internal_format,
5013 GLsizei width,
5014 GLsizei height) {
5015 // TODO(sievers): This could be resolved at the GL binding level, but the
5016 // binding process is currently a bit too 'brute force'.
5017 if (feature_info_->feature_flags().is_angle) {
5018 glRenderbufferStorageMultisampleANGLE(
5019 target, samples, internal_format, width, height);
5020 } else if (feature_info_->feature_flags().use_core_framebuffer_multisample) {
5021 glRenderbufferStorageMultisample(
5022 target, samples, internal_format, width, height);
5023 } else {
5024 glRenderbufferStorageMultisampleEXT(
5025 target, samples, internal_format, width, height);
5026 }
5027 }
5028
5029 void GLES2DecoderImpl::BlitFramebufferHelper(GLint srcX0,
5030 GLint srcY0,
5031 GLint srcX1,
5032 GLint srcY1,
5033 GLint dstX0,
5034 GLint dstY0,
5035 GLint dstX1,
5036 GLint dstY1,
5037 GLbitfield mask,
5038 GLenum filter) {
5039 // TODO(sievers): This could be resolved at the GL binding level, but the
5040 // binding process is currently a bit too 'brute force'.
5041 if (feature_info_->feature_flags().is_angle) {
5001 glBlitFramebufferANGLE( 5042 glBlitFramebufferANGLE(
5002 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); 5043 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
5044 } else if (feature_info_->feature_flags().use_core_framebuffer_multisample) {
5045 glBlitFramebuffer(
5046 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
5003 } else { 5047 } else {
5004 glBlitFramebufferEXT( 5048 glBlitFramebufferEXT(
5005 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); 5049 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
5006 } 5050 }
5007 EnableDisable(GL_SCISSOR_TEST, state_.enable_flags.scissor_test);
5008 } 5051 }
5009 5052
5010 bool GLES2DecoderImpl::ValidateRenderbufferStorageMultisample( 5053 bool GLES2DecoderImpl::ValidateRenderbufferStorageMultisample(
5011 GLsizei samples, 5054 GLsizei samples,
5012 GLenum internalformat, 5055 GLenum internalformat,
5013 GLsizei width, 5056 GLsizei width,
5014 GLsizei height) { 5057 GLsizei height) {
5015 if (samples > renderbuffer_manager()->max_samples()) { 5058 if (samples > renderbuffer_manager()->max_samples()) {
5016 LOCAL_SET_GL_ERROR( 5059 LOCAL_SET_GL_ERROR(
5017 GL_INVALID_VALUE, 5060 GL_INVALID_VALUE,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
5067 if (!ValidateRenderbufferStorageMultisample( 5110 if (!ValidateRenderbufferStorageMultisample(
5068 samples, internalformat, width, height)) { 5111 samples, internalformat, width, height)) {
5069 return; 5112 return;
5070 } 5113 }
5071 5114
5072 GLenum impl_format = 5115 GLenum impl_format =
5073 renderbuffer_manager()->InternalRenderbufferFormatToImplFormat( 5116 renderbuffer_manager()->InternalRenderbufferFormatToImplFormat(
5074 internalformat); 5117 internalformat);
5075 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER( 5118 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(
5076 "glRenderbufferStorageMultisampleCHROMIUM"); 5119 "glRenderbufferStorageMultisampleCHROMIUM");
5077 if (IsAngle()) { 5120 RenderbufferStorageMultisampleHelper(
5078 glRenderbufferStorageMultisampleANGLE( 5121 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 = 5122 GLenum error =
5085 LOCAL_PEEK_GL_ERROR("glRenderbufferStorageMultisampleCHROMIUM"); 5123 LOCAL_PEEK_GL_ERROR("glRenderbufferStorageMultisampleCHROMIUM");
5086 if (error == GL_NO_ERROR) { 5124 if (error == GL_NO_ERROR) {
5087 5125
5088 if (workarounds().validate_multisample_buffer_allocation) { 5126 if (workarounds().validate_multisample_buffer_allocation) {
5089 if (!VerifyMultisampleRenderbufferIntegrity( 5127 if (!VerifyMultisampleRenderbufferIntegrity(
5090 renderbuffer->service_id(), impl_format)) { 5128 renderbuffer->service_id(), impl_format)) {
5091 LOCAL_SET_GL_ERROR( 5129 LOCAL_SET_GL_ERROR(
5092 GL_OUT_OF_MEMORY, 5130 GL_OUT_OF_MEMORY,
5093 "glRenderbufferStorageMultisampleCHROMIUM", "out of memory"); 5131 "glRenderbufferStorageMultisampleCHROMIUM", "out of memory");
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
5213 glGetFloatv(GL_COLOR_CLEAR_VALUE, clear_color); 5251 glGetFloatv(GL_COLOR_CLEAR_VALUE, clear_color);
5214 glClearColor(1.0f, 0.0f, 1.0f, 1.0f); 5252 glClearColor(1.0f, 0.0f, 1.0f, 1.0f);
5215 5253
5216 // Clear the buffer to the desired key color. 5254 // Clear the buffer to the desired key color.
5217 glClear(GL_COLOR_BUFFER_BIT); 5255 glClear(GL_COLOR_BUFFER_BIT);
5218 5256
5219 // Blit from the multisample buffer to a standard texture. 5257 // Blit from the multisample buffer to a standard texture.
5220 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, validation_fbo_multisample_); 5258 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, validation_fbo_multisample_);
5221 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, validation_fbo_); 5259 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, validation_fbo_);
5222 5260
5223 glBlitFramebufferEXT(0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_NEAREST); 5261 BlitFramebufferHelper(
5262 0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_NEAREST);
5224 5263
5225 // Read a pixel from the buffer. 5264 // Read a pixel from the buffer.
5226 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_); 5265 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_);
5227 5266
5228 unsigned char pixel[3] = {0, 0, 0}; 5267 unsigned char pixel[3] = {0, 0, 0};
5229 glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pixel); 5268 glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pixel);
5230 5269
5231 // Detach the renderbuffer. 5270 // Detach the renderbuffer.
5232 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_multisample_); 5271 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_multisample_);
5233 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 5272 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
(...skipping 3610 matching lines...) Expand 10 before | Expand all | Expand 10 after
8844 SetServiceId(offscreen_target_color_texture_->id()); 8883 SetServiceId(offscreen_target_color_texture_->id());
8845 8884
8846 offscreen_saved_color_texture_.swap(offscreen_target_color_texture_); 8885 offscreen_saved_color_texture_.swap(offscreen_target_color_texture_);
8847 offscreen_target_frame_buffer_->AttachRenderTexture( 8886 offscreen_target_frame_buffer_->AttachRenderTexture(
8848 offscreen_target_color_texture_.get()); 8887 offscreen_target_color_texture_.get());
8849 } 8888 }
8850 8889
8851 // Ensure the side effects of the copy are visible to the parent 8890 // 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 8891 // context. There is no need to do this for ANGLE because it uses a
8853 // single D3D device for all contexts. 8892 // single D3D device for all contexts.
8854 if (!IsAngle()) 8893 if (!feature_info_->feature_flags().is_angle)
8855 glFlush(); 8894 glFlush();
8856 } 8895 }
8857 } else { 8896 } else {
8858 TRACE_EVENT2("gpu", "Onscreen", 8897 TRACE_EVENT2("gpu", "Onscreen",
8859 "width", surface_->GetSize().width(), 8898 "width", surface_->GetSize().width(),
8860 "height", surface_->GetSize().height()); 8899 "height", surface_->GetSize().height());
8861 if (!surface_->SwapBuffers()) { 8900 if (!surface_->SwapBuffers()) {
8862 LOG(ERROR) << "Context lost because SwapBuffers failed."; 8901 LOG(ERROR) << "Context lost because SwapBuffers failed.";
8863 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); 8902 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB);
8864 } 8903 }
(...skipping 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after
10464 DoDidUseTexImageIfNeeded(texture, texture->target()); 10503 DoDidUseTexImageIfNeeded(texture, texture->target());
10465 } 10504 }
10466 10505
10467 // Include the auto-generated part of this file. We split this because it means 10506 // 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 10507 // 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. 10508 // instead of having to edit some template or the code generator.
10470 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10509 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10471 10510
10472 } // namespace gles2 10511 } // namespace gles2
10473 } // namespace gpu 10512 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/feature_info_unittest.cc ('k') | gpu/command_buffer/service/test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698