Skip to content

Using latest main causes core to no be found. #365

@Makogan

Description

@Makogan

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"

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