Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Vulkan layer for injecting SPIR-V -> SPIR-T -> SPIR-V into any Vulkan users. #53

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

eddyb
Copy link
Contributor

@eddyb eddyb commented Nov 17, 2023

Behavior is kind of arbitrary right now (mostly a demo), and ergonomics are lacking.
The main goal will be to run the full Vulkan CTS ("Conformance Test Suite") with it enabled.

Both of these should work (where vkapp is e.g. vkcube) on Linux:

VK_LAYER_PATH=$PWD/vk-layer/manifests/target_debug_lib.so VK_LOADER_LAYERS_ENABLE=VK_LAYER_SPIRT_shaders vkapp
cargo build -p spirt-vk-layer --target=i686-unknown-linux-gnu
VK_LAYER_PATH=$PWD/vk-layer/manifests/target_i686-unknown-linux-gnu_debug_lib.so VK_LOADER_LAYERS_ENABLE=VK_LAYER_SPIRT_shaders vkapp32

On Linux/Mesa, by setting MESA_LOADER_DRIVER_OVERRIDE=zink as well, it ends up affecting OpenGL too:

@eddyb eddyb force-pushed the vk-layer branch 3 times, most recently from 0473505 to 3e83a5d Compare January 31, 2024 14:19
github-merge-queue bot pushed a commit that referenced this pull request Jan 31, 2024
…turization. (#55)

Original motivation back when I first started this refactor was this
bug:
- EmbarkStudios/rust-gpu#1086

Progress stalled back then and I only revived the branch for the Vulkan
layer (#53), because trying
to run the Vulkan CTS with the SPIR-T layer would run into:
- missing `OpSpecConstantOp` support (already implemented in the Vulkan
layer branch)
- structurizer region desync `list_eq_key` panics (fixed by this PR)
- missing `OpTypeForwardPointer` support (not implemented yet, but it's
much rarer and only used with `PhysicalStorageBuffer` pointers, since
logical pointers don't allow recursive data types in the first place)

On top of unblocking the SPIR-T Vulkan layer for in-depth testing, this
refactor, out of necessity of not introducing even more spurious unused
`bool`s, makes the existing ones as lazy as possible (within the limits
of what the structurizer knows without adding more analysis passes).

You can see in the `README.md` example, that this PR removes *both*
extraneous `bool`s (for "does `break`" vs "doesn't `break`"), and
instead the original condition (`v2`) is now used directly by the loop.

I've also theoretically come up with even more advanced techniques (such
as taking N disjoint targets that can be dispatched all at once, and
lazily generating the appropriate propagation of integer values `0..N`
to use a `switch`), but they either require other PRs to land as well
first, and/or are too invasive and this has already been a ridiculous
sunken cost compared to the measely benefits it offers.
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.

1 participant