KhronosGroup / KhronosGroup/Vulkan-ValidationLayers

Incorrect access out of bounds

Open
#10,036 4 comments 0 reactions 1 assignee View on GitHub

@spencer-lunarg is already working on this.

Since Apr 29, 2025.

GPU-AV
Dominant language
C++
Stars
1k
Forks
505
Avg merge
11h 25m
Merged PRs (30d)
229

Description

Environment:

  • OS: Win11 24H2
  • GPU and driver version: RTX 5080 572.83
  • SDK or header version if building from repo: 1.4.309
  • Options enabled (synchronization, best practices, etc.): GPU-AV Preset

Describe the Issue

Im using a graphics pipeline with a task and mesh shader. The indirect command buffer ("DispatchStorage") used by the vkCmdDrawMeshTasksIndirectEXT function is bound readonly to the task shader and the mesh shader uses a uniform buffer ("CamUBO").
If the Task Shader accesses the indirect command buffer and the mesh shader accesses the uniform buffer I get the following error:

validation layer: [ Debug region: PrimaryVisibilityPass ] vkCmdDrawMeshTasksIndirectEXT(): (set = 1, binding = 0, index 0)  access out of bounds. The descriptor buffer (VkBuffer 0x22ae932c618[ffffb804cb634080 CullingBuffers.ClustersToDraw.Dispatch]) size is 16 bytes, 16 bytes were bound, and the highest out of bounds access was at [63] bytes
Stage = MeshEXT. Global invocation ID (x, y, z) = (0, 0, 0 )
Command buffer (Frame 1)(0x22ab324b028)
	Draw Index 0
Pipeline (22ab2f3d3f8)
Shader Module (Visibility.mesh.spv)(22ab3967b88) (internal ID 3e)
SPIR-V Instruction Index = 92
Shader validation error occurred at RenderPasses\Visibility\Visibility.mesh.glsl:29

    mat4 m = Mat; // if this line is removed the error disappears   
The Vulkan spec states: If any stage of the VkPipeline object bound to the pipeline bind point used by this command accesses a storage buffer, and that stage was created without enabling either VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS or VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS_2 for storageBuffers, and the robustBufferAccess feature is not enabled, that stage must not access values outside of the range of the buffer as specified in the descriptor set bound to the same pipeline bind point (https://vulkan.lunarg.com/doc/view/1.4.309.0/windows/antora/spec/latest/chapters/drawing.html#VUID-vkCmdDrawMeshTasksIndirectEXT-storageBuffers-06936)

That error doesnt make any sense because:

  • the buffer mentioned isnt accessed by the shader module/code the message reports.
  • the buffer isnt read out of bounds anywhere.
  • sometimes the message reports even more incorrectly where the shader module and source code dont match

Image

Task shader:

layout(AUTOGEN) readonly buffer DispatchStorage
{
    // workgroup counts
    uvec3 Command;
    // total count of elements.
    uint Count;
};
void main()
{
    if (gl_GlobalInvocationID.x < Count) // if Count is not accessed, the error disappears.
    {
        sharedData.I[0] = 0;
        sharedData.M[0] = 0;
    }
    
    EmitMeshTasksEXT(1, 1, 1);
}

Mesh shader:

layout(AUTOGEN) readonly uniform CamUBO
{   
 mat4 Mat;
};
void main()
{
    mat4 m = Mat; // if this line is removed the error disappears   
}

Expected behavior

  • No error or error for the correct out of bound access.

Additional context

I can provide a repro project privately through share.lunarg.com if needed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.