()
| 213 | } |
| 214 | |
| 215 | pub fn compile_shaders() -> Vec<SpvFile> { |
| 216 | // Hack: spirv_builder builds into a custom directory if running under cargo, to not |
| 217 | // deadlock, and the default target directory if not. However, packages like `proc-macro2` |
| 218 | // have different configurations when being built here vs. when building |
| 219 | // rustc_codegen_spirv normally, so we *want* to build into a separate target directory, to |
| 220 | // not have to rebuild half the crate graph every time we run. So, pretend we're running |
| 221 | // under cargo by setting these environment variables. |
| 222 | std::env::set_var("OUT_DIR", env!("OUT_DIR")); |
| 223 | std::env::set_var("PROFILE", env!("PROFILE")); |
| 224 | |
| 225 | SpirvBuilder::new("examples/shaders/sky-shader", "spirv-unknown-vulkan1.1") |
| 226 | .print_metadata(MetadataPrintout::None) |
| 227 | .shader_panic_strategy(spirv_builder::ShaderPanicStrategy::DebugPrintfThenExit { |
| 228 | print_inputs: true, |
| 229 | print_backtrace: true, |
| 230 | }) |
| 231 | // HACK(eddyb) needed because of `debugPrintf` instrumentation limitations |
| 232 | // (see https://github.com/KhronosGroup/SPIRV-Tools/issues/4892). |
| 233 | .multimodule(true) |
| 234 | .build() |
| 235 | .unwrap() |
| 236 | .module |
| 237 | .unwrap_multi() |
| 238 | .iter() |
| 239 | .map(|(name, path)| SpvFile { |
| 240 | name: format!("sky_shader::{name}"), |
| 241 | data: read_spv(&mut File::open(path).unwrap()).unwrap(), |
| 242 | }) |
| 243 | .collect() |
| 244 | } |
| 245 | |
| 246 | #[derive(Debug)] |
| 247 | pub struct SpvFile { |
no test coverage detected