@@ -179,46 +179,72 @@ pub enum ShaderPanicStrategy {
179
179
/// Like `SilentExit`, but also using `debugPrintf` to report the panic in
180
180
/// a way that can reach the user, before returning from the entry-point.
181
181
///
182
- /// Will automatically require the `SPV_KHR_non_semantic_info` extension,
183
- /// as `debugPrintf` uses a "non-semantic extended instruction set".
182
+ /// Quick setup for enabling `debugPrintf` output (to stdout) at runtime:
183
+ /// - **set these environment variables**:
184
+ /// - `VK_LOADER_LAYERS_ENABLE=VK_LAYER_KHRONOS_validation`
185
+ /// - `VK_LAYER_PRINTF_ONLY_PRESET=1`
186
+ /// - `VK_LAYER_PRINTF_TO_STDOUT=1` (not always needed, but can help)
187
+ /// - if using `wgpu`, enable `wgpu::Features::SPIRV_SHADER_PASSTHROUGH`,
188
+ /// and use `create_shader_module_passthrough` instead of `create_shader_module`
189
+ /// - in case of errors, or no output (from a `panic!()`/`debug_printf!()`),
190
+ /// keep reading below for additional information and alternatives
184
191
///
185
- /// If you have multiple entry-points, you *may* need to also enable the
186
- /// `multimodule` node (see <https://github.com/KhronosGroup/SPIRV-Tools/issues/4892>).
192
+ /// ---
187
193
///
188
- /// **Note**: actually obtaining the `debugPrintf` output requires:
189
- /// * Vulkan Validation Layers (from e.g. the Vulkan SDK)
190
- /// * (they contain the `debugPrintf` implementation, a SPIR-V -> SPIR-V translation)
191
- /// * **set the `VK_LOADER_LAYERS_ENABLE=VK_LAYER_KHRONOS_validation`
192
- /// environment variable** to easily enable them without any code changes
193
- /// * alternatively, `"VK_LAYER_KHRONOS_validation"` can be passed during
194
- /// instance creation, to enable them programmatically
195
- /// * Validation Layers' `debugPrintf` support:
196
- /// * **set the `VK_LAYER_ENABLES=VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT`
197
- /// environment variable** to easily enable the `debugPrintf` support
198
- /// * alternatively, `VkValidationFeaturesEXT` during instance creation,
199
- /// or the `khronos_validation.enables` field in `vk_layer_settings.txt`,
200
- /// can be used to enable `VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT`
201
- /// (see also <https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/main/docs/debug_printf.md>)
202
- /// * for outputting the `debugPrintf` messages sent back from the GPU:
203
- /// * **set the `DEBUG_PRINTF_TO_STDOUT=1` environment variable** if you don't
204
- /// plan on customizing the reporting (see below for alternatives)
205
- /// * for `wgpu`:
206
- /// * **required**: `wgpu::Features::SPIRV_SHADER_PASSTHROUGH` (Naga lacks `debugPrintf`)
207
- /// * *optional*: building in debug mode (and/or with debug-assertions enabled),
208
- /// to enable `wgpu` logging/debug support
209
- /// * (the debug assertions requirement may be lifted in future `wgpu` versions)
210
- /// * this uses `VK_EXT_debug_utils` internally, and is a better-integrated
211
- /// alternative to just setting `DEBUG_PRINTF_TO_STDOUT=1`
212
- /// * `RUST_LOG=wgpu_hal::vulkan=info` (or equivalent) will enable said
213
- /// output (as `debugPrintf` messages have the "info" level)
214
- /// * `RUST_LOG` controls `env_logger`, which isn't itself required,
215
- /// but *some* `log`/`tracing` subscriber is needed to get any output
216
- /// * for Vulkan (e.g. via `ash`):
217
- /// * **required**: enabling the `VK_KHR_shader_non_semantic_info` Vulkan *Device* extension
218
- /// * *optional*: as described above, enabling the Validation Layers and
219
- /// their `debugPrintf` support can be done during instance creation
220
- /// * *optional*: integrating [`VK_EXT_debug_utils`](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_debug_utils.html)
221
- /// allows more reporting flexibility than `DEBUG_PRINTF_TO_STDOUT=1`)
194
+ /// **Note**: enabling this automatically adds the `SPV_KHR_non_semantic_info`
195
+ /// extension, as `debugPrintf` is from a "non-semantic extended instruction set".
196
+ ///
197
+ /// **Note**: `debugPrintf` output reaching the user involves:
198
+ /// - being able to load the shader in the first place:
199
+ /// - for `wgpu`, use "SPIR-V shader passthrough" (Naga lacks `debugPrintf`):
200
+ /// - enable `wgpu::Features::SPIRV_SHADER_PASSTHROUGH`
201
+ /// - replace `create_shader_module` calls with `create_shader_module_passthrough`
202
+ /// - *in theory*, the `VK_KHR_shader_non_semantic_info` Vulkan *Device* extension
203
+ /// (or requiring at least Vulkan 1.3, which incorporated it)
204
+ /// - *however*, Validation Layers don't actually check this anymore,
205
+ /// since Vulkan SDK version 1.4.313.0 (and drivers shouldn't care either)
206
+ /// - **general configurability** of [Vulkan SDK](https://vulkan.lunarg.com/sdk/home)
207
+ /// and/or [Vulkan Loader](https://github.com/KhronosGroup/Vulkan-Loader)
208
+ /// - *(this list doubles as a legend for shorthands used later below)*
209
+ /// - **env**: setting environment variables on the fly
210
+ /// - easiest for quick testing, no code changes/rebuilding needed
211
+ /// - e.g. `FOO=1 cargo run ...` (in UNIX-style shells)
212
+ /// - **instance**: programmatic control via `vkCreateInstance()` params
213
+ /// - best for integration with app-specific debugging functionality
214
+ /// - limited to direct Vulkan usage (e.g. `ash`, not `wgpu`)
215
+ /// - `VK_EXT_layer_settings` as a `VK_LAYER_*` environment variables
216
+ /// analogue, e.g. `VK_LAYER_FOO` controlled by a `VkLayerSettingEXT`
217
+ /// with `"foo"` as `pSettingName` (and an appropriate `type`/value),
218
+ /// included in `VkLayerSettingsCreateInfoEXT`'s `pSettings`
219
+ /// - on-disk configuration and interactive tooling, e.g.:
220
+ /// - `vk_layer_settings.txt` files, either hand-written, or generated by
221
+ /// the "Vulkan Configurator" GUI tool (included with the Vulkan SDK)
222
+ /// - third-party Vulkan debuggers like `RenderDoc`
223
+ /// - [Vulkan Validation Layers](https://github.com/KhronosGroup/Vulkan-ValidationLayers)
224
+ /// - (they contain the `debugPrintf` implementation, a SPIR-V -> SPIR-V translation)
225
+ /// - enabled by one of (as per "**general configurability**" above):
226
+ /// - **env**: `VK_LOADER_LAYERS_ENABLE=VK_LAYER_KHRONOS_validation`
227
+ /// - **instance**: `"VK_LAYER_KHRONOS_validation"` in the list of layers
228
+ /// - via `wgpu`: `wgpu::InstanceFlags::VALIDATION`
229
+ /// - Validation Layers' `debugPrintf` support
230
+ /// ([official docs](https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/main/docs/debug_printf.md)):
231
+ /// - enabled by one of (as per "**general configurability**" above):
232
+ /// - **env**: `VK_LAYER_PRINTF_ENABLE=1` (validation + `debugPrintf`)
233
+ /// - **env**: `VK_LAYER_PRINTF_ONLY_PRESET=1` (*only* `debugPrintf`, no validation)
234
+ /// - **instance**: `"printf_enable"` / `"printf_only_preset"` via `VkLayerSettingEXT`
235
+ /// (i.e. analogues for the two environment variables)
236
+ /// - **instance**: `VkValidationFeaturesEXT` with `pEnabledValidationFeatures`
237
+ /// containing `VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT`
238
+ /// - outputting the `debugPrintf` messages sent back from the GPU:
239
+ /// - defaults to common validation logging (itself defaulting to stdout)
240
+ /// - **env**: `VK_LAYER_PRINTF_TO_STDOUT=1` (and its **instance** analogue)
241
+ /// forces direct printing to stdout, bypassing `VK_EXT_debug_utils` etc.
242
+ /// - validation logging can itself be controlled via `VK_EXT_debug_utils`
243
+ /// - `wgpu` built in debug mode (and/or with debug-assertions enabled):
244
+ /// - it uses `VK_EXT_debug_utils` internally, exposing it via `log`
245
+ /// - with e.g. `env_logger`, `RUST_LOG=info` suffices for `debugPrintf`
246
+ /// messages (as they specifically have the "info" level)
247
+ /// - other `log`/`tracing` subscribers should be configured similarly
222
248
#[ cfg_attr( feature = "clap" , clap( skip) ) ]
223
249
DebugPrintfThenExit {
224
250
/// Whether to also print the entry-point inputs (excluding buffers/resources),
0 commit comments