Skip to content

Fragment shader just copying values doesn't compile #185

Open
@Firestar99

Description

@Firestar99

Expected Behaviour

The following code snippet defines 3 fragment shaders, but the middle one does not get compiled / emit an entry point / generates a spv (with multibuilder true). Looks like it's somehow getting inlined / optimized away before monomorphization, so it's not picked up as an entry point?

#[spirv(fragment)]
pub fn fragment_works(v_color: Vec4, frag_color: &mut Vec4) {
  *frag_color = v_color +1.;
}

#[spirv(fragment)]
pub fn fragment_doesnt(v_color: Vec4, frag_color: &mut Vec4) {
  *frag_color = v_color;
}

/// causes a warning by rust-gpu about having to be inlined anyway
#[inline(never)]
#[spirv(fragment)]
pub fn fragment_works_again(v_color: Vec4, frag_color: &mut Vec4) {
  *frag_color = v_color;
}

Found while investigating an issue with hadronized on discord.

System Info

  • cargo-gpu main
  • I have no idea what rust-gpu version this is, cargo-gpu doesn't tell, apparently it's pointing to the git repo but it can't be main as the toolchains would mismatch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions