Skip to content

Commit e29fbe9

Browse files
committed
address requested changes.
1 parent c4a362a commit e29fbe9

File tree

2 files changed

+109
-25
lines changed

2 files changed

+109
-25
lines changed

chapters/development_tools.adoc

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Layers are optional components that augment the Vulkan system. They can intercep
2424
The validation layer included multiple features:
2525
** link:https://vulkan.lunarg.com/doc/sdk/latest/windows/synchronization_usage.html[Synchronization Validation]: Identify resource access conflicts due to missing or incorrect synchronization operations between actions (Draw, Copy, Dispatch, Blit) reading or writing the same regions of memory.
2626
** link:https://vulkan.lunarg.com/doc/sdk/latest/windows/gpu_validation.html[GPU-Assisted Validation]: Instrument shader code to perform run-time checks for error conditions produced during shader execution.
27-
** link:https://vulkan.lunarg.com/doc/sdk/latest/windows/debug_printf.html[Shader printf]: Debug shader code by "`printing`" any values of interest to the debug callback or stdout.
27+
** link:https://vulkan.lunarg.com/doc/sdk/latest/windows/debug_printf.html[Shader printf]: Debug shader code by "`printing`" any values of interest to the debug callback or stdout. Environment variables provide a fast path for enabling this feature without code changes.
2828
** link:https://vulkan.lunarg.com/doc/sdk/latest/windows/best_practices.html[Best Practices Warnings]: Highlights potential performance issues, questionable usage patterns, common mistakes.
2929

3030
=== Vulkan SDK layers
@@ -113,14 +113,6 @@ With anything related to a GPU it is best to not assume and profile when possibl
113113
** Includes shader profiling and memory analysis
114114
** Integrates with xref:{chapters}ide.adoc#visual-studio[Visual Studio] and can be used standalone
115115

116-
==== Intel
117-
118-
* link:https://www.intel.com/content/www/us/en/developer/tools/graphics-performance-analyzers/overview.html[Intel(R) Graphics Performance Analyzers (GPA)] - Suite of tools for Intel GPUs.
119-
** Supports capturing and analyzing multi-frame streams of Vulkan apps
120-
** Provides CPU and GPU metrics visualization
121-
** Includes frame analysis and real-time performance monitoring
122-
** Works with xref:{chapters}ide.adoc#visual-studio[Visual Studio] and other development environments
123-
124116
==== ARM
125117

126118
* link:https://developer.arm.com/Tools%20and%20Software/Streamline%20Performance%20Analyzer[Arm Streamline Performance Analyzer] - Performance analysis tool for Arm-based devices.
@@ -157,12 +149,6 @@ With anything related to a GPU it is best to not assume and profile when possibl
157149

158150
=== Cross-Platform Profiling Tools
159151

160-
* link:https://renderdoc.org/[RenderDoc] - Open-source graphics debugger that supports Vulkan.
161-
** Captures and analyzes individual frames
162-
** Provides detailed API usage information
163-
** Supports shader debugging and resource inspection
164-
** Integrates with multiple IDEs including xref:{chapters}ide.adoc#visual-studio[Visual Studio], xref:{chapters}ide.adoc#visual-studio-code[VS Code], and others
165-
166152
* link:https://github.com/GPUOpen-Tools/OCAT[OCAT] (Open Capture and Analytics Tool) - FPS overlay and performance measurement tool.
167153
** Provides real-time FPS monitoring and performance metrics
168154
** Supports D3D11, D3D12, and Vulkan

chapters/ide.adoc

Lines changed: 108 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -798,10 +798,37 @@ VkInstanceCreateInfo createInfo{};
798798
createInfo.pNext = &validationFeatures;
799799
----
800800

