From 88868a0a3aa94331fb722d6032149593e762308e Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Mon, 15 Oct 2018 10:13:34 +1000 Subject: wasm: fix opengl layers, depth stencil MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WebGL is more strict than OpenGL ES2 https://www.khronos.org/registry/webgl/specs/1.0/#FBO_ATTACHMENTS Task-number: QTBUG-71132 Task-number: QTBUG-71099 Fixes: QTBUG-71132 Fixes: QTBUG-71099 Change-Id: I27c31f3a9833e7187612ee4bc211d0b0b6fa935b Reviewed-by: Morten Johan Sørvig Reviewed-by: Laszlo Agocs --- .../scenegraph/util/qsgdepthstencilbuffer.cpp | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/quick/scenegraph') diff --git a/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp b/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp index 56508af152..94912778f8 100644 --- a/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp +++ b/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp @@ -57,20 +57,34 @@ QSGDepthStencilBuffer::~QSGDepthStencilBuffer() m_manager->m_buffers.remove(m_format); } +#ifndef GL_DEPTH_STENCIL_ATTACHMENT +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#endif + void QSGDepthStencilBuffer::attach() { +#ifndef Q_OS_WASM m_functions.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthBuffer); m_functions.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_stencilBuffer); +#else + m_functions.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, + GL_RENDERBUFFER, m_stencilBuffer); +#endif } void QSGDepthStencilBuffer::detach() { +#ifndef Q_OS_WASM m_functions.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); m_functions.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0); +#else + m_functions.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, + GL_RENDERBUFFER, 0); +#endif } #ifndef GL_DEPTH24_STENCIL8_OES @@ -81,12 +95,17 @@ void QSGDepthStencilBuffer::detach() #define GL_DEPTH_COMPONENT24_OES 0x81A6 #endif +#ifndef GL_DEPTH_STENCIL +#define GL_DEPTH_STENCIL 0x84F9 +#endif + QSGDefaultDepthStencilBuffer::QSGDefaultDepthStencilBuffer(QOpenGLContext *context, const Format &format) : QSGDepthStencilBuffer(context, format) { const GLsizei width = format.size.width(); const GLsizei height = format.size.height(); +#ifndef Q_OS_WASM if (format.attachments == (DepthAttachment | StencilAttachment) && m_functions.hasOpenGLExtension(QOpenGLExtensions::PackedDepthStencil)) { @@ -138,6 +157,12 @@ QSGDefaultDepthStencilBuffer::QSGDefaultDepthStencilBuffer(QOpenGLContext *conte m_functions.glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, width, height); } } +#else + m_functions.glGenRenderbuffers(1, &m_depthBuffer); + m_functions.glBindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer); + m_functions.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, width, height); + m_stencilBuffer = m_depthBuffer; +#endif } QSGDefaultDepthStencilBuffer::~QSGDefaultDepthStencilBuffer() -- cgit v1.2.3