Skip to content

Tint SPIRV parser error (struct member not found) #212

Open

Description

@vada4367

./linux_x86_64/sokol-shdc -i ./raytracing.glsl -o ./out.h -l wgsl

./src/tracing/raytracing.glsl:18:0: error: error: struct member tri_start not found

I do not have any ideas :(

raytracing.txt

P.S. Sorry for big file, i will try to make smaller for debug this error

Activity

  1. vada4367 commented on Apr 4, 2026

    @vada4367
    Author

    Now it's really small:

    @vs vs
    void main() {
        gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
    }
    @end
    
    @fs fs
    out vec4 frag_color;
    
    struct idx_t {
        uint i;
    };
    
    struct model_state_t {
        uint animation;
        uint frame;
    };
    
    struct model_instance_t {
        uint model;
        model_state_t state;
    };
    
    struct mesh_t {
        uint tri_start;
        uint bvh_root;
    };
    
    layout(binding = 3) readonly buffer models {
        idx_t animation_ptrs[];
    };
    
    layout(binding = 4) readonly buffer animations {
        idx_t frame_ptrs[];
    };
    
    layout(binding = 5) readonly buffer frames {
        mesh_t mesh_ptrs[];
    };
    
    layout(binding = 8) readonly buffer models_instances {
        model_instance_t scene_models_instances[];
    };
    
    mesh_t get_mesh(const uint model) {
        return mesh_ptrs[
            frame_ptrs[
                animation_ptrs[scene_models_instances[model].model].i
                + scene_models_instances[model].state.animation
            ].i + scene_models_instances[model].state.frame
        ];
    }
    
    void main() {
        mesh_t m = get_mesh(0);
        frag_color = vec4(float(m.tri_start));
    }
    @end
    
    @program raytracing vs fs
    
  2. vada4367 commented on Apr 4, 2026

    @vada4367
    Author

    There is solution:

    mesh_t get_mesh(const uint model) {
        const uint inst = model;
        const uint model_idx = scene_models_instances[inst].model;
        const uint anim_base = animation_ptrs[model_idx].i;
        const uint anim_idx = anim_base + scene_models_instances[inst].state.animation;
        const uint frame_idx = frame_ptrs[anim_idx].i + scene_models_instances[inst].state.frame;
        return mesh_ptrs[frame_idx];
    }
    

    I will close issue if you want to.

  3. vada4367 commented on Apr 5, 2026

    @vada4367
    Author

    That's not how you solve it, I really do not know what is going on with mesh_t/bvh_t

    How to debug sokol-shdc?

  4. floooh commented on Apr 5, 2026

    @floooh
    Owner

    Hmm, the error is coming out of Tint's SPIRV parser (Google's WGSL compiler), e.g. not much I can do about it.

    Might be fixed in a more recent version of Tint, but updating isn't trivial. I'll keep the ticket open until I get around to that.

  5. changed the title [-]wgsl error[/-] [+]Tint SPIRV parser error (struct member not found)[/+] on Apr 5, 2026
  6. vada4367 commented on Apr 5, 2026

    @vada4367
    Author

    How do you use it? I tried (git version), it says:

    spirv:1:1 error: Invalid SPIR-V binary version 1.4 for target environment SPIR-V 1.3 (under Vulkan 1.1 semantics).

  7. floooh commented on Apr 5, 2026

    @floooh
    Owner

    How do you use it? I tried (git version), it says:

    How do I use what, exactly? :)

    The Tint compiler is integrated into sokol-shdc as library, not called as an executable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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