Conversation
|
Looking into how the validation layers implement this, there's no reason we couldn't universally support a feature like this in a similar way with a pass on the naga IR + transparently adding a bind group to shader dispatches. That being said I think this basic validation layer based impl would still be nice to have immediately for users on vulkan platforms. |
92fc6a5 to
dae4b17
Compare
b6841ff to
b4c2a18
Compare
|
I believe the minimal functionality in WGSL you'd need in order to support this in user space is just a string type. As soon as you have a string literal to work with, you can have WGSL preprocessor recognizing a construct and writing the format string as well as arguments into some debug buffer. |
The intent behind this PR was to make debugging shaders easier for wgpu users, with this PR if I want to inspect a value all I have to do is enable the validation layers and wgpu feature, and add a single line to my shader source. Even without string support in the language a user can already implement printf-like behavior in their project, as done here for example, but I think it's a much better experience if we can provide built in debugging utilities, so I can debug my shaders without having to make any changes to my project. |
cwfitzgerald
left a comment
There was a problem hiding this comment.
Looking good from wgpu side.
Please re-request a review from me once the changes are addressed to make sure I see it!
cwfitzgerald
left a comment
There was a problem hiding this comment.
Approving the wgpu side!
|
Is there anything left to do here besides rebase? |
|
Needs a review from the Naga team, will poke them in our next meeting, but holidays are approaching, so it may be a little bit. |
fc5647c to
a492318
Compare
|
I took the liberty of rebasing the branch on trunk, replacing the merge commit. I hope that's all right. |
|
My rebase seems to have broken something. I'm looking into it. |
92bca6b to
a970533
Compare
|
@exrook friendly poke :) |
DXC doesn't support printf when targeting dxil, disable the test to allow CI to pass.
9a36c03 to
d7b3be9
Compare
|
Is this ready for re-review? |
cwfitzgerald
left a comment
There was a problem hiding this comment.
Small nits, just waiting on naga review.
| /// Enables support for debugPrintf in WGSL shaders. | ||
| /// | ||
| /// Supported Platforms: | ||
| /// - DX11 (fxc only) |
There was a problem hiding this comment.
| /// - DX11 (fxc only) |
| /// - DX11 (fxc only) | ||
| /// - DX12 (fxc only) | ||
| /// - Vulkan | ||
| /// - OpenGL |
There was a problem hiding this comment.
We don't support it on GL, so we should label this as an "unimplemented platform, if it is implementable
|
@exrook I'm very sorry - this PR fell through the cracks, and we didn't get around to reviewing it. The wgpu maintainers decided to review our outstanding PRs each week, and in our meeting today, everyone agreed we would like to take this PR, as it seems like something that Vulkan users use pretty frequently. Would you be able to rebase this PR against the current trunk? |
|
Looking forward to this getting merged |
|
Apologies - this should have gotten prompt attention from us. But at this point the PR is two years old, and we haven't heard back from the author, so we're going to close the PR. If someone is interested in creating a fresh PR for the same feature, that'd be great. |
|
Did anyone make a fresh PR salvaging this or is there still no way to log wgsl? |
cargo clippy.cargo clippy --target wasm32-unknown-unknownif applicable.Connections
Migrated from gfx-rs/naga#2563
Description
Exposes the vulkan validation layers shader printf feature to wgsl shaders through a new
debugPrintfbuiltin function.example:
output with validation layers enabled and configured properly:
This feature is also supported on HLSL/DirectX though only when using FXC. DXC does not fully support printf, see microsoft/hlsl-specs#245.
Additionally supports converting SPIR-V shaders containing
NonSemantic.DebugPrintfto wgsl, glsl, hlsl.Testing
TBD