Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Error when trying to compile a simple shader聽#57

Open

Description

@Makogan

I have a minimal rust shader that just renders a triangle to the screen that I am compiling with an old wrapper around rust-gpu.

I am trying to compile the same shader with cargo gpu as:

cargo gpu build                                                                       

馃 Running `spirv-builder-cli` to compile shader at /home/makogan/rust_never_engine/examples/01_spinning_triangle/spinning_triangle_shader...
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error("missing field `force_overwrite_lockfiles_v4_to_v3`", line: 31, column: 3)', src/main.rs:82:62
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[2025-03-15T17:36:26Z ERROR cargo_gpu] build failed
Error: build failed

I am within the crate folder when Invoke the command.

I am not entirely sure what the problem actually is. I know the crate has to be correct because it compiles with my custom wrapper.

the shader:

//! Ported to Rust from <https://github.com/Tw1ddle/Sky-Shader/blob/master/src/shaders/glsl/sky.fragment>

#![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,
    position_bind0: Vec2,
    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);
}

The cargo.toml:

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

[lib]
crate-type = ["lib", "dylib"]

[dependencies]
spirv-std = "0.9.0"
bytemuck = { version = "1.20.0", features = ["derive"] }

Activity

  1. tombh commented on Mar 15, 2025

    @tombh
    Collaborator

    Oh, maybe none of the cargo gpu-specific config values are default 馃槵 So I mean all these values need to be placed in your shader's Cargo.toml: https://github.com/Rust-GPU/cargo-gpu/blob/main/crates/shader-crate-template/Cargo.toml#L22

    Damn, that's a pretty big oversight if so 馃う

  2. schell commented on Mar 16, 2025

    @schell
    Collaborator

    Oof, we should fix this ASAP! Thanks @Makogan :)

  3. Makogan commented on Mar 16, 2025

    @Makogan
    Author

    Oof, copying all of that into the toml is a lot. For now someone else suggested something that worked for me:
    cargo install --git https://github.com/Rust-GPU/cargo-gpu cargo-gpu --force

  4. schell commented on Mar 16, 2025

    @schell
    Collaborator

    What version of cargo-gpu were you on before, @Makogan ? I would expect this to be the same on main

  5. tombh commented on Mar 23, 2025

    @tombh
    Collaborator

    I just tried compiling the shader-crate-template shader in our repo without any cargo-gpu config in the shader's Cargo.toml and it compiled okay. So I think my initial theory is wrong. @Makogan, I think I'd need to see your shader's crate, or at least your shader's Cargo.toml, to have more of an idea of what caused this error.

    But of course, if you got it compiling then that's the most important thing! I'm sure we'll get more reports if there is an underlying bug.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions