#3486·bgfx

Android vulkan validator crashes on depth only (shadow map ) rendering

Author: attilazCreated Nov 11, 2025Updated Nov 11, 2025

Describe the bug I have enabled vulkan validation on android with https://developer.android.com/ndk/guides/graphics/validation-layer.

Our app crashed here with shadowmap rendering shader. https://github.com/bkaradzic/bgfx/blob/35911ac2d9b651bc0097ea40867f193274d9d960/src/renderer_vk.cpp#L3891C13-L3891C24

Turning off shadowmap rendering fixed the crash. So I checked what is different for this shaders.

I had already seen a strange thing in renderdoc. The shadowmap rendering pass looked like this: vkCmdBeginRenderPass(C=Unused, D=Clear) C = Unused looked strange. Why there is a Color buffer?

https://github.com/bkaradzic/bgfx/blob/35911ac2d9b651bc0097ea40867f193274d9d960/src/renderer_vk.cpp#L3377

It always set color buffer, even when not used.

Commit is here: https://github.com/bkaradzic/bgfx/commit/870d14110b63d2f66df05f5fae39dbb122529855

So it was a fix to be able to output color even where there is no color buffer attached.

I have removed this unused colorbuffer. And also removed shader outputs from shaders.

Removed half4 fragColor[[color(0)]]; from metal fragment shader output. And removed layout(location=0) out vec4 fragColor; from glsl shader output.

It works for metal/gles/vulkan. I don't know if this is possible on d3d11/12, but I think it would be a cleaner solution to not output color info in shader when there is no color buffer.