Vulkan-ValidationLayers icon indicating copy to clipboard operation
Vulkan-ValidationLayers copied to clipboard

Incorrect access out of bounds

Open StefanPoelloth opened this issue 10 months ago • 4 comments

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.

StefanPoelloth avatar Apr 29 '25 09:04 StefanPoelloth

Thanks for raising this, I will try and reproduce with a test locally today

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

Edit - (created folder and sent you email) Could you try and upload to LunarG Share?

I am always looking for more content that I know is "clean" to test GPU-AV with for false positive regression

spencer-lunarg avatar Apr 29 '25 14:04 spencer-lunarg

@StefanPoelloth thanks for the reproduce, I will get to this in the near future

spencer-lunarg avatar May 07 '25 11:05 spencer-lunarg

@StefanPoelloth got back from PTO and got down my backlog stack and started to look at this (and the other issue)

I tried to repro but was hitting an

Severity Code Description Project File Line Suppression State Details Error (active) NU1101 Unable to find package FS.Utilities. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages, nuget.org FS.VulkanRenderer Downloads\repro\FS.VulkanRenderer\FS.VulkanRenderer.csproj 1

and new to nuget and not sure where to find this FS.Utilities

spencer-lunarg avatar May 30 '25 21:05 spencer-lunarg

@spencer-lunarg Please find the fixed sample uploaded to the share folder.

The issue doesn't seem to happen with the 313.X VVL version. I'll keep the issue open because we get new false-positive AV errors with almost every VVL release, while the errors from the previous version no longer occur, so it might be an underlying issue.

StefanPoelloth avatar Jun 02 '25 09:06 StefanPoelloth