Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan Validation Error when using multiple dynamic indexing #7048

Open
lorinjacot opened this issue Feb 2, 2025 · 1 comment
Open

Vulkan Validation Error when using multiple dynamic indexing #7048

lorinjacot opened this issue Feb 2, 2025 · 1 comment
Labels
area: naga back-end Outputs of naga shader conversion lang: SPIR-V Vulkan's Shading Language naga Shader Translator type: bug Something isn't working

Comments

@lorinjacot
Copy link

Description
When trying to run the code

@fragment
fn fs_main() -> @location(0) vec4f {
    let my_array = array(
        vec2f(0.0, 0.0),
        vec2f(0.0, 0.0),
    );

    let val_0 = my_array[index_0];
    let val_1 = my_array[index_0];

    return (val_0 * val_1).xxyy;
}

on the Vulkan backend, a Validation Error is raised:

Validation Error: [ VUID-VkShaderModuleCreateInfo-pCode-08737 ] | MessageID = 0xa5625282 | vkCreateShaderModule(): pCreateInfo->pCode (spirv-val produced an error):
    ID '28[%28]' has not been defined
      OpStore %28 %25
    The Vulkan spec states: If pCode is a pointer to SPIR-V code, pCode must adhere to the validation rules described by the Validation Rules within a Module section of the SPIR-V Environment appendix (https://vulkan.lunarg.com/doc/view/1.4.304.0/windows/1.4-extensions/vkspec.html#VUID-VkShaderModuleCreateInfo-pCode-08737)

The same fragment shader runs fine on DirectX 12 and OpenGL.

Repro steps

git clone https://github.com/lorinjacot/wgsl-indexing-bug.git
cd wgsl-indexing-bug
cargo run

Expected vs observed behavior
I expect the program to run and exit without any error. Currently, the program exits with the error (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION) on the Vulkan backend.

Platform
OS: Windows 11 Home, version 24H2
wgpu version: 24.0.1
GPU: Integrated, AMD Ryzen 5 5500U with Radeon Graphics

@teoxoy teoxoy added type: bug Something isn't working area: naga back-end Outputs of naga shader conversion naga Shader Translator lang: SPIR-V Vulkan's Shading Language labels Feb 3, 2025
@ryanw
Copy link

ryanw commented Feb 10, 2025

I hit this bug in a pretty simple use case. Using wgpu 24.0 and vulkan 1.4.303 on Linux.

fn foobar(normals: array<vec3f, 12>, count: u32) -> QEFResult {
        for (var i = 0u; i < count; i++) {
                var n0 = normals[i];
        }

        for (var j = 0u; j < count; j++) {
                var n1 = normals[j];
        }

        return QEFResult(0.0, vec3(0.0));
}

Was easy to work around by assigning normals to a var and using that instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga back-end Outputs of naga shader conversion lang: SPIR-V Vulkan's Shading Language naga Shader Translator type: bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

3 participants