bkaradzic / bgfx

Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.
https://bkaradzic.github.io/bgfx/overview.html
BSD 2-Clause "Simplified" License
14.6k stars 1.92k forks source link

gles depth texture: GL_INVALID_VALUE #1071

Open attilaz opened 7 years ago

attilaz commented 7 years ago

I got an invalid value when tried to create a d16 texture on a galaxy s2 with mali 400. OES_depth_texture is supported and the problem seems to be that GL_DEPTH_COMPONENT16 was the internal format while it expects GL_DEPTH_COMPONENT. (see here: https://www.khronos.org/registry/OpenGL/extensions/OES/OES_depth_texture.txt ) "Textures with and values of DEPTH_COMPONENT refer to a texture that contains depth component data."

Then I found this: https://github.com/bkaradzic/bgfx/blob/master/src/renderer_gl.cpp#L1728

This is enabled on iOS and emscripten I wonder why? Because this seems to be the proper solution.

Note: GL_DEPTH_COMPONENT16 internalformat works on some android devices. I don't know if this is because some other extension that enables this, or the driver just accepts an invalid value to be compatible with some app.

hcomere commented 7 years ago

Hello,

Initially the line you mentioned was missing the emscripten part. I think you can safely replace it with

if (BX_ENABLED(BX_PLATFORM_IOS) || BX_ENABLED(BX_PLATFORM_EMSCRIPTEN) || BX_ENABLED(BX_PLATFORM_ANDROID))

as it is just to modify texture support tests on different platforms.