From cd9c438ce3c8bd46754cb3b0e12966a006dc6177 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Fri, 16 Mar 2018 16:47:06 -0700 Subject: [PATCH] Eliminate iOS depth/stencil buffer code (#4802) As of ba67d0fe718299050bf0195295aba3415c417b91, depth/stencil buffer attachments are never used. This patch eliminates generation and binding of depth/stencil render buffers since these code paths are no longer hit. --- shell/platform/darwin/ios/ios_gl_context.h | 3 - shell/platform/darwin/ios/ios_gl_context.mm | 75 +-------------------- 2 files changed, 1 insertion(+), 77 deletions(-) diff --git a/shell/platform/darwin/ios/ios_gl_context.h b/shell/platform/darwin/ios/ios_gl_context.h index 263031ca9..89ad7e034 100644 --- a/shell/platform/darwin/ios/ios_gl_context.h +++ b/shell/platform/darwin/ios/ios_gl_context.h @@ -42,9 +42,6 @@ class IOSGLContext { fml::scoped_nsobject resource_context_; GLuint framebuffer_; GLuint colorbuffer_; - GLuint depthbuffer_; - GLuint stencilbuffer_; - GLuint depth_stencil_packed_buffer_; GLint storage_size_width_; GLint storage_size_height_; sk_sp color_space_; diff --git a/shell/platform/darwin/ios/ios_gl_context.mm b/shell/platform/darwin/ios/ios_gl_context.mm index 6ad9ada39..de94018d0 100644 --- a/shell/platform/darwin/ios/ios_gl_context.mm +++ b/shell/platform/darwin/ios/ios_gl_context.mm @@ -23,9 +23,6 @@ IOSGLContext::IOSGLContext(PlatformView::SurfaceConfig config, CAEAGLLayer* laye sharegroup:context_.get().sharegroup]), framebuffer_(GL_NONE), colorbuffer_(GL_NONE), - depthbuffer_(GL_NONE), - stencilbuffer_(GL_NONE), - depth_stencil_packed_buffer_(GL_NONE), storage_size_width_(0), storage_size_height_(0), valid_(false) { @@ -58,48 +55,6 @@ IOSGLContext::IOSGLContext(PlatformView::SurfaceConfig config, CAEAGLLayer* laye glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer_); VERIFY(glGetError() == GL_NO_ERROR); - // On iOS, if both depth and stencil attachments are requested, we are - // required to create a single renderbuffer that acts as both. - - auto requires_packed = (config.depth_bits != 0) && (config.stencil_bits != 0); - - if (requires_packed) { - glGenRenderbuffers(1, &depth_stencil_packed_buffer_); - glBindRenderbuffer(GL_RENDERBUFFER, depth_stencil_packed_buffer_); - VERIFY(depth_stencil_packed_buffer_ != GL_NONE); - - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, - depth_stencil_packed_buffer_); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, - depth_stencil_packed_buffer_); - VERIFY(depth_stencil_packed_buffer_ != GL_NONE); - } else { - // Setup the depth attachment if necessary - if (config.depth_bits != 0) { - glGenRenderbuffers(1, &depthbuffer_); - VERIFY(depthbuffer_ != GL_NONE); - - glBindRenderbuffer(GL_RENDERBUFFER, depthbuffer_); - VERIFY(glGetError() == GL_NO_ERROR); - - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthbuffer_); - VERIFY(glGetError() == GL_NO_ERROR); - } - - // Setup the stencil attachment if necessary - if (config.stencil_bits != 0) { - glGenRenderbuffers(1, &stencilbuffer_); - VERIFY(stencilbuffer_ != GL_NONE); - - glBindRenderbuffer(GL_RENDERBUFFER, stencilbuffer_); - VERIFY(glGetError() == GL_NO_ERROR); - - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, - stencilbuffer_); - VERIFY(glGetError() == GL_NO_ERROR); - } - } - // TODO: // iOS displays are more variable than just P3 or sRGB. Reading the display // gamut just tells us what color space it makes sense to render into. We @@ -135,11 +90,7 @@ IOSGLContext::~IOSGLContext() { // Deletes on GL_NONEs are ignored glDeleteFramebuffers(1, &framebuffer_); - glDeleteRenderbuffers(1, &colorbuffer_); - glDeleteRenderbuffers(1, &depthbuffer_); - glDeleteRenderbuffers(1, &stencilbuffer_); - glDeleteRenderbuffers(1, &depth_stencil_packed_buffer_); FXL_DCHECK(glGetError() == GL_NO_ERROR); } @@ -190,10 +141,8 @@ bool IOSGLContext::UpdateStorageSizeIfNecessary() { GLint width = 0; GLint height = 0; - bool rebind_color_buffer = false; - if (depthbuffer_ != GL_NONE || stencilbuffer_ != GL_NONE || - depth_stencil_packed_buffer_ != GL_NONE || colorbuffer_ != GL_NONE) { + if (colorbuffer_ != GL_NONE) { // Fetch the dimensions of the color buffer whose backing was just updated // so that backing of the attachments can be updated glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &width); @@ -202,28 +151,6 @@ bool IOSGLContext::UpdateStorageSizeIfNecessary() { glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &height); FXL_DCHECK(glGetError() == GL_NO_ERROR); - rebind_color_buffer = true; - } - - if (depth_stencil_packed_buffer_ != GL_NONE) { - glBindRenderbuffer(GL_RENDERBUFFER, depth_stencil_packed_buffer_); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, width, height); - FXL_DCHECK(glGetError() == GL_NO_ERROR); - } - - if (depthbuffer_ != GL_NONE) { - glBindRenderbuffer(GL_RENDERBUFFER, depthbuffer_); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height); - FXL_DCHECK(glGetError() == GL_NO_ERROR); - } - - if (stencilbuffer_ != GL_NONE) { - glBindRenderbuffer(GL_RENDERBUFFER, stencilbuffer_); - glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, width, height); - FXL_DCHECK(glGetError() == GL_NO_ERROR); - } - - if (rebind_color_buffer) { glBindRenderbuffer(GL_RENDERBUFFER, colorbuffer_); FXL_DCHECK(glGetError() == GL_NO_ERROR); } -- GitLab