Rust-GPU / Rust-GPU/rust-gpu

Using latest `main` breaks `glam` build (`core::…` not found).

Open
#365 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
3.4k
Forks
125
PR merge metrics
No merged PRs in 30d

Description

I have a shader whose logic I can compile under rust-gpu by modifying the simplest-shader's toml and lib.rs.

However, under my own project, the exact same shader fails to compile with a long list of errors claiming that core funcitons such as panic, clone, copy... cannot be found, for example:

error[E0405]: cannot find trait `Clone` in this scope
 --> /home/makogan/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/glam-0.24.2/src/swizzles/vec_traits.rs:3:40
  |
3 | pub trait Vec2Swizzles: Sized + Copy + Clone {
  |                                        ^^^^^ not found in this scope
  |
help: consider importing this trait
  |
3 + use core::clone::Clone;

This code does compile on my project if I depend on sirv-std 0.9.0, but not if I depend on the latest gh branch.

This shader:

#![cfg_attr(target_arch = "spirv", no_std, feature(lang_items))]
#![allow(internal_features)]

extern crate bytemuck;
extern crate spirv_std;

pub use spirv_std::glam::{Mat2, Vec2, Vec3, Vec4};
use spirv_std::spirv;

#[spirv(fragment)]
pub fn main_fs(color: Vec4, output: &mut Vec4)
{
    *output = Vec4::new(color.x, color.y, color.z, 1.0); //
}

#[spirv(vertex)]
pub fn main_vs(
    #[spirv(uniform, descriptor_set = 1, binding = 0)] transform: &Mat2,
    // [[dem_config(binding = 0)]]
    position_bind0: Vec2,
    // [[dem_config(binding = 0)]]
    color_bind0: Vec3,
    #[spirv(position, invariant)] out_pos: &mut Vec4,
    out_color: &mut Vec4,
)
{
    let res: Vec2 = *transform * position_bind0;
    *out_pos = Vec4::new(res.x, res.y, 0., 1.);

    *out_color = Vec4::new(color_bind0.x, color_bind0.y, color_bind0.z, 1.0);
}

And this toml:

[package]
name = "spinning-triangle-shader"
version = "0.0.0"
publish = false

[lib]
crate-type = ["rlib", "cdylib"]

[dependencies]
spirv-std = { git = "https://github.com/Rust-GPU/rust-gpu/", rev = "df1628a" }
bytemuck = { version = "1.20.0", features = ["derive"] }
libm = "=0.2.11"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the shader source, Cargo.toml dependencies, and latest main, comparing it with the working simplest-shader setup. Start from the reported glam errors about missing core traits and functions, then verify the fix by compiling the provided shader with the latest branch rather than sirv-std 0.9.0.

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
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.