Three.js: gl.DEPTH_STENCIL not accepted by renderbufferStorageMultisample()

Created on 10 Jun 2019  路  11Comments  路  Source: mrdoob/three.js

The value DEPTH_STENCIL here is rejected as invalid in Chrome 75 (but accepted by Firefox).

https://github.com/mrdoob/three.js/blob/6737d0dfe3a92a83f0a7e385e223bae437bce091/src/renderers/webgl/WebGLTextures.js#L795

..looking into the specs for the underlying openGL call at https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glRenderbufferStorageMultisample.xhtml

a sized internalFormat such as DEPTH24_STENCIL8 is required, Firefox translates DEPTH_STENCIL to DEPTH24_STENCIL8 internally.

Is changing this to DEPTH24_STENCIL8 acceptable?

Most helpful comment

The unsized DEPTH_STENCIL format was accepted as a renderbuffer internal format in WebGL 1.0 as a workaround.

In WebGL 2.0 the sized internal format is (or should be) required. Can you conditionalize these code paths to pass in the sized internal format when running on WebGL 2.0?

Separately, I've filed a bug against KhronosGroup/WebGL to add a test to clear up this discrepancy.

All 11 comments

DEPTH_STENCIL is used multiple times in WebGLTextures. Does this issue also occur with a non-multisampled render targets?

https://github.com/mrdoob/three.js/blob/6737d0dfe3a92a83f0a7e385e223bae437bce091/src/renderers/webgl/WebGLTextures.js#L799

I've not checked those code paths.

Tested the line you highlighted. works fine in Chrome.

Um, strange 馃

@kenrussell Do you have any recommendations what to do in this case? It seems applying DEPTH_STENCIL to WebGL2RenderingContext.renderbufferStorageMultisample() is not a valid operation in Chrome.

The unsized DEPTH_STENCIL format was accepted as a renderbuffer internal format in WebGL 1.0 as a workaround.

In WebGL 2.0 the sized internal format is (or should be) required. Can you conditionalize these code paths to pass in the sized internal format when running on WebGL 2.0?

Separately, I've filed a bug against KhronosGroup/WebGL to add a test to clear up this discrepancy.

@kenrussell Many thanks for your feedback.

Tested the line you highlighted. works fine in Chrome.

@aardgoose Have you actually tested with a WebGL2 rendering context?

I tested both paths with a WebGL2 context

So using DEPTH_STENCIL with renderbufferStorage is no problem but it is an issue with renderbufferStorageMultisample? Shouldn't both variants treated the same?

Ideally, but WebGL 1 doesn't support the DEPTH28_STENCIL8 constant. (just tested with Chrome, it gives 'invalid internal format' and agrees with MDN documentation, where it is only given for WebGL2.

@Mugen87 it's supported in renderbufferStorage for backward compatibility. renderbufferStorageMultisample is a new WebGL 2.0 entry point so the WebGL WG avoided carrying forward the handling of the unsized version for that API. Sized internal formats weren't supported in WebGL 1.0 at all.

Okay, understood! In this case the PR of @aardgoose provides the correct fix.

Was this page helpful?
0 / 5 - 0 ratings