Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.

Comments

Fix example-runner-ash#693

Merged
khyperia merged 2 commits intoEmbarkStudios:mainfrom
hatoo:fix-example-runner-ash2
Aug 3, 2021
Merged

Fix example-runner-ash#693
khyperia merged 2 commits intoEmbarkStudios:mainfrom
hatoo:fix-example-runner-ash2

Conversation

@hatoo
Copy link
Contributor

@hatoo hatoo commented Jul 26, 2021

example-runner-ash fails to run because it fails to get sky_shader.

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', examples\runners\ash\src\main.rs:706:74
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\example-runner-ash.exe` (exit code: 101)

compile_shaders() had obtained shader name from path.file_stem() but path is

[examples\runners\ash\src\main.rs:212] &spv_paths = [
    "C:\\Users\\hato2\\Desktop\\rust-gpu\\target\\spirv-unknown-vulkan1.1\\release\\deps\\sky_shader.spv.dir\\module",
]

in my environment (Windows11).

I've fixed compile_shaders() to return corrent shader name from path.
Sorry if this fix is incompatioble for other environments.

@khyperia
Copy link
Contributor

khyperia commented Aug 3, 2021

... oh wow, yeah, this code is really incorrect and should not be grabbing the name from the filename - and like, it's excessively weirdly complicated. I think I'd prefer to change the whole function to just something like this:

fn compile_shaders() -> Vec<SpvFile> {
    let sky_shader_path =
        SpirvBuilder::new("examples/shaders/sky-shader", "spirv-unknown-vulkan1.1")
            .print_metadata(MetadataPrintout::None)
            .build()
            .unwrap()
            .module
            .unwrap_single()
            .to_path_buf();
    let sky_shader = SpvFile {
        name: "sky_shader".to_string(),
        data: read_spv(&mut File::open(sky_shader_path).unwrap()).unwrap(),
    };
    vec![sky_shader]
}

and to be honest, I don't know why we're even doing this whole Vec<SpvFile> thing instead of just returning a module... the fact that it's been broken for months and nobody noticed until now is a good argument for what we've been considering for a while, and just nuking the whole thing, haha.

hatoo added 2 commits August 3, 2021 16:30
Fix compile_shaders() to return correct shader name.
- Stop to get shader name from path. It was too complicated.
@hatoo hatoo force-pushed the fix-example-runner-ash2 branch from 0398ca3 to 7133637 Compare August 3, 2021 07:30
@hatoo
Copy link
Contributor Author

hatoo commented Aug 3, 2021

Yeah, I agree that the code is complicated.
I copypasted your code. And confirmed to run.

@khyperia khyperia enabled auto-merge (squash) August 3, 2021 07:34
@khyperia khyperia merged commit 710e6ab into EmbarkStudios:main Aug 3, 2021
@hatoo hatoo deleted the fix-example-runner-ash2 branch August 4, 2021 02:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants