-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Verify debugPrintf specifiers #9641
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
Draft
evilpie
wants to merge
37
commits into
gfx-rs:trunk
Choose a base branch
from
evilpie:printf-verify
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
d27de59
added debugPrintf to msl
39ali f09b74d
fix test
39ali ac87fe7
format readme
39ali dfcd46a
fix format
39ali b0a7533
fix test
39ali 275fa9a
added debugPrintf support in vulkan
39ali 0ede493
Update examples/features/src/debug_printf/mod.rs
39ali 9d6ba5c
Update naga/src/back/msl/writer.rs
39ali 5bf6a28
Update naga/src/back/wgsl/writer.rs
39ali a8a03ed
Update naga/src/back/wgsl/writer.rs
39ali 272cbe8
Update naga/src/back/wgsl/writer.rs
39ali 1e6d73b
Update naga/src/ir/mod.rs
39ali 184ca24
Update naga/src/front/wgsl/parse/lexer.rs
39ali 0116ea0
Update naga/src/back/wgsl/writer.rs
39ali 946cab1
Update naga/src/front/wgsl/parse/directive/enable_extension.rs
39ali 3072942
removed InvalidExpression
39ali 5f43f26
refactor unsafe block
39ali e907a75
refactor
39ali a602e14
update changelog
39ali 109ba6b
increase validation_feature_list size to 4
39ali 95b8190
Update wgpu-hal/src/metal/adapter.rs
39ali 62b44e0
Update wgpu-hal/src/metal/adapter.rs
39ali 8af8f14
Update naga/src/ir/mod.rs
39ali b7045d1
Update naga/src/front/wgsl/error.rs
39ali 9b9df6f
Update naga/src/front/wgsl/lower/mod.rs
39ali 4b7b646
Update naga/src/front/wgsl/parse/directive/enable_extension.rs
39ali c476167
Update CHANGELOG.md
39ali 9aa237a
Update wgpu-types/src/features.rs
39ali a60edef
Update naga/src/front/wgsl/lower/mod.rs
39ali cd706ea
Update CHANGELOG.md
39ali 50e2ceb
fmt
39ali 39e7a1e
use AtomicBool for use_debug_printf and remove WEBGPU_FEATURE_DEBUG_P…
39ali c2d074d
fmt
39ali d0a2d0b
Document and test debugPrintf extension
39ali e6607f0
Use Metal 3.2 for debugPrintf snapshot
39ali 171656d
normalize debugPrintf SPIR-V validation
39ali 382fb45
Verify debugPrintf specifieres
evilpie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Shader `debugPrintf` | ||
|
|
||
| `wgpu` supports shader debug printing on native backends when `Features::DEBUG_PRINTF` is enabled. | ||
| This is a debugging extension and is not part of core WebGPU. | ||
|
|
||
| ## Requirements | ||
|
|
||
| - Request `Features::DEBUG_PRINTF` when creating the device. | ||
| - Add `enable wgpu_debug_printf;` to each WGSL module that calls `debugPrintf`. | ||
| - Use a backend that advertises the feature: | ||
| - Metal with shader logging support, available in Metal 3.2 and later. | ||
| - Vulkan with `VK_KHR_shader_non_semantic_info` support. | ||
|
|
||
| On Vulkan, `debugPrintf` output is produced through the validation layer debug-printf path. It is not enabled when GPU-assisted validation is enabled, because the two validation features are mutually exclusive. | ||
|
|
||
| ## WGSL Syntax | ||
|
|
||
| `debugPrintf` is a statement-like built-in: | ||
|
|
||
| ```wgsl | ||
| enable wgpu_debug_printf; | ||
|
|
||
| @compute @workgroup_size(1) | ||
| fn main(@builtin(global_invocation_id) id: vec3<u32>) { | ||
| debugPrintf("invocation: %u %u %u", id.x, id.y, id.z); | ||
| } | ||
| ``` | ||
|
|
||
| The first argument must be a string literal. String literals are currently only accepted as the format argument to `debugPrintf`. | ||
|
|
||
| Remaining arguments must currently be scalar values. Vector and matrix arguments may be supported in the future, but for now vector components should be passed individually. | ||
|
|
||
| Format string interpretation follows the active backend's shader logging implementation. The supported format syntax is therefore intentionally limited to the common C-style debug printf forms accepted by Metal shader logging and Vulkan shader debug printf. | ||
|
|
||
| ## Backend Notes | ||
|
|
||
| - Metal lowers `debugPrintf` to `metal::os_log_default.log_info`. | ||
| - Vulkan lowers `debugPrintf` through SPIR-V `NonSemantic.DebugPrintf`. | ||
|
|
||
| ## References | ||
|
|
||
| - Apple Metal shader logging: https://developer.apple.com/documentation/metal/logging-shader-debug-messages | ||
| - Vulkan shader debug printf sample: https://docs.vulkan.org/samples/latest/samples/extensions/shader_debugprintf/README.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This on its own is very valuable
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is part of the original PR. It would probably make sense to list the supported specifiers explicitly now.