Skip to content

Commit 710e6ab

Browse files
authored
Fix example-runner-ash (#693)
* Fix example-runner-ash Fix compile_shaders() to return correct shader name. * Refactor example-runner-ash - Stop to get shader name from path. It was too complicated.
1 parent d77cc6d commit 710e6ab

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

examples/runners/ash/src/main.rs

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ use std::{
8989
ffi::{CStr, CString},
9090
fs::File,
9191
ops::Drop,
92-
path::PathBuf,
9392
sync::mpsc::{sync_channel, TryRecvError, TrySendError},
9493
thread,
9594
};
@@ -199,24 +198,19 @@ pub fn main() {
199198
}
200199

201200
pub fn compile_shaders() -> Vec<SpvFile> {
202-
let spv_paths: Vec<PathBuf> =
203-
vec![
204-
SpirvBuilder::new("examples/shaders/sky-shader", "spirv-unknown-vulkan1.1")
205-
.print_metadata(MetadataPrintout::None)
206-
.build()
207-
.unwrap()
208-
.module
209-
.unwrap_single()
210-
.to_path_buf(),
211-
];
212-
let mut spv_files = Vec::<SpvFile>::with_capacity(spv_paths.len());
213-
for path in spv_paths.iter() {
214-
spv_files.push(SpvFile {
215-
name: path.file_stem().unwrap().to_str().unwrap().to_owned(),
216-
data: read_spv(&mut File::open(path).unwrap()).unwrap(),
217-
});
218-
}
219-
spv_files
201+
let sky_shader_path =
202+
SpirvBuilder::new("examples/shaders/sky-shader", "spirv-unknown-vulkan1.1")
203+
.print_metadata(MetadataPrintout::None)
204+
.build()
205+
.unwrap()
206+
.module
207+
.unwrap_single()
208+
.to_path_buf();
209+
let sky_shader = SpvFile {
210+
name: "sky_shader".to_string(),
211+
data: read_spv(&mut File::open(sky_shader_path).unwrap()).unwrap(),
212+
};
213+
vec![sky_shader]
220214
}
221215

222216
#[derive(Debug)]

0 commit comments

Comments
 (0)