801+
* Using environment variables (fast path):
802+
* Environment variables provide a quicker way to enable shader printf without code changes
803+
* These variables help avoid common configuration issues where shader printf appears not to work
804+
* Key environment variables:
805+
** `VK_VALIDATION_FEATURES=DEBUG_PRINTF`: Enables shader printf while disabling other validation
806+
** `VK_VALIDATION_FEATURES=+DEBUG_PRINTF,-CORE_VALIDATION`: Enables shader printf and disables core validation
807+
** `VK_LAYER_ENABLES`: Controls which validation layers are enabled
808+
** `VK_DBG_LAYER_LEVEL`: Controls the log level for validation messages
809+
** `VK_LAYER_PRINTF_ONLY_PRESET`: Preset that enables only shader printf functionality while disabling other validation features
810+
** `VK_LAYER_PRINTF_TO_STDOUT`: Redirects shader printf output to stdout instead of the debug callback
811+
* Example configuration:
812+
+
813+
[source,bash]
814+
----
815+
# Enable shader printf and disable core validation
816+
export VK_VALIDATION_FEATURES=+DEBUG_PRINTF,-CORE_VALIDATION
817+
# Set debug log level to verbose
818+
export VK_DBG_LAYER_LEVEL=info
819+
820+
# Alternative: Use the printf-only preset (simpler approach)
821+
export VK_LAYER_PRINTF_ONLY_PRESET=1
822+
823+
# Optional: Redirect printf output to stdout instead of debug callback
824+
export VK_LAYER_PRINTF_TO_STDOUT=1
825+
----
826+
801827
* IDE Integration:
802828
* Configure your IDE to capture debug output
803829
* For Visual Studio: Debug → Windows → Output
804830
* For VS Code: Add "console": "integratedTerminal" to your launch.json
831+
* Set environment variables in your IDE's debug configuration
805832

806833
==== Vendor-Specific Tools
807834

@@ -834,12 +861,22 @@ Vendor-specific tools offer advanced shader debugging capabilities:
834861
* Use Debug → Graphics → Start Graphics Debugging
835862
* Capture frames and analyze shaders
836863

837-
2. Configure NVIDIA Nsight integration:
864+
2. Configure shader printf environment variables:
865+
* Right-click on your project → Properties → Debugging
866+
* In the "Environment" field, add the following:
867+
** `VK_VALIDATION_FEATURES=+DEBUG_PRINTF,-CORE_VALIDATION`
868+
** `VK_DBG_LAYER_LEVEL=info`
869+
** Or use the simpler approach: `VK_LAYER_PRINTF_ONLY_PRESET=1`
870+
** Optionally add: `VK_LAYER_PRINTF_TO_STDOUT=1` to redirect output to stdout
871+
* These environment variables provide a fast path for enabling shader printf without code changes
872+
* Output will appear in the Debug → Windows → Output window (or in the console if using stdout redirection)
873+
874+
3. Configure NVIDIA Nsight integration:
838875
* Install NVIDIA Nsight Graphics
839876
* Use Extensions → NVIDIA → Start Graphics Debugging
840877
* Use the shader debugger to step through shader code
841878

842-
3. Configure AMD integration:
879+
4. Configure AMD integration:
843880
* Install AMD Radeon Developer Panel
844881
* Configure as an external tool
845882
* Capture and analyze shader performance
@@ -854,8 +891,11 @@ Vendor-specific tools offer advanced shader debugging capabilities:
854891
2. Configure shader debugging environment:
855892
* Add validation layer environment variables to launch.json
856893
* Configure terminal output capture for shader printf
894+
* Use the fast path environment variables for quick shader printf setup
895+
* You can use `VK_LAYER_PRINTF_ONLY_PRESET` for a simpler approach
896+
* Use `VK_LAYER_PRINTF_TO_STDOUT` to redirect output to stdout
857897

858-
.VS Code launch.json for shader debugging
898+
.VS Code launch.json for shader debugging with standard approach
859899
[source,json]
860900
----
861901
{
@@ -872,7 +912,33 @@ Vendor-specific tools offer advanced shader debugging capabilities:
872912
"environment": [
873913
{"name": "VK_LAYER_PATH", "value": "path/to/vulkan/sdk/layers"},
874914
{"name": "VK_INSTANCE_LAYERS", "value": "VK_LAYER_KHRONOS_validation"},
875-
{"name": "VK_VALIDATION_FEATURES", "value": "GPU_ASSISTED,DEBUG_PRINTF"}
915+
{"name": "VK_VALIDATION_FEATURES", "value": "+DEBUG_PRINTF,-CORE_VALIDATION"},
916+
{"name": "VK_DBG_LAYER_LEVEL", "value": "info"}
917+
],
918+
"console": "integratedTerminal"
919+
}
920+
]
921+
}
922+
----
923+
924+
.VS Code launch.json for shader debugging with printf-only preset
925+
[source,json]
926+
----
927+
{
928+
"version": "0.2.0",
929+
"configurations": [
930+
{
931+
"name": "Debug Vulkan Shaders (Printf Only)",
932+
"type": "cppdbg",
933+
"request": "launch",
934+
"program": "${workspaceFolder}/build/your_app",
935+
"args": [],
936+
"stopAtEntry": false,
937+
"cwd": "${workspaceFolder}",
938+
"environment": [
939+
{"name": "VK_LAYER_PATH", "value": "path/to/vulkan/sdk/layers"},
940+
{"name": "VK_LAYER_PRINTF_ONLY_PRESET", "value": "1"},
941+
{"name": "VK_LAYER_PRINTF_TO_STDOUT", "value": "1"}
876942
],
877943
"console": "integratedTerminal"
878944
}
@@ -888,15 +954,27 @@ Vendor-specific tools offer advanced shader debugging capabilities:
888954
* Create a run configuration that uses this external tool
889955

890956
2. Configure shader debugging environment:
891-
* Add validation layer environment variables to your run configuration
892-
* Enable console output capture for shader printf
957+
* Go to Run → Edit Configurations → Select your configuration
958+
* Click on "Environment Variables" and add:
959+
** `VK_VALIDATION_FEATURES=+DEBUG_PRINTF,-CORE_VALIDATION`
960+
** `VK_DBG_LAYER_LEVEL=info`
961+
** Or use the simpler approach: `VK_LAYER_PRINTF_ONLY_PRESET=1`
962+
** Optionally add: `VK_LAYER_PRINTF_TO_STDOUT=1` to redirect output to stdout
963+
* These environment variables provide a fast path for enabling shader printf without code changes
964+
* Enable console output capture for shader printf by selecting "Allow parallel run"
893965

894966
==== Xcode
895967

896968
1. Configure shader debugging on macOS:
897969
* MoltenVK has limited shader debugging support
898-
* Use environment variables to enable validation layers
899-
* Configure shader printf output capture
970+
* Edit your scheme (Product → Scheme → Edit Scheme)
971+
* In the Run section, go to Arguments → Environment Variables and add:
972+
** `VK_VALIDATION_FEATURES=+DEBUG_PRINTF,-CORE_VALIDATION`
973+
** `VK_DBG_LAYER_LEVEL=info`
974+
** Or use the simpler approach: `VK_LAYER_PRINTF_ONLY_PRESET=1`
975+
** Optionally add: `VK_LAYER_PRINTF_TO_STDOUT=1` to redirect output to stdout
976+
* These environment variables provide a fast path for enabling shader printf without code changes
977+
* Configure shader printf output capture by enabling "Show Debug Output" in the Options tab
900978

901979
2. Alternative approaches:
902980
* Use RenderDoc on a different platform for shader debugging
@@ -911,8 +989,28 @@ Vendor-specific tools offer advanced shader debugging capabilities:
911989

912990
2. Configure shader debugging for Android:
913991
* Add validation layer configuration to your application
914-
* Use logcat to capture shader printf output
915-
* Configure environment variables in your launch configuration
992+
* For shader printf, add the following to your AndroidManifest.xml:
993+
+
994+
[source,xml]
995+
----
996+
<application>
997+
<!-- Standard approach -->
998+
<meta-data android:name="debug.vulkan.validation_features"
999+
android:value="+DEBUG_PRINTF,-CORE_VALIDATION" />
1000+
<meta-data android:name="debug.vulkan.debug_layer_level"
1001+
android:value="info" />
1002+
1003+
<!-- Alternative: Use the printf-only preset (simpler approach) -->
1004+
<meta-data android:name="debug.vulkan.layer_printf_only_preset"
1005+
android:value="1" />
1006+
1007+
<!-- Optional: Redirect printf output to stdout -->
1008+
<meta-data android:name="debug.vulkan.layer_printf_to_stdout"
1009+
android:value="1" />
1010+
</application>
1011+
----
1012+
* These meta-data entries provide a fast path for enabling shader printf without code changes
1013+
* Use logcat to capture shader printf output with the filter tag "Vulkan"
9161014

9171015
=== Shader Debugging Best Practices
9181016

0 commit comments

Comments
 (0)