PENGUINLIONG/spirq-rs

Cannot load push_constant vert shader compiled by naga-cli correctly

Latias94 opened this issue · 3 comments

shader.vert

#version 450

layout (location = 0) in vec3 inPosition;
layout (location = 1) in vec3 inColor;
layout (location = 2) in vec2 inTexCoord;

layout (location = 0) out vec3 fragColor;
layout (location = 1) out vec2 fragTexCoord;

layout (set = 0, binding = 0) uniform UniformBufferObject {
    mat4 view;
    mat4 proj;
} ubo;

layout (push_constant) uniform PushConstants {
    mat4 model;
} pcs;

void main() {
    gl_Position = ubo.proj * ubo.view * pcs.model * vec4(inPosition, 1.0);
    fragColor = inColor;
    fragTexCoord = inTexCoord;
}

spirq can load spv file compiled by glslangValidator.exe

❯ glslangValidator.exe -V .\shader.vert -o .\shader.vert.spv

I inspect this shader.vert.spv with your 'gallery\main.rs' example, it works well:

[
    main {
        exec_model: Vertex,
        name: "main",
        vars: [
            Descriptor {
                name: Some(
                    "ubo",
                ),
...

However, I try to inspect the spv file compile by naga-cli, it doesn't work.

❯ naga .\shader.vert .\shader_naga.vert.spv
[
    main {
        exec_model: Vertex,
        name: "main",
        vars: [],
        exec_modes: [],
    },
]

I have attched the shader and both spv files below.

shader_and_spv.zip

That's funny. 🤔 Thanks for your report!

I can't believe such fatal bug existed for so many years! The instruction parser drains all remaining instructions when there isn't a debug op. Will send a PR to fix it.

I can confirm it fix in v0.6.3, thanks for amazingly quick fix. :)