Fragment shader just copying values doesn't compile
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.4k
- Forks
- 125
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the three fragment entry points from the issue using cargo-gpu at the referenced main commit, with multibuilder enabled, and compare their compilation and SPIR-V output. Focus on why fragment_doesnt is omitted while fragment_works_again is retained despite both copying v_color. Done means all three functions compile, emit entry points, and generate valid SPIR-V without requiring inline(never).
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100