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

Function handle_compile_result

examples/runners/wgpu/src/lib.rs:173–195  ·  view source on GitHub ↗
(compile_result: CompileResult)

Source from the content-addressed store, hash-verified

171 builder.build().unwrap()
172 };
173 fn handle_compile_result(compile_result: CompileResult) -> CompiledShaderModules {
174 let load_spv_module = |path| {
175 let data = std::fs::read(path).unwrap();
176 // FIXME(eddyb) this reallocates all the data pointlessly, there is
177 // not a good reason to use `ShaderModuleDescriptorSpirV` specifically.
178 let spirv = Cow::Owned(wgpu::util::make_spirv_raw(&data).into_owned());
179 wgpu::ShaderModuleDescriptorSpirV {
180 label: None,
181 source: spirv,
182 }
183 };
184 CompiledShaderModules {
185 named_spv_modules: match compile_result.module {
186 spirv_builder::ModuleResult::SingleModule(path) => {
187 vec![(None, load_spv_module(path))]
188 }
189 spirv_builder::ModuleResult::MultiModule(modules) => modules
190 .into_iter()
191 .map(|(name, path)| (Some(name), load_spv_module(path)))
192 .collect(),
193 },
194 }
195 }
196 handle_compile_result(initial_result)
197 }
198 #[cfg(any(target_os = "android", target_arch = "wasm32"))]

Callers 1

maybe_watchFunction · 0.85

Calls 2

into_iterMethod · 0.80
collectMethod · 0.45

Tested by

no test coverage detected