Skip to content

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

@attilaz

Description

@attilaz

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?

sd[0].colorAttachmentCount = bx::max<uint32_t>(numColorAr, 1);

It always set color buffer, even when not used.

Commit is here:
870d141

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions