Skip to content

Conversation

Firestar99
Copy link
Member

@Firestar99 Firestar99 commented Sep 30, 2025

Requires #442

Followup from #418

I've noticed that running the ash runner with debug layers enabled (--debug-layers) prints tons of validation errors, all of which should be considered programming errors and sort of equivalent to a runtime panic. Instead of trying to fix what is there, I decided to completely rewrite the ash runner instead, and update it to the modern Vulkan 1.3 way you'd render things.

  • use Vulkan 1.3
  • use DynamicRendering feature replacing Framebuffers
  • extract MyDevice struct containing vk initialization
  • decouple rendering from swapchain management
  • redo swapchain sync, fixes validation errors, intentionally kept basic
  • make rendering lazily recreate its pipeline

MacOS: removes the ash-molten dependency, which means we now require MoltenVK (or the Vulkan SDK) to be installed on MacOS for the ash runner to work. The wgpu runner still works as normal, with the metal backend.

Reviews

Please test this on your machine with validation layers turned on, if possible (requires the Vulkan SDK). Report back if it runs and on which OS and graphics card.

git checkout simplify-ash-runner2
cargo run --bin example-runner-ash -- --debug-layer --shader=sky
cargo run --bin example-runner-ash -- --debug-layer --shader=mouse

Note:

  • --shader=sky: holding arrow keys should change brightness
  • --shader=mouse: should be animated
  • --debug-layer requires vulkan sdk

@nnethercote
Copy link
Contributor

Thanks for cleaning this up, I don't understand everything about this code but the parts I do understand look good. I can see you've generally improved the error handling, fixed a bunch of "FIXME" comments, etc.

It would be nice to have some commit messages that are more than a single line. The "ash runner: rewrite" commit in particular changes a lot of code with zero explanation.

Comment on lines 173 to 177
let message_id_name = if callback_data.p_message_id_name.is_null() {
Cow::from("")
} else {
unsafe { CStr::from_ptr(callback_data.p_message_id_name).to_string_lossy() }
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I very much would! I think that section is just copied from the old runner :D

@Firestar99 Firestar99 force-pushed the simplify-ash-runner2 branch from 2c6bab2 to fb61b79 Compare October 2, 2025 12:08
Comment on lines -239 to -248
// Hack: spirv_builder builds into a custom directory if running under cargo, to not
// deadlock, and the default target directory if not. However, packages like `proc-macro2`
// have different configurations when being built here vs. when building
// rustc_codegen_spirv normally, so we *want* to build into a separate target directory, to
// not have to rebuild half the crate graph every time we run. So, pretend we're running
// under cargo by setting these environment variables.
unsafe {
std::env::set_var("OUT_DIR", env!("OUT_DIR"));
std::env::set_var("PROFILE", env!("PROFILE"));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked that running the wgpu runner, after this change, doesn't result in spurious rebuilds every time? (it might only happen on debug or release, probably only on release if I had to guess)

AFAIK, without the OUT_DIR and PROFILE env vars, spirv-builder will not pass its custom --target-dir to Cargo, and therefore the same top-level target dir will get used for both the runner and the shaders, which can cause rebuilds due to build deps/proc macros (when their Cargo feature sets differ etc.).

But it's possible there could be other reasons why this isn't a problem anymore.

Copy link
Member Author

@Firestar99 Firestar99 Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of d416b65 from the original difftest PR #216, the env vars have been replaced with cargo_metadata to ensure we always grab the correct target dir. But they haven't propagated to all examples...

See diff: d416b65#diff-84c98121dbc8466f5e6e1503a3771f2ec4f8f37fa048ebf01c201b1b5cd1b191L935-L962

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's great, glad it's been fixed, would it be too much to ask for a separate PR for at least updating the wgpu example, as a nicer place to "document" the fact that this change happened?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I should have probably split that into it's own PR to begin with... sure let's split c1d2b48 into it's own PR

I even mentioned it in the commit:

ash & wgpu runner: remove build script forwarding PROFILE env var

no longer necessary since d416b65

Copy link
Member Author

@Firestar99 Firestar99 Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pulled out the commit to #442, you can now independently merge this PR from the new one

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I found some extra stuff that #442 should probably remove, which caused conflicts and this PR now depends on that one.

@Firestar99 Firestar99 force-pushed the simplify-ash-runner2 branch from 5d13b21 to c9c689f Compare October 16, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants