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

Unified Diff: third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp

Issue 1675973002: Prefer to use the OES_depth24 extension for WebGL's depth-only back buffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 4 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
index df28ac3c8d30949935fafbe5b545df3f4a642160..4dea14b5ef679d0e13d11ebeea7c4e467eff90dc 100644
--- a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
+++ b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
@@ -104,21 +104,27 @@ PassRefPtr<DrawingBuffer> DrawingBuffer::create(PassOwnPtr<WebGraphicsContext3D>
}
ASSERT(extensionsUtil->supportsExtension("GL_OES_packed_depth_stencil"));
extensionsUtil->ensureExtensionEnabled("GL_OES_packed_depth_stencil");
- bool multisampleSupported = (extensionsUtil->supportsExtension("GL_CHROMIUM_framebuffer_multisample")
+
+ SupportedExtensions exts;
+ exts.multisample = (extensionsUtil->supportsExtension("GL_CHROMIUM_framebuffer_multisample")
|| extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_texture"))
&& extensionsUtil->supportsExtension("GL_OES_rgb8_rgba8");
- if (multisampleSupported) {
+ if (exts.multisample) {
extensionsUtil->ensureExtensionEnabled("GL_OES_rgb8_rgba8");
if (extensionsUtil->supportsExtension("GL_CHROMIUM_framebuffer_multisample"))
extensionsUtil->ensureExtensionEnabled("GL_CHROMIUM_framebuffer_multisample");
else
extensionsUtil->ensureExtensionEnabled("GL_EXT_multisampled_render_to_texture");
}
- bool discardFramebufferSupported = extensionsUtil->supportsExtension("GL_EXT_discard_framebuffer");
- if (discardFramebufferSupported)
+ exts.packedDepthStencil = true;
+ exts.depth24 = extensionsUtil->supportsExtension("GL_OES_depth24");
+ if (exts.depth24)
+ extensionsUtil->ensureExtensionEnabled("GL_OES_depth24");
+ exts.discardFramebuffer = extensionsUtil->supportsExtension("GL_EXT_discard_framebuffer");
+ if (exts.discardFramebuffer)
extensionsUtil->ensureExtensionEnabled("GL_EXT_discard_framebuffer");
- RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(std::move(context), extensionsUtil.release(), multisampleSupported, true, discardFramebufferSupported, preserve, requestedAttributes));
+ RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(std::move(context), extensionsUtil.release(), exts, preserve, requestedAttributes));
if (!drawingBuffer->initialize(size)) {
drawingBuffer->beginDestruction();
return PassRefPtr<DrawingBuffer>();
@@ -131,11 +137,12 @@ void DrawingBuffer::forceNextDrawingBufferCreationToFail()
shouldFailDrawingBufferCreationForTesting = true;
}
+DrawingBuffer::SupportedExtensions::SupportedExtensions() :
+ multisample(false), packedDepthStencil(false), depth24(false), discardFramebuffer(false) {}
+
DrawingBuffer::DrawingBuffer(PassOwnPtr<WebGraphicsContext3D> context,
PassOwnPtr<Extensions3DUtil> extensionsUtil,
- bool multisampleExtensionSupported,
- bool packedDepthStencilExtensionSupported,
- bool discardFramebufferSupported,
+ const SupportedExtensions& supportedExtensions,
PreserveDrawingBuffer preserve,
WebGraphicsContext3D::Attributes requestedAttributes)
: m_preserveDrawingBuffer(preserve)
@@ -148,9 +155,10 @@ DrawingBuffer::DrawingBuffer(PassOwnPtr<WebGraphicsContext3D> context,
, m_extensionsUtil(std::move(extensionsUtil))
, m_size(-1, -1)
, m_requestedAttributes(requestedAttributes)
- , m_multisampleExtensionSupported(multisampleExtensionSupported)
- , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupported)
- , m_discardFramebufferSupported(discardFramebufferSupported)
+ , m_multisampleExtensionSupported(supportedExtensions.multisample)
+ , m_packedDepthStencilExtensionSupported(supportedExtensions.packedDepthStencil)
+ , m_depth24ExtensionSupported(supportedExtensions.depth24)
+ , m_discardFramebufferSupported(supportedExtensions.discardFramebuffer)
, m_fbo(0)
, m_depthStencilBuffer(0)
, m_depthBuffer(0)
@@ -697,7 +705,18 @@ void DrawingBuffer::resizeDepthStencil(const IntSize& size)
if (!m_requestedAttributes.depth && !m_requestedAttributes.stencil)
return;
- if (m_packedDepthStencilExtensionSupported) {
+ if (m_requestedAttributes.depth && !m_requestedAttributes.stencil && m_depth24ExtensionSupported) {
+ if (!m_depthBuffer)
+ m_depthBuffer = m_context->createRenderbuffer();
+ m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer);
+ if (m_antiAliasingMode == MSAAImplicitResolve)
+ m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_sampleCount, GL_DEPTH_COMPONENT24, size.width(), size.height());
+ else if (m_antiAliasingMode == MSAAExplicitResolve)
+ m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCount, GL_DEPTH_COMPONENT24, size.width(), size.height());
+ else
+ m_context->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, size.width(), size.height());
+ m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthBuffer);
+ } else if (m_packedDepthStencilExtensionSupported) {
if (!m_depthStencilBuffer)
m_depthStencilBuffer = m_context->createRenderbuffer();
m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer);

Powered by Google App Engine
This is Rietveld 408576698