MCPcopy Create free account
hub / github.com/Rust-GPU/rust-gpu / compile_shaders

Function compile_shaders

examples/runners/ash/src/main.rs:215–244  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

213}
214
215pub 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)]
247pub struct SpvFile {

Callers 1

mainFunction · 0.85

Calls 7

iterMethod · 0.80
unwrap_multiMethod · 0.80
multimoduleMethod · 0.80
shader_panic_strategyMethod · 0.80
print_metadataMethod · 0.80
collectMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected