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

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: rebase 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,
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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 bool BoundFramebufferHasColorAttachmentWithAlpha(bool all_draw_buffers); 638 bool BoundFramebufferHasColorAttachmentWithAlpha(bool all_draw_buffers);
636 bool BoundFramebufferHasDepthAttachment(); 639 bool BoundFramebufferHasDepthAttachment();
637 bool BoundFramebufferHasStencilAttachment(); 640 bool BoundFramebufferHasStencilAttachment();
638 641
639 virtual error::ContextLostReason GetContextLostReason() OVERRIDE; 642 virtual error::ContextLostReason GetContextLostReason() OVERRIDE;
640 643
641 // Overridden from FramebufferManager::TextureDetachObserver: 644 // Overridden from FramebufferManager::TextureDetachObserver:
642 virtual void OnTextureRefDetachedFromFramebuffer( 645 virtual void OnTextureRefDetachedFromFramebuffer(
643 TextureRef* texture) OVERRIDE; 646 TextureRef* texture) OVERRIDE;
644 647
648 // Helpers to facilitate calling into compatible extensions.
649 void RenderbufferStorageMultisampleHelper(GLenum target,
650 GLsizei samples,
651 GLenum internal_format,
652 GLsizei width,
653 GLsizei height);
654 void BlitFramebufferHelper(GLint srcX0,
655 GLint srcY0,
656 GLint srcX1,
657 GLint srcY1,
658 GLint dstX0,
659 GLint dstY0,
660 GLint dstX1,
661 GLint dstY1,
662 GLbitfield mask,
663 GLenum filter);
664
645 private: 665 private:
646 friend class ScopedFrameBufferBinder; 666 friend class ScopedFrameBufferBinder;
647 friend class ScopedResolvedFrameBufferBinder; 667 friend class ScopedResolvedFrameBufferBinder;
648 friend class BackFramebuffer; 668 friend class BackFramebuffer;
649 669
650 // Initialize or re-initialize the shader translator. 670 // Initialize or re-initialize the shader translator.
651 bool InitializeShaderTranslator(); 671 bool InitializeShaderTranslator();
652 672
653 void UpdateCapabilities(); 673 void UpdateCapabilities();
654 674
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1810 } 1830 }
1811 } 1831 }
1812 targetid = decoder_->offscreen_resolved_frame_buffer_->id(); 1832 targetid = decoder_->offscreen_resolved_frame_buffer_->id();
1813 } else { 1833 } else {
1814 targetid = decoder_->offscreen_saved_frame_buffer_->id(); 1834 targetid = decoder_->offscreen_saved_frame_buffer_->id();
1815 } 1835 }
1816 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, targetid); 1836 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, targetid);
1817 const int width = decoder_->offscreen_size_.width(); 1837 const int width = decoder_->offscreen_size_.width();
1818 const int height = decoder_->offscreen_size_.height(); 1838 const int height = decoder_->offscreen_size_.height();
1819 glDisable(GL_SCISSOR_TEST); 1839 glDisable(GL_SCISSOR_TEST);
1820 if (GLES2Decoder::IsAngle()) { 1840 decoder->BlitFramebufferHelper(0,
1821 glBlitFramebufferANGLE(0, 0, width, height, 0, 0, width, height, 1841 0,
1822 GL_COLOR_BUFFER_BIT, GL_NEAREST); 1842 width,
1823 } else { 1843 height,
1824 glBlitFramebufferEXT(0, 0, width, height, 0, 0, width, height, 1844 0,
1825 GL_COLOR_BUFFER_BIT, GL_NEAREST); 1845 0,
1826 } 1846 width,
1847 height,
1848 GL_COLOR_BUFFER_BIT,
1849 GL_NEAREST);
1827 glBindFramebufferEXT(GL_FRAMEBUFFER, targetid); 1850 glBindFramebufferEXT(GL_FRAMEBUFFER, targetid);
1828 } 1851 }
1829 1852
1830 ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() { 1853 ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() {
1831 if (!resolve_and_bind_) 1854 if (!resolve_and_bind_)
1832 return; 1855 return;
1833 1856
1834 ScopedGLErrorSuppressor suppressor( 1857 ScopedGLErrorSuppressor suppressor(
1835 "ScopedResolvedFrameBufferBinder::dtor", decoder_->GetErrorState()); 1858 "ScopedResolvedFrameBufferBinder::dtor", decoder_->GetErrorState());
1836 decoder_->RestoreCurrentFramebufferBindings(); 1859 decoder_->RestoreCurrentFramebufferBindings();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 DCHECK_EQ(id_, 0u); 1991 DCHECK_EQ(id_, 0u);
1969 } 1992 }
1970 1993
1971 void BackRenderbuffer::Create() { 1994 void BackRenderbuffer::Create() {
1972 ScopedGLErrorSuppressor suppressor("BackRenderbuffer::Create", 1995 ScopedGLErrorSuppressor suppressor("BackRenderbuffer::Create",
1973 state_->GetErrorState()); 1996 state_->GetErrorState());
1974 Destroy(); 1997 Destroy();
1975 glGenRenderbuffersEXT(1, &id_); 1998 glGenRenderbuffersEXT(1, &id_);
1976 } 1999 }
1977 2000
1978 bool BackRenderbuffer::AllocateStorage(const gfx::Size& size, GLenum format, 2001 bool BackRenderbuffer::AllocateStorage(GLES2DecoderImpl* decoder,
2002 const gfx::Size& size,
2003 GLenum format,
1979 GLsizei samples) { 2004 GLsizei samples) {
1980 ScopedGLErrorSuppressor suppressor( 2005 ScopedGLErrorSuppressor suppressor(
1981 "BackRenderbuffer::AllocateStorage", state_->GetErrorState()); 2006 "BackRenderbuffer::AllocateStorage", state_->GetErrorState());
1982 ScopedRenderBufferBinder binder(state_, id_); 2007 ScopedRenderBufferBinder binder(state_, id_);
1983 2008
1984 uint32 estimated_size = 0; 2009 uint32 estimated_size = 0;
1985 if (!renderbuffer_manager_->ComputeEstimatedRenderbufferSize( 2010 if (!renderbuffer_manager_->ComputeEstimatedRenderbufferSize(
1986 size.width(), size.height(), samples, format, &estimated_size)) { 2011 size.width(), size.height(), samples, format, &estimated_size)) {
1987 return false; 2012 return false;
1988 } 2013 }
1989 2014
1990 if (!memory_tracker_.EnsureGPUMemoryAvailable(estimated_size)) { 2015 if (!memory_tracker_.EnsureGPUMemoryAvailable(estimated_size)) {
1991 return false; 2016 return false;
1992 } 2017 }
1993 2018
1994 if (samples <= 1) { 2019 if (samples <= 1) {
1995 glRenderbufferStorageEXT(GL_RENDERBUFFER, 2020 glRenderbufferStorageEXT(GL_RENDERBUFFER,
1996 format, 2021 format,
1997 size.width(), 2022 size.width(),
1998 size.height()); 2023 size.height());
1999 } else { 2024 } else {
2000 if (GLES2Decoder::IsAngle()) { 2025 decoder->RenderbufferStorageMultisampleHelper(
2001 glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, 2026 GL_RENDERBUFFER, samples, format, size.width(), size.height());
2002 samples,
2003 format,
2004 size.width(),
2005 size.height());
2006 } else {
2007 glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER,
2008 samples,
2009 format,
2010 size.width(),
2011 size.height());
2012 }
2013 } 2027 }
2014 bool success = glGetError() == GL_NO_ERROR; 2028 bool success = glGetError() == GL_NO_ERROR;
2015 if (success) { 2029 if (success) {
2016 // Mark the previously allocated bytes as free. 2030 // Mark the previously allocated bytes as free.
2017 memory_tracker_.TrackMemFree(bytes_allocated_); 2031 memory_tracker_.TrackMemFree(bytes_allocated_);
2018 bytes_allocated_ = estimated_size; 2032 bytes_allocated_ = estimated_size;
2019 // Track the newly allocated bytes. 2033 // Track the newly allocated bytes.
2020 memory_tracker_.TrackMemAlloc(bytes_allocated_); 2034 memory_tracker_.TrackMemAlloc(bytes_allocated_);
2021 } 2035 }
2022 return success; 2036 return success;
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
2303 GL_RGBA8 : GL_RGB8; 2317 GL_RGBA8 : GL_RGB8;
2304 } else { 2318 } else {
2305 offscreen_target_samples_ = 1; 2319 offscreen_target_samples_ = 1;
2306 offscreen_target_color_format_ = attrib_parser.alpha_size_ > 0 ? 2320 offscreen_target_color_format_ = attrib_parser.alpha_size_ > 0 ?
2307 GL_RGBA : GL_RGB; 2321 GL_RGBA : GL_RGB;
2308 } 2322 }
2309 2323
2310 // ANGLE only supports packed depth/stencil formats, so use it if it is 2324 // ANGLE only supports packed depth/stencil formats, so use it if it is
2311 // available. 2325 // available.
2312 const bool depth24_stencil8_supported = 2326 const bool depth24_stencil8_supported =
2313 context_->HasExtension("GL_OES_packed_depth_stencil"); 2327 feature_info_->feature_flags().packed_depth24_stencil8;
2314 VLOG(1) << "GL_OES_packed_depth_stencil " 2328 VLOG(1) << "GL_OES_packed_depth_stencil "
2315 << (depth24_stencil8_supported ? "" : "not ") << "supported."; 2329 << (depth24_stencil8_supported ? "" : "not ") << "supported.";
2316 if ((attrib_parser.depth_size_ > 0 || attrib_parser.stencil_size_ > 0) && 2330 if ((attrib_parser.depth_size_ > 0 || attrib_parser.stencil_size_ > 0) &&
2317 depth24_stencil8_supported) { 2331 depth24_stencil8_supported) {
2318 offscreen_target_depth_format_ = GL_DEPTH24_STENCIL8; 2332 offscreen_target_depth_format_ = GL_DEPTH24_STENCIL8;
2319 offscreen_target_stencil_format_ = 0; 2333 offscreen_target_stencil_format_ = 0;
2320 } else { 2334 } else {
2321 // It may be the case that this depth/stencil combination is not 2335 // It may be the case that this depth/stencil combination is not
2322 // supported, but this will be checked later by CheckFramebufferStatus. 2336 // supported, but this will be checked later by CheckFramebufferStatus.
2323 offscreen_target_depth_format_ = attrib_parser.depth_size_ > 0 ? 2337 offscreen_target_depth_format_ = attrib_parser.depth_size_ > 0 ?
2324 GL_DEPTH_COMPONENT16 : 0; 2338 GL_DEPTH_COMPONENT16 : 0;
2325 offscreen_target_stencil_format_ = attrib_parser.stencil_size_ > 0 ? 2339 offscreen_target_stencil_format_ = attrib_parser.stencil_size_ > 0 ?
2326 GL_STENCIL_INDEX8 : 0; 2340 GL_STENCIL_INDEX8 : 0;
2327 } 2341 }
2328 } else { 2342 } else {
2329 offscreen_target_color_format_ = attrib_parser.alpha_size_ > 0 ? 2343 offscreen_target_color_format_ = attrib_parser.alpha_size_ > 0 ?
2330 GL_RGBA : GL_RGB; 2344 GL_RGBA : GL_RGB;
2331 2345
2332 // If depth is requested at all, use the packed depth stencil format if 2346 // If depth is requested at all, use the packed depth stencil format if
2333 // it's available, as some desktop GL drivers don't support any non-packed 2347 // it's available, as some desktop GL drivers don't support any non-packed
2334 // formats for depth attachments. 2348 // formats for depth attachments.
2335 const bool depth24_stencil8_supported = 2349 const bool depth24_stencil8_supported =
2336 context_->HasExtension("GL_EXT_packed_depth_stencil"); 2350 feature_info_->feature_flags().packed_depth24_stencil8;
2337 VLOG(1) << "GL_EXT_packed_depth_stencil " 2351 VLOG(1) << "GL_EXT_packed_depth_stencil "
2338 << (depth24_stencil8_supported ? "" : "not ") << "supported."; 2352 << (depth24_stencil8_supported ? "" : "not ") << "supported.";
2339 2353
2340 if ((attrib_parser.depth_size_ > 0 || attrib_parser.stencil_size_ > 0) && 2354 if ((attrib_parser.depth_size_ > 0 || attrib_parser.stencil_size_ > 0) &&
2341 depth24_stencil8_supported) { 2355 depth24_stencil8_supported) {
2342 offscreen_target_depth_format_ = GL_DEPTH24_STENCIL8; 2356 offscreen_target_depth_format_ = GL_DEPTH24_STENCIL8;
2343 offscreen_target_stencil_format_ = 0; 2357 offscreen_target_stencil_format_ = 0;
2344 } else { 2358 } else {
2345 offscreen_target_depth_format_ = attrib_parser.depth_size_ > 0 ? 2359 offscreen_target_depth_format_ = attrib_parser.depth_size_ > 0 ?
2346 GL_DEPTH_COMPONENT : 0; 2360 GL_DEPTH_COMPONENT : 0;
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
3321 if (w < 0 || h < 0 || h >= (INT_MAX / 4) / (w ? w : 1)) { 3335 if (w < 0 || h < 0 || h >= (INT_MAX / 4) / (w ? w : 1)) {
3322 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " 3336 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed "
3323 << "to allocate storage due to excessive dimensions."; 3337 << "to allocate storage due to excessive dimensions.";
3324 return false; 3338 return false;
3325 } 3339 }
3326 3340
3327 // Reallocate the offscreen target buffers. 3341 // Reallocate the offscreen target buffers.
3328 DCHECK(offscreen_target_color_format_); 3342 DCHECK(offscreen_target_color_format_);
3329 if (IsOffscreenBufferMultisampled()) { 3343 if (IsOffscreenBufferMultisampled()) {
3330 if (!offscreen_target_color_render_buffer_->AllocateStorage( 3344 if (!offscreen_target_color_render_buffer_->AllocateStorage(
3331 offscreen_size_, offscreen_target_color_format_, 3345 this, offscreen_size_, offscreen_target_color_format_,
3332 offscreen_target_samples_)) { 3346 offscreen_target_samples_)) {
3333 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " 3347 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed "
3334 << "to allocate storage for offscreen target color buffer."; 3348 << "to allocate storage for offscreen target color buffer.";
3335 return false; 3349 return false;
3336 } 3350 }
3337 } else { 3351 } else {
3338 if (!offscreen_target_color_texture_->AllocateStorage( 3352 if (!offscreen_target_color_texture_->AllocateStorage(
3339 offscreen_size_, offscreen_target_color_format_, false)) { 3353 offscreen_size_, offscreen_target_color_format_, false)) {
3340 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " 3354 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed "
3341 << "to allocate storage for offscreen target color texture."; 3355 << "to allocate storage for offscreen target color texture.";
3342 return false; 3356 return false;
3343 } 3357 }
3344 } 3358 }
3345 if (offscreen_target_depth_format_ && 3359 if (offscreen_target_depth_format_ &&
3346 !offscreen_target_depth_render_buffer_->AllocateStorage( 3360 !offscreen_target_depth_render_buffer_->AllocateStorage(
3347 offscreen_size_, offscreen_target_depth_format_, 3361 this, offscreen_size_, offscreen_target_depth_format_,
3348 offscreen_target_samples_)) { 3362 offscreen_target_samples_)) {
3349 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " 3363 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed "
3350 << "to allocate storage for offscreen target depth buffer."; 3364 << "to allocate storage for offscreen target depth buffer.";
3351 return false; 3365 return false;
3352 } 3366 }
3353 if (offscreen_target_stencil_format_ && 3367 if (offscreen_target_stencil_format_ &&
3354 !offscreen_target_stencil_render_buffer_->AllocateStorage( 3368 !offscreen_target_stencil_render_buffer_->AllocateStorage(
3355 offscreen_size_, offscreen_target_stencil_format_, 3369 this, offscreen_size_, offscreen_target_stencil_format_,
3356 offscreen_target_samples_)) { 3370 offscreen_target_samples_)) {
3357 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " 3371 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed "
3358 << "to allocate storage for offscreen target stencil buffer."; 3372 << "to allocate storage for offscreen target stencil buffer.";
3359 return false; 3373 return false;
3360 } 3374 }
3361 3375
3362 // Attach the offscreen target buffers to the target frame buffer. 3376 // Attach the offscreen target buffers to the target frame buffer.
3363 if (IsOffscreenBufferMultisampled()) { 3377 if (IsOffscreenBufferMultisampled()) {
3364 offscreen_target_frame_buffer_->AttachRenderBuffer( 3378 offscreen_target_frame_buffer_->AttachRenderBuffer(
3365 GL_COLOR_ATTACHMENT0, 3379 GL_COLOR_ATTACHMENT0,
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after
4997 GL_INVALID_OPERATION, 5011 GL_INVALID_OPERATION,
4998 "glBlitFramebufferCHROMIUM", "function not available"); 5012 "glBlitFramebufferCHROMIUM", "function not available");
4999 return; 5013 return;
5000 } 5014 }
5001 5015
5002 if (!CheckBoundFramebuffersValid("glBlitFramebufferCHROMIUM")) { 5016 if (!CheckBoundFramebuffersValid("glBlitFramebufferCHROMIUM")) {
5003 return; 5017 return;
5004 } 5018 }
5005 5019
5006 glDisable(GL_SCISSOR_TEST); 5020 glDisable(GL_SCISSOR_TEST);
5021 BlitFramebufferHelper(
5022 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
5023 EnableDisable(GL_SCISSOR_TEST, state_.enable_flags.scissor_test);
5024 }
5025
5026 void GLES2DecoderImpl::RenderbufferStorageMultisampleHelper(
5027 GLenum target,
5028 GLsizei samples,
5029 GLenum internal_format,
5030 GLsizei width,
5031 GLsizei height) {
5032 // TODO(sievers): This could be resolved at the GL binding level, but the
5033 // binding process is currently a bit too 'brute force'.
5034 if (IsAngle()) {
5035 glRenderbufferStorageMultisampleANGLE(
5036 target, samples, internal_format, width, height);
5037 } else if (feature_info_->feature_flags().core_framebuffer_multisample) {
5038 glRenderbufferStorageMultisample(
5039 target, samples, internal_format, width, height);
5040 } else {
5041 glRenderbufferStorageMultisampleEXT(
5042 target, samples, internal_format, width, height);
5043 }
5044 }
5045
5046 void GLES2DecoderImpl::BlitFramebufferHelper(GLint srcX0,
5047 GLint srcY0,
5048 GLint srcX1,
5049 GLint srcY1,
5050 GLint dstX0,
5051 GLint dstY0,
5052 GLint dstX1,
5053 GLint dstY1,
5054 GLbitfield mask,
5055 GLenum filter) {
5056 // TODO(sievers): This could be resolved at the GL binding level, but the
5057 // binding process is currently a bit too 'brute force'.
5007 if (IsAngle()) { 5058 if (IsAngle()) {
5008 glBlitFramebufferANGLE( 5059 glBlitFramebufferANGLE(
5009 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); 5060 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
5061 } else if (feature_info_->feature_flags().core_framebuffer_multisample) {
5062 glBlitFramebuffer(
5063 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
5010 } else { 5064 } else {
5011 glBlitFramebufferEXT( 5065 glBlitFramebufferEXT(
5012 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); 5066 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
5013 } 5067 }
5014 EnableDisable(GL_SCISSOR_TEST, state_.enable_flags.scissor_test);
5015 } 5068 }
5016 5069
5017 bool GLES2DecoderImpl::ValidateRenderbufferStorageMultisample( 5070 bool GLES2DecoderImpl::ValidateRenderbufferStorageMultisample(
5018 GLsizei samples, 5071 GLsizei samples,
5019 GLenum internalformat, 5072 GLenum internalformat,
5020 GLsizei width, 5073 GLsizei width,
5021 GLsizei height) { 5074 GLsizei height) {
5022 if (samples > renderbuffer_manager()->max_samples()) { 5075 if (samples > renderbuffer_manager()->max_samples()) {
5023 LOCAL_SET_GL_ERROR( 5076 LOCAL_SET_GL_ERROR(
5024 GL_INVALID_VALUE, 5077 GL_INVALID_VALUE,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
5074 if (!ValidateRenderbufferStorageMultisample( 5127 if (!ValidateRenderbufferStorageMultisample(
5075 samples, internalformat, width, height)) { 5128 samples, internalformat, width, height)) {
5076 return; 5129 return;
5077 } 5130 }
5078 5131
5079 GLenum impl_format = 5132 GLenum impl_format =
5080 renderbuffer_manager()->InternalRenderbufferFormatToImplFormat( 5133 renderbuffer_manager()->InternalRenderbufferFormatToImplFormat(
5081 internalformat); 5134 internalformat);
5082 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER( 5135 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(
5083 "glRenderbufferStorageMultisampleCHROMIUM"); 5136 "glRenderbufferStorageMultisampleCHROMIUM");
5084 if (IsAngle()) { 5137 RenderbufferStorageMultisampleHelper(
5085 glRenderbufferStorageMultisampleANGLE( 5138 target, samples, impl_format, width, height);
5086 target, samples, impl_format, width, height);
5087 } else {
5088 glRenderbufferStorageMultisampleEXT(
5089 target, samples, impl_format, width, height);
5090 }
5091 GLenum error = 5139 GLenum error =
5092 LOCAL_PEEK_GL_ERROR("glRenderbufferStorageMultisampleCHROMIUM"); 5140 LOCAL_PEEK_GL_ERROR("glRenderbufferStorageMultisampleCHROMIUM");
5093 if (error == GL_NO_ERROR) { 5141 if (error == GL_NO_ERROR) {
5094 5142
5095 if (workarounds().validate_multisample_buffer_allocation) { 5143 if (workarounds().validate_multisample_buffer_allocation) {
5096 if (!VerifyMultisampleRenderbufferIntegrity( 5144 if (!VerifyMultisampleRenderbufferIntegrity(
5097 renderbuffer->service_id(), impl_format)) { 5145 renderbuffer->service_id(), impl_format)) {
5098 LOCAL_SET_GL_ERROR( 5146 LOCAL_SET_GL_ERROR(
5099 GL_OUT_OF_MEMORY, 5147 GL_OUT_OF_MEMORY,
5100 "glRenderbufferStorageMultisampleCHROMIUM", "out of memory"); 5148 "glRenderbufferStorageMultisampleCHROMIUM", "out of memory");
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
5220 glGetFloatv(GL_COLOR_CLEAR_VALUE, clear_color); 5268 glGetFloatv(GL_COLOR_CLEAR_VALUE, clear_color);
5221 glClearColor(1.0f, 0.0f, 1.0f, 1.0f); 5269 glClearColor(1.0f, 0.0f, 1.0f, 1.0f);
5222 5270
5223 // Clear the buffer to the desired key color. 5271 // Clear the buffer to the desired key color.
5224 glClear(GL_COLOR_BUFFER_BIT); 5272 glClear(GL_COLOR_BUFFER_BIT);
5225 5273
5226 // Blit from the multisample buffer to a standard texture. 5274 // Blit from the multisample buffer to a standard texture.
5227 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, validation_fbo_multisample_); 5275 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, validation_fbo_multisample_);
5228 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, validation_fbo_); 5276 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, validation_fbo_);
5229 5277
5230 glBlitFramebufferEXT(0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_NEAREST); 5278 BlitFramebufferHelper(
5279 0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_NEAREST);
5231 5280
5232 // Read a pixel from the buffer. 5281 // Read a pixel from the buffer.
5233 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_); 5282 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_);
5234 5283
5235 unsigned char pixel[3] = {0, 0, 0}; 5284 unsigned char pixel[3] = {0, 0, 0};
5236 glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pixel); 5285 glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pixel);
5237 5286
5238 // Detach the renderbuffer. 5287 // Detach the renderbuffer.
5239 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_multisample_); 5288 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_multisample_);
5240 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 5289 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
(...skipping 5229 matching lines...) Expand 10 before | Expand all | Expand 10 after
10470 DoDidUseTexImageIfNeeded(texture, texture->target()); 10519 DoDidUseTexImageIfNeeded(texture, texture->target());
10471 } 10520 }
10472 10521
10473 // Include the auto-generated part of this file. We split this because it means 10522 // Include the auto-generated part of this file. We split this because it means
10474 // we can easily edit the non-auto generated parts right here in this file 10523 // we can easily edit the non-auto generated parts right here in this file
10475 // instead of having to edit some template or the code generator. 10524 // instead of having to edit some template or the code generator.
10476 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10525 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10477 10526
10478 } // namespace gles2 10527 } // namespace gles2
10479 } // namespace gpu 10528 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698