From d474f0624e23baab6d4dab6521addd9698c397ff Mon Sep 17 00:00:00 2001 From: Firestar99 Date: Wed, 11 Jun 2025 13:04:11 +0200 Subject: [PATCH 01/10] difftest: replace error enums with anyhow --- Cargo.lock | 6 +- tests/difftests/lib/Cargo.toml | 2 +- tests/difftests/lib/src/config.rs | 11 +-- .../lib/src/scaffold/compute/wgpu.rs | 77 +++++++------------ tests/difftests/tests/Cargo.lock | 8 +- 5 files changed, 40 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6e5df0ff0f..cc17d21f01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -156,9 +156,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.95" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "ar" @@ -707,13 +707,13 @@ checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" name = "difftest" version = "0.9.0" dependencies = [ + "anyhow", "bytemuck", "futures", "serde", "serde_json", "spirv-builder", "tempfile", - "thiserror 1.0.69", "wgpu", ] diff --git a/tests/difftests/lib/Cargo.toml b/tests/difftests/lib/Cargo.toml index 25bb14b3de..5c1786fb37 100644 --- a/tests/difftests/lib/Cargo.toml +++ b/tests/difftests/lib/Cargo.toml @@ -23,7 +23,7 @@ wgpu = { version = "23", features = ["spirv", "vulkan-portability"] } tempfile = "3.5" futures = "0.3.31" bytemuck = "1.21.0" -thiserror = "1.0" +anyhow = "1.0.98" [lints] workspace = true diff --git a/tests/difftests/lib/src/config.rs b/tests/difftests/lib/src/config.rs index 28c6ebb6b3..ed717502f8 100644 --- a/tests/difftests/lib/src/config.rs +++ b/tests/difftests/lib/src/config.rs @@ -1,14 +1,5 @@ use serde::Deserialize; use std::{fs, path::Path}; -use thiserror::Error; - -#[derive(Error, Debug)] -pub enum ConfigError { - #[error("I/O error: {0}")] - Io(#[from] std::io::Error), - #[error("JSON error: {0}")] - Json(#[from] serde_json::Error), -} #[derive(Debug, Deserialize)] pub struct Config { @@ -16,7 +7,7 @@ pub struct Config { } impl Config { - pub fn from_path>(path: P) -> Result { + pub fn from_path>(path: P) -> anyhow::Result { let content = fs::read_to_string(path)?; let config = serde_json::from_str(&content)?; Ok(config) diff --git a/tests/difftests/lib/src/scaffold/compute/wgpu.rs b/tests/difftests/lib/src/scaffold/compute/wgpu.rs index 1125fd4f39..44d1762c20 100644 --- a/tests/difftests/lib/src/scaffold/compute/wgpu.rs +++ b/tests/difftests/lib/src/scaffold/compute/wgpu.rs @@ -1,6 +1,7 @@ use crate::config::Config; +use anyhow::Context; use bytemuck::Pod; -use futures::{channel::oneshot::Canceled, executor::block_on}; +use futures::executor::block_on; use spirv_builder::{ModuleResult, SpirvBuilder}; use std::{ borrow::Cow, @@ -9,29 +10,14 @@ use std::{ io::Write, path::PathBuf, }; -use thiserror::Error; -use wgpu::{BufferAsyncError, PipelineCompilationOptions, util::DeviceExt}; - -#[derive(Error, Debug)] -pub enum ComputeError { - #[error("Failed to find a suitable GPU adapter")] - AdapterNotFound, - #[error("Failed to create device: {0}")] - DeviceCreationFailed(String), - #[error("Failed to load shader: {0}")] - ShaderLoadFailed(String), - #[error("Mapping compute output future canceled: {0}")] - MappingCanceled(Canceled), - #[error("Mapping compute output failed: {0}")] - MappingFailed(BufferAsyncError), -} +use wgpu::{PipelineCompilationOptions, util::DeviceExt}; /// Trait that creates a shader module and provides its entry point. pub trait ComputeShader { fn create_module( &self, device: &wgpu::Device, - ) -> Result<(wgpu::ShaderModule, Option), ComputeError>; + ) -> anyhow::Result<(wgpu::ShaderModule, Option)>; } /// A compute shader written in Rust compiled with spirv-builder. @@ -49,40 +35,33 @@ impl ComputeShader for RustComputeShader { fn create_module( &self, device: &wgpu::Device, - ) -> Result<(wgpu::ShaderModule, Option), ComputeError> { + ) -> anyhow::Result<(wgpu::ShaderModule, Option)> { let builder = SpirvBuilder::new(&self.path, "spirv-unknown-vulkan1.1") .print_metadata(spirv_builder::MetadataPrintout::None) .release(true) .multimodule(false) .shader_panic_strategy(spirv_builder::ShaderPanicStrategy::SilentExit) .preserve_bindings(true); - let artifact = builder - .build() - .map_err(|e| ComputeError::ShaderLoadFailed(e.to_string()))?; + let artifact = builder.build().context("SpirvBuilder::build() failed")?; if artifact.entry_points.len() != 1 { - return Err(ComputeError::ShaderLoadFailed(format!( + anyhow::bail!( "Expected exactly one entry point, found {}", artifact.entry_points.len() - ))); + ); } let entry_point = artifact.entry_points.into_iter().next().unwrap(); let shader_bytes = match artifact.module { - ModuleResult::SingleModule(path) => { - fs::read(&path).map_err(|e| ComputeError::ShaderLoadFailed(e.to_string()))? - } + ModuleResult::SingleModule(path) => fs::read(&path) + .with_context(|| format!("reading spv file '{}' failed", path.display()))?, ModuleResult::MultiModule(_modules) => { - return Err(ComputeError::ShaderLoadFailed( - "Multiple modules produced".to_string(), - )); + anyhow::bail!("MultiModule modules produced"); } }; if shader_bytes.len() % 4 != 0 { - return Err(ComputeError::ShaderLoadFailed( - "SPIR-V binary length is not a multiple of 4".to_string(), - )); + anyhow::bail!("SPIR-V binary length is not a multiple of 4"); } let shader_words: Vec = bytemuck::cast_slice(&shader_bytes).to_vec(); let module = device.create_shader_module(wgpu::ShaderModuleDescriptor { @@ -112,9 +91,9 @@ impl ComputeShader for WgslComputeShader { fn create_module( &self, device: &wgpu::Device, - ) -> Result<(wgpu::ShaderModule, Option), ComputeError> { + ) -> anyhow::Result<(wgpu::ShaderModule, Option)> { let shader_source = fs::read_to_string(&self.path) - .map_err(|e| ComputeError::ShaderLoadFailed(e.to_string()))?; + .with_context(|| format!("reading wgsl source file '{}'", &self.path.display()))?; let module = device.create_shader_module(wgpu::ShaderModuleDescriptor { label: Some("Compute Shader"), source: wgpu::ShaderSource::Wgsl(Cow::Owned(shader_source)), @@ -142,7 +121,7 @@ where } } - fn init() -> Result<(wgpu::Device, wgpu::Queue), ComputeError> { + fn init() -> anyhow::Result<(wgpu::Device, wgpu::Queue)> { block_on(async { let instance = wgpu::Instance::new(wgpu::InstanceDescriptor { #[cfg(target_os = "linux")] @@ -160,7 +139,7 @@ where force_fallback_adapter: false, }) .await - .ok_or(ComputeError::AdapterNotFound)?; + .context("Failed to find a suitable GPU adapter")?; let (device, queue) = adapter .request_device( &wgpu::DeviceDescriptor { @@ -175,12 +154,12 @@ where None, ) .await - .map_err(|e| ComputeError::DeviceCreationFailed(e.to_string()))?; + .context("Failed to create device")?; Ok((device, queue)) }) } - fn run_internal(self, input: Option) -> Result, ComputeError> + fn run_internal(self, input: Option) -> anyhow::Result> where I: Sized + Pod, { @@ -278,20 +257,20 @@ where }); device.poll(wgpu::Maintain::Wait); block_on(receiver) - .map_err(ComputeError::MappingCanceled)? - .map_err(ComputeError::MappingFailed)?; + .context("mapping canceled")? + .context("mapping failed")?; let data = buffer_slice.get_mapped_range().to_vec(); staging_buffer.unmap(); Ok(data) } /// Runs the compute shader with no input. - pub fn run(self) -> Result, ComputeError> { + pub fn run(self) -> anyhow::Result> { self.run_internal::<()>(None) } /// Runs the compute shader with provided input. - pub fn run_with_input(self, input: I) -> Result, ComputeError> + pub fn run_with_input(self, input: I) -> anyhow::Result> where I: Sized + Pod, { @@ -299,21 +278,21 @@ where } /// Runs the compute shader with no input and writes the output to a file. - pub fn run_test(self, config: &Config) -> Result<(), ComputeError> { + pub fn run_test(self, config: &Config) -> anyhow::Result<()> { let output = self.run()?; - let mut f = File::create(&config.output_path).unwrap(); - f.write_all(&output).unwrap(); + let mut f = File::create(&config.output_path)?; + f.write_all(&output)?; Ok(()) } /// Runs the compute shader with provided input and writes the output to a file. - pub fn run_test_with_input(self, config: &Config, input: I) -> Result<(), ComputeError> + pub fn run_test_with_input(self, config: &Config, input: I) -> anyhow::Result<()> where I: Sized + Pod, { let output = self.run_with_input(input)?; - let mut f = File::create(&config.output_path).unwrap(); - f.write_all(&output).unwrap(); + let mut f = File::create(&config.output_path)?; + f.write_all(&output)?; Ok(()) } } diff --git a/tests/difftests/tests/Cargo.lock b/tests/difftests/tests/Cargo.lock index 686e22f50d..596627780a 100644 --- a/tests/difftests/tests/Cargo.lock +++ b/tests/difftests/tests/Cargo.lock @@ -11,6 +11,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anyhow" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" + [[package]] name = "arrayvec" version = "0.7.6" @@ -165,13 +171,13 @@ dependencies = [ name = "difftest" version = "0.9.0" dependencies = [ + "anyhow", "bytemuck", "futures", "serde", "serde_json", "spirv-builder", "tempfile", - "thiserror 1.0.69", "wgpu", ] From 018dd8946b1c0d6d7f975fe658e7274731644a80 Mon Sep 17 00:00:00 2001 From: Firestar99 Date: Mon, 26 May 2025 16:53:50 +0200 Subject: [PATCH 02/10] upgrade wgpu 23 -> 25 --- Cargo.lock | 246 +++++++++++------- deny.toml | 4 - examples/runners/wgpu/Cargo.toml | 2 +- examples/runners/wgpu/src/compute.rs | 29 ++- examples/runners/wgpu/src/graphics.rs | 30 ++- examples/runners/wgpu/src/lib.rs | 6 +- tests/difftests/lib/Cargo.toml | 2 +- .../lib/src/scaffold/compute/wgpu.rs | 29 +-- tests/difftests/tests/Cargo.lock | 198 +++++++++++--- 9 files changed, 370 insertions(+), 176 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cc17d21f01..e28edb2bc5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,7 +59,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef6978589202a00cd7e118380c448a08b6ed394c3a8df3a430d0898e3a42d046" dependencies = [ "android-properties", - "bitflags 2.6.0", + "bitflags 2.9.1", "cc", "cesu8", "jni", @@ -257,9 +257,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.6.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" dependencies = [ "serde", ] @@ -287,9 +287,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.21.0" +version = "1.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" +checksum = "5c76a5792e44e4abe34d3abf15636779261d45a7450612059293d1d2cfc63422" dependencies = [ "bytemuck_derive", ] @@ -323,7 +323,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b99da2f8558ca23c71f4fd15dc57c906239752dd27ff3c00a1d56b685b7cbfec" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "log", "polling", "rustix", @@ -398,12 +398,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "cfg_aliases" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" - [[package]] name = "cfg_aliases" version = "0.2.1" @@ -482,10 +476,11 @@ dependencies = [ [[package]] name = "codespan-reporting" -version = "0.11.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81" dependencies = [ + "serde", "termcolor", "unicode-width", ] @@ -663,6 +658,12 @@ version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" +[[package]] +name = "crunchy" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" + [[package]] name = "cty" version = "0.2.2" @@ -771,9 +772,9 @@ dependencies = [ [[package]] name = "document-features" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6969eaabd2421f8a2775cfd2471a2b634372b4a25d41e3bd647b79912850a0" +checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d" dependencies = [ "litrs", ] @@ -924,9 +925,9 @@ dependencies = [ [[package]] name = "fixedbitset" -version = "0.4.2" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" [[package]] name = "flate2" @@ -1133,9 +1134,9 @@ dependencies = [ [[package]] name = "glow" -version = "0.14.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51fa363f025f5c111e03f13eda21162faeacb6911fe8caa0c0349f9cf0c4483" +checksum = "c5e5ea60d70410161c8bf5da3fdfeaa1c72ed2c15f8bbb9d19fe3a4fad085f08" dependencies = [ "js-sys", "slotmap", @@ -1158,7 +1159,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "gpu-alloc-types", ] @@ -1168,7 +1169,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", ] [[package]] @@ -1189,7 +1190,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf29e94d6d243368b7a56caa16bc213e4f9f8ed38c4d9557069527b5d5281ca" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "gpu-descriptor-types", "hashbrown 0.15.2", ] @@ -1200,7 +1201,18 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdf242682df893b86f33a73828fb09ca4b2d3bb6cc95249707fc684d27484b91" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", +] + +[[package]] +name = "half" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "459196ed295495a68f7d7fe1d84f6c4b7ff0e21fe3017b2f283c6fac3ad803c9" +dependencies = [ + "cfg-if", + "crunchy", + "num-traits", ] [[package]] @@ -1219,6 +1231,8 @@ version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ + "allocator-api2", + "equivalent", "foldhash", ] @@ -1254,9 +1268,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "indexmap" -version = "2.7.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", "hashbrown 0.15.2", @@ -1433,7 +1447,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "libc", "redox_syscall 0.5.8", ] @@ -1516,11 +1530,11 @@ dependencies = [ [[package]] name = "metal" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ecfd3296f8c56b7c1f6fbac3c71cefa9d78ce009850c45000015f206dc7fa21" +checksum = "f569fb946490b5743ad69813cb19629130ce9374034abe31614a36402d18f99e" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "block", "core-graphics-types", "foreign-types", @@ -1602,24 +1616,28 @@ dependencies = [ [[package]] name = "naga" -version = "23.1.0" +version = "25.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "364f94bc34f61332abebe8cad6f6cd82a5b65cff22c828d05d0968911462ca4f" +checksum = "2b977c445f26e49757f9aca3631c3b8b836942cb278d69a92e7b80d3b24da632" dependencies = [ "arrayvec", "bit-set", - "bitflags 2.6.0", - "cfg_aliases 0.1.1", + "bitflags 2.9.1", + "cfg_aliases", "codespan-reporting", + "half", + "hashbrown 0.15.2", "hexf-parse", "indexmap", "log", + "num-traits", + "once_cell", "petgraph", "rustc-hash", "spirv", - "termcolor", - "thiserror 1.0.69", - "unicode-xid", + "strum", + "thiserror 2.0.12", + "unicode-ident", ] [[package]] @@ -1628,7 +1646,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "jni-sys", "log", "ndk-sys 0.6.0+11769913", @@ -1680,7 +1698,7 @@ version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c533b4c39709f9ba5005d8002048266593c1cfaf3c5f0739d5b8ab0c6c504009" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "filetime", "fsevent-sys", "inotify", @@ -1799,7 +1817,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "block2", "libc", "objc2", @@ -1815,7 +1833,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "block2", "objc2", "objc2-core-location", @@ -1839,7 +1857,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "block2", "objc2", "objc2-foundation", @@ -1881,7 +1899,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "block2", "dispatch", "libc", @@ -1906,7 +1924,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "block2", "objc2", "objc2-foundation", @@ -1918,7 +1936,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "block2", "objc2", "objc2-foundation", @@ -1941,7 +1959,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "block2", "objc2", "objc2-cloud-kit", @@ -1973,7 +1991,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "block2", "objc2", "objc2-core-location", @@ -1997,9 +2015,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.2" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "orbclient" @@ -2013,6 +2031,15 @@ dependencies = [ "sdl2-sys", ] +[[package]] +name = "ordered-float" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951" +dependencies = [ + "num-traits", +] + [[package]] name = "overload" version = "0.1.1" @@ -2065,12 +2092,14 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "petgraph" -version = "0.6.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +checksum = "54acf3a685220b533e437e264e4d932cfbdc4cc7ec0cd232ed73c08d03b8a7ca" dependencies = [ "fixedbitset", + "hashbrown 0.15.2", "indexmap", + "serde", ] [[package]] @@ -2139,6 +2168,12 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "portable-atomic" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" + [[package]] name = "powerfmt" version = "0.2.0" @@ -2292,7 +2327,7 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", ] [[package]] @@ -2457,7 +2492,7 @@ version = "0.38.42" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "errno", "itoa", "libc", @@ -2676,7 +2711,7 @@ version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "calloop", "calloop-wayland-source", "cursor-icon", @@ -2731,7 +2766,7 @@ version = "0.3.0+sdk-1.3.268.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "serde", ] @@ -3182,12 +3217,6 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" -[[package]] -name = "unicode-xid" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" - [[package]] name = "utf8parse" version = "0.2.2" @@ -3301,7 +3330,7 @@ version = "0.222.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4adf50fde1b1a49c1add6a80d47aea500c88db70551805853aa8b88f3ea27ab5" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", ] [[package]] @@ -3340,7 +3369,7 @@ version = "0.31.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b66249d3fc69f76fd74c82cc319300faa554e9d865dab1f7cd66cc20db10b280" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "rustix", "wayland-backend", "wayland-scanner 0.31.5", @@ -3364,7 +3393,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "cursor-icon", "wayland-backend", ] @@ -3409,7 +3438,7 @@ version = "0.32.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cd0ade57c4e6e9a8952741325c30bf82f4246885dca8bf561898b86d0c1f58e" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "wayland-backend", "wayland-client 0.31.7", "wayland-scanner 0.31.5", @@ -3421,7 +3450,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b31cab548ee68c7eb155517f2212049dc151f7cd7910c2b66abfd31c3ee12bd" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "wayland-backend", "wayland-client 0.31.7", "wayland-protocols 0.32.5", @@ -3434,7 +3463,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "782e12f6cd923c3c316130d56205ebab53f55d6666b7faddfad36cecaeeb4022" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "wayland-backend", "wayland-client 0.31.7", "wayland-protocols 0.32.5", @@ -3508,17 +3537,20 @@ dependencies = [ [[package]] name = "wgpu" -version = "23.0.1" +version = "25.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80f70000db37c469ea9d67defdc13024ddf9a5f1b89cb2941b812ad7cde1735a" +checksum = "ec8fb398f119472be4d80bc3647339f56eb63b2a331f6a3d16e25d8144197dd9" dependencies = [ "arrayvec", - "cfg_aliases 0.1.1", + "bitflags 2.9.1", + "cfg_aliases", "document-features", + "hashbrown 0.15.2", "js-sys", "log", "naga", "parking_lot", + "portable-atomic", "profiling", "raw-window-handle 0.6.2", "smallvec", @@ -3533,50 +3565,85 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "23.0.1" +version = "25.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d63c3c478de8e7e01786479919c8769f62a22eec16788d8c2ac77ce2c132778a" +checksum = "f7b882196f8368511d613c6aeec80655160db6646aebddf8328879a88d54e500" dependencies = [ "arrayvec", + "bit-set", "bit-vec", - "bitflags 2.6.0", + "bitflags 2.9.1", "bytemuck", - "cfg_aliases 0.1.1", + "cfg_aliases", "document-features", + "hashbrown 0.15.2", "indexmap", "log", "naga", "once_cell", "parking_lot", + "portable-atomic", "profiling", "raw-window-handle 0.6.2", "rustc-hash", "smallvec", - "thiserror 1.0.69", + "thiserror 2.0.12", + "wgpu-core-deps-apple", + "wgpu-core-deps-emscripten", + "wgpu-core-deps-windows-linux-android", "wgpu-hal", "wgpu-types", ] +[[package]] +name = "wgpu-core-deps-apple" +version = "25.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfd488b3239b6b7b185c3b045c39ca6bf8af34467a4c5de4e0b1a564135d093d" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-core-deps-emscripten" +version = "25.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f09ad7aceb3818e52539acc679f049d3475775586f3f4e311c30165cf2c00445" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-core-deps-windows-linux-android" +version = "25.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cba5fb5f7f9c98baa7c889d444f63ace25574833df56f5b817985f641af58e46" +dependencies = [ + "wgpu-hal", +] + [[package]] name = "wgpu-hal" -version = "23.0.1" +version = "25.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89364b8a0b211adc7b16aeaf1bd5ad4a919c1154b44c9ce27838213ba05fd821" +checksum = "f968767fe4d3d33747bbd1473ccd55bf0f6451f55d733b5597e67b5deab4ad17" dependencies = [ "android_system_properties", "arrayvec", "ash", "bit-set", - "bitflags 2.6.0", + "bitflags 2.9.1", "block", "bytemuck", - "cfg_aliases 0.1.1", + "cfg-if", + "cfg_aliases", "core-graphics-types", "glow", "glutin_wgl_sys", "gpu-alloc", "gpu-allocator", "gpu-descriptor", + "hashbrown 0.15.2", "js-sys", "khronos-egl", "libc", @@ -3586,15 +3653,15 @@ dependencies = [ "naga", "ndk-sys 0.5.0+25.2.9519653", "objc", - "once_cell", + "ordered-float", "parking_lot", + "portable-atomic", "profiling", "range-alloc", "raw-window-handle 0.6.2", "renderdoc-sys", - "rustc-hash", "smallvec", - "thiserror 1.0.69", + "thiserror 2.0.12", "wasm-bindgen", "web-sys", "wgpu-types", @@ -3604,12 +3671,15 @@ dependencies = [ [[package]] name = "wgpu-types" -version = "23.0.0" +version = "25.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "610f6ff27778148c31093f3b03abc4840f9636d58d597ca2f5977433acfe0068" +checksum = "2aa49460c2a8ee8edba3fca54325540d904dd85b2e086ada762767e17d06e8bc" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", + "bytemuck", "js-sys", + "log", + "thiserror 2.0.12", "web-sys", ] @@ -3931,11 +4001,11 @@ dependencies = [ "ahash", "android-activity", "atomic-waker", - "bitflags 2.6.0", + "bitflags 2.9.1", "block2", "bytemuck", "calloop", - "cfg_aliases 0.2.1", + "cfg_aliases", "concurrent-queue", "core-foundation", "core-graphics", @@ -4028,7 +4098,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.1", "dlib", "log", "once_cell", diff --git a/deny.toml b/deny.toml index 4d99a3c874..5ec1a30bb1 100644 --- a/deny.toml +++ b/deny.toml @@ -33,10 +33,6 @@ skip = [ { name = "raw-window-handle", version = "=0.5.2" }, { name = "raw-window-handle", version = "=0.6.2" }, - # HACK(eddyb) the newer version hasn't propagated through the ecosystem yet. - { name = "cfg_aliases", version = "=0.1.1" }, - { name = "cfg_aliases", version = "=0.2.1" }, - # HACK(eddyb) the newer version hasn't propagated through the ecosystem yet. { name = "hashbrown", version = "=0.14.5" }, { name = "hashbrown", version = "=0.15.2" }, diff --git a/examples/runners/wgpu/Cargo.toml b/examples/runners/wgpu/Cargo.toml index b28d1d0d98..3c5226e0e2 100644 --- a/examples/runners/wgpu/Cargo.toml +++ b/examples/runners/wgpu/Cargo.toml @@ -21,7 +21,7 @@ cfg-if = "1.0.0" shared = { path = "../../shaders/shared" } futures = { version = "0.3", default-features = false, features = ["std", "executor"] } # Vulkan SDK or MoltenVK needs to be installed for `vulkan-portability` to work on macOS -wgpu = { version = "23", features = ["spirv", "vulkan-portability"] } +wgpu = { version = "25.0.2", features = ["spirv", "vulkan-portability"] } winit = { version = "0.30.0", features = ["android-native-activity", "rwh_05"] } clap = { version = "4", features = ["derive"] } strum = { version = "0.26.0", default-features = false, features = ["std", "derive"] } diff --git a/examples/runners/wgpu/src/compute.rs b/examples/runners/wgpu/src/compute.rs index 00589fb675..6d97aaf7d0 100644 --- a/examples/runners/wgpu/src/compute.rs +++ b/examples/runners/wgpu/src/compute.rs @@ -12,10 +12,9 @@ pub fn start(options: &Options) { } async fn start_internal(options: &Options, compiled_shader_modules: CompiledShaderModules) { - let backends = wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::PRIMARY); - let instance = wgpu::Instance::new(wgpu::InstanceDescriptor { + let backends = wgpu::Backends::from_env().unwrap_or(wgpu::Backends::PRIMARY); + let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor { backends, - dx12_shader_compiler: wgpu::util::dx12_shader_compiler_from_env().unwrap_or_default(), ..Default::default() }); let adapter = wgpu::util::initialize_adapter_from_env_or_default(&instance, None) @@ -43,15 +42,13 @@ async fn start_internal(options: &Options, compiled_shader_modules: CompiledShad } let (device, queue) = adapter - .request_device( - &wgpu::DeviceDescriptor { - label: None, - required_features, - required_limits: wgpu::Limits::default(), - memory_hints: wgpu::MemoryHints::Performance, - }, - None, - ) + .request_device(&wgpu::DeviceDescriptor { + label: None, + required_features, + required_limits: wgpu::Limits::default(), + memory_hints: wgpu::MemoryHints::Performance, + trace: Default::default(), + }) .await .expect("Failed to create device"); drop(instance); @@ -67,7 +64,11 @@ async fn start_internal(options: &Options, compiled_shader_modules: CompiledShad // FIXME(eddyb) automate this decision by default. let module = compiled_shader_modules.spv_module_for_entry_point(entry_point); let module = if options.force_spirv_passthru { - unsafe { device.create_shader_module_spirv(&module) } + unsafe { + device.create_shader_module_passthrough(wgpu::ShaderModuleDescriptorPassthrough::SpirV( + module, + )) + } } else { let wgpu::ShaderModuleDescriptorSpirV { label, source } = module; device.create_shader_module(wgpu::ShaderModuleDescriptor { @@ -225,7 +226,7 @@ async fn start_internal(options: &Options, compiled_shader_modules: CompiledShad buffer_slice.map_async(wgpu::MapMode::Read, |r| r.unwrap()); // NOTE(eddyb) `poll` should return only after the above callbacks fire // (see also https://github.com/gfx-rs/wgpu/pull/2698 for more details). - device.poll(wgpu::Maintain::Wait); + device.poll(wgpu::PollType::Wait).unwrap(); if timestamping { if let (Some(timestamp_readback_buffer), Some(timestamp_period)) = diff --git a/examples/runners/wgpu/src/graphics.rs b/examples/runners/wgpu/src/graphics.rs index 04a02bb1d3..ba2f316cee 100644 --- a/examples/runners/wgpu/src/graphics.rs +++ b/examples/runners/wgpu/src/graphics.rs @@ -1,4 +1,5 @@ use crate::{CompiledShaderModules, Options, maybe_watch}; +use wgpu::ShaderModuleDescriptorPassthrough; use shared::ShaderConstants; use winit::{ @@ -39,11 +40,10 @@ async fn run( window: Window, compiled_shader_modules: CompiledShaderModules, ) { - let backends = wgpu::util::backend_bits_from_env() - .unwrap_or(wgpu::Backends::VULKAN | wgpu::Backends::METAL); - let instance = wgpu::Instance::new(wgpu::InstanceDescriptor { + let backends = + wgpu::Backends::from_env().unwrap_or(wgpu::Backends::VULKAN | wgpu::Backends::METAL); + let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor { backends, - dx12_shader_compiler: wgpu::util::dx12_shader_compiler_from_env().unwrap_or_default(), ..Default::default() }); @@ -83,15 +83,13 @@ async fn run( // Create the logical device and command queue let (device, queue) = adapter - .request_device( - &wgpu::DeviceDescriptor { - label: None, - required_features, - required_limits, - memory_hints: wgpu::MemoryHints::Performance, - }, - None, - ) + .request_device(&wgpu::DeviceDescriptor { + label: None, + required_features, + required_limits, + memory_hints: wgpu::MemoryHints::Performance, + trace: Default::default(), + }) .await .expect("Failed to create device"); @@ -373,7 +371,11 @@ fn create_pipeline( // FIXME(eddyb) automate this decision by default. let create_module = |module| { if options.force_spirv_passthru { - unsafe { device.create_shader_module_spirv(&module) } + unsafe { + device.create_shader_module_passthrough(ShaderModuleDescriptorPassthrough::SpirV( + module, + )) + } } else { let wgpu::ShaderModuleDescriptorSpirV { label, source } = module; device.create_shader_module(wgpu::ShaderModuleDescriptor { diff --git a/examples/runners/wgpu/src/lib.rs b/examples/runners/wgpu/src/lib.rs index 0b8e608f76..34daf8d6f6 100644 --- a/examples/runners/wgpu/src/lib.rs +++ b/examples/runners/wgpu/src/lib.rs @@ -216,8 +216,12 @@ fn maybe_watch( RustGPUShader::Compute => wgpu::include_spirv_raw!(env!("compute_shader.spv")), RustGPUShader::Mouse => wgpu::include_spirv_raw!(env!("mouse_shader.spv")), }; + let spirv = match module { + wgpu::ShaderModuleDescriptorPassthrough::SpirV(spirv) => spirv, + _ => panic!("not spirv"), + }; CompiledShaderModules { - named_spv_modules: vec![(None, module)], + named_spv_modules: vec![(None, spirv)], } } } diff --git a/tests/difftests/lib/Cargo.toml b/tests/difftests/lib/Cargo.toml index 5c1786fb37..afd3e21a49 100644 --- a/tests/difftests/lib/Cargo.toml +++ b/tests/difftests/lib/Cargo.toml @@ -19,7 +19,7 @@ use-compiled-tools = [ spirv-builder.workspace = true serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -wgpu = { version = "23", features = ["spirv", "vulkan-portability"] } +wgpu = { version = "25.0.2", features = ["spirv", "vulkan-portability"] } tempfile = "3.5" futures = "0.3.31" bytemuck = "1.21.0" diff --git a/tests/difftests/lib/src/scaffold/compute/wgpu.rs b/tests/difftests/lib/src/scaffold/compute/wgpu.rs index 44d1762c20..08c32f0937 100644 --- a/tests/difftests/lib/src/scaffold/compute/wgpu.rs +++ b/tests/difftests/lib/src/scaffold/compute/wgpu.rs @@ -123,14 +123,13 @@ where fn init() -> anyhow::Result<(wgpu::Device, wgpu::Queue)> { block_on(async { - let instance = wgpu::Instance::new(wgpu::InstanceDescriptor { + let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor { #[cfg(target_os = "linux")] backends: wgpu::Backends::VULKAN, #[cfg(not(target_os = "linux"))] backends: wgpu::Backends::PRIMARY, - dx12_shader_compiler: Default::default(), flags: Default::default(), - gles_minor_version: Default::default(), + backend_options: Default::default(), }); let adapter = instance .request_adapter(&wgpu::RequestAdapterOptions { @@ -141,18 +140,16 @@ where .await .context("Failed to find a suitable GPU adapter")?; let (device, queue) = adapter - .request_device( - &wgpu::DeviceDescriptor { - label: Some("wgpu Device"), - #[cfg(target_os = "linux")] - required_features: wgpu::Features::SPIRV_SHADER_PASSTHROUGH, - #[cfg(not(target_os = "linux"))] - required_features: wgpu::Features::empty(), - required_limits: wgpu::Limits::default(), - memory_hints: Default::default(), - }, - None, - ) + .request_device(&wgpu::DeviceDescriptor { + label: Some("wgpu Device"), + #[cfg(target_os = "linux")] + required_features: wgpu::Features::SPIRV_SHADER_PASSTHROUGH, + #[cfg(not(target_os = "linux"))] + required_features: wgpu::Features::empty(), + required_limits: wgpu::Limits::default(), + memory_hints: Default::default(), + trace: Default::default(), + }) .await .context("Failed to create device")?; Ok((device, queue)) @@ -255,7 +252,7 @@ where buffer_slice.map_async(wgpu::MapMode::Read, move |res| { let _ = sender.send(res); }); - device.poll(wgpu::Maintain::Wait); + device.poll(wgpu::PollType::Wait)?; block_on(receiver) .context("mapping canceled")? .context("mapping failed")?; diff --git a/tests/difftests/tests/Cargo.lock b/tests/difftests/tests/Cargo.lock index 596627780a..7ad114e41e 100644 --- a/tests/difftests/tests/Cargo.lock +++ b/tests/difftests/tests/Cargo.lock @@ -2,6 +2,12 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -85,6 +91,20 @@ name = "bytemuck" version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6b1fc10dbac614ebc03540c9dbd60e83887fda27794998c6528f1782047d540" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ecc273b49b3205b83d648f0690daa588925572cc5063745bfe547fe7ec8e1a1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "camino" @@ -126,16 +146,17 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cfg_aliases" -version = "0.1.1" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "codespan-reporting" -version = "0.11.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81" dependencies = [ + "serde", "termcolor", "unicode-width", ] @@ -167,6 +188,12 @@ dependencies = [ "libc", ] +[[package]] +name = "crunchy" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" + [[package]] name = "difftest" version = "0.9.0" @@ -214,9 +241,9 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "fixedbitset" -version = "0.4.2" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" [[package]] name = "foldhash" @@ -374,9 +401,9 @@ dependencies = [ [[package]] name = "glow" -version = "0.14.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51fa363f025f5c111e03f13eda21162faeacb6911fe8caa0c0349f9cf0c4483" +checksum = "c5e5ea60d70410161c8bf5da3fdfeaa1c72ed2c15f8bbb9d19fe3a4fad085f08" dependencies = [ "js-sys", "slotmap", @@ -444,15 +471,34 @@ dependencies = [ "bitflags 2.9.0", ] +[[package]] +name = "half" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "459196ed295495a68f7d7fe1d84f6c4b7ff0e21fe3017b2f283c6fac3ad803c9" +dependencies = [ + "cfg-if", + "crunchy", + "num-traits", +] + [[package]] name = "hashbrown" version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ + "allocator-api2", + "equivalent", "foldhash", ] +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hexf-parse" version = "0.2.1" @@ -575,9 +621,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "metal" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ecfd3296f8c56b7c1f6fbac3c71cefa9d78ce009850c45000015f206dc7fa21" +checksum = "f569fb946490b5743ad69813cb19629130ce9374034abe31614a36402d18f99e" dependencies = [ "bitflags 2.9.0", "block", @@ -590,24 +636,28 @@ dependencies = [ [[package]] name = "naga" -version = "23.1.0" +version = "25.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "364f94bc34f61332abebe8cad6f6cd82a5b65cff22c828d05d0968911462ca4f" +checksum = "2b977c445f26e49757f9aca3631c3b8b836942cb278d69a92e7b80d3b24da632" dependencies = [ "arrayvec", "bit-set", "bitflags 2.9.0", "cfg_aliases", "codespan-reporting", + "half", + "hashbrown", "hexf-parse", "indexmap", "log", + "num-traits", + "once_cell", "petgraph", "rustc-hash", "spirv", - "termcolor", - "thiserror 1.0.69", - "unicode-xid", + "strum", + "thiserror 2.0.12", + "unicode-ident", ] [[package]] @@ -640,9 +690,18 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.21.1" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "ordered-float" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951" +dependencies = [ + "num-traits", +] [[package]] name = "parking_lot" @@ -675,12 +734,14 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "petgraph" -version = "0.6.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +checksum = "54acf3a685220b533e437e264e4d932cfbdc4cc7ec0cd232ed73c08d03b8a7ca" dependencies = [ "fixedbitset", + "hashbrown", "indexmap", + "serde", ] [[package]] @@ -701,6 +762,12 @@ version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" +[[package]] +name = "portable-atomic" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" + [[package]] name = "presser" version = "0.3.1" @@ -957,6 +1024,28 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "strum" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + [[package]] name = "syn" version = "2.0.100" @@ -1042,12 +1131,6 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" -[[package]] -name = "unicode-xid" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" - [[package]] name = "version_check" version = "0.9.5" @@ -1146,17 +1229,20 @@ dependencies = [ [[package]] name = "wgpu" -version = "23.0.1" +version = "25.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80f70000db37c469ea9d67defdc13024ddf9a5f1b89cb2941b812ad7cde1735a" +checksum = "ec8fb398f119472be4d80bc3647339f56eb63b2a331f6a3d16e25d8144197dd9" dependencies = [ "arrayvec", + "bitflags 2.9.0", "cfg_aliases", "document-features", + "hashbrown", "js-sys", "log", "naga", "parking_lot", + "portable-atomic", "profiling", "raw-window-handle", "smallvec", @@ -1171,35 +1257,68 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "23.0.1" +version = "25.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d63c3c478de8e7e01786479919c8769f62a22eec16788d8c2ac77ce2c132778a" +checksum = "f7b882196f8368511d613c6aeec80655160db6646aebddf8328879a88d54e500" dependencies = [ "arrayvec", + "bit-set", "bit-vec", "bitflags 2.9.0", "bytemuck", "cfg_aliases", "document-features", + "hashbrown", "indexmap", "log", "naga", "once_cell", "parking_lot", + "portable-atomic", "profiling", "raw-window-handle", "rustc-hash", "smallvec", - "thiserror 1.0.69", + "thiserror 2.0.12", + "wgpu-core-deps-apple", + "wgpu-core-deps-emscripten", + "wgpu-core-deps-windows-linux-android", "wgpu-hal", "wgpu-types", ] +[[package]] +name = "wgpu-core-deps-apple" +version = "25.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfd488b3239b6b7b185c3b045c39ca6bf8af34467a4c5de4e0b1a564135d093d" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-core-deps-emscripten" +version = "25.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f09ad7aceb3818e52539acc679f049d3475775586f3f4e311c30165cf2c00445" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-core-deps-windows-linux-android" +version = "25.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cba5fb5f7f9c98baa7c889d444f63ace25574833df56f5b817985f641af58e46" +dependencies = [ + "wgpu-hal", +] + [[package]] name = "wgpu-hal" -version = "23.0.1" +version = "25.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89364b8a0b211adc7b16aeaf1bd5ad4a919c1154b44c9ce27838213ba05fd821" +checksum = "f968767fe4d3d33747bbd1473ccd55bf0f6451f55d733b5597e67b5deab4ad17" dependencies = [ "android_system_properties", "arrayvec", @@ -1208,6 +1327,7 @@ dependencies = [ "bitflags 2.9.0", "block", "bytemuck", + "cfg-if", "cfg_aliases", "core-graphics-types", "glow", @@ -1215,6 +1335,7 @@ dependencies = [ "gpu-alloc", "gpu-allocator", "gpu-descriptor", + "hashbrown", "js-sys", "khronos-egl", "libc", @@ -1224,15 +1345,15 @@ dependencies = [ "naga", "ndk-sys", "objc", - "once_cell", + "ordered-float", "parking_lot", + "portable-atomic", "profiling", "range-alloc", "raw-window-handle", "renderdoc-sys", - "rustc-hash", "smallvec", - "thiserror 1.0.69", + "thiserror 2.0.12", "wasm-bindgen", "web-sys", "wgpu-types", @@ -1242,12 +1363,15 @@ dependencies = [ [[package]] name = "wgpu-types" -version = "23.0.0" +version = "25.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "610f6ff27778148c31093f3b03abc4840f9636d58d597ca2f5977433acfe0068" +checksum = "2aa49460c2a8ee8edba3fca54325540d904dd85b2e086ada762767e17d06e8bc" dependencies = [ "bitflags 2.9.0", + "bytemuck", "js-sys", + "log", + "thiserror 2.0.12", "web-sys", ] From 4ae5f115f569e5c4721538217f6294fc58971c2c Mon Sep 17 00:00:00 2001 From: Firestar99 Date: Fri, 13 Jun 2025 10:41:08 +0200 Subject: [PATCH 03/10] `enum SpirvTargetEnv` containing all targets --- .github/workflows/ci.yaml | 2 +- Cargo.lock | 3 + .../Cargo.toml | 3 + .../src/include_str.rs | 139 +++++++-------- .../src/lib.rs | 112 ++++++++++++- .../rustc_codegen_spirv/src/builder_spirv.rs | 5 +- .../rustc_codegen_spirv/src/codegen_cx/mod.rs | 5 +- crates/rustc_codegen_spirv/src/linker/test.rs | 5 +- crates/rustc_codegen_spirv/src/target.rs | 158 +++++++----------- crates/spirv-builder/Cargo.toml | 4 +- crates/spirv-builder/src/lib.rs | 61 ++----- tests/compiletests/src/main.rs | 46 ++--- tests/difftests/tests/Cargo.lock | 8 + 13 files changed, 302 insertions(+), 249 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 48153bd030..e6c8a2a5a2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -50,7 +50,7 @@ jobs: run: cargo test -p rustc_codegen_spirv --release --no-default-features --features "use-installed-tools" - name: workspace test (excluding examples & difftest) - run: cargo test --release --workspace --exclude "example-runner-*" --exclude "difftest*" --no-default-features --features "use-installed-tools" + run: cargo test --release --workspace --exclude "example-runner-*" --exclude "difftest*" --no-default-features --features use-installed-tools,include_str # Examples - name: cargo check examples diff --git a/Cargo.lock b/Cargo.lock index e28edb2bc5..f963daf9c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2454,6 +2454,9 @@ dependencies = [ [[package]] name = "rustc_codegen_spirv-target-specs" version = "0.9.0" +dependencies = [ + "strum", +] [[package]] name = "rustc_codegen_spirv-types" diff --git a/crates/rustc_codegen_spirv-target-specs/Cargo.toml b/crates/rustc_codegen_spirv-target-specs/Cargo.toml index 76e6e2c106..d431ead8f8 100644 --- a/crates/rustc_codegen_spirv-target-specs/Cargo.toml +++ b/crates/rustc_codegen_spirv-target-specs/Cargo.toml @@ -10,3 +10,6 @@ repository.workspace = true [features] include_str = [] dir_path = [] + +[dependencies] +strum = { version = "0.26.3", features = ["derive"] } diff --git a/crates/rustc_codegen_spirv-target-specs/src/include_str.rs b/crates/rustc_codegen_spirv-target-specs/src/include_str.rs index 53fba7f788..93941e8da4 100644 --- a/crates/rustc_codegen_spirv-target-specs/src/include_str.rs +++ b/crates/rustc_codegen_spirv-target-specs/src/include_str.rs @@ -1,75 +1,64 @@ -/// Metadata for the compile targets supported by `rust-gpu` -pub const TARGET_SPECS: &[(&str, &str)] = &[ - ( - "spirv-unknown-opengl4.0.json", - include_str!("../target-specs/spirv-unknown-opengl4.0.json"), - ), - ( - "spirv-unknown-opengl4.1.json", - include_str!("../target-specs/spirv-unknown-opengl4.1.json"), - ), - ( - "spirv-unknown-opengl4.2.json", - include_str!("../target-specs/spirv-unknown-opengl4.2.json"), - ), - ( - "spirv-unknown-opengl4.3.json", - include_str!("../target-specs/spirv-unknown-opengl4.3.json"), - ), - ( - "spirv-unknown-opengl4.5.json", - include_str!("../target-specs/spirv-unknown-opengl4.5.json"), - ), - ( - "spirv-unknown-spv1.0.json", - include_str!("../target-specs/spirv-unknown-spv1.0.json"), - ), - ( - "spirv-unknown-spv1.1.json", - include_str!("../target-specs/spirv-unknown-spv1.1.json"), - ), - ( - "spirv-unknown-spv1.2.json", - include_str!("../target-specs/spirv-unknown-spv1.2.json"), - ), - ( - "spirv-unknown-spv1.3.json", - include_str!("../target-specs/spirv-unknown-spv1.3.json"), - ), - ( - "spirv-unknown-spv1.4.json", - include_str!("../target-specs/spirv-unknown-spv1.4.json"), - ), - ( - "spirv-unknown-spv1.5.json", - include_str!("../target-specs/spirv-unknown-spv1.5.json"), - ), - ( - "spirv-unknown-spv1.6.json", - include_str!("../target-specs/spirv-unknown-spv1.6.json"), - ), - ( - "spirv-unknown-vulkan1.0.json", - include_str!("../target-specs/spirv-unknown-vulkan1.0.json"), - ), - ( - "spirv-unknown-vulkan1.1.json", - include_str!("../target-specs/spirv-unknown-vulkan1.1.json"), - ), - ( - "spirv-unknown-vulkan1.1spv1.4.json", - include_str!("../target-specs/spirv-unknown-vulkan1.1spv1.4.json"), - ), - ( - "spirv-unknown-vulkan1.2.json", - include_str!("../target-specs/spirv-unknown-vulkan1.2.json"), - ), - ( - "spirv-unknown-vulkan1.3.json", - include_str!("../target-specs/spirv-unknown-vulkan1.3.json"), - ), - ( - "spirv-unknown-vulkan1.4.json", - include_str!("../target-specs/spirv-unknown-vulkan1.4.json"), - ), -]; +//! Metadata for the compile targets supported by `rust-gpu` + +use crate::SpirvTargetEnv; + +impl SpirvTargetEnv { + pub fn include_str(&self) -> &'static str { + match self { + SpirvTargetEnv::OpenGL_4_0 => { + include_str!("../target-specs/spirv-unknown-opengl4.0.json") + } + SpirvTargetEnv::OpenGL_4_1 => { + include_str!("../target-specs/spirv-unknown-opengl4.1.json") + } + SpirvTargetEnv::OpenGL_4_2 => { + include_str!("../target-specs/spirv-unknown-opengl4.2.json") + } + SpirvTargetEnv::OpenGL_4_3 => { + include_str!("../target-specs/spirv-unknown-opengl4.3.json") + } + SpirvTargetEnv::OpenGL_4_5 => { + include_str!("../target-specs/spirv-unknown-opengl4.5.json") + } + SpirvTargetEnv::Spv_1_0 => { + include_str!("../target-specs/spirv-unknown-spv1.0.json") + } + SpirvTargetEnv::Spv_1_1 => { + include_str!("../target-specs/spirv-unknown-spv1.1.json") + } + SpirvTargetEnv::Spv_1_2 => { + include_str!("../target-specs/spirv-unknown-spv1.2.json") + } + SpirvTargetEnv::Spv_1_3 => { + include_str!("../target-specs/spirv-unknown-spv1.3.json") + } + SpirvTargetEnv::Spv_1_4 => { + include_str!("../target-specs/spirv-unknown-spv1.4.json") + } + SpirvTargetEnv::Spv_1_5 => { + include_str!("../target-specs/spirv-unknown-spv1.5.json") + } + SpirvTargetEnv::Spv_1_6 => { + include_str!("../target-specs/spirv-unknown-spv1.6.json") + } + SpirvTargetEnv::Vulkan_1_0 => { + include_str!("../target-specs/spirv-unknown-vulkan1.0.json") + } + SpirvTargetEnv::Vulkan_1_1 => { + include_str!("../target-specs/spirv-unknown-vulkan1.1.json") + } + SpirvTargetEnv::Vulkan_1_1_Spv_1_4 => { + include_str!("../target-specs/spirv-unknown-vulkan1.1spv1.4.json") + } + SpirvTargetEnv::Vulkan_1_2 => { + include_str!("../target-specs/spirv-unknown-vulkan1.2.json") + } + SpirvTargetEnv::Vulkan_1_3 => { + include_str!("../target-specs/spirv-unknown-vulkan1.3.json") + } + SpirvTargetEnv::Vulkan_1_4 => { + include_str!("../target-specs/spirv-unknown-vulkan1.4.json") + } + } + } +} diff --git a/crates/rustc_codegen_spirv-target-specs/src/lib.rs b/crates/rustc_codegen_spirv-target-specs/src/lib.rs index b3033d9fee..b3a830ee82 100644 --- a/crates/rustc_codegen_spirv-target-specs/src/lib.rs +++ b/crates/rustc_codegen_spirv-target-specs/src/lib.rs @@ -1,10 +1,118 @@ #![doc = include_str!("../README.md")] +use strum::{Display, EnumIter, EnumString, IntoStaticStr}; + /// directory with all the `target-specs` jsons for our codegen backend #[cfg(feature = "dir_path")] pub const TARGET_SPEC_DIR_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/target-specs"); #[cfg(feature = "include_str")] mod include_str; -#[cfg(feature = "include_str")] -pub use include_str::TARGET_SPECS; + +pub const SPIRV_ARCH: &str = "spirv"; +pub const SPIRV_VENDOR: &str = "unknown"; + +/// All target envs rust-gpu supports +#[allow(non_camel_case_types, clippy::upper_case_acronyms)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, EnumString, IntoStaticStr, EnumIter, Display)] +pub enum SpirvTargetEnv { + #[strum(to_string = "opengl4.0")] + OpenGL_4_0, + #[strum(to_string = "opengl4.1")] + OpenGL_4_1, + #[strum(to_string = "opengl4.2")] + OpenGL_4_2, + #[strum(to_string = "opengl4.3")] + OpenGL_4_3, + #[strum(to_string = "opengl4.5")] + OpenGL_4_5, + #[strum(to_string = "spv1.0")] + Spv_1_0, + #[strum(to_string = "spv1.1")] + Spv_1_1, + #[strum(to_string = "spv1.2")] + Spv_1_2, + #[strum(to_string = "spv1.3")] + Spv_1_3, + #[strum(to_string = "spv1.4")] + Spv_1_4, + #[strum(to_string = "spv1.5")] + Spv_1_5, + #[strum(to_string = "spv1.6")] + Spv_1_6, + #[strum(to_string = "vulkan1.0")] + Vulkan_1_0, + #[strum(to_string = "vulkan1.1")] + Vulkan_1_1, + #[strum(to_string = "vulkan1.1spv1.4")] + Vulkan_1_1_Spv_1_4, + #[strum(to_string = "vulkan1.2")] + Vulkan_1_2, + #[strum(to_string = "vulkan1.3")] + Vulkan_1_3, + #[strum(to_string = "vulkan1.4")] + Vulkan_1_4, +} + +impl SpirvTargetEnv { + pub fn parse_triple(target: &str) -> Option { + target + .strip_prefix(&format!("{SPIRV_ARCH}-{SPIRV_VENDOR}-")) + .and_then(|env| TryFrom::try_from(env).ok()) + } + + pub fn as_str(&self) -> &'static str { + self.into() + } + + pub fn target_triple(&self) -> String { + format!("{SPIRV_ARCH}-{SPIRV_VENDOR}-{}", self.as_str()) + } + + pub fn target_json_file_name(&self) -> String { + format!("{SPIRV_ARCH}-{SPIRV_VENDOR}-{}.json", self.as_str()) + } + + #[cfg(feature = "dir_path")] + pub fn target_json_path(&self) -> String { + format!( + "{TARGET_SPEC_DIR_PATH}/{SPIRV_ARCH}-{SPIRV_VENDOR}-{}.json", + self.as_str() + ) + } + + pub fn iter() -> impl DoubleEndedIterator { + ::iter() + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + pub fn test_parse_as_str_loop() { + for target in SpirvTargetEnv::iter() { + let parsed = SpirvTargetEnv::parse_triple(target.as_str()).unwrap(); + assert_eq!(target, parsed); + } + } + + #[test] + #[cfg(feature = "dir_path")] + pub fn test_target_json_path() { + for target in SpirvTargetEnv::iter() { + let file = std::path::PathBuf::from(target.target_json_path()); + assert!(file.is_file()); + } + } + + #[test] + #[cfg(all(feature = "dir_path", feature = "include_str"))] + pub fn test_target_json_content() { + for target in SpirvTargetEnv::iter() { + let content = std::fs::read_to_string(target.target_json_path()).unwrap(); + assert_eq!(content, target.include_str()); + } + } +} diff --git a/crates/rustc_codegen_spirv/src/builder_spirv.rs b/crates/rustc_codegen_spirv/src/builder_spirv.rs index 4c87f0584d..b08c076a6c 100644 --- a/crates/rustc_codegen_spirv/src/builder_spirv.rs +++ b/crates/rustc_codegen_spirv/src/builder_spirv.rs @@ -5,7 +5,7 @@ use crate::builder; use crate::codegen_cx::CodegenCx; use crate::spirv_type::SpirvType; use crate::symbols::Symbols; -use crate::target::SpirvTarget; +use crate::target::TargetsExt; use crate::target_feature::TargetFeature; use rspirv::dr::{Block, Builder, Instruction, Module, Operand}; use rspirv::spirv::{ @@ -13,6 +13,7 @@ use rspirv::spirv::{ }; use rspirv::{binary::Assemble, binary::Disassemble}; use rustc_arena::DroplessArena; +use rustc_codegen_spirv_target_specs::SpirvTargetEnv; use rustc_codegen_ssa::traits::ConstCodegenMethods as _; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::sync::Lrc; @@ -431,7 +432,7 @@ impl<'tcx> BuilderSpirv<'tcx> { pub fn new( tcx: TyCtxt<'tcx>, sym: &Symbols, - target: &SpirvTarget, + target: &SpirvTargetEnv, features: &[TargetFeature], ) -> Self { let version = target.spirv_version(); diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs index f3a3828018..dffd154da3 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs @@ -8,15 +8,16 @@ use crate::builder_spirv::{BuilderCursor, BuilderSpirv, SpirvConst, SpirvValue, use crate::custom_decorations::{CustomDecoration, SrcLocDecoration, ZombieDecoration}; use crate::spirv_type::{SpirvType, SpirvTypePrinter, TypeCache}; use crate::symbols::Symbols; -use crate::target::SpirvTarget; // HACK(eddyb) avoids rewriting all of the imports (see `lib.rs` and `build.rs`). use crate::maybe_pqp_cg_ssa as rustc_codegen_ssa; +use crate::target::TargetsExt; use itertools::Itertools as _; use rspirv::dr::{Module, Operand}; use rspirv::spirv::{Decoration, LinkageType, Op, Word}; use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece}; +use rustc_codegen_spirv_target_specs::SpirvTargetEnv; use rustc_codegen_ssa::mir::debuginfo::{FunctionDebugContext, VariableKind}; use rustc_codegen_ssa::traits::{ AsmCodegenMethods, BackendTypes, DebugInfoCodegenMethods, GlobalAsmOperandRef, @@ -95,7 +96,7 @@ impl<'tcx> CodegenCx<'tcx> { pub fn new(tcx: TyCtxt<'tcx>, codegen_unit: &'tcx CodegenUnit<'tcx>) -> Self { // Validate the target spec, as the backend doesn't control `--target`. let target_tuple = tcx.sess.opts.target_triple.tuple(); - let target: SpirvTarget = target_tuple.parse().unwrap_or_else(|_| { + let target = SpirvTargetEnv::parse_triple(target_tuple).unwrap_or_else(|| { let qualifier = if !target_tuple.starts_with("spirv-") { "non-SPIR-V " } else { diff --git a/crates/rustc_codegen_spirv/src/linker/test.rs b/crates/rustc_codegen_spirv/src/linker/test.rs index 529b4c697b..191474ca6d 100644 --- a/crates/rustc_codegen_spirv/src/linker/test.rs +++ b/crates/rustc_codegen_spirv/src/linker/test.rs @@ -1,5 +1,7 @@ use super::{LinkResult, link}; +use crate::target::TargetsExt; use rspirv::dr::{Loader, Module}; +use rustc_codegen_spirv_target_specs::SpirvTargetEnv; use rustc_errors::registry::Registry; use rustc_session::CompilerIO; use rustc_session::config::{Input, OutputFilenames, OutputTypes}; @@ -130,8 +132,7 @@ fn link_with_linker_opts( .unwrap(); let sopts = rustc_session::config::build_session_options(&mut early_dcx, &matches); - let target = "spirv-unknown-spv1.0" - .parse::() + let target = SpirvTargetEnv::parse_triple("spirv-unknown-spv1.0") .unwrap() .rustc_target(); let sm_inputs = rustc_span::source_map::SourceMapInputs { diff --git a/crates/rustc_codegen_spirv/src/target.rs b/crates/rustc_codegen_spirv/src/target.rs index 8a6cdaf03f..c9912877da 100644 --- a/crates/rustc_codegen_spirv/src/target.rs +++ b/crates/rustc_codegen_spirv/src/target.rs @@ -1,55 +1,70 @@ use rspirv::spirv::MemoryModel; +use rustc_codegen_spirv_target_specs::{SPIRV_ARCH, SPIRV_VENDOR, SpirvTargetEnv}; use rustc_target::spec::{Cc, LinkerFlavor, PanicStrategy, Target, TargetOptions}; -use spirv_tools::TargetEnv; -const ARCH: &str = "spirv"; - -pub struct SpirvTarget { - env: TargetEnv, - vendor: String, +pub trait TargetsExt { + fn memory_model(&self) -> MemoryModel; + fn to_spirv_tools(&self) -> spirv_tools::TargetEnv; + fn spirv_version(&self) -> (u8, u8); + fn rustc_target(&self) -> Target; } -impl SpirvTarget { - pub fn memory_model(&self) -> MemoryModel { - match self.env { - TargetEnv::Universal_1_0 - | TargetEnv::Universal_1_1 - | TargetEnv::Universal_1_2 - | TargetEnv::Universal_1_3 - | TargetEnv::Universal_1_4 - | TargetEnv::Universal_1_5 - | TargetEnv::Universal_1_6 => MemoryModel::Simple, - - TargetEnv::OpenGL_4_0 - | TargetEnv::OpenGL_4_1 - | TargetEnv::OpenGL_4_2 - | TargetEnv::OpenGL_4_3 - | TargetEnv::OpenGL_4_5 => MemoryModel::GLSL450, - - TargetEnv::OpenCL_2_1 - | TargetEnv::OpenCL_2_2 - | TargetEnv::OpenCL_1_2 - | TargetEnv::OpenCLEmbedded_1_2 - | TargetEnv::OpenCL_2_0 - | TargetEnv::OpenCLEmbedded_2_0 - | TargetEnv::OpenCLEmbedded_2_1 - | TargetEnv::OpenCLEmbedded_2_2 => MemoryModel::OpenCL, +impl TargetsExt for SpirvTargetEnv { + #[allow(clippy::match_same_arms)] + fn memory_model(&self) -> MemoryModel { + match self { + SpirvTargetEnv::Spv_1_0 + | SpirvTargetEnv::Spv_1_1 + | SpirvTargetEnv::Spv_1_2 + | SpirvTargetEnv::Spv_1_3 + | SpirvTargetEnv::Spv_1_4 + | SpirvTargetEnv::Spv_1_5 + | SpirvTargetEnv::Spv_1_6 => MemoryModel::Simple, + + SpirvTargetEnv::OpenGL_4_0 + | SpirvTargetEnv::OpenGL_4_1 + | SpirvTargetEnv::OpenGL_4_2 + | SpirvTargetEnv::OpenGL_4_3 + | SpirvTargetEnv::OpenGL_4_5 => MemoryModel::GLSL450, + + SpirvTargetEnv::Vulkan_1_0 + | SpirvTargetEnv::Vulkan_1_1 + | SpirvTargetEnv::Vulkan_1_1_Spv_1_4 + | SpirvTargetEnv::Vulkan_1_2 + | SpirvTargetEnv::Vulkan_1_3 + | SpirvTargetEnv::Vulkan_1_4 => MemoryModel::Vulkan, + } + } - TargetEnv::Vulkan_1_0 - | TargetEnv::Vulkan_1_1 - | TargetEnv::WebGPU_0 - | TargetEnv::Vulkan_1_1_Spirv_1_4 - | TargetEnv::Vulkan_1_2 - | TargetEnv::Vulkan_1_3 - | TargetEnv::Vulkan_1_4 => MemoryModel::Vulkan, + #[allow(clippy::match_same_arms)] + fn to_spirv_tools(&self) -> spirv_tools::TargetEnv { + match self { + SpirvTargetEnv::OpenGL_4_0 => spirv_tools::TargetEnv::OpenGL_4_0, + SpirvTargetEnv::OpenGL_4_1 => spirv_tools::TargetEnv::OpenGL_4_1, + SpirvTargetEnv::OpenGL_4_2 => spirv_tools::TargetEnv::OpenGL_4_2, + SpirvTargetEnv::OpenGL_4_3 => spirv_tools::TargetEnv::OpenGL_4_3, + SpirvTargetEnv::OpenGL_4_5 => spirv_tools::TargetEnv::OpenGL_4_5, + SpirvTargetEnv::Spv_1_0 => spirv_tools::TargetEnv::Universal_1_0, + SpirvTargetEnv::Spv_1_1 => spirv_tools::TargetEnv::Universal_1_1, + SpirvTargetEnv::Spv_1_2 => spirv_tools::TargetEnv::Universal_1_2, + SpirvTargetEnv::Spv_1_3 => spirv_tools::TargetEnv::Universal_1_3, + SpirvTargetEnv::Spv_1_4 => spirv_tools::TargetEnv::Universal_1_4, + SpirvTargetEnv::Spv_1_5 => spirv_tools::TargetEnv::Universal_1_5, + SpirvTargetEnv::Spv_1_6 => spirv_tools::TargetEnv::Universal_1_6, + SpirvTargetEnv::Vulkan_1_0 => spirv_tools::TargetEnv::Vulkan_1_0, + SpirvTargetEnv::Vulkan_1_1 => spirv_tools::TargetEnv::Vulkan_1_1, + SpirvTargetEnv::Vulkan_1_1_Spv_1_4 => spirv_tools::TargetEnv::Vulkan_1_1_Spirv_1_4, + SpirvTargetEnv::Vulkan_1_2 => spirv_tools::TargetEnv::Vulkan_1_2, + SpirvTargetEnv::Vulkan_1_3 => spirv_tools::TargetEnv::Vulkan_1_3, + SpirvTargetEnv::Vulkan_1_4 => spirv_tools::TargetEnv::Vulkan_1_4, } } - pub fn spirv_version(&self) -> (u8, u8) { - self.env.spirv_version() + fn spirv_version(&self) -> (u8, u8) { + self.to_spirv_tools().spirv_version() } - fn init_target_opts(&self) -> TargetOptions { + fn rustc_target(&self) -> Target { let mut o = TargetOptions::default(); o.simd_types_indirect = false; o.allows_weak_linkage = false; @@ -61,69 +76,18 @@ impl SpirvTarget { o.linker_flavor = LinkerFlavor::Unix(Cc::No); o.panic_strategy = PanicStrategy::Abort; o.os = "unknown".into(); - o.env = self.env.to_string().into(); - o.vendor = self.vendor.clone().into(); + o.env = self.as_str().into(); + o.vendor = SPIRV_VENDOR.into(); // TODO: Investigate if main_needs_argc_argv is useful (for building exes) o.main_needs_argc_argv = false; - o - } - pub fn rustc_target(&self) -> Target { Target { - llvm_target: self.to_string().into(), + llvm_target: self.target_triple().into(), metadata: Default::default(), pointer_width: 32, data_layout: "e-m:e-p:32:32:32-i64:64-n8:16:32:64".into(), - arch: ARCH.into(), - options: self.init_target_opts(), - } - } -} - -impl std::str::FromStr for SpirvTarget { - type Err = InvalidTarget; - - fn from_str(target: &str) -> Result { - let mut iter = target.split('-'); - let error = || InvalidTarget(target.into()); - - if iter.next() != Some(ARCH) { - return Err(error()); + arch: SPIRV_ARCH.into(), + options: o, } - - let vendor = iter.next().map(From::from).ok_or_else(error)?; - - let env = iter - .next() - .and_then(|env| env.parse().ok()) - .ok_or_else(error)?; - - if iter.next().is_some() { - return Err(error()); - } - - let result = Self { env, vendor }; - - if result.memory_model() == MemoryModel::OpenCL { - return Err(error()); - } - - Ok(result) - } -} - -impl std::fmt::Display for SpirvTarget { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}-{}-{}", ARCH, self.vendor, self.env) - } -} - -#[derive(Debug)] -pub struct InvalidTarget(String); - -impl std::error::Error for InvalidTarget {} -impl std::fmt::Display for InvalidTarget { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "Invalid target `{}`.", self.0) } } diff --git a/crates/spirv-builder/Cargo.toml b/crates/spirv-builder/Cargo.toml index f5c1bd2206..76db88c988 100644 --- a/crates/spirv-builder/Cargo.toml +++ b/crates/spirv-builder/Cargo.toml @@ -24,7 +24,7 @@ default = ["use-compiled-tools"] rustc_codegen_spirv = ["dep:rustc_codegen_spirv"] # Inclide target spec json files, allows constructing SpirvBuilder without # explicitly passing a path to the target spec json -include-target-specs = ["dep:rustc_codegen_spirv-target-specs"] +include-target-specs = ["rustc_codegen_spirv-target-specs/dir_path"] # See `rustc_codegen_spirv/Cargo.toml` for details on these features. # We add new "default" features to `use-installed-tools` and `use-compiled-tools` to keep # backwards compat with `default-features = false, features = "use-installed-tools"` setups @@ -38,7 +38,7 @@ clap = ["dep:clap"] [dependencies] rustc_codegen_spirv = { workspace = true, optional = true } rustc_codegen_spirv-types = { workspace = true } -rustc_codegen_spirv-target-specs = { workspace = true, features = ["dir_path"], optional = true } +rustc_codegen_spirv-target-specs = { workspace = true } memchr = "2.4" raw-string = "0.3.5" diff --git a/crates/spirv-builder/src/lib.rs b/crates/spirv-builder/src/lib.rs index c757b59f63..1ea4b886fc 100644 --- a/crates/spirv-builder/src/lib.rs +++ b/crates/spirv-builder/src/lib.rs @@ -77,6 +77,7 @@ mod depfile; mod watch; use raw_string::{RawStr, RawString}; +use rustc_codegen_spirv_target_specs::SpirvTargetEnv; use semver::Version; use serde::Deserialize; use std::borrow::Borrow; @@ -88,8 +89,7 @@ use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; use thiserror::Error; -pub use rustc_codegen_spirv_types::Capability; -pub use rustc_codegen_spirv_types::{CompileResult, ModuleResult}; +pub use rustc_codegen_spirv_types::*; #[cfg(feature = "include-target-specs")] pub use rustc_codegen_spirv_target_specs::TARGET_SPEC_DIR_PATH; @@ -99,10 +99,8 @@ pub use rustc_codegen_spirv_target_specs::TARGET_SPEC_DIR_PATH; pub enum SpirvBuilderError { #[error("`target` must be set, for example `spirv-unknown-vulkan1.2`")] MissingTarget, - #[error("expected `{SPIRV_TARGET_PREFIX}...` target, found `{target}`")] - NonSpirvTarget { target: String }, - #[error("SPIR-V target `{SPIRV_TARGET_PREFIX}-{target_env}` is not supported")] - UnsupportedSpirvTargetEnv { target_env: String }, + #[error("Unknown target `{target}`")] + UnknownTarget { target: String }, #[error("`path_to_crate` must be set")] MissingCratePath, #[error("crate path '{0}' does not exist")] @@ -132,8 +130,6 @@ pub enum SpirvBuilderError { CargoMetadata(#[from] cargo_metadata::Error), } -const SPIRV_TARGET_PREFIX: &str = "spirv-unknown-"; - #[derive(Debug, PartialEq, Eq, Clone, Copy, Default, serde::Deserialize, serde::Serialize)] #[cfg_attr(feature = "clap", derive(clap::ValueEnum))] #[non_exhaustive] @@ -764,44 +760,20 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result { .target .as_ref() .ok_or(SpirvBuilderError::MissingTarget)?; + let target = SpirvTargetEnv::parse_triple(target).ok_or(SpirvBuilderError::UnknownTarget { + target: target.clone(), + })?; let path_to_crate = builder .path_to_crate .as_ref() .ok_or(SpirvBuilderError::MissingCratePath)?; - { - let target_env = target.strip_prefix(SPIRV_TARGET_PREFIX).ok_or_else(|| { - SpirvBuilderError::NonSpirvTarget { - target: target.clone(), - } - })?; - // HACK(eddyb) used only to split the full list into groups. - #[allow(clippy::match_same_arms)] - match target_env { - // HACK(eddyb) hardcoded list to avoid checking if the JSON file - // for a particular target exists (and sanitizing strings for paths). - // - // FIXME(eddyb) consider moving this list, or even `target-specs`, - // into `rustc_codegen_spirv_types`'s code/source. - "spv1.0" | "spv1.1" | "spv1.2" | "spv1.3" | "spv1.4" | "spv1.5" | "spv1.6" => {} - "opengl4.0" | "opengl4.1" | "opengl4.2" | "opengl4.3" | "opengl4.5" => {} - "vulkan1.0" | "vulkan1.1" | "vulkan1.1spv1.4" | "vulkan1.2" | "vulkan1.3" - | "vulkan1.4" => {} - - _ => { - return Err(SpirvBuilderError::UnsupportedSpirvTargetEnv { - target_env: target_env.into(), - }); - } - } - - if (builder.print_metadata == MetadataPrintout::Full) && builder.multimodule { - return Err(SpirvBuilderError::MultiModuleWithPrintMetadata); - } - if !path_to_crate.is_dir() { - return Err(SpirvBuilderError::CratePathDoesntExist( - path_to_crate.clone(), - )); - } + if (builder.print_metadata == MetadataPrintout::Full) && builder.multimodule { + return Err(SpirvBuilderError::MultiModuleWithPrintMetadata); + } + if !path_to_crate.is_dir() { + return Err(SpirvBuilderError::CratePathDoesntExist( + path_to_crate.clone(), + )); } let toolchain_rustc_version = @@ -984,8 +956,7 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result { let path; #[cfg(feature = "include-target-specs")] { - path = path_opt - .unwrap_or_else(|| PathBuf::from(format!("{TARGET_SPEC_DIR_PATH}/{target}.json"))); + path = path_opt.unwrap_or_else(|| PathBuf::from(target.target_json_path())); } #[cfg(not(feature = "include-target-specs"))] { @@ -993,7 +964,7 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result { } cargo.arg("--target").arg(path); } else { - cargo.arg("--target").arg(target); + cargo.arg("--target").arg(target.target_triple()); } if !builder.shader_crate_features.default_features { diff --git a/tests/compiletests/src/main.rs b/tests/compiletests/src/main.rs index ffb42b0577..37f57a0949 100644 --- a/tests/compiletests/src/main.rs +++ b/tests/compiletests/src/main.rs @@ -1,6 +1,6 @@ use clap::Parser; use itertools::Itertools as _; -use rustc_codegen_spirv_target_specs::TARGET_SPEC_DIR_PATH; +use rustc_codegen_spirv_target_specs::SpirvTargetEnv; use std::{ env, io, path::{Path, PathBuf}, @@ -28,12 +28,6 @@ impl Opt { } } -const SPIRV_TARGET_PREFIX: &str = "spirv-unknown-"; - -fn target_spec_json(target: &str) -> String { - format!("{TARGET_SPEC_DIR_PATH}/{target}.json") -} - #[derive(Copy, Clone)] enum DepKind { SpirvLib, @@ -48,9 +42,9 @@ impl DepKind { } } - fn target_dir_suffix(self, target: &str) -> String { + fn target_dir_suffix(self, target: SpirvTargetEnv) -> String { match self { - Self::SpirvLib => format!("{target}/debug/deps"), + Self::SpirvLib => format!("{}/debug/deps", target.target_triple()), Self::ProcMacro => "debug/deps".into(), } } @@ -134,32 +128,38 @@ impl Runner { extra_flags: "", }]; - for (env, variation) in self + for (target, variation) in self .opt .environments() - .flat_map(|env| VARIATIONS.iter().map(move |variation| (env, variation))) + .flat_map(|target| VARIATIONS.iter().map(move |variation| (target, variation))) { + let target = if target.contains("-") { + SpirvTargetEnv::parse_triple(target) + } else { + SpirvTargetEnv::parse_triple(&format!("spirv-unknown-{target}")) + } + .unwrap_or_else(|| panic!("unknown target {}", target)); + // HACK(eddyb) in order to allow *some* tests to have separate output // in different testing variations (i.e. experimental features), while // keeping *most* of the tests unchanged, we make use of "stage IDs", // which offer `// only-S` and `// ignore-S` for any stage ID `S`. let stage_id = if variation.name == "default" { // Use the environment name as the stage ID. - env.to_string() + target.to_string() } else { // Include the variation name in the stage ID. - format!("{}-{}", env, variation.name) + format!("{}-{}", target, variation.name) }; - let target = format!("{SPIRV_TARGET_PREFIX}{env}"); - let libs = build_deps(&self.deps_target_dir, &self.codegen_backend_path, &target); + let libs = build_deps(&self.deps_target_dir, &self.codegen_backend_path, target); let mut flags = test_rustc_flags(&self.codegen_backend_path, &libs, &[ &self .deps_target_dir - .join(DepKind::SpirvLib.target_dir_suffix(&target)), + .join(DepKind::SpirvLib.target_dir_suffix(target)), &self .deps_target_dir - .join(DepKind::ProcMacro.target_dir_suffix(&target)), + .join(DepKind::ProcMacro.target_dir_suffix(target)), ]); flags += variation.extra_flags; @@ -167,7 +167,7 @@ impl Runner { stage_id, target_rustcflags: Some(flags), mode: mode.parse().expect("Invalid mode"), - target: target_spec_json(&target), + target: target.target_json_path(), src_base: self.tests_dir.join(mode), build_base: self.compiletest_build_dir.clone(), bless: self.opt.bless, @@ -183,7 +183,11 @@ impl Runner { } /// Runs the processes needed to build `spirv-std` & other deps. -fn build_deps(deps_target_dir: &Path, codegen_backend_path: &Path, target: &str) -> TestDeps { +fn build_deps( + deps_target_dir: &Path, + codegen_backend_path: &Path, + target: SpirvTargetEnv, +) -> TestDeps { // Build compiletests-deps-helper std::process::Command::new("cargo") .args([ @@ -192,7 +196,7 @@ fn build_deps(deps_target_dir: &Path, codegen_backend_path: &Path, target: &str) "compiletests-deps-helper", "-Zbuild-std=core", "-Zbuild-std-features=compiler-builtins-mem", - &*format!("--target={}", target_spec_json(target)), + &*format!("--target={}", target.target_json_path()), ]) .arg("--target-dir") .arg(deps_target_dir) @@ -277,7 +281,7 @@ fn find_lib( deps_target_dir: &Path, base: impl AsRef, dep_kind: DepKind, - target: &str, + target: SpirvTargetEnv, ) -> Result { let base = base.as_ref(); let (expected_prefix, expected_extension) = dep_kind.prefix_and_extension(); diff --git a/tests/difftests/tests/Cargo.lock b/tests/difftests/tests/Cargo.lock index 7ad114e41e..45e25a248a 100644 --- a/tests/difftests/tests/Cargo.lock +++ b/tests/difftests/tests/Cargo.lock @@ -847,6 +847,13 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc_codegen_spirv-target-specs" +version = "0.9.0" +dependencies = [ + "strum", +] + [[package]] name = "rustc_codegen_spirv-types" version = "0.9.0" @@ -985,6 +992,7 @@ dependencies = [ "cargo_metadata", "memchr", "raw-string", + "rustc_codegen_spirv-target-specs", "rustc_codegen_spirv-types", "semver", "serde", From 436815892b33af413ff75810edba4ad5305bec11 Mon Sep 17 00:00:00 2001 From: Firestar99 Date: Thu, 12 Jun 2025 19:23:26 +0200 Subject: [PATCH 04/10] wgsl: add `spirv-unknown-wgsl` target, transpiling with naga --- Cargo.lock | 1 + .../src/include_str.rs | 3 + .../src/lib.rs | 4 +- .../target-specs/spirv-unknown-wgsl.json | 26 +++++++ crates/rustc_codegen_spirv/Cargo.toml | 1 + crates/rustc_codegen_spirv/src/lib.rs | 1 + crates/rustc_codegen_spirv/src/link.rs | 5 ++ .../rustc_codegen_spirv/src/naga_transpile.rs | 75 +++++++++++++++++++ crates/rustc_codegen_spirv/src/target.rs | 4 + 9 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 crates/rustc_codegen_spirv-target-specs/target-specs/spirv-unknown-wgsl.json create mode 100644 crates/rustc_codegen_spirv/src/naga_transpile.rs diff --git a/Cargo.lock b/Cargo.lock index f963daf9c2..966b9a6f6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2433,6 +2433,7 @@ dependencies = [ "lazy_static", "libc", "log", + "naga", "object", "pretty_assertions", "regex", diff --git a/crates/rustc_codegen_spirv-target-specs/src/include_str.rs b/crates/rustc_codegen_spirv-target-specs/src/include_str.rs index 93941e8da4..ab6b7a4415 100644 --- a/crates/rustc_codegen_spirv-target-specs/src/include_str.rs +++ b/crates/rustc_codegen_spirv-target-specs/src/include_str.rs @@ -59,6 +59,9 @@ impl SpirvTargetEnv { SpirvTargetEnv::Vulkan_1_4 => { include_str!("../target-specs/spirv-unknown-vulkan1.4.json") } + SpirvTargetEnv::Wgsl => { + include_str!("../target-specs/spirv-unknown-wgsl.json") + } } } } diff --git a/crates/rustc_codegen_spirv-target-specs/src/lib.rs b/crates/rustc_codegen_spirv-target-specs/src/lib.rs index b3a830ee82..1984fbc1ac 100644 --- a/crates/rustc_codegen_spirv-target-specs/src/lib.rs +++ b/crates/rustc_codegen_spirv-target-specs/src/lib.rs @@ -52,6 +52,8 @@ pub enum SpirvTargetEnv { Vulkan_1_3, #[strum(to_string = "vulkan1.4")] Vulkan_1_4, + #[strum(to_string = "wgsl")] + Wgsl, } impl SpirvTargetEnv { @@ -93,7 +95,7 @@ mod tests { #[test] pub fn test_parse_as_str_loop() { for target in SpirvTargetEnv::iter() { - let parsed = SpirvTargetEnv::parse_triple(target.as_str()).unwrap(); + let parsed = SpirvTargetEnv::parse_triple(&target.target_triple()).unwrap(); assert_eq!(target, parsed); } } diff --git a/crates/rustc_codegen_spirv-target-specs/target-specs/spirv-unknown-wgsl.json b/crates/rustc_codegen_spirv-target-specs/target-specs/spirv-unknown-wgsl.json new file mode 100644 index 0000000000..602d077026 --- /dev/null +++ b/crates/rustc_codegen_spirv-target-specs/target-specs/spirv-unknown-wgsl.json @@ -0,0 +1,26 @@ +{ + "allows-weak-linkage": false, + "arch": "spirv", + "crt-objects-fallback": "false", + "crt-static-allows-dylibs": true, + "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", + "dll-prefix": "", + "dll-suffix": ".spv.json", + "dynamic-linking": true, + "emit-debug-gdb-scripts": false, + "env": "wgsl", + "linker-flavor": "unix", + "linker-is-gnu": false, + "llvm-target": "spirv-unknown-wgsl", + "main-needs-argc-argv": false, + "metadata": { + "description": null, + "host_tools": null, + "std": null, + "tier": null + }, + "os": "unknown", + "panic-strategy": "abort", + "simd-types-indirect": false, + "target-pointer-width": "32" +} diff --git a/crates/rustc_codegen_spirv/Cargo.toml b/crates/rustc_codegen_spirv/Cargo.toml index 5af8dbea20..1e08fe839c 100644 --- a/crates/rustc_codegen_spirv/Cargo.toml +++ b/crates/rustc_codegen_spirv/Cargo.toml @@ -60,6 +60,7 @@ itertools = "0.10.5" tracing.workspace = true tracing-subscriber.workspace = true tracing-tree = "0.3.0" +naga = { version = "25.0.1", features = ["spv-in", "wgsl-out"] } # required for cargo gpu to resolve the needed target specs rustc_codegen_spirv-target-specs.workspace = true diff --git a/crates/rustc_codegen_spirv/src/lib.rs b/crates/rustc_codegen_spirv/src/lib.rs index 82d8e8e7a2..2422bc42a8 100644 --- a/crates/rustc_codegen_spirv/src/lib.rs +++ b/crates/rustc_codegen_spirv/src/lib.rs @@ -129,6 +129,7 @@ mod custom_decorations; mod custom_insts; mod link; mod linker; +mod naga_transpile; mod spirv_type; mod spirv_type_constraints; mod symbols; diff --git a/crates/rustc_codegen_spirv/src/link.rs b/crates/rustc_codegen_spirv/src/link.rs index 4c702b7c78..21771f9041 100644 --- a/crates/rustc_codegen_spirv/src/link.rs +++ b/crates/rustc_codegen_spirv/src/link.rs @@ -2,6 +2,7 @@ use crate::maybe_pqp_cg_ssa as rustc_codegen_ssa; use crate::codegen_cx::{CodegenArgs, SpirvMetadata}; +use crate::naga_transpile::should_transpile; use crate::{SpirvCodegenBackend, SpirvModuleBuffer, SpirvThinBuffer, linker}; use ar::{Archive, GnuBuilder, Header}; use rspirv::binary::Assemble; @@ -311,6 +312,10 @@ fn post_link_single_module( drop(save_modules_timer); } + + if let Some(transpile) = should_transpile(sess) { + transpile(sess, cg_args, &spv_binary, out_filename).ok(); + } } fn do_spirv_opt( diff --git a/crates/rustc_codegen_spirv/src/naga_transpile.rs b/crates/rustc_codegen_spirv/src/naga_transpile.rs new file mode 100644 index 0000000000..0acb2b5bce --- /dev/null +++ b/crates/rustc_codegen_spirv/src/naga_transpile.rs @@ -0,0 +1,75 @@ +use crate::codegen_cx::CodegenArgs; +use rustc_codegen_spirv_target_specs::SpirvTargetEnv; +use rustc_session::Session; +use rustc_span::ErrorGuaranteed; +use std::path::Path; + +pub type NagaTranspile = fn( + sess: &Session, + cg_args: &CodegenArgs, + spv_binary: &[u32], + out_filename: &Path, +) -> Result<(), ErrorGuaranteed>; + +pub fn should_transpile(sess: &Session) -> Option { + let target = SpirvTargetEnv::parse_triple(sess.opts.target_triple.tuple()) + .expect("parsing should fail earlier"); + match target { + SpirvTargetEnv::Wgsl => Some(transpile::wgsl_transpile), + _ => None, + } +} + +mod transpile { + use crate::codegen_cx::CodegenArgs; + use naga::error::ShaderError; + use naga::valid::Capabilities; + use rustc_session::Session; + use rustc_span::ErrorGuaranteed; + use std::path::Path; + + pub fn wgsl_transpile( + sess: &Session, + _cg_args: &CodegenArgs, + spv_binary: &[u32], + out_filename: &Path, + ) -> Result<(), ErrorGuaranteed> { + // these should be params via spirv-builder + let opts = naga::front::spv::Options::default(); + let capabilities = Capabilities::default(); + let writer_flags = naga::back::wgsl::WriterFlags::empty(); + + let module = naga::front::spv::parse_u8_slice(bytemuck::cast_slice(spv_binary), &opts) + .map_err(|err| { + sess.dcx() + .err(format!("Naga failed to parse spv: \n{}", ShaderError { + source: String::new(), + label: None, + inner: Box::new(err), + })) + })?; + let mut validator = + naga::valid::Validator::new(naga::valid::ValidationFlags::default(), capabilities); + let info = validator.validate(&module).map_err(|err| { + sess.dcx() + .err(format!("Naga validation failed: \n{}", ShaderError { + source: String::new(), + label: None, + inner: Box::new(err), + })) + })?; + + let wgsl_dst = out_filename.with_extension("wgsl"); + let wgsl = naga::back::wgsl::write_string(&module, &info, writer_flags).map_err(|err| { + sess.dcx() + .err(format!("Naga failed to write wgsl : \n{}", err)) + })?; + + std::fs::write(&wgsl_dst, wgsl).map_err(|err| { + sess.dcx() + .err(format!("failed to write wgsl to file: {}", err)) + })?; + + Ok(()) + } +} diff --git a/crates/rustc_codegen_spirv/src/target.rs b/crates/rustc_codegen_spirv/src/target.rs index c9912877da..9ea4822a04 100644 --- a/crates/rustc_codegen_spirv/src/target.rs +++ b/crates/rustc_codegen_spirv/src/target.rs @@ -33,6 +33,8 @@ impl TargetsExt for SpirvTargetEnv { | SpirvTargetEnv::Vulkan_1_2 | SpirvTargetEnv::Vulkan_1_3 | SpirvTargetEnv::Vulkan_1_4 => MemoryModel::Vulkan, + + SpirvTargetEnv::Wgsl => MemoryModel::Vulkan, } } @@ -57,6 +59,8 @@ impl TargetsExt for SpirvTargetEnv { SpirvTargetEnv::Vulkan_1_2 => spirv_tools::TargetEnv::Vulkan_1_2, SpirvTargetEnv::Vulkan_1_3 => spirv_tools::TargetEnv::Vulkan_1_3, SpirvTargetEnv::Vulkan_1_4 => spirv_tools::TargetEnv::Vulkan_1_4, + + SpirvTargetEnv::Wgsl => spirv_tools::TargetEnv::Vulkan_1_2, } } From 203396c4e8f44adc938670704356b31736deb5d5 Mon Sep 17 00:00:00 2001 From: Firestar99 Date: Mon, 16 Jun 2025 09:50:52 +0200 Subject: [PATCH 05/10] spirv-std: never disable `read_shader_clock()` intrinsics based on target features --- crates/spirv-std/src/arch.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/crates/spirv-std/src/arch.rs b/crates/spirv-std/src/arch.rs index 2d9ccdfded..95e7d908d8 100644 --- a/crates/spirv-std/src/arch.rs +++ b/crates/spirv-std/src/arch.rs @@ -147,11 +147,6 @@ pub fn kill() -> ! { /// /// See: /// -#[cfg(all( - target_feature = "Int64", - target_feature = "ShaderClockKHR", - target_feature = "ext:SPV_KHR_shader_clock" -))] #[spirv_std_macros::gpu_only] #[doc(alias = "OpReadClockKHR")] pub unsafe fn read_clock_khr() -> u64 { @@ -172,10 +167,6 @@ pub unsafe fn read_clock_khr() -> u64 { /// capability. It returns a 'vector of two-components of 32-bit unsigned /// integer type with the first component containing the 32 least significant /// bits and the second component containing the 32 most significant bits.' -#[cfg(all( - target_feature = "ShaderClockKHR", - target_feature = "ext:SPV_KHR_shader_clock" -))] #[spirv_std_macros::gpu_only] #[doc(alias = "OpReadClockKHR")] pub unsafe fn read_clock_uvec2_khr, const SCOPE: u32>() -> V { From 3ef086389fb0160e5388f421444d692994f5c619 Mon Sep 17 00:00:00 2001 From: Firestar99 Date: Mon, 16 Jun 2025 09:51:29 +0200 Subject: [PATCH 06/10] compiletest: remove ShaderClockKHR from implied target features, naga does not support it --- tests/compiletests/src/main.rs | 10 +--------- tests/compiletests/ui/dis/asm_op_decorate.stderr | 2 -- tests/compiletests/ui/dis/custom_entry_point.stderr | 2 -- tests/compiletests/ui/dis/generic-fn-op-name.stderr | 2 -- tests/compiletests/ui/dis/issue-723-output.stderr | 2 -- .../ui/dis/non-writable-storage_buffer.stderr | 2 -- .../ui/dis/panic_builtin_bounds_check.stderr | 2 -- tests/compiletests/ui/dis/panic_sequential_many.stderr | 2 -- tests/compiletests/ui/dis/spec_constant-attr.stderr | 2 -- 9 files changed, 1 insertion(+), 25 deletions(-) diff --git a/tests/compiletests/src/main.rs b/tests/compiletests/src/main.rs index 37f57a0949..20cb6e838d 100644 --- a/tests/compiletests/src/main.rs +++ b/tests/compiletests/src/main.rs @@ -346,15 +346,7 @@ struct TestDeps { /// The RUSTFLAGS passed to all SPIR-V builds. // FIXME(eddyb) expose most of these from `spirv-builder`. fn rust_flags(codegen_backend_path: &Path) -> String { - let target_features = [ - "Int8", - "Int16", - "Int64", - "Float64", - // Only needed for `ui/arch/read_clock_khr.rs`. - "ShaderClockKHR", - "ext:SPV_KHR_shader_clock", - ]; + let target_features = ["Int8", "Int16", "Int64", "Float64"]; [ &*format!("-Zcodegen-backend={}", codegen_backend_path.display()), diff --git a/tests/compiletests/ui/dis/asm_op_decorate.stderr b/tests/compiletests/ui/dis/asm_op_decorate.stderr index 7364346cab..bb0bf87147 100644 --- a/tests/compiletests/ui/dis/asm_op_decorate.stderr +++ b/tests/compiletests/ui/dis/asm_op_decorate.stderr @@ -3,10 +3,8 @@ OpCapability Float64 OpCapability Int64 OpCapability Int16 OpCapability Int8 -OpCapability ShaderClockKHR OpCapability RuntimeDescriptorArray OpExtension "SPV_EXT_descriptor_indexing" -OpExtension "SPV_KHR_shader_clock" OpMemoryModel Logical Simple OpEntryPoint Fragment %1 "main" OpExecutionMode %1 OriginUpperLeft diff --git a/tests/compiletests/ui/dis/custom_entry_point.stderr b/tests/compiletests/ui/dis/custom_entry_point.stderr index e243af37f7..5132df948a 100644 --- a/tests/compiletests/ui/dis/custom_entry_point.stderr +++ b/tests/compiletests/ui/dis/custom_entry_point.stderr @@ -3,8 +3,6 @@ OpCapability Float64 OpCapability Int64 OpCapability Int16 OpCapability Int8 -OpCapability ShaderClockKHR -OpExtension "SPV_KHR_shader_clock" OpMemoryModel Logical Simple OpEntryPoint Fragment %1 "hello_world" OpExecutionMode %1 OriginUpperLeft diff --git a/tests/compiletests/ui/dis/generic-fn-op-name.stderr b/tests/compiletests/ui/dis/generic-fn-op-name.stderr index 09d24a139e..d8eea9b9c4 100644 --- a/tests/compiletests/ui/dis/generic-fn-op-name.stderr +++ b/tests/compiletests/ui/dis/generic-fn-op-name.stderr @@ -3,8 +3,6 @@ OpCapability Float64 OpCapability Int64 OpCapability Int16 OpCapability Int8 -OpCapability ShaderClockKHR -OpExtension "SPV_KHR_shader_clock" OpMemoryModel Logical Simple OpEntryPoint Fragment %1 "main" OpExecutionMode %1 OriginUpperLeft diff --git a/tests/compiletests/ui/dis/issue-723-output.stderr b/tests/compiletests/ui/dis/issue-723-output.stderr index e6c4b35256..e3ea37dbe7 100644 --- a/tests/compiletests/ui/dis/issue-723-output.stderr +++ b/tests/compiletests/ui/dis/issue-723-output.stderr @@ -3,8 +3,6 @@ OpCapability Float64 OpCapability Int64 OpCapability Int16 OpCapability Int8 -OpCapability ShaderClockKHR -OpExtension "SPV_KHR_shader_clock" OpMemoryModel Logical Simple OpEntryPoint Fragment %1 "main" %2 OpExecutionMode %1 OriginUpperLeft diff --git a/tests/compiletests/ui/dis/non-writable-storage_buffer.stderr b/tests/compiletests/ui/dis/non-writable-storage_buffer.stderr index f36836e850..823fef4a29 100644 --- a/tests/compiletests/ui/dis/non-writable-storage_buffer.stderr +++ b/tests/compiletests/ui/dis/non-writable-storage_buffer.stderr @@ -3,8 +3,6 @@ OpCapability Float64 OpCapability Int64 OpCapability Int16 OpCapability Int8 -OpCapability ShaderClockKHR -OpExtension "SPV_KHR_shader_clock" OpMemoryModel Logical Simple OpEntryPoint Fragment %1 "main" OpExecutionMode %1 OriginUpperLeft diff --git a/tests/compiletests/ui/dis/panic_builtin_bounds_check.stderr b/tests/compiletests/ui/dis/panic_builtin_bounds_check.stderr index e1c8f3b28c..69712fbd74 100644 --- a/tests/compiletests/ui/dis/panic_builtin_bounds_check.stderr +++ b/tests/compiletests/ui/dis/panic_builtin_bounds_check.stderr @@ -3,9 +3,7 @@ OpCapability Float64 OpCapability Int64 OpCapability Int16 OpCapability Int8 -OpCapability ShaderClockKHR OpExtension "SPV_KHR_non_semantic_info" -OpExtension "SPV_KHR_shader_clock" %1 = OpExtInstImport "NonSemantic.DebugPrintf" OpMemoryModel Logical Simple OpEntryPoint Fragment %2 "main" diff --git a/tests/compiletests/ui/dis/panic_sequential_many.stderr b/tests/compiletests/ui/dis/panic_sequential_many.stderr index d748d2fd49..94a4ddabac 100644 --- a/tests/compiletests/ui/dis/panic_sequential_many.stderr +++ b/tests/compiletests/ui/dis/panic_sequential_many.stderr @@ -3,9 +3,7 @@ OpCapability Float64 OpCapability Int64 OpCapability Int16 OpCapability Int8 -OpCapability ShaderClockKHR OpExtension "SPV_KHR_non_semantic_info" -OpExtension "SPV_KHR_shader_clock" %1 = OpExtInstImport "NonSemantic.DebugPrintf" OpMemoryModel Logical Simple OpEntryPoint Fragment %2 "main" %3 %4 %5 diff --git a/tests/compiletests/ui/dis/spec_constant-attr.stderr b/tests/compiletests/ui/dis/spec_constant-attr.stderr index 5cdc1f968d..8619e3f39d 100644 --- a/tests/compiletests/ui/dis/spec_constant-attr.stderr +++ b/tests/compiletests/ui/dis/spec_constant-attr.stderr @@ -3,8 +3,6 @@ OpCapability Float64 OpCapability Int64 OpCapability Int16 OpCapability Int8 -OpCapability ShaderClockKHR -OpExtension "SPV_KHR_shader_clock" OpMemoryModel Logical Simple OpEntryPoint Fragment %1 "main" %2 OpExecutionMode %1 OriginUpperLeft From a5e4aaff5dd3ee820d73ba946f84bdf64d5cdb23 Mon Sep 17 00:00:00 2001 From: Firestar99 Date: Mon, 16 Jun 2025 10:03:25 +0200 Subject: [PATCH 07/10] wgsl: hide naga behind feature --- crates/rustc_codegen_spirv/Cargo.toml | 3 ++- crates/rustc_codegen_spirv/src/link.rs | 6 ++++-- .../rustc_codegen_spirv/src/naga_transpile.rs | 20 ++++++++++++++----- tests/compiletests/Cargo.toml | 2 +- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/crates/rustc_codegen_spirv/Cargo.toml b/crates/rustc_codegen_spirv/Cargo.toml index 1e08fe839c..0408aebdd1 100644 --- a/crates/rustc_codegen_spirv/Cargo.toml +++ b/crates/rustc_codegen_spirv/Cargo.toml @@ -29,6 +29,7 @@ use-compiled-tools = ["spirv-tools/use-compiled-tools"] # and will likely produce compile errors when built against a different toolchain. # Enable this feature to be able to experiment with other versions. skip-toolchain-check = [] +naga = ["dep:naga"] [dependencies] # HACK(eddyb) these only exist to unify features across dependency trees, @@ -60,7 +61,7 @@ itertools = "0.10.5" tracing.workspace = true tracing-subscriber.workspace = true tracing-tree = "0.3.0" -naga = { version = "25.0.1", features = ["spv-in", "wgsl-out"] } +naga = { version = "25.0.1", features = ["spv-in", "wgsl-out"], optional = true } # required for cargo gpu to resolve the needed target specs rustc_codegen_spirv-target-specs.workspace = true diff --git a/crates/rustc_codegen_spirv/src/link.rs b/crates/rustc_codegen_spirv/src/link.rs index 21771f9041..e4dc0f03d3 100644 --- a/crates/rustc_codegen_spirv/src/link.rs +++ b/crates/rustc_codegen_spirv/src/link.rs @@ -313,8 +313,10 @@ fn post_link_single_module( drop(save_modules_timer); } - if let Some(transpile) = should_transpile(sess) { - transpile(sess, cg_args, &spv_binary, out_filename).ok(); + if let Ok(transpile) = should_transpile(sess) { + if let Some(transpile) = transpile { + transpile(sess, cg_args, &spv_binary, out_filename).ok(); + } } } diff --git a/crates/rustc_codegen_spirv/src/naga_transpile.rs b/crates/rustc_codegen_spirv/src/naga_transpile.rs index 0acb2b5bce..ba9cb4f580 100644 --- a/crates/rustc_codegen_spirv/src/naga_transpile.rs +++ b/crates/rustc_codegen_spirv/src/naga_transpile.rs @@ -11,15 +11,25 @@ pub type NagaTranspile = fn( out_filename: &Path, ) -> Result<(), ErrorGuaranteed>; -pub fn should_transpile(sess: &Session) -> Option { +pub fn should_transpile(sess: &Session) -> Result, ErrorGuaranteed> { let target = SpirvTargetEnv::parse_triple(sess.opts.target_triple.tuple()) .expect("parsing should fail earlier"); - match target { - SpirvTargetEnv::Wgsl => Some(transpile::wgsl_transpile), - _ => None, - } + let result: Result, ()> = match target { + #[cfg(feature = "naga")] + SpirvTargetEnv::Wgsl => Ok(Some(transpile::wgsl_transpile)), + #[cfg(not(feature = "naga"))] + SpirvTargetEnv::Wgsl => Err(()), + _ => Ok(None), + }; + result.map_err(|_| { + sess.dcx().err(format!( + "Target {} requires feature \"naga\" on rustc_codegen_spirv", + target.target_triple() + )) + }) } +#[cfg(feature = "naga")] mod transpile { use crate::codegen_cx::CodegenArgs; use naga::error::ShaderError; diff --git a/tests/compiletests/Cargo.toml b/tests/compiletests/Cargo.toml index b03db33b8e..1c45e1925b 100644 --- a/tests/compiletests/Cargo.toml +++ b/tests/compiletests/Cargo.toml @@ -15,7 +15,7 @@ use-compiled-tools = ["rustc_codegen_spirv/use-compiled-tools"] [dependencies] compiletest = { version = "0.11.2", package = "compiletest_rs" } -rustc_codegen_spirv = { workspace = true } +rustc_codegen_spirv = { workspace = true, features = ["naga"] } rustc_codegen_spirv-target-specs = { workspace = true, features = ["dir_path"] } clap = { version = "4", features = ["derive"] } itertools = "0.10.5" From 71e6ea4e208d1310fa18b1d3801d07d6bc15b2e6 Mon Sep 17 00:00:00 2001 From: Firestar99 Date: Mon, 16 Jun 2025 11:07:07 +0200 Subject: [PATCH 08/10] wgsl: ignore wgsl in compile tests with unsupported extensions or instructions --- .../ui/arch/all_memory_barrier.rs | 1 + ...convert_u_to_acceleration_structure_khr.rs | 1 + tests/compiletests/ui/arch/debug_printf.rs | 1 + .../ui/arch/demote_to_helper_invocation.rs | 1 + .../ui/arch/emit_stream_vertex.rs | 1 + tests/compiletests/ui/arch/emit_vertex.rs | 1 + tests/compiletests/ui/arch/end_primitive.rs | 1 + .../ui/arch/end_stream_primitive.rs | 1 + .../compiletests/ui/arch/execute_callable.rs | 1 + .../ui/arch/ignore_intersection_khr.rs | 1 + tests/compiletests/ui/arch/memory_barrier.rs | 1 + .../ray_query_confirm_intersection_khr.rs | 1 + ...query_get_intersection_barycentrics_khr.rs | 1 + ..._intersection_candidate_aabb_opaque_khr.rs | 1 + ...y_query_get_intersection_front_face_khr.rs | 1 + ...ery_get_intersection_geometry_index_khr.rs | 1 + ..._intersection_instance_custom_index_khr.rs | 1 + ..._query_get_intersection_instance_id_khr.rs | 1 + ...t_intersection_object_ray_direction_khr.rs | 1 + ..._get_intersection_object_ray_origin_khr.rs | 1 + ...ry_get_intersection_object_to_world_khr.rs | 1 + ...ry_get_intersection_primitive_index_khr.rs | 1 + ..._shader_binding_table_record_offset_khr.rs | 1 + .../arch/ray_query_get_intersection_t_khr.rs | 1 + .../ray_query_get_intersection_type_khr.rs | 1 + .../ui/arch/ray_query_get_ray_flags_khr.rs | 1 + .../ui/arch/ray_query_get_ray_t_min_khr.rs | 1 + .../ray_query_get_world_ray_direction_khr.rs | 1 + .../ray_query_get_world_ray_origin_khr.rs | 1 + .../ui/arch/ray_query_initialize_khr.rs | 1 + .../ui/arch/ray_query_terminate_khr.rs | 1 + tests/compiletests/ui/arch/read_clock_khr.rs | 1 + .../ui/arch/report_intersection_khr.rs | 1 + .../compiletests/ui/arch/terminate_ray_khr.rs | 1 + tests/compiletests/ui/arch/trace_ray_khr.rs | 1 + .../ui/arch/workgroup_memory_barrier.rs | 1 + tests/compiletests/ui/dis/asm.rs | 1 + tests/compiletests/ui/dis/asm.stderr | 2 +- tests/compiletests/ui/dis/asm_op_decorate.rs | 1 + .../ui/dis/complex_image_sample_inst.rs | 1 + .../ui/dis/complex_image_sample_inst.stderr | 2 +- .../ui/dis/non-writable-storage_buffer.rs | 1 + .../ui/dis/panic_builtin_bounds_check.rs | 2 + .../ui/dis/panic_builtin_bounds_check.stderr | 6 +- .../ui/dis/panic_sequential_many.rs | 2 + .../ui/dis/panic_sequential_many.stderr | 76 +++++++++---------- .../compiletests/ui/image/query/query_lod.rs | 1 + .../ui/image/query/rect_image_query_size.rs | 1 + .../sampled_image_rect_query_size_lod_err.rs | 1 + ...mpled_image_rect_query_size_lod_err.stderr | 4 +- .../ui/lang/asm/infer-access-chain-array.rs | 1 + .../compiletests/ui/spirv-attr/bool-inputs.rs | 1 + tests/compiletests/ui/spirv-attr/invariant.rs | 5 +- .../compiletests/ui/spirv-attr/matrix-type.rs | 1 + .../storage_class/runtime_descriptor_array.rs | 1 + .../runtime_descriptor_array_error.rs | 1 + .../runtime_descriptor_array_error.stderr | 8 +- .../typed_buffer_descriptor_array.rs | 1 + .../typed_buffer_descriptor_array_slice.rs | 1 + tests/compiletests/ui/target_features_err.rs | 1 + 60 files changed, 108 insertions(+), 50 deletions(-) diff --git a/tests/compiletests/ui/arch/all_memory_barrier.rs b/tests/compiletests/ui/arch/all_memory_barrier.rs index b3f6d2f374..2507788306 100644 --- a/tests/compiletests/ui/arch/all_memory_barrier.rs +++ b/tests/compiletests/ui/arch/all_memory_barrier.rs @@ -1,6 +1,7 @@ // build-pass // compile-flags: -C target-feature=+VulkanMemoryModelDeviceScopeKHR,+ext:SPV_KHR_vulkan_memory_model // compile-flags: -C llvm-args=--disassemble-fn=all_memory_barrier::all_memory_barrier +// ignore-wgsl use spirv_std::spirv; diff --git a/tests/compiletests/ui/arch/convert_u_to_acceleration_structure_khr.rs b/tests/compiletests/ui/arch/convert_u_to_acceleration_structure_khr.rs index b053ef6d87..c3a6ee89bd 100644 --- a/tests/compiletests/ui/arch/convert_u_to_acceleration_structure_khr.rs +++ b/tests/compiletests/ui/arch/convert_u_to_acceleration_structure_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayTracingKHR,+ext:SPV_KHR_ray_tracing +// ignore-wgsl use spirv_std::spirv; diff --git a/tests/compiletests/ui/arch/debug_printf.rs b/tests/compiletests/ui/arch/debug_printf.rs index e396b2f538..1c37084f7b 100644 --- a/tests/compiletests/ui/arch/debug_printf.rs +++ b/tests/compiletests/ui/arch/debug_printf.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+ext:SPV_KHR_non_semantic_info +// ignore-wgsl use spirv_std::spirv; use spirv_std::{ diff --git a/tests/compiletests/ui/arch/demote_to_helper_invocation.rs b/tests/compiletests/ui/arch/demote_to_helper_invocation.rs index 862b1f4a6b..fcaa27afb2 100644 --- a/tests/compiletests/ui/arch/demote_to_helper_invocation.rs +++ b/tests/compiletests/ui/arch/demote_to_helper_invocation.rs @@ -1,6 +1,7 @@ // build-pass // // compile-flags: -C target-feature=+DemoteToHelperInvocationEXT,+ext:SPV_EXT_demote_to_helper_invocation +// ignore-wgsl use spirv_std::spirv; diff --git a/tests/compiletests/ui/arch/emit_stream_vertex.rs b/tests/compiletests/ui/arch/emit_stream_vertex.rs index 09b5874f61..f0be0f9403 100644 --- a/tests/compiletests/ui/arch/emit_stream_vertex.rs +++ b/tests/compiletests/ui/arch/emit_stream_vertex.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -C target-feature=+GeometryStreams +// ignore-wgsl use spirv_std::spirv; diff --git a/tests/compiletests/ui/arch/emit_vertex.rs b/tests/compiletests/ui/arch/emit_vertex.rs index c8fa3fe781..26a17d12ec 100644 --- a/tests/compiletests/ui/arch/emit_vertex.rs +++ b/tests/compiletests/ui/arch/emit_vertex.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+Geometry +// ignore-wgsl use spirv_std::spirv; diff --git a/tests/compiletests/ui/arch/end_primitive.rs b/tests/compiletests/ui/arch/end_primitive.rs index 0749ecd1e2..c6f365c66a 100644 --- a/tests/compiletests/ui/arch/end_primitive.rs +++ b/tests/compiletests/ui/arch/end_primitive.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+Geometry +// ignore-wgsl use spirv_std::spirv; diff --git a/tests/compiletests/ui/arch/end_stream_primitive.rs b/tests/compiletests/ui/arch/end_stream_primitive.rs index 82e138538d..d98400dd24 100644 --- a/tests/compiletests/ui/arch/end_stream_primitive.rs +++ b/tests/compiletests/ui/arch/end_stream_primitive.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -C target-feature=+GeometryStreams +// ignore-wgsl use spirv_std::spirv; diff --git a/tests/compiletests/ui/arch/execute_callable.rs b/tests/compiletests/ui/arch/execute_callable.rs index 41375a5153..d4b5c84924 100644 --- a/tests/compiletests/ui/arch/execute_callable.rs +++ b/tests/compiletests/ui/arch/execute_callable.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayTracingKHR,+ext:SPV_KHR_ray_tracing +// ignore-wgsl use spirv_std::spirv; diff --git a/tests/compiletests/ui/arch/ignore_intersection_khr.rs b/tests/compiletests/ui/arch/ignore_intersection_khr.rs index c7c68f7fb1..57a2df3b42 100644 --- a/tests/compiletests/ui/arch/ignore_intersection_khr.rs +++ b/tests/compiletests/ui/arch/ignore_intersection_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayTracingKHR,+ext:SPV_KHR_ray_tracing +// ignore-wgsl use spirv_std::spirv; diff --git a/tests/compiletests/ui/arch/memory_barrier.rs b/tests/compiletests/ui/arch/memory_barrier.rs index 3c6033b910..ff57dfa6ac 100644 --- a/tests/compiletests/ui/arch/memory_barrier.rs +++ b/tests/compiletests/ui/arch/memory_barrier.rs @@ -1,4 +1,5 @@ // build-pass +// ignore-wgsl #![feature(adt_const_params)] #![allow(incomplete_features)] diff --git a/tests/compiletests/ui/arch/ray_query_confirm_intersection_khr.rs b/tests/compiletests/ui/arch/ray_query_confirm_intersection_khr.rs index d75c69878c..3db1cded3d 100644 --- a/tests/compiletests/ui/arch/ray_query_confirm_intersection_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_confirm_intersection_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayQueryKHR,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/ray_query_get_intersection_barycentrics_khr.rs b/tests/compiletests/ui/arch/ray_query_get_intersection_barycentrics_khr.rs index 4e859c6fea..fa445f04d9 100644 --- a/tests/compiletests/ui/arch/ray_query_get_intersection_barycentrics_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_get_intersection_barycentrics_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayQueryKHR,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/ray_query_get_intersection_candidate_aabb_opaque_khr.rs b/tests/compiletests/ui/arch/ray_query_get_intersection_candidate_aabb_opaque_khr.rs index 87376f005c..79caa709e5 100644 --- a/tests/compiletests/ui/arch/ray_query_get_intersection_candidate_aabb_opaque_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_get_intersection_candidate_aabb_opaque_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayQueryKHR,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/ray_query_get_intersection_front_face_khr.rs b/tests/compiletests/ui/arch/ray_query_get_intersection_front_face_khr.rs index ba6006988e..3b27c2c058 100644 --- a/tests/compiletests/ui/arch/ray_query_get_intersection_front_face_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_get_intersection_front_face_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayQueryKHR,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/ray_query_get_intersection_geometry_index_khr.rs b/tests/compiletests/ui/arch/ray_query_get_intersection_geometry_index_khr.rs index 69323141d3..ff5f61dae7 100644 --- a/tests/compiletests/ui/arch/ray_query_get_intersection_geometry_index_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_get_intersection_geometry_index_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayQueryKHR,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/ray_query_get_intersection_instance_custom_index_khr.rs b/tests/compiletests/ui/arch/ray_query_get_intersection_instance_custom_index_khr.rs index 2dfc5bb17e..11fa6bbc77 100644 --- a/tests/compiletests/ui/arch/ray_query_get_intersection_instance_custom_index_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_get_intersection_instance_custom_index_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayQueryKHR,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/ray_query_get_intersection_instance_id_khr.rs b/tests/compiletests/ui/arch/ray_query_get_intersection_instance_id_khr.rs index 20b413deec..07e55fe3d2 100644 --- a/tests/compiletests/ui/arch/ray_query_get_intersection_instance_id_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_get_intersection_instance_id_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayQueryKHR,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/ray_query_get_intersection_object_ray_direction_khr.rs b/tests/compiletests/ui/arch/ray_query_get_intersection_object_ray_direction_khr.rs index 177490b1b2..f53ded11cd 100644 --- a/tests/compiletests/ui/arch/ray_query_get_intersection_object_ray_direction_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_get_intersection_object_ray_direction_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayQueryKHR,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/ray_query_get_intersection_object_ray_origin_khr.rs b/tests/compiletests/ui/arch/ray_query_get_intersection_object_ray_origin_khr.rs index a0ea175b89..3551f50045 100644 --- a/tests/compiletests/ui/arch/ray_query_get_intersection_object_ray_origin_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_get_intersection_object_ray_origin_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayQueryKHR,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/ray_query_get_intersection_object_to_world_khr.rs b/tests/compiletests/ui/arch/ray_query_get_intersection_object_to_world_khr.rs index ac3f9c3ac7..baf5f384ec 100644 --- a/tests/compiletests/ui/arch/ray_query_get_intersection_object_to_world_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_get_intersection_object_to_world_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayQueryKHR,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/ray_query_get_intersection_primitive_index_khr.rs b/tests/compiletests/ui/arch/ray_query_get_intersection_primitive_index_khr.rs index a4f9ab84cc..c7f590bc1f 100644 --- a/tests/compiletests/ui/arch/ray_query_get_intersection_primitive_index_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_get_intersection_primitive_index_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayQueryKHR,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/ray_query_get_intersection_shader_binding_table_record_offset_khr.rs b/tests/compiletests/ui/arch/ray_query_get_intersection_shader_binding_table_record_offset_khr.rs index 159c4aa16d..53bfe38def 100644 --- a/tests/compiletests/ui/arch/ray_query_get_intersection_shader_binding_table_record_offset_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_get_intersection_shader_binding_table_record_offset_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayQueryKHR,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/ray_query_get_intersection_t_khr.rs b/tests/compiletests/ui/arch/ray_query_get_intersection_t_khr.rs index 39cd3dde59..1701a69edb 100644 --- a/tests/compiletests/ui/arch/ray_query_get_intersection_t_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_get_intersection_t_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayQueryKHR,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/ray_query_get_intersection_type_khr.rs b/tests/compiletests/ui/arch/ray_query_get_intersection_type_khr.rs index 39b848003e..41616987ee 100644 --- a/tests/compiletests/ui/arch/ray_query_get_intersection_type_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_get_intersection_type_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayQueryKHR,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/ray_query_get_ray_flags_khr.rs b/tests/compiletests/ui/arch/ray_query_get_ray_flags_khr.rs index 816e808b93..203e7d63a9 100644 --- a/tests/compiletests/ui/arch/ray_query_get_ray_flags_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_get_ray_flags_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayQueryKHR,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/ray_query_get_ray_t_min_khr.rs b/tests/compiletests/ui/arch/ray_query_get_ray_t_min_khr.rs index b5c0d82c3f..af907449fe 100644 --- a/tests/compiletests/ui/arch/ray_query_get_ray_t_min_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_get_ray_t_min_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayQueryKHR,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/ray_query_get_world_ray_direction_khr.rs b/tests/compiletests/ui/arch/ray_query_get_world_ray_direction_khr.rs index 1f579e38b5..e944de22bf 100644 --- a/tests/compiletests/ui/arch/ray_query_get_world_ray_direction_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_get_world_ray_direction_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayQueryKHR,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/ray_query_get_world_ray_origin_khr.rs b/tests/compiletests/ui/arch/ray_query_get_world_ray_origin_khr.rs index f56a47e67b..61bc0337a7 100644 --- a/tests/compiletests/ui/arch/ray_query_get_world_ray_origin_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_get_world_ray_origin_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayQueryKHR,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/ray_query_initialize_khr.rs b/tests/compiletests/ui/arch/ray_query_initialize_khr.rs index ac2e5f0fab..07ce9d04a2 100644 --- a/tests/compiletests/ui/arch/ray_query_initialize_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_initialize_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayTracingKHR,+RayQueryKHR,+ext:SPV_KHR_ray_tracing,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/ray_query_terminate_khr.rs b/tests/compiletests/ui/arch/ray_query_terminate_khr.rs index 02c5b4fde6..3d7ac033e0 100644 --- a/tests/compiletests/ui/arch/ray_query_terminate_khr.rs +++ b/tests/compiletests/ui/arch/ray_query_terminate_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayQueryKHR,+ext:SPV_KHR_ray_query +// ignore-wgsl use glam::Vec3; use spirv_std::ray_tracing::{AccelerationStructure, RayFlags, RayQuery}; diff --git a/tests/compiletests/ui/arch/read_clock_khr.rs b/tests/compiletests/ui/arch/read_clock_khr.rs index 681388db1b..69a4d076b1 100644 --- a/tests/compiletests/ui/arch/read_clock_khr.rs +++ b/tests/compiletests/ui/arch/read_clock_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+Int64,+ShaderClockKHR,+ext:SPV_KHR_shader_clock +// ignore-wgsl use glam::UVec2; use spirv_std::spirv; diff --git a/tests/compiletests/ui/arch/report_intersection_khr.rs b/tests/compiletests/ui/arch/report_intersection_khr.rs index a7d3cca8c8..f4b26f3d8d 100644 --- a/tests/compiletests/ui/arch/report_intersection_khr.rs +++ b/tests/compiletests/ui/arch/report_intersection_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayTracingKHR,+ext:SPV_KHR_ray_tracing +// ignore-wgsl use spirv_std::spirv; diff --git a/tests/compiletests/ui/arch/terminate_ray_khr.rs b/tests/compiletests/ui/arch/terminate_ray_khr.rs index 5d986dfa1c..e3a349ead2 100644 --- a/tests/compiletests/ui/arch/terminate_ray_khr.rs +++ b/tests/compiletests/ui/arch/terminate_ray_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayTracingKHR,+ext:SPV_KHR_ray_tracing +// ignore-wgsl use spirv_std::spirv; diff --git a/tests/compiletests/ui/arch/trace_ray_khr.rs b/tests/compiletests/ui/arch/trace_ray_khr.rs index f210a65c98..533ef1c5e0 100644 --- a/tests/compiletests/ui/arch/trace_ray_khr.rs +++ b/tests/compiletests/ui/arch/trace_ray_khr.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayTracingKHR,+ext:SPV_KHR_ray_tracing +// ignore-wgsl use spirv_std::spirv; diff --git a/tests/compiletests/ui/arch/workgroup_memory_barrier.rs b/tests/compiletests/ui/arch/workgroup_memory_barrier.rs index 1a4b6de668..e70c45a0ac 100644 --- a/tests/compiletests/ui/arch/workgroup_memory_barrier.rs +++ b/tests/compiletests/ui/arch/workgroup_memory_barrier.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -C llvm-args=--disassemble-fn=workgroup_memory_barrier::workgroup_memory_barrier +// ignore-wgsl use spirv_std::spirv; diff --git a/tests/compiletests/ui/dis/asm.rs b/tests/compiletests/ui/dis/asm.rs index 1e2a5a6f01..1829f2d2a9 100644 --- a/tests/compiletests/ui/dis/asm.rs +++ b/tests/compiletests/ui/dis/asm.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -C llvm-args=--disassemble-fn=asm::asm +// ignore-wgsl use core::arch::asm; use spirv_std::spirv; diff --git a/tests/compiletests/ui/dis/asm.stderr b/tests/compiletests/ui/dis/asm.stderr index b0e55dbc55..501c02b442 100644 --- a/tests/compiletests/ui/dis/asm.stderr +++ b/tests/compiletests/ui/dis/asm.stderr @@ -1,6 +1,6 @@ %1 = OpFunction %2 None %3 %4 = OpLabel -OpLine %5 9 8 +OpLine %5 10 8 OpMemoryBarrier %6 %7 OpNoLine OpReturn diff --git a/tests/compiletests/ui/dis/asm_op_decorate.rs b/tests/compiletests/ui/dis/asm_op_decorate.rs index a46835ee64..95379135c4 100644 --- a/tests/compiletests/ui/dis/asm_op_decorate.rs +++ b/tests/compiletests/ui/dis/asm_op_decorate.rs @@ -14,6 +14,7 @@ // ignore-vulkan1.2 // ignore-vulkan1.3 // ignore-vulkan1.4 +// ignore-wgsl use core::arch::asm; use spirv_std::spirv; diff --git a/tests/compiletests/ui/dis/complex_image_sample_inst.rs b/tests/compiletests/ui/dis/complex_image_sample_inst.rs index f42cce8d0b..89791d33be 100644 --- a/tests/compiletests/ui/dis/complex_image_sample_inst.rs +++ b/tests/compiletests/ui/dis/complex_image_sample_inst.rs @@ -1,6 +1,7 @@ // build-pass // compile-flags: -Ctarget-feature=+RuntimeDescriptorArray,+ext:SPV_EXT_descriptor_indexing // compile-flags: -C llvm-args=--disassemble-fn=complex_image_sample_inst::sample_proj_lod +// ignore-wgsl use core::arch::asm; use spirv_std::spirv; diff --git a/tests/compiletests/ui/dis/complex_image_sample_inst.stderr b/tests/compiletests/ui/dis/complex_image_sample_inst.stderr index 2682527c58..5d28c521a2 100644 --- a/tests/compiletests/ui/dis/complex_image_sample_inst.stderr +++ b/tests/compiletests/ui/dis/complex_image_sample_inst.stderr @@ -5,7 +5,7 @@ %8 = OpFunctionParameter %9 %10 = OpFunctionParameter %9 %11 = OpLabel -OpLine %12 18 8 +OpLine %12 19 8 %13 = OpAccessChain %14 %15 %16 %17 = OpLoad %18 %13 %19 = OpImageSampleProjExplicitLod %2 %17 %4 Grad|ConstOffset %5 %7 %20 diff --git a/tests/compiletests/ui/dis/non-writable-storage_buffer.rs b/tests/compiletests/ui/dis/non-writable-storage_buffer.rs index 483f7c75ad..b03ea9e939 100644 --- a/tests/compiletests/ui/dis/non-writable-storage_buffer.rs +++ b/tests/compiletests/ui/dis/non-writable-storage_buffer.rs @@ -15,6 +15,7 @@ // ignore-vulkan1.2 // ignore-vulkan1.3 // ignore-vulkan1.4 +// ignore-wgsl use spirv_std::spirv; diff --git a/tests/compiletests/ui/dis/panic_builtin_bounds_check.rs b/tests/compiletests/ui/dis/panic_builtin_bounds_check.rs index 93b5e62a8f..a3ce594b33 100644 --- a/tests/compiletests/ui/dis/panic_builtin_bounds_check.rs +++ b/tests/compiletests/ui/dis/panic_builtin_bounds_check.rs @@ -18,6 +18,8 @@ // normalize-stderr-test "\S:\S*/panic_builtin_bounds_check.rs" -> "$$DIR/panic_builtin_bounds_check.rs" // FIXME(eddyb) handle this one in the test runner. // normalize-stderr-test "\S*/lib/rustlib/" -> "$$SYSROOT/lib/rustlib/" +// +// ignore-wgsl use spirv_std::spirv; diff --git a/tests/compiletests/ui/dis/panic_builtin_bounds_check.stderr b/tests/compiletests/ui/dis/panic_builtin_bounds_check.stderr index 69712fbd74..d37846c822 100644 --- a/tests/compiletests/ui/dis/panic_builtin_bounds_check.stderr +++ b/tests/compiletests/ui/dis/panic_builtin_bounds_check.stderr @@ -8,7 +8,7 @@ OpExtension "SPV_KHR_non_semantic_info" OpMemoryModel Logical Simple OpEntryPoint Fragment %2 "main" OpExecutionMode %2 OriginUpperLeft -%3 = OpString "/n[Rust panicked at $DIR/panic_builtin_bounds_check.rs:25:5]/n index out of bounds: the len is %u but the index is %u/n in main()/n" +%3 = OpString "/n[Rust panicked at $DIR/panic_builtin_bounds_check.rs:27:5]/n index out of bounds: the len is %u but the index is %u/n in main()/n" %4 = OpString "$DIR/panic_builtin_bounds_check.rs" %5 = OpTypeVoid %6 = OpTypeFunction %5 @@ -19,7 +19,7 @@ OpExecutionMode %2 OriginUpperLeft %11 = OpUndef %8 %2 = OpFunction %5 None %6 %12 = OpLabel -OpLine %4 25 4 +OpLine %4 27 4 %13 = OpULessThan %7 %9 %10 OpNoLine OpSelectionMerge %14 None @@ -27,7 +27,7 @@ OpBranchConditional %13 %15 %16 %15 = OpLabel OpBranch %14 %16 = OpLabel -OpLine %4 25 4 +OpLine %4 27 4 %17 = OpExtInst %5 %1 1 %3 %11 %9 OpNoLine OpReturn diff --git a/tests/compiletests/ui/dis/panic_sequential_many.rs b/tests/compiletests/ui/dis/panic_sequential_many.rs index 4cb7db174d..679e19edce 100644 --- a/tests/compiletests/ui/dis/panic_sequential_many.rs +++ b/tests/compiletests/ui/dis/panic_sequential_many.rs @@ -19,6 +19,8 @@ // normalize-stderr-test "\S:\S*/panic_sequential_many.rs" -> "$$DIR/panic_sequential_many.rs" // FIXME(eddyb) handle this one in the test runner. // normalize-stderr-test "\S*/lib/rustlib/" -> "$$SYSROOT/lib/rustlib/" +// +// ignore-wgsl use spirv_std::spirv; diff --git a/tests/compiletests/ui/dis/panic_sequential_many.stderr b/tests/compiletests/ui/dis/panic_sequential_many.stderr index 94a4ddabac..04875034e0 100644 --- a/tests/compiletests/ui/dis/panic_sequential_many.stderr +++ b/tests/compiletests/ui/dis/panic_sequential_many.stderr @@ -8,7 +8,7 @@ OpExtension "SPV_KHR_non_semantic_info" OpMemoryModel Logical Simple OpEntryPoint Fragment %2 "main" %3 %4 %5 OpExecutionMode %2 OriginUpperLeft -%6 = OpString "/n[Rust panicked at $DIR/panic_sequential_many.rs:29:10]/n attempt to divide by zero/n in main()/n" +%6 = OpString "/n[Rust panicked at $DIR/panic_sequential_many.rs:31:10]/n attempt to divide by zero/n in main()/n" %7 = OpString "$DIR/panic_sequential_many.rs" OpName %3 "x" OpName %4 "y" @@ -30,248 +30,248 @@ OpDecorate %5 Location 0 %5 = OpVariable %10 Output %2 = OpFunction %11 None %12 %15 = OpLabel -OpLine %7 26 12 +OpLine %7 28 12 %16 = OpLoad %8 %3 -OpLine %7 26 35 +OpLine %7 28 35 %17 = OpLoad %8 %4 -OpLine %7 29 9 +OpLine %7 31 9 %18 = OpIEqual %13 %17 %14 OpNoLine OpSelectionMerge %19 None OpBranchConditional %18 %20 %21 %20 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %22 = OpExtInst %11 %1 1 %6 OpNoLine OpReturn %21 = OpLabel OpBranch %19 %19 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %23 = OpUDiv %8 %16 %17 %24 = OpIEqual %13 %17 %14 OpNoLine OpSelectionMerge %25 None OpBranchConditional %24 %26 %27 %26 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %28 = OpExtInst %11 %1 1 %6 OpNoLine OpReturn %27 = OpLabel OpBranch %25 %25 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %29 = OpUDiv %8 %23 %17 %30 = OpIEqual %13 %17 %14 OpNoLine OpSelectionMerge %31 None OpBranchConditional %30 %32 %33 %32 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %34 = OpExtInst %11 %1 1 %6 OpNoLine OpReturn %33 = OpLabel OpBranch %31 %31 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %35 = OpUDiv %8 %29 %17 %36 = OpIEqual %13 %17 %14 OpNoLine OpSelectionMerge %37 None OpBranchConditional %36 %38 %39 %38 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %40 = OpExtInst %11 %1 1 %6 OpNoLine OpReturn %39 = OpLabel OpBranch %37 %37 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %41 = OpUDiv %8 %35 %17 %42 = OpIEqual %13 %17 %14 OpNoLine OpSelectionMerge %43 None OpBranchConditional %42 %44 %45 %44 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %46 = OpExtInst %11 %1 1 %6 OpNoLine OpReturn %45 = OpLabel OpBranch %43 %43 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %47 = OpUDiv %8 %41 %17 %48 = OpIEqual %13 %17 %14 OpNoLine OpSelectionMerge %49 None OpBranchConditional %48 %50 %51 %50 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %52 = OpExtInst %11 %1 1 %6 OpNoLine OpReturn %51 = OpLabel OpBranch %49 %49 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %53 = OpUDiv %8 %47 %17 %54 = OpIEqual %13 %17 %14 OpNoLine OpSelectionMerge %55 None OpBranchConditional %54 %56 %57 %56 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %58 = OpExtInst %11 %1 1 %6 OpNoLine OpReturn %57 = OpLabel OpBranch %55 %55 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %59 = OpUDiv %8 %53 %17 %60 = OpIEqual %13 %17 %14 OpNoLine OpSelectionMerge %61 None OpBranchConditional %60 %62 %63 %62 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %64 = OpExtInst %11 %1 1 %6 OpNoLine OpReturn %63 = OpLabel OpBranch %61 %61 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %65 = OpUDiv %8 %59 %17 %66 = OpIEqual %13 %17 %14 OpNoLine OpSelectionMerge %67 None OpBranchConditional %66 %68 %69 %68 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %70 = OpExtInst %11 %1 1 %6 OpNoLine OpReturn %69 = OpLabel OpBranch %67 %67 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %71 = OpUDiv %8 %65 %17 %72 = OpIEqual %13 %17 %14 OpNoLine OpSelectionMerge %73 None OpBranchConditional %72 %74 %75 %74 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %76 = OpExtInst %11 %1 1 %6 OpNoLine OpReturn %75 = OpLabel OpBranch %73 %73 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %77 = OpUDiv %8 %71 %17 %78 = OpIEqual %13 %17 %14 OpNoLine OpSelectionMerge %79 None OpBranchConditional %78 %80 %81 %80 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %82 = OpExtInst %11 %1 1 %6 OpNoLine OpReturn %81 = OpLabel OpBranch %79 %79 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %83 = OpUDiv %8 %77 %17 %84 = OpIEqual %13 %17 %14 OpNoLine OpSelectionMerge %85 None OpBranchConditional %84 %86 %87 %86 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %88 = OpExtInst %11 %1 1 %6 OpNoLine OpReturn %87 = OpLabel OpBranch %85 %85 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %89 = OpUDiv %8 %83 %17 %90 = OpIEqual %13 %17 %14 OpNoLine OpSelectionMerge %91 None OpBranchConditional %90 %92 %93 %92 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %94 = OpExtInst %11 %1 1 %6 OpNoLine OpReturn %93 = OpLabel OpBranch %91 %91 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %95 = OpUDiv %8 %89 %17 %96 = OpIEqual %13 %17 %14 OpNoLine OpSelectionMerge %97 None OpBranchConditional %96 %98 %99 %98 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %100 = OpExtInst %11 %1 1 %6 OpNoLine OpReturn %99 = OpLabel OpBranch %97 %97 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %101 = OpUDiv %8 %95 %17 %102 = OpIEqual %13 %17 %14 OpNoLine OpSelectionMerge %103 None OpBranchConditional %102 %104 %105 %104 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %106 = OpExtInst %11 %1 1 %6 OpNoLine OpReturn %105 = OpLabel OpBranch %103 %103 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %107 = OpUDiv %8 %101 %17 %108 = OpIEqual %13 %17 %14 OpNoLine OpSelectionMerge %109 None OpBranchConditional %108 %110 %111 %110 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %112 = OpExtInst %11 %1 1 %6 OpNoLine OpReturn %111 = OpLabel OpBranch %109 %109 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %113 = OpUDiv %8 %107 %17 %114 = OpIEqual %13 %17 %14 OpNoLine OpSelectionMerge %115 None OpBranchConditional %114 %116 %117 %116 = OpLabel -OpLine %7 29 9 +OpLine %7 31 9 %118 = OpExtInst %11 %1 1 %6 OpNoLine OpReturn %117 = OpLabel OpBranch %115 %115 = OpLabel -OpLine %7 29 4 +OpLine %7 31 4 %119 = OpUDiv %8 %113 %17 OpStore %5 %119 OpNoLine diff --git a/tests/compiletests/ui/image/query/query_lod.rs b/tests/compiletests/ui/image/query/query_lod.rs index 4d764d0514..06eef09871 100644 --- a/tests/compiletests/ui/image/query/query_lod.rs +++ b/tests/compiletests/ui/image/query/query_lod.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -C target-feature=+ImageQuery +// ignore-wgsl use spirv_std::spirv; use spirv_std::{Image, Sampler, arch}; diff --git a/tests/compiletests/ui/image/query/rect_image_query_size.rs b/tests/compiletests/ui/image/query/rect_image_query_size.rs index 3182412157..9806c1c075 100644 --- a/tests/compiletests/ui/image/query/rect_image_query_size.rs +++ b/tests/compiletests/ui/image/query/rect_image_query_size.rs @@ -6,6 +6,7 @@ // ignore-vulkan1.2 // ignore-vulkan1.3 // ignore-vulkan1.4 +// ignore-wgsl use spirv_std::spirv; use spirv_std::{Image, arch}; diff --git a/tests/compiletests/ui/image/query/sampled_image_rect_query_size_lod_err.rs b/tests/compiletests/ui/image/query/sampled_image_rect_query_size_lod_err.rs index acfe0a61a3..44aaf782e8 100644 --- a/tests/compiletests/ui/image/query/sampled_image_rect_query_size_lod_err.rs +++ b/tests/compiletests/ui/image/query/sampled_image_rect_query_size_lod_err.rs @@ -7,6 +7,7 @@ // ignore-vulkan1.2 // ignore-vulkan1.3 // ignore-vulkan1.4 +// ignore-wgsl use spirv_std::{Image, arch, image::SampledImage, spirv}; diff --git a/tests/compiletests/ui/image/query/sampled_image_rect_query_size_lod_err.stderr b/tests/compiletests/ui/image/query/sampled_image_rect_query_size_lod_err.stderr index 32c369a9bd..9c6a0fe48c 100644 --- a/tests/compiletests/ui/image/query/sampled_image_rect_query_size_lod_err.stderr +++ b/tests/compiletests/ui/image/query/sampled_image_rect_query_size_lod_err.stderr @@ -1,7 +1,7 @@ error[E0277]: the trait bound `Image: HasQuerySizeLod` is not satisfied - --> $DIR/sampled_image_rect_query_size_lod_err.rs:21:28 + --> $DIR/sampled_image_rect_query_size_lod_err.rs:22:28 | -21 | *output = rect_sampled.query_size_lod(0); +22 | *output = rect_sampled.query_size_lod(0); | ^^^^^^^^^^^^^^ the trait `HasQuerySizeLod` is not implemented for `Image` | = help: the following other types implement trait `HasQuerySizeLod`: diff --git a/tests/compiletests/ui/lang/asm/infer-access-chain-array.rs b/tests/compiletests/ui/lang/asm/infer-access-chain-array.rs index cd3649989a..faeae33b2f 100644 --- a/tests/compiletests/ui/lang/asm/infer-access-chain-array.rs +++ b/tests/compiletests/ui/lang/asm/infer-access-chain-array.rs @@ -2,6 +2,7 @@ // when used to index arrays. // build-pass +// ignore-wgsl use core::arch::asm; use glam::Vec4; diff --git a/tests/compiletests/ui/spirv-attr/bool-inputs.rs b/tests/compiletests/ui/spirv-attr/bool-inputs.rs index c0d74df93b..b03acfe8fd 100644 --- a/tests/compiletests/ui/spirv-attr/bool-inputs.rs +++ b/tests/compiletests/ui/spirv-attr/bool-inputs.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+FragmentFullyCoveredEXT,+ext:SPV_EXT_fragment_fully_covered +// ignore-wgsl use spirv_std::spirv; diff --git a/tests/compiletests/ui/spirv-attr/invariant.rs b/tests/compiletests/ui/spirv-attr/invariant.rs index 37e7a698ec..027e951eaa 100644 --- a/tests/compiletests/ui/spirv-attr/invariant.rs +++ b/tests/compiletests/ui/spirv-attr/invariant.rs @@ -1,7 +1,10 @@ // Tests that the invariant attribute works // build-pass +use spirv_std::glam::Vec4; use spirv_std::spirv; #[spirv(vertex)] -pub fn main(#[spirv(invariant)] output: &mut f32) {} +pub fn main(#[spirv(invariant)] output: &mut f32, #[spirv(position)] pos: &mut Vec4) { + *pos = Vec4::ZERO; +} diff --git a/tests/compiletests/ui/spirv-attr/matrix-type.rs b/tests/compiletests/ui/spirv-attr/matrix-type.rs index ef8ca60349..a00c002ef0 100644 --- a/tests/compiletests/ui/spirv-attr/matrix-type.rs +++ b/tests/compiletests/ui/spirv-attr/matrix-type.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -Ctarget-feature=+RayTracingKHR,+ext:SPV_KHR_ray_tracing +// ignore-wgsl use spirv_std::spirv; diff --git a/tests/compiletests/ui/storage_class/runtime_descriptor_array.rs b/tests/compiletests/ui/storage_class/runtime_descriptor_array.rs index 0596b56725..5e107ab17f 100644 --- a/tests/compiletests/ui/storage_class/runtime_descriptor_array.rs +++ b/tests/compiletests/ui/storage_class/runtime_descriptor_array.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -C target-feature=+RuntimeDescriptorArray,+ext:SPV_EXT_descriptor_indexing +// ignore-wgsl use spirv_std::spirv; use spirv_std::{Image, RuntimeArray, Sampler}; diff --git a/tests/compiletests/ui/storage_class/runtime_descriptor_array_error.rs b/tests/compiletests/ui/storage_class/runtime_descriptor_array_error.rs index 5ccefec3de..46c52d91fe 100644 --- a/tests/compiletests/ui/storage_class/runtime_descriptor_array_error.rs +++ b/tests/compiletests/ui/storage_class/runtime_descriptor_array_error.rs @@ -1,4 +1,5 @@ // build-fail +// ignore-wgsl use spirv_std::{Image, RuntimeArray, spirv}; diff --git a/tests/compiletests/ui/storage_class/runtime_descriptor_array_error.stderr b/tests/compiletests/ui/storage_class/runtime_descriptor_array_error.stderr index a3c0d1b0b6..15d94679c3 100644 --- a/tests/compiletests/ui/storage_class/runtime_descriptor_array_error.stderr +++ b/tests/compiletests/ui/storage_class/runtime_descriptor_array_error.stderr @@ -1,13 +1,13 @@ error: descriptor indexing must use &RuntimeArray, not &[T] - --> $DIR/runtime_descriptor_array_error.rs:7:52 + --> $DIR/runtime_descriptor_array_error.rs:8:52 | -7 | #[spirv(descriptor_set = 0, binding = 0)] one: &[Image!(2D, type=f32, sampled)], +8 | #[spirv(descriptor_set = 0, binding = 0)] one: &[Image!(2D, type=f32, sampled)], | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: use &[T] instead of &RuntimeArray - --> $DIR/runtime_descriptor_array_error.rs:8:61 + --> $DIR/runtime_descriptor_array_error.rs:9:61 | -8 | #[spirv(uniform, descriptor_set = 0, binding = 0)] two: &RuntimeArray, +9 | #[spirv(uniform, descriptor_set = 0, binding = 0)] two: &RuntimeArray, | ^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/compiletests/ui/storage_class/typed_buffer_descriptor_array.rs b/tests/compiletests/ui/storage_class/typed_buffer_descriptor_array.rs index 1383707dec..fe221bf5ed 100644 --- a/tests/compiletests/ui/storage_class/typed_buffer_descriptor_array.rs +++ b/tests/compiletests/ui/storage_class/typed_buffer_descriptor_array.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -C target-feature=+RuntimeDescriptorArray,+ext:SPV_EXT_descriptor_indexing +// ignore-wgsl use glam::Vec4; use spirv_std::spirv; diff --git a/tests/compiletests/ui/storage_class/typed_buffer_descriptor_array_slice.rs b/tests/compiletests/ui/storage_class/typed_buffer_descriptor_array_slice.rs index 9e62e99706..1141cfade4 100644 --- a/tests/compiletests/ui/storage_class/typed_buffer_descriptor_array_slice.rs +++ b/tests/compiletests/ui/storage_class/typed_buffer_descriptor_array_slice.rs @@ -1,5 +1,6 @@ // build-pass // compile-flags: -C target-feature=+RuntimeDescriptorArray,+ext:SPV_EXT_descriptor_indexing +// ignore-wgsl use glam::Vec4; use spirv_std::spirv; diff --git a/tests/compiletests/ui/target_features_err.rs b/tests/compiletests/ui/target_features_err.rs index f6def31c4f..74db9699a2 100644 --- a/tests/compiletests/ui/target_features_err.rs +++ b/tests/compiletests/ui/target_features_err.rs @@ -1,5 +1,6 @@ // build-fail // compile-flags: -Ctarget-feature=+rayTracingKHR,+ext:SPV_KHR_ray_tracing +// ignore-wgsl use spirv_std::spirv; From 566bee09fc1aef2d44abe5d2b447afc5a1a07408 Mon Sep 17 00:00:00 2001 From: Firestar99 Date: Mon, 16 Jun 2025 11:13:11 +0200 Subject: [PATCH 09/10] wgsl: fix clippy --- crates/rustc_codegen_spirv/src/link.rs | 6 ++---- crates/rustc_codegen_spirv/src/naga_transpile.rs | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/rustc_codegen_spirv/src/link.rs b/crates/rustc_codegen_spirv/src/link.rs index e4dc0f03d3..760e107125 100644 --- a/crates/rustc_codegen_spirv/src/link.rs +++ b/crates/rustc_codegen_spirv/src/link.rs @@ -313,10 +313,8 @@ fn post_link_single_module( drop(save_modules_timer); } - if let Ok(transpile) = should_transpile(sess) { - if let Some(transpile) = transpile { - transpile(sess, cg_args, &spv_binary, out_filename).ok(); - } + if let Ok(Some(transpile)) = should_transpile(sess) { + transpile(sess, cg_args, &spv_binary, out_filename).ok(); } } diff --git a/crates/rustc_codegen_spirv/src/naga_transpile.rs b/crates/rustc_codegen_spirv/src/naga_transpile.rs index ba9cb4f580..15bcc13f2a 100644 --- a/crates/rustc_codegen_spirv/src/naga_transpile.rs +++ b/crates/rustc_codegen_spirv/src/naga_transpile.rs @@ -21,7 +21,7 @@ pub fn should_transpile(sess: &Session) -> Result, ErrorGu SpirvTargetEnv::Wgsl => Err(()), _ => Ok(None), }; - result.map_err(|_| { + result.map_err(|_e| { sess.dcx().err(format!( "Target {} requires feature \"naga\" on rustc_codegen_spirv", target.target_triple() From 1e81bd392e497048c481e5cad43f446f43e77160 Mon Sep 17 00:00:00 2001 From: Firestar99 Date: Mon, 16 Jun 2025 11:10:22 +0200 Subject: [PATCH 10/10] wgsl ci: add experimental wgsl compiletest to ci --- .github/workflows/ci.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e6c8a2a5a2..dd7576d2c1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -119,9 +119,17 @@ jobs: compiletest: name: Compiletest strategy: + fail-fast: false matrix: os: [ ubuntu-24.04, windows-2022, macOS-latest ] + target_env: [ vulkan1.1,vulkan1.2,vulkan1.3,vulkan1.4 ] + experimental: [ false ] + include: + - os: ubuntu-24.04 + target_env: wgsl + experimental: true runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.experimental }} steps: - uses: actions/checkout@v4 - name: Install Vulkan SDK @@ -134,7 +142,7 @@ jobs: - name: cargo fetch --locked run: cargo fetch --locked --target $TARGET - name: compiletest - run: cargo run -p compiletests --release --no-default-features --features "use-installed-tools" -- --target-env vulkan1.1,vulkan1.2,vulkan1.3,vulkan1.4,spv1.3 + run: cargo run -p compiletests --release --no-default-features --features "use-installed-tools" -- --target-env ${{ matrix.target_env }} difftest: name: Difftest