Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
members = [
"crates/cargo-gpu",
"crates/test-shaders",
"crates/xtask",
]

Expand Down
2 changes: 2 additions & 0 deletions crates/cargo-gpu/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ impl Build {
fn parse_compilation_result(&self, result: &CompileResult) -> anyhow::Result<()> {
let shaders = match &result.module {
ModuleResult::MultiModule(modules) => {
log::debug!("modules: {modules:#?}");
anyhow::ensure!(!modules.is_empty(), "No shader modules were compiled");
modules.iter().collect::<Vec<_>>()
}
Expand All @@ -128,6 +129,7 @@ impl Build {
let mut linkage: Vec<Linkage> = shaders
.into_iter()
.map(|(entry, filepath)| -> anyhow::Result<Linkage> {
log::debug!("Compiled {entry} to {filepath:?}");
use relative_path::PathExt as _;
let path = self.build.output_dir.join(
filepath
Expand Down
11 changes: 11 additions & 0 deletions crates/test-shaders/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "test-shaders"
version = "0.1.0"
edition = "2024"

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

[dependencies]
spirv-std = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "de03e8d8c997c68aed1a950863c0d79ba9bd8c72" }

32 changes: 32 additions & 0 deletions crates/test-shaders/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//! Test shaders.
//!
//! Here we have some shaders that have been problematic in the past.
#![no_std]
#![expect(
unexpected_cfgs,
reason = "rust-gpu uses the spirv attribute macro heavily"
)]
use spirv_std::{glam::Vec4, spirv};

/// This shader has the same name as the vertex shader below it.
/// It should be compiled and then named something so that the two
/// don't clobber each other.
/// See <https://github.com/Rust-GPU/cargo-gpu/issues/85>
#[inline(never)]
#[spirv(fragment(entry_point_name = "duplicate_main"))]
pub const fn dupe_frag(in_color: Vec4, output: &mut Vec4) {
*output = in_color;
}

/// This shader has the same name as the fragment shader above it.
/// It should be compiled and then named something so that the two
/// don't clobber each other.
/// See <https://github.com/Rust-GPU/cargo-gpu/issues/85>
#[spirv(vertex(entry_point_name = "duplicate_main"))]
pub const fn implicit_isosceles_vertex(
// Which vertex within the render unit are we rendering
#[spirv(vertex_index)] vertex_index: u32,
#[spirv(position)] clip_pos: &mut Vec4,
) {
*clip_pos = Vec4::splat(vertex_index as f32);
}
Binary file added output/duplicate_main.1.spv
Binary file not shown.
7 changes: 7 additions & 0 deletions output/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"source_path": "../../output/duplicate_main.1.spv",
"entry_point": "duplicate_main",
"wgsl_entry_point": "duplicate_main"
}
]
Loading