diff --git a/docs/debug_printf.md b/docs/debug_printf.md index e8ff8e987fc..d6f88e35cd9 100644 --- a/docs/debug_printf.md +++ b/docs/debug_printf.md @@ -25,9 +25,13 @@ The Debug Printf settings are managed by configuring the Validation Layer. These Debug Printf settings can also be managed using the [Vulkan Configurator](https://vulkan.lunarg.com/doc/sdk/latest/windows/vkconfig.html) included with the Vulkan SDK. +For those who "just need to quick use it" there is also a `set VK_LAYER_PRINTF_ONLY_PRESET=1` environment variable that will turn on DebugPrintf and turn off all of the other validation logic. + ### Settings > All settings are found in Vulkan Configurator (`VkConfig`) +> +> Even if you use `VK_LAYER_PRINTF_ONLY_PRESET` you need to set this settings yourself as desired There are currently 3 environment variables that are used for settings in Debug Printf @@ -182,8 +186,6 @@ Would print **"Here's a vector of floats 1.20, 2.20, 3.20, 4.20"** Would print **"Unsigned long as decimal 2305843009213693953 and as hex 0x2000000000000001"** ### Limitations -* Debug Printf cannot be used at the same time as GPU Assisted Validation. - * https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/8192 * Debug Printf consumes a descriptor set. If your application uses every last descriptor set on the GPU, Debug Printf will not work. * Suggest using `VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT` @@ -193,8 +195,7 @@ buffer size. * Can be controlled with `VK_LAYER_PRINTF_BUFFER_SIZE` * Validation Layers version: `1.2.135.0` or later is required * Vulkan API version 1.1 or greater is required -* VkPhysicalDevice features: `fragmentStoresAndAtomics` and `vertexPipelineStoresAndAtomics` -are required +* When using Validation Layers, the `fragmentStoresAndAtomics`, `vertexPipelineStoresAndAtomics`, and `timelineSemaphore` features are required * The `VK_KHR_shader_non_semantic_info` extension must be supported and enabled * If using the Validation Layers, we attempt to strip it out to allow wider range of users to still use Debug Printf * RenderDoc release 1.14 or later diff --git a/layers/VkLayer_khronos_validation.json.in b/layers/VkLayer_khronos_validation.json.in index 0cbeeef47d9..f10ac254f04 100644 --- a/layers/VkLayer_khronos_validation.json.in +++ b/layers/VkLayer_khronos_validation.json.in @@ -125,8 +125,12 @@ "value": false }, { - "key": "validate_gpu_based", - "value": "GPU_BASED_NONE" + "key": "printf_enable", + "value": false + }, + { + "key": "gpuav_enable", + "value": false }, { "key": "validate_best_practices", @@ -207,8 +211,12 @@ "value": false }, { - "key": "validate_gpu_based", - "value": "GPU_BASED_NONE" + "key": "printf_enable", + "value": false + }, + { + "key": "gpuav_enable", + "value": false }, { "key": "validate_best_practices", @@ -290,8 +298,12 @@ "value": false }, { - "key": "validate_gpu_based", - "value": "GPU_BASED_NONE" + "key": "printf_enable", + "value": false + }, + { + "key": "gpuav_enable", + "value": false }, { "key": "validate_best_practices", @@ -375,8 +387,20 @@ "value": true }, { - "key": "validate_gpu_based", - "value": "GPU_BASED_NONE" + "key": "printf_enable", + "value": false + }, + { + "key": "gpuav_enable", + "value": false + }, + { + "key": "gpuav_shader_instrumentation", + "value": false + }, + { + "key": "gpuav_buffers_validation", + "value": false }, { "key": "validate_best_practices", @@ -456,8 +480,28 @@ "value": false }, { - "key": "validate_gpu_based", - "value": "GPU_BASED_GPU_ASSISTED" + "key": "printf_enable", + "value": false + }, + { + "key": "gpuav_enable", + "value": true + }, + { + "key": "gpuav_shader_instrumentation", + "value": true + }, + { + "key": "gpuav_cache_instrumented_shaders", + "value": true + }, + { + "key": "gpuav_select_instrumented_shaders", + "value": false + }, + { + "key": "gpuav_buffers_validation", + "value": true }, { "key": "gpuav_reserve_binding_slot", @@ -541,8 +585,12 @@ "value": false }, { - "key": "validate_gpu_based", - "value": "GPU_BASED_DEBUG_PRINTF" + "key": "gpuav_enable", + "value": false + }, + { + "key": "printf_enable", + "value": true }, { "key": "validate_best_practices", @@ -819,10 +867,11 @@ { "key": "validate_gpu_based", "label": "GPU Base", - "description": "Setting an option here will enable specialized areas of validation", + "description": "[Deprecated] Setting to choose between DebugPrintf and GPU-AV", "type": "ENUM", "default": "GPU_BASED_NONE", "expanded": true, + "view": "HIDDEN", "status": "STABLE", "platforms": [ "WINDOWS", @@ -840,15 +889,243 @@ "description": "Enables processing of debug printf instructions in shaders and sending debug strings to the debug callback.", "url": "${LUNARG_SDK}/debug_printf.html", "status": "STABLE", + "platforms": [ + "WINDOWS", + "LINUX" + ] + }, + { + "key": "GPU_BASED_GPU_ASSISTED", + "label": "GPU-Assisted", + "description": "Check for API usage errors at shader execution time.", + "url": "${LUNARG_SDK}/gpu_validation.html", + "status": "STABLE", + "platforms": [ + "WINDOWS", + "LINUX" + ] + } + ] + }, + { + "key": "printf_only_preset", + "label": "Debug Printf only preset", + "description": "A single, quick setting to turn on only DebugPrintf and turn off everything else", + "type": "BOOL", + "default": false, + "view": "HIDDEN", + "platforms": [ + "WINDOWS", + "LINUX" + ] + }, + { + "key": "printf_enable", + "label": "Debug Printf", + "description": "Enable DebugPrintf and will print anything use NonSemantic.DebugPrintf in their SPIR-V", + "type": "BOOL", + "url": "${LUNARG_SDK}/debug_printf.html", + "default": false, + "platforms": [ + "WINDOWS", + "LINUX" + ], + "settings": [ + { + "key": "printf_to_stdout", + "label": "Redirect Printf messages to stdout", + "description": "Enable redirection of Debug Printf messages from the debug callback to stdout", + "type": "BOOL", + "default": true, + "platforms": [ + "WINDOWS", + "LINUX" + ], + "dependence": { + "mode": "ALL", + "settings": [ + { + "key": "printf_enable", + "value": true + } + ] + } + }, + { + "key": "printf_verbose", + "label": "Printf verbose", + "description": "Will print out handles, instruction location, position in command buffer, and more", + "type": "BOOL", + "default": false, + "platforms": [ + "WINDOWS", + "LINUX" + ], + "dependence": { + "mode": "ALL", + "settings": [ + { + "key": "printf_enable", + "value": true + } + ] + } + }, + { + "key": "printf_buffer_size", + "label": "Printf buffer size", + "description": "Set the size in bytes of the buffer per draw/dispatch/traceRays to hold the messages", + "type": "INT", + "default": 1024, + "range": { + "min": 128, + "max": 1048576 + }, + "unit": "bytes", + "platforms": [ + "WINDOWS", + "LINUX" + ], + "dependence": { + "mode": "ALL", + "settings": [ + { + "key": "printf_enable", + "value": true + } + ] + } + } + ] + }, + { + "key": "gpuav_enable", + "label": "GPU Assisted Validation", + "description": "Enable validation that cannot be done the CPU and needs hooks into the GPU execution", + "type": "BOOL", + "default": false, + "expanded": true, + "status": "STABLE", + "platforms": [ + "WINDOWS", + "LINUX" + ], + "settings": [ + { + "key": "gpuav_shader_instrumentation", + "label": "Shader instrumentation", + "description": "Instrument shaders to validate descriptors, descriptor indexing, buffer device addresses and ray queries. Warning: will considerably slow down shader executions.", + "type": "BOOL", + "expanded": true, + "default": true, "platforms": [ "WINDOWS", "LINUX" ], + "dependence": { + "mode": "ALL", + "settings": [ + { + "key": "gpuav_enable", + "value": true + } + ] + }, "settings": [ { - "key": "printf_to_stdout", - "label": "Redirect Printf messages to stdout", - "description": "Enable redirection of Debug Printf messages from the debug callback to stdout", + "key": "gpuav_descriptor_checks", + "label": "Descriptors indexing", + "description": "Enable descriptors and buffer out of bounds validation when using descriptor indexing", + "type": "BOOL", + "expanded": true, + "default": true, + "platforms": [ + "WINDOWS", + "LINUX" + ], + "dependence": { + "mode": "ALL", + "settings": [ + { + "key": "gpuav_shader_instrumentation", + "value": true + } + ] + }, + "settings": [ + { + "key": "gpuav_warn_on_robust_oob", + "label": "Generate warning on out of bounds accesses even if buffer robustness is enabled", + "description": "Warn on out of bounds accesses even if robustness is enabled", + "type": "BOOL", + "default": true, + "platforms": [ + "WINDOWS", + "LINUX" + ], + "dependence": { + "mode": "ALL", + "settings": [ + { + "key": "gpuav_descriptor_checks", + "value": true + } + ] + } + } + ] + }, + { + "key": "gpuav_buffer_address_oob", + "label": "Out of bounds buffer device addresses", + "type": "BOOL", + "default": true, + "expanded": true, + "description": "Check for invalid access using buffer device address", + "platforms": [ + "WINDOWS", + "LINUX" + ], + "dependence": { + "mode": "ALL", + "settings": [ + { + "key": "gpuav_shader_instrumentation", + "value": true + } + ] + }, + "settings": [ + { + "key": "gpuav_max_buffer_device_addresses", + "label": "Maximum number of buffer device addresses in use at one time", + "description": "", + "type": "INT", + "default": 10000, + "range": { + "min": 100, + "max": 10000000 + }, + "platforms": [ + "WINDOWS", + "LINUX" + ], + "dependence": { + "mode": "ALL", + "settings": [ + { + "key": "gpuav_buffer_address_oob", + "value": true + } + ] + } + } + ] + }, + { + "key": "gpuav_validate_ray_query", + "label": "RayQuery SPIR-V Instructions", + "description": "Enable shader instrumentation on OpRayQueryInitializeKHR", "type": "BOOL", "default": true, "platforms": [ @@ -859,18 +1136,18 @@ "mode": "ALL", "settings": [ { - "key": "validate_gpu_based", - "value": "GPU_BASED_DEBUG_PRINTF" + "key": "gpuav_shader_instrumentation", + "value": true } ] } }, { - "key": "printf_verbose", - "label": "Printf verbose", - "description": "Will print out handles, instruction location, position in command buffer, and more", + "key": "gpuav_cache_instrumented_shaders", + "label": "Cache instrumented shaders rather than instrumenting them on every run", + "description": "Enable instrumented shader caching", "type": "BOOL", - "default": false, + "default": true, "platforms": [ "WINDOWS", "LINUX" @@ -879,23 +1156,18 @@ "mode": "ALL", "settings": [ { - "key": "validate_gpu_based", - "value": "GPU_BASED_DEBUG_PRINTF" + "key": "gpuav_shader_instrumentation", + "value": true } ] } }, { - "key": "printf_buffer_size", - "label": "Printf buffer size", - "description": "Set the size in bytes of the buffer per draw/dispatch/traceRays to hold the messages", - "type": "INT", - "default": 1024, - "range": { - "min": 128, - "max": 1048576 - }, - "unit": "bytes", + "key": "gpuav_select_instrumented_shaders", + "label": "Enable instrumenting shaders selectively", + "description": "Select which shaders to instrument passing a VkValidationFeaturesEXT struct with GPU-AV enabled in the VkShaderModuleCreateInfo pNext", + "type": "BOOL", + "default": false, "platforms": [ "WINDOWS", "LINUX" @@ -904,8 +1176,8 @@ "mode": "ALL", "settings": [ { - "key": "validate_gpu_based", - "value": "GPU_BASED_DEBUG_PRINTF" + "key": "gpuav_shader_instrumentation", + "value": true } ] } @@ -913,21 +1185,31 @@ ] }, { - "key": "GPU_BASED_GPU_ASSISTED", - "label": "GPU-Assisted", - "description": "Check for API usage errors at shader execution time.", - "url": "${LUNARG_SDK}/gpu_validation.html", + "key": "gpuav_buffers_validation", + "label": "Buffer content validation", + "description": "Validate buffers containing parameters used in indirect Vulkan commands, or used in copy commands", + "type": "BOOL", + "default": true, "platforms": [ "WINDOWS", "LINUX" ], + "dependence": { + "mode": "ALL", + "settings": [ + { + "key": "gpuav_enable", + "value": true + } + ] + }, "settings": [ { - "key": "gpuav_shader_instrumentation", - "label": "Shader instrumentation", - "description": "Instrument shaders to validate descriptors, descriptor indexing, buffer device addresses and ray queries. Warning: will considerably slow down shader executions.", + "key": "gpuav_indirect_draws_buffers", + "label": "Indirect draws parameters", "type": "BOOL", - "default": true, + "default": false, + "description": "(Warning - still experimental) Validate buffers containing draw parameters used in indirect draw commands", "platforms": [ "WINDOWS", "LINUX" @@ -936,168 +1218,58 @@ "mode": "ALL", "settings": [ { - "key": "validate_gpu_based", - "value": "GPU_BASED_GPU_ASSISTED" + "key": "gpuav_buffers_validation", + "value": true } ] - }, - "settings": [ - { - "key": "gpuav_descriptor_checks", - "label": "Descriptors indexing", - "description": "Enable descriptors and buffer out of bounds validation when using descriptor indexing", - "type": "BOOL", - "default": true, - "platforms": [ - "WINDOWS", - "LINUX" - ], - "dependence": { - "mode": "ALL", - "settings": [ - { - "key": "gpuav_shader_instrumentation", - "value": true - } - ] - }, - "settings": [ - { - "key": "gpuav_warn_on_robust_oob", - "label": "Generate warning on out of bounds accesses even if buffer robustness is enabled", - "description": "Warn on out of bounds accesses even if robustness is enabled", - "type": "BOOL", - "default": true, - "platforms": [ - "WINDOWS", - "LINUX" - ], - "dependence": { - "mode": "ALL", - "settings": [ - { - "key": "gpuav_shader_instrumentation", - "value": true - } - ] - } - } - ] - }, - { - "key": "gpuav_buffer_address_oob", - "label": "Out of bounds buffer device addresses", - "type": "BOOL", - "default": true, - "description": "Check for ", - "platforms": [ - "WINDOWS", - "LINUX" - ], - "dependence": { - "mode": "ALL", - "settings": [ - { - "key": "gpuav_shader_instrumentation", - "value": true - } - ] - }, - "settings": [ - { - "key": "gpuav_max_buffer_device_addresses", - "label": "Maximum number of buffer device addresses in use at one time", - "description": "", - "type": "INT", - "default": 10000, - "range": { - "min": 100, - "max": 10000000 - }, - "platforms": [ - "WINDOWS", - "LINUX" - ], - "dependence": { - "mode": "ALL", - "settings": [ - { - "key": "gpuav_shader_instrumentation", - "value": true - } - ] - } - } - ] - }, - { - "key": "gpuav_validate_ray_query", - "label": "RayQuery SPIR-V Instructions", - "description": "Enable shader instrumentation on OpRayQueryInitializeKHR", - "type": "BOOL", - "default": true, - "platforms": [ - "WINDOWS", - "LINUX" - ], - "dependence": { - "mode": "ALL", - "settings": [ - { - "key": "gpuav_shader_instrumentation", - "value": true - } - ] - } - }, - { - "key": "gpuav_cache_instrumented_shaders", - "label": "Cache instrumented shaders rather than instrumenting them on every run", - "description": "Enable instrumented shader caching", - "type": "BOOL", - "default": true, - "platforms": [ - "WINDOWS", - "LINUX" - ], - "dependence": { - "mode": "ALL", - "settings": [ - { - "key": "gpuav_shader_instrumentation", - "value": true - } - ] + } + }, + { + "key": "gpuav_indirect_dispatches_buffers", + "label": "Indirect dispatches parameters", + "type": "BOOL", + "default": false, + "description": "(Warning - still experimental) Validate buffers containing dispatch parameters used in indirect dispatch commands", + "platforms": [ + "WINDOWS", + "LINUX" + ], + "dependence": { + "mode": "ALL", + "settings": [ + { + "key": "gpuav_buffers_validation", + "value": true } - }, - { - "key": "gpuav_select_instrumented_shaders", - "label": "Enable instrumenting shaders selectively", - "description": "Select which shaders to instrument passing a VkValidationFeaturesEXT struct with GPU-AV enabled in the VkShaderModuleCreateInfo pNext", - "type": "BOOL", - "default": false, - "platforms": [ - "WINDOWS", - "LINUX" - ], - "dependence": { - "mode": "ALL", - "settings": [ - { - "key": "gpuav_shader_instrumentation", - "value": true - } - ] + ] + } + }, + { + "key": "gpuav_indirect_trace_rays_buffers", + "label": "Indirect trace rays parameters", + "type": "BOOL", + "default": false, + "description": "(Warning - still experimental) Validate buffers containing ray tracing parameters used in indirect ray tracing commands", + "platforms": [ + "WINDOWS", + "LINUX" + ], + "dependence": { + "mode": "ALL", + "settings": [ + { + "key": "gpuav_buffers_validation", + "value": true } - } - ] + ] + } }, { - "key": "gpuav_buffers_validation", - "label": "Buffer content validation", - "description": "Validate buffers containing parameters used in indirect Vulkan commands, or used in copy commands", + "key": "gpuav_buffer_copies", + "label": "Buffer copies", "type": "BOOL", "default": true, + "description": "Validate copies involving a VkBuffer. Right now only validates copy buffer to image.", "platforms": [ "WINDOWS", "LINUX" @@ -1106,100 +1278,60 @@ "mode": "ALL", "settings": [ { - "key": "validate_gpu_based", - "value": "GPU_BASED_GPU_ASSISTED" + "key": "gpuav_buffers_validation", + "value": true } ] - }, - "settings": [ - { - "key": "gpuav_indirect_draws_buffers", - "label": "Indirect draws parameters", - "type": "BOOL", - "default": false, - "description": "(Warning - still experimental) Validate buffers containing draw parameters used in indirect draw commands", - "platforms": [ - "WINDOWS", - "LINUX" - ], - "dependence": { - "mode": "ALL", - "settings": [ - { - "key": "gpuav_buffers_validation", - "value": true - } - ] - } - }, - { - "key": "gpuav_indirect_dispatches_buffers", - "label": "Indirect dispatches parameters", - "type": "BOOL", - "default": false, - "description": "(Warning - still experimental) Validate buffers containing dispatch parameters used in indirect dispatch commands", - "platforms": [ - "WINDOWS", - "LINUX" - ], - "dependence": { - "mode": "ALL", - "settings": [ - { - "key": "gpuav_buffers_validation", - "value": true - } - ] - } - }, - { - "key": "gpuav_indirect_trace_rays_buffers", - "label": "Indirect trace rays parameters", - "type": "BOOL", - "default": false, - "description": "(Warning - still experimental) Validate buffers containing ray tracing parameters used in indirect ray tracing commands", - "platforms": [ - "WINDOWS", - "LINUX" - ], - "dependence": { - "mode": "ALL", - "settings": [ - { - "key": "gpuav_buffers_validation", - "value": true - } - ] - } - }, - { - "key": "gpuav_buffer_copies", - "label": "Buffer copies", - "type": "BOOL", - "default": true, - "description": "Validate copies involving a VkBuffer. Right now only validates copy buffer to image.", - "platforms": [ - "WINDOWS", - "LINUX" - ], - "dependence": { - "mode": "ALL", - "settings": [ - { - "key": "gpuav_buffers_validation", - "value": true - } - ] + } + } + ] + }, + { + "key": "gpuav_advanced_settings", + "label": "Advanced Settings", + "description": "GPU-AV advanced settings", + "type": "GROUP", + "view": "ADVANCED", + "platforms": [ + "WINDOWS", + "LINUX" + ], + "dependence": { + "mode": "ALL", + "settings": [ + { + "key": "gpuav_enable", + "value": true + } + ] + }, + "settings": [ + { + "key": "gpuav_reserve_binding_slot", + "label": "Reserve Descriptor Set Binding Slot", + "type": "BOOL", + "default": true, + "description": "Specifies that the validation layers reserve a descriptor set binding slot for their own use. The layer reports a value for VkPhysicalDeviceLimits::maxBoundDescriptorSets that is one less than the value reported by the device. If the device supports the binding of only one descriptor set, the validation layer does not perform GPU-assisted validation.", + "platforms": [ + "WINDOWS", + "LINUX" + ], + "dependence": { + "mode": "ALL", + "settings": [ + { + "key": "gpuav_enable", + "value": true } - } - ] + ] + } }, { - "key": "gpuav_advanced_settings", - "label": "Advanced Settings", - "description": "GPU-AV advanced settings", - "type": "GROUP", - "view": "ADVANCED", + "key": "gpuav_vma_linear_output", + "label": "Linear Memory Allocation Mode", + "description": "Use VMA linear memory allocations for GPU-AV output buffers instead of finding best place for new allocations among free regions to optimize memory usage. Enabling this setting reduces performance cost but disabling this method minimizes memory usage.", + "type": "BOOL", + "default": true, "platforms": [ "WINDOWS", "LINUX" @@ -1208,60 +1340,81 @@ "mode": "ALL", "settings": [ { - "key": "validate_gpu_based", - "value": "GPU_BASED_GPU_ASSISTED" + "key": "gpuav_enable", + "value": true } ] - }, - "settings": [ - { - "key": "gpuav_reserve_binding_slot", - "label": "Reserve Descriptor Set Binding Slot", - "type": "BOOL", - "default": true, - "description": "Specifies that the validation layers reserve a descriptor set binding slot for their own use. The layer reports a value for VkPhysicalDeviceLimits::maxBoundDescriptorSets that is one less than the value reported by the device. If the device supports the binding of only one descriptor set, the validation layer does not perform GPU-assisted validation.", - "platforms": [ - "WINDOWS", - "LINUX" - ], - "dependence": { - "mode": "ALL", - "settings": [ - { - "key": "validate_gpu_based", - "value": "GPU_BASED_GPU_ASSISTED" - } - ] + } + } + ] + }, + { + "key": "gpuav_debug_settings", + "label": "Developer Debug Settings", + "description": "GPU-AV debug settings", + "type": "GROUP", + "view": "ADVANCED", + "platforms": [ + "WINDOWS", + "LINUX" + ], + "dependence": { + "mode": "ALL", + "settings": [ + { + "key": "gpuav_enable", + "value": true + } + ] + }, + "settings": [ + { + "key": "gpuav_debug_disable_all", + "label": "Disable all of GPU-AV", + "description": "Acts as a VkValidationFeatureDisableEXT to override the VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT passed by the user", + "type": "BOOL", + "view": "HIDDEN", + "default": false, + "platforms": [ + "WINDOWS", + "LINUX" + ], + "dependence": { + "mode": "ALL", + "settings": [ + { + "key": "gpuav_enable", + "value": true } - }, - { - "key": "gpuav_vma_linear_output", - "label": "Linear Memory Allocation Mode", - "description": "Use VMA linear memory allocations for GPU-AV output buffers instead of finding best place for new allocations among free regions to optimize memory usage. Enabling this setting reduces performance cost but disabling this method minimizes memory usage.", - "type": "BOOL", - "default": true, - "platforms": [ - "WINDOWS", - "LINUX" - ], - "dependence": { - "mode": "ALL", - "settings": [ - { - "key": "validate_gpu_based", - "value": "GPU_BASED_GPU_ASSISTED" - } - ] + ] + } + }, + { + "key": "gpuav_debug_validate_instrumented_shaders", + "label": "Validate instrumented shaders", + "description": "Run spirv-val after doing shader instrumentation", + "type": "BOOL", + "default": false, + "platforms": [ + "WINDOWS", + "LINUX" + ], + "dependence": { + "mode": "ALL", + "settings": [ + { + "key": "gpuav_enable", + "value": true } - } - ] + ] + } }, { - "key": "gpuav_debug_settings", - "label": "Developer Debug Settings", - "description": "GPU-AV debug settings", - "type": "GROUP", - "view": "ADVANCED", + "key": "gpuav_debug_dump_instrumented_shaders", + "label": "Dump instrumented shaders", + "description": "Will dump the instrumented shaders (before and after) to working directory", + "type": "BOOL", + "default": false, "platforms": [ "WINDOWS", "LINUX" @@ -1270,117 +1423,54 @@ "mode": "ALL", "settings": [ { - "key": "validate_gpu_based", - "value": "GPU_BASED_GPU_ASSISTED" + "key": "gpuav_enable", + "value": true } ] + } + }, + { + "key": "gpuav_debug_max_instrumented_count", + "label": "Limit how many time a pass can instrument the SPIR-V", + "description": "Zero is same as unlimited", + "type": "INT", + "default": 0, + "range": { + "min": 0 }, - "settings": [ - { - "key": "gpuav_debug_disable_all", - "label": "Disable all of GPU-AV", - "description": "Acts as a VkValidationFeatureDisableEXT to override the VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT passed by the user", - "type": "BOOL", - "view": "HIDDEN", - "default": false, - "platforms": [ - "WINDOWS", - "LINUX" - ], - "dependence": { - "mode": "ALL", - "settings": [ - { - "key": "validate_gpu_based", - "value": "GPU_BASED_GPU_ASSISTED" - } - ] - } - }, - { - "key": "gpuav_debug_validate_instrumented_shaders", - "label": "Validate instrumented shaders", - "description": "Run spirv-val after doing shader instrumentation", - "type": "BOOL", - "default": false, - "platforms": [ - "WINDOWS", - "LINUX" - ], - "dependence": { - "mode": "ALL", - "settings": [ - { - "key": "validate_gpu_based", - "value": "GPU_BASED_GPU_ASSISTED" - } - ] - } - }, - { - "key": "gpuav_debug_dump_instrumented_shaders", - "label": "Dump instrumented shaders", - "description": "Will dump the instrumented shaders (before and after) to working directory", - "type": "BOOL", - "default": false, - "platforms": [ - "WINDOWS", - "LINUX" - ], - "dependence": { - "mode": "ALL", - "settings": [ - { - "key": "validate_gpu_based", - "value": "GPU_BASED_GPU_ASSISTED" - } - ] - } - }, - { - "key": "gpuav_debug_max_instrumented_count", - "label": "Limit how many time a pass can instrument the SPIR-V", - "description": "Zero is same as unlimited", - "type": "INT", - "default": 0, - "range": { - "min": 0 - }, - "platforms": [ - "WINDOWS", - "LINUX" - ], - "dependence": { - "mode": "ALL", - "settings": [ - { - "key": "validate_gpu_based", - "value": "GPU_BASED_GPU_ASSISTED" - } - ] + "platforms": [ + "WINDOWS", + "LINUX" + ], + "dependence": { + "mode": "ALL", + "settings": [ + { + "key": "gpuav_enable", + "value": true } - }, - { - "key": "gpuav_debug_print_instrumentation_info", - "label": "Print SPIR-V instrumentation info", - "description": "Prints verbose information about the instrumentation of the SPIR-V", - "type": "BOOL", - "default": false, - "platforms": [ - "WINDOWS", - "LINUX" - ], - "dependence": { - "mode": "ALL", - "settings": [ - { - "key": "validate_gpu_based", - "value": "GPU_BASED_GPU_ASSISTED" - } - ] + ] + } + }, + { + "key": "gpuav_debug_print_instrumentation_info", + "label": "Print SPIR-V instrumentation info", + "description": "Prints verbose information about the instrumentation of the SPIR-V", + "type": "BOOL", + "default": false, + "platforms": [ + "WINDOWS", + "LINUX" + ], + "dependence": { + "mode": "ALL", + "settings": [ + { + "key": "gpuav_enable", + "value": true } - } - ] + ] + } } ] } diff --git a/layers/gpu/core/gpu_settings.h b/layers/gpu/core/gpu_settings.h index 257b3a0c0ac..ce33c25a926 100644 --- a/layers/gpu/core/gpu_settings.h +++ b/layers/gpu/core/gpu_settings.h @@ -25,7 +25,6 @@ struct GpuAVSettings { bool cache_instrumented_shaders = true; bool select_instrumented_shaders = false; - bool buffers_validation_enabled = true; // Turned off until we can fix things // see https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/8579 bool validate_indirect_draws_buffers = false; @@ -40,7 +39,9 @@ struct GpuAVSettings { uint32_t debug_max_instrumented_count = 0; // zero is same as "unlimited" bool debug_print_instrumentation_info = false; - bool shader_instrumentation_enabled = true; + // Note - even though DebugPrintf basically fits in here, from the user point of view they are different and that is reflected + // in the settings (which are reflected in VkConfig). To make our lives easier, we just make these settings with the hierarchy + // of the settings exposed struct ShaderInstrumentation { bool bindless_descriptor = true; bool buffer_device_address = true; @@ -53,8 +54,6 @@ struct GpuAVSettings { } // Also disables shader caching and select shader instrumentation void DisableShaderInstrumentationAndOptions() { - shader_instrumentation_enabled = false; - shader_instrumentation.bindless_descriptor = false; shader_instrumentation.buffer_device_address = false; shader_instrumentation.ray_query = false; @@ -73,6 +72,18 @@ struct GpuAVSettings { validate_buffer_copies = enabled; } + // For people who are using VkValidationFeatureEnableEXT to set only DebugPrintf (and want the rest of GPU-AV off) + bool debug_printf_only = false; + void SetOnlyDebugPrintf() { + DisableShaderInstrumentationAndOptions(); + SetBufferValidationEnabled(false); + + // Turn on the minmal settings for DebugPrintf + debug_printf_enabled = true; + debug_printf_only = true; + } + + bool debug_printf_enabled = false; bool debug_printf_to_stdout = false; bool debug_printf_verbose = false; uint32_t debug_printf_buffer_size = 1024; diff --git a/layers/gpu/core/gpuav.h b/layers/gpu/core/gpuav.h index 8014f53c217..f1b32d64a4d 100644 --- a/layers/gpu/core/gpuav.h +++ b/layers/gpu/core/gpuav.h @@ -55,10 +55,7 @@ class Validator : public gpu::GpuShaderInstrumentor { using Field = vvl::Field; public: - Validator() { - container_type = LayerObjectTypeGpuAssisted; - gpuav_enabled = true; - } + Validator() { container_type = LayerObjectTypeGpuAssisted; } // gpuav_setup.cpp // ------------- diff --git a/layers/gpu/core/gpuav_record.cpp b/layers/gpu/core/gpuav_record.cpp index bb20ef85bbe..5f4e14a062d 100644 --- a/layers/gpu/core/gpuav_record.cpp +++ b/layers/gpu/core/gpuav_record.cpp @@ -306,7 +306,6 @@ void Validator::PreCallRecordCmdDraw(VkCommandBuffer commandBuffer, uint32_t ver InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - PreCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); } @@ -319,8 +318,9 @@ void Validator::PostCallRecordCmdDraw(VkCommandBuffer commandBuffer, uint32_t ve InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, @@ -334,7 +334,6 @@ void Validator::PreCallRecordCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - PreCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); } @@ -349,8 +348,9 @@ void Validator::PostCallRecordCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uin InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, @@ -376,7 +376,9 @@ void Validator::PostCallRecordCmdDrawIndexed(VkCommandBuffer commandBuffer, uint InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, @@ -407,8 +409,9 @@ void Validator::PostCallRecordCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuff InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, @@ -420,7 +423,6 @@ void Validator::PreCallRecordCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBu InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - InsertIndirectDrawValidation(*this, record_obj.location, *cb_state, buffer, offset, count, VK_NULL_HANDLE, 0, stride); PreCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); } @@ -434,8 +436,9 @@ void Validator::PostCallRecordCmdDrawIndirect(VkCommandBuffer commandBuffer, VkB InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, @@ -447,7 +450,6 @@ void Validator::PreCallRecordCmdDrawIndexedIndirect(VkCommandBuffer commandBuffe InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - InsertIndirectDrawValidation(*this, record_obj.location, *cb_state, buffer, offset, count, VK_NULL_HANDLE, 0, stride); PreCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); } @@ -461,8 +463,9 @@ void Validator::PostCallRecordCmdDrawIndexedIndirect(VkCommandBuffer commandBuff InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, @@ -506,8 +509,9 @@ void Validator::PostCallRecordCmdDrawIndirectCount(VkCommandBuffer commandBuffer InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount, @@ -535,7 +539,9 @@ void Validator::PostCallRecordCmdDrawIndirectByteCountEXT(VkCommandBuffer comman InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, @@ -581,8 +587,9 @@ void Validator::PostCallRecordCmdDrawIndexedIndirectCount(VkCommandBuffer comman InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, uint32_t firstTask, @@ -604,7 +611,9 @@ void Validator::PostCallRecordCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, @@ -629,7 +638,9 @@ void Validator::PostCallRecordCmdDrawMeshTasksIndirectNV(VkCommandBuffer command InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, @@ -661,8 +672,9 @@ void Validator::PostCallRecordCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer co InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdDrawMeshTasksEXT(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, @@ -684,7 +696,9 @@ void Validator::PostCallRecordCmdDrawMeshTasksEXT(VkCommandBuffer commandBuffer, InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdDrawMeshTasksIndirectEXT(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, @@ -709,7 +723,9 @@ void Validator::PostCallRecordCmdDrawMeshTasksIndirectEXT(VkCommandBuffer comman InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdDrawMeshTasksIndirectCountEXT(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, @@ -741,8 +757,9 @@ void Validator::PostCallRecordCmdDrawMeshTasksIndirectCountEXT(VkCommandBuffer c InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z, @@ -766,7 +783,9 @@ void Validator::PostCallRecordCmdDispatch(VkCommandBuffer commandBuffer, uint32_ InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_COMPUTE, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_COMPUTE; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, @@ -791,8 +810,9 @@ void Validator::PostCallRecordCmdDispatchIndirect(VkCommandBuffer commandBuffer, InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_COMPUTE, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_COMPUTE; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdDispatchBase(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, @@ -820,7 +840,9 @@ void Validator::PostCallRecordCmdDispatchBase(VkCommandBuffer commandBuffer, uin InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_COMPUTE, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_COMPUTE; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, @@ -876,7 +898,9 @@ void Validator::PostCallRecordCmdTraceRaysNV(VkCommandBuffer commandBuffer, VkBu InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdTraceRaysKHR(VkCommandBuffer commandBuffer, @@ -910,7 +934,9 @@ void Validator::PostCallRecordCmdTraceRaysKHR(VkCommandBuffer commandBuffer, InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer, @@ -947,7 +973,9 @@ void Validator::PostCallRecordCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuf InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdTraceRaysIndirect2KHR(VkCommandBuffer commandBuffer, VkDeviceAddress indirectDeviceAddress, @@ -971,7 +999,9 @@ void Validator::PostCallRecordCmdTraceRaysIndirect2KHR(VkCommandBuffer commandBu InternalError(commandBuffer, record_obj.location, "Unrecognized command buffer."); return; } - PostCallSetupShaderInstrumentationResources(*this, *cb_state, VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR, record_obj.location); + const VkPipelineBindPoint bind_point = VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR; + PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } void Validator::PreCallRecordCmdExecuteGeneratedCommandsEXT(VkCommandBuffer commandBuffer, VkBool32 isPreprocessed, @@ -1000,6 +1030,7 @@ void Validator::PostCallRecordCmdExecuteGeneratedCommandsEXT(VkCommandBuffer com } const VkPipelineBindPoint bind_point = ConvertToPipelineBindPoint(pGeneratedCommandsInfo->shaderStages); PostCallSetupShaderInstrumentationResources(*this, *cb_state, bind_point, record_obj.location); + cb_state->UpdateCommandCount(bind_point); } } // namespace gpuav diff --git a/layers/gpu/core/gpuav_setup.cpp b/layers/gpu/core/gpuav_setup.cpp index 2559171ad32..1f2fa31b2a5 100644 --- a/layers/gpu/core/gpuav_setup.cpp +++ b/layers/gpu/core/gpuav_setup.cpp @@ -209,6 +209,8 @@ void Validator::PostCreateDevice(const VkDeviceCreateInfo *pCreateInfo, const Lo desc_heap_.emplace(*this, 0, loc); instrumentation_bindings_ = { + // DebugPrintf Output buffer + {glsl::kBindingInstDebugPrintf, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_ALL, nullptr}, // Error output buffer {glsl::kBindingInstErrorBuffer, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_ALL, nullptr}, // Current bindless buffer @@ -223,7 +225,6 @@ void Validator::PostCreateDevice(const VkDeviceCreateInfo *pCreateInfo, const Lo {glsl::kBindingInstCmdErrorsCount, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_ALL, nullptr}, }; - // Currently, both GPU-AV and DebugPrintf set their own instrumentation_bindings_ that this call will use BaseClass::PostCreateDevice(pCreateInfo, loc); // We might fail in parent class device creation if global requirements are not met if (aborted_) return; @@ -390,7 +391,7 @@ void Validator::InitSettings(const Location &loc) { InternalWarning( device, loc, "VK_EXT_descriptor_buffer is enabled, but GPU-AV does not currently support validation of descriptor buffers. " - "[Disabling shader_instrumentation_enabled]"); + "[Disabling all shader instrumentation checks]"); // Because of VUs like VUID-VkPipelineLayoutCreateInfo-pSetLayouts-08008 we currently would need to rework the entire shader // instrumentation logic gpuav_settings.DisableShaderInstrumentationAndOptions(); diff --git a/layers/gpu/debug_printf/debug_printf.cpp b/layers/gpu/debug_printf/debug_printf.cpp index b1aaa24f935..d5043f47238 100644 --- a/layers/gpu/debug_printf/debug_printf.cpp +++ b/layers/gpu/debug_printf/debug_printf.cpp @@ -16,40 +16,21 @@ */ #include "gpu/debug_printf/debug_printf.h" +#include "gpu/instrumentation/gpu_shader_instrumentor.h" #include "error_message/log_message_type.h" #include "error_message/logging.h" #include "generated/layer_chassis_dispatch.h" #include "chassis/chassis_modification_state.h" #include "gpu/shaders/gpu_error_header.h" +#include "gpu/shaders/gpu_shaders_constants.h" +#include "gpu/resources/gpuav_subclasses.h" +#include "gpu/core/gpuav.h" #include +namespace gpuav { namespace debug_printf { -void Validator::PreCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, - const RecordObject &record_obj, vku::safe_VkDeviceCreateInfo *modified_create_info) { - BaseClass::PreCallRecordCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice, record_obj, modified_create_info); -} - -// Perform initializations that can be done at Create Device time. -void Validator::PostCreateDevice(const VkDeviceCreateInfo *pCreateInfo, const Location &loc) { - if (enabled[gpu_validation]) { - InternalError(device, loc, "Debug Printf cannot be enabled when gpu assisted validation is enabled."); - return; - } - - debug_printf_binding_slot_ = (uint32_t)instrumentation_bindings_.size(); // get next free binding - instrumentation_bindings_.emplace_back( - VkDescriptorSetLayoutBinding{debug_printf_binding_slot_, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, - kShaderStageAllGraphics | VK_SHADER_STAGE_COMPUTE_BIT | kShaderStageAllRayTracing, nullptr}); - - // Currently, both GPU-AV and DebugPrintf set their own instrumentation_bindings_ that this call will use - BaseClass::PostCreateDevice(pCreateInfo, loc); - // We might fail in parent class device creation if global requirements are not met - if (aborted_) return; -} - enum NumericType { NumericTypeUnknown = 0, NumericTypeFloat = 1, @@ -211,8 +192,9 @@ struct OutputRecord { uint32_t values; // place holder to be casted to get rest of items in record }; -void Validator::AnalyzeAndGenerateMessage(VkCommandBuffer command_buffer, VkQueue queue, BufferInfo &buffer_info, - uint32_t *const debug_output_buffer, const Location &loc) { +void AnalyzeAndGenerateMessage(Validator &gpuav, VkCommandBuffer command_buffer, VkQueue queue, + gpuav::DebugPrintfBufferInfo &buffer_info, uint32_t *const debug_output_buffer, + const Location &loc) { uint32_t output_record_counts = debug_output_buffer[gpuav::kDebugPrintfOutputBufferSize]; if (!output_record_counts) return; @@ -224,14 +206,14 @@ void Validator::AnalyzeAndGenerateMessage(VkCommandBuffer command_buffer, VkQueu // Lookup the VkShaderModule handle and SPIR-V code used to create the shader, using the unique shader ID value returned // by the instrumented shader. const gpu::GpuAssistedShaderTracker *tracker_info = nullptr; - auto it = shader_map_.find(debug_record->shader_id); - if (it != shader_map_.end()) { + auto it = gpuav.shader_map_.find(debug_record->shader_id); + if (it != gpuav.shader_map_.end()) { tracker_info = &it->second; } // without the instrumented spirv, there is nothing valuable to print out if (!tracker_info || tracker_info->instrumented_spirv.empty()) { - InternalWarning(queue, loc, "Can't find instructions from any handles in shader_map"); + gpuav.InternalWarning(queue, loc, "Can't find instructions from any handles in shader_map"); return; } @@ -331,9 +313,9 @@ void Validator::AnalyzeAndGenerateMessage(VkCommandBuffer command_buffer, VkQueu shader_message << temp_string.c_str(); } - const bool use_stdout = gpuav_settings.debug_printf_to_stdout; - if (gpuav_settings.debug_printf_verbose) { - std::string debug_info_message = GenerateDebugInfoMessage( + const bool use_stdout = gpuav.gpuav_settings.debug_printf_to_stdout; + if (gpuav.gpuav_settings.debug_printf_verbose) { + std::string debug_info_message = gpuav.GenerateDebugInfoMessage( command_buffer, instructions, debug_record->stage_id, debug_record->stage_info_0, debug_record->stage_info_1, debug_record->stage_info_2, debug_record->instruction_position, tracker_info, debug_record->shader_id, buffer_info.pipeline_bind_point, buffer_info.action_command_index); @@ -341,7 +323,7 @@ void Validator::AnalyzeAndGenerateMessage(VkCommandBuffer command_buffer, VkQueu std::cout << "VVL-DEBUG-PRINTF " << shader_message.str() << '\n' << debug_info_message; } else { LogObjectList objlist(queue, command_buffer); - LogInfo("VVL-DEBUG-PRINTF", objlist, loc, "%s\n%s", shader_message.str().c_str(), debug_info_message.c_str()); + gpuav.LogInfo("VVL-DEBUG-PRINTF", objlist, loc, "%s\n%s", shader_message.str().c_str(), debug_info_message.c_str()); } } else { @@ -350,360 +332,58 @@ void Validator::AnalyzeAndGenerateMessage(VkCommandBuffer command_buffer, VkQueu } else { // LogInfo will print out a lot of extra information (Object handles, VUID, hash, etc) // If the user doesn't set "verbose", but wants to use the debug callback, we should limit it to the bare minimum - debug_report->DebugLogMsg(kInformationBit, {}, shader_message.str().c_str(), "VVL-DEBUG-PRINTF"); + gpuav.debug_report->DebugLogMsg(kInformationBit, {}, shader_message.str().c_str(), "VVL-DEBUG-PRINTF"); } } index += debug_record->size; } if ((index - gpuav::kDebugPrintfOutputBufferData) != output_record_counts) { std::stringstream message; - message << "Debug Printf message was truncated due to a buffer size (" << gpuav_settings.debug_printf_buffer_size + message << "Debug Printf message was truncated due to a buffer size (" << gpuav.gpuav_settings.debug_printf_buffer_size << ") being too small for the messages. (This can be adjusted with VK_LAYER_PRINTF_BUFFER_SIZE or vkconfig)"; - InternalWarning(command_buffer, loc, message.str().c_str()); + gpuav.InternalWarning(command_buffer, loc, message.str().c_str()); } // Only memset what is needed, in case we are only using a small portion of a large buffer_size. // At the same time we want to make sure we don't memset past the actual VkBuffer allocation uint32_t clear_size = sizeof(uint32_t) * (debug_output_buffer[gpuav::kDebugPrintfOutputBufferSize] + gpuav::kDebugPrintfOutputBufferData); - clear_size = std::min(gpuav_settings.debug_printf_buffer_size, clear_size); + clear_size = std::min(gpuav.gpuav_settings.debug_printf_buffer_size, clear_size); memset(debug_output_buffer, 0, clear_size); } -// For the given command buffer, map its debug data buffers and read their contents for analysis. -void CommandBuffer::PostProcess(VkQueue queue, const Location &loc) { - auto *device_state = static_cast(&dev_data); - for (auto &buffer_info : buffer_infos) { - char *data; - - VkResult result = vmaMapMemory(device_state->vma_allocator_, buffer_info.output_mem_block.allocation, (void **)&data); - if (result == VK_SUCCESS) { - device_state->AnalyzeAndGenerateMessage(VkHandle(), queue, buffer_info, (uint32_t *)data, loc); - vmaUnmapMemory(device_state->vma_allocator_, buffer_info.output_mem_block.allocation); - } - } -} - #if defined(__GNUC__) #pragma GCC diagnostic pop #endif -void Validator::PreCallRecordCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, - uint32_t firstVertex, uint32_t firstInstance, const RecordObject &record_obj) { - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); -} - -void Validator::PreCallRecordCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, - const VkMultiDrawInfoEXT *pVertexInfo, uint32_t instanceCount, uint32_t firstInstance, - uint32_t stride, const RecordObject &record_obj) { - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); -} - -void Validator::PreCallRecordCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, - uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance, - const RecordObject &record_obj) { - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); -} - -void Validator::PreCallRecordCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, - const VkMultiDrawIndexedInfoEXT *pIndexInfo, uint32_t instanceCount, - uint32_t firstInstance, uint32_t stride, const int32_t *pVertexOffset, - const RecordObject &record_obj) { - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); -} - -void Validator::PreCallRecordCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, - uint32_t stride, const RecordObject &record_obj) { - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); -} - -void Validator::PreCallRecordCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - uint32_t count, uint32_t stride, const RecordObject &record_obj) { - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); -} - -void Validator::PreCallRecordCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z, - const RecordObject &record_obj) { - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, record_obj.location); -} - -void Validator::PreCallRecordCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - const RecordObject &record_obj) { - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, record_obj.location); -} - -void Validator::PreCallRecordCmdDispatchBase(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, - uint32_t baseGroupZ, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ, - const RecordObject &record_obj) { - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, record_obj.location); -} - -void Validator::PreCallRecordCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, - uint32_t baseGroupZ, uint32_t groupCountX, uint32_t groupCountY, - uint32_t groupCountZ, const RecordObject &record_obj) { - PreCallRecordCmdDispatchBase(commandBuffer, baseGroupX, baseGroupY, baseGroupZ, groupCountX, groupCountY, groupCountZ, - record_obj); -} - -void Validator::PreCallRecordCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, - uint32_t stride, const RecordObject &record_obj) { - PreCallRecordCmdDrawIndirectCount(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride, - record_obj); -} - -void Validator::PreCallRecordCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, - uint32_t stride, const RecordObject &record_obj) { - ValidationStateTracker::PreCallRecordCmdDrawIndirectCount(commandBuffer, buffer, offset, countBuffer, countBufferOffset, - maxDrawCount, stride, record_obj); - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); -} - -void Validator::PreCallRecordCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - VkBuffer countBuffer, VkDeviceSize countBufferOffset, - uint32_t maxDrawCount, uint32_t stride, - const RecordObject &record_obj) { - PreCallRecordCmdDrawIndexedIndirectCount(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride, - record_obj); -} - -void Validator::PreCallRecordCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - VkBuffer countBuffer, VkDeviceSize countBufferOffset, - uint32_t maxDrawCount, uint32_t stride, const RecordObject &record_obj) { - ValidationStateTracker::PreCallRecordCmdDrawIndexedIndirectCount(commandBuffer, buffer, offset, countBuffer, countBufferOffset, - maxDrawCount, stride, record_obj); - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); -} - -void Validator::PreCallRecordCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount, - uint32_t firstInstance, VkBuffer counterBuffer, - VkDeviceSize counterBufferOffset, uint32_t counterOffset, - uint32_t vertexStride, const RecordObject &record_obj) { - ValidationStateTracker::PreCallRecordCmdDrawIndirectByteCountEXT(commandBuffer, instanceCount, firstInstance, counterBuffer, - counterBufferOffset, counterOffset, vertexStride, record_obj); - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); -} - -void Validator::PreCallRecordCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, uint32_t firstTask, - const RecordObject &record_obj) { - ValidationStateTracker::PreCallRecordCmdDrawMeshTasksNV(commandBuffer, taskCount, firstTask, record_obj); - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); -} - -void Validator::PreCallRecordCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - uint32_t drawCount, uint32_t stride, const RecordObject &record_obj) { - ValidationStateTracker::PreCallRecordCmdDrawMeshTasksIndirectNV(commandBuffer, buffer, offset, drawCount, stride, record_obj); - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); -} - -void Validator::PreCallRecordCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - VkBuffer countBuffer, VkDeviceSize countBufferOffset, - uint32_t maxDrawCount, uint32_t stride, - const RecordObject &record_obj) { - ValidationStateTracker::PreCallRecordCmdDrawMeshTasksIndirectCountNV(commandBuffer, buffer, offset, countBuffer, - countBufferOffset, maxDrawCount, stride, record_obj); - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); -} - -void Validator::PreCallRecordCmdDrawMeshTasksEXT(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, - uint32_t groupCountZ, const RecordObject &record_obj) { - ValidationStateTracker::PreCallRecordCmdDrawMeshTasksEXT(commandBuffer, groupCountX, groupCountY, groupCountZ, record_obj); - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); -} - -void Validator::PreCallRecordCmdDrawMeshTasksIndirectEXT(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - uint32_t drawCount, uint32_t stride, const RecordObject &record_obj) { - ValidationStateTracker::PreCallRecordCmdDrawMeshTasksIndirectEXT(commandBuffer, buffer, offset, drawCount, stride, record_obj); - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); -} - -void Validator::PreCallRecordCmdDrawMeshTasksIndirectCountEXT(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - VkBuffer countBuffer, VkDeviceSize countBufferOffset, - uint32_t maxDrawCount, uint32_t stride, - const RecordObject &record_obj) { - ValidationStateTracker::PreCallRecordCmdDrawMeshTasksIndirectCountEXT(commandBuffer, buffer, offset, countBuffer, - countBufferOffset, maxDrawCount, stride, record_obj); - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location); -} - -void Validator::PreCallRecordCmdTraceRaysNV(VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, - VkDeviceSize raygenShaderBindingOffset, VkBuffer missShaderBindingTableBuffer, - VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride, - VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, - VkDeviceSize hitShaderBindingStride, VkBuffer callableShaderBindingTableBuffer, - VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride, - uint32_t width, uint32_t height, uint32_t depth, const RecordObject &record_obj) { - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_RAY_TRACING_NV, record_obj.location); -} - -void Validator::PreCallRecordCmdTraceRaysKHR(VkCommandBuffer commandBuffer, - const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable, - const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, - const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable, - const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, uint32_t width, - uint32_t height, uint32_t depth, const RecordObject &record_obj) { - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR, record_obj.location); -} - -void Validator::PreCallRecordCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer, - const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable, - const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, - const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable, - const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, - VkDeviceAddress indirectDeviceAddress, const RecordObject &record_obj) { - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR, record_obj.location); -} - -void Validator::PreCallRecordCmdTraceRaysIndirect2KHR(VkCommandBuffer commandBuffer, VkDeviceAddress indirectDeviceAddress, - const RecordObject &record_obj) { - AllocateDebugPrintfResources(commandBuffer, VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR, record_obj.location); -} - -void Validator::PreCallRecordCmdExecuteGeneratedCommandsEXT(VkCommandBuffer commandBuffer, VkBool32 isPreprocessed, - const VkGeneratedCommandsInfoEXT *pGeneratedCommandsInfo, - const RecordObject &record_obj) { - const VkPipelineBindPoint bind_point = ConvertToPipelineBindPoint(pGeneratedCommandsInfo->shaderStages); - AllocateDebugPrintfResources(commandBuffer, bind_point, record_obj.location); -}; - -void Validator::AllocateDebugPrintfResources(const VkCommandBuffer cmd_buffer, const VkPipelineBindPoint bind_point, - const Location &loc) { - assert(bind_point == VK_PIPELINE_BIND_POINT_GRAPHICS || bind_point == VK_PIPELINE_BIND_POINT_COMPUTE || - bind_point == VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR); - - auto cb_state = GetWrite(cmd_buffer); - if (!cb_state) { - InternalError(cmd_buffer, loc, "Unrecognized command buffer."); - return; - } - - const auto lv_bind_point = ConvertToLvlBindPoint(bind_point); - const auto &last_bound = cb_state->lastBound[lv_bind_point]; - const auto *pipeline_state = last_bound.pipeline_state; - - // If there is no DebugPrintf instrumented, there is no reason to allocate buffers - if (pipeline_state) { - if (!pipeline_state->instrumentation_data.was_instrumented && (pipeline_state->linking_shaders == 0)) { - cb_state->action_command_count++; - return; - } - } else if (last_bound.HasShaderObjects()) { - // TODO - Add same skip for shader object - } else { - InternalError(cmd_buffer, loc, "Neither pipeline state nor shader object states were found."); - return; - } - - // TODO - use the following when we combine the two command buffer classes - // VkDescriptorSet printf_desc_set = cb_state->gpu_resources_manager.GetManagedDescriptorSet(GetDebugDescriptorSetLayout()); - std::vector desc_sets; - VkDescriptorPool desc_pool = VK_NULL_HANDLE; - VkResult result = desc_set_manager_->GetDescriptorSets(1, &desc_pool, GetInstrumentationDescriptorSetLayout(), &desc_sets); - if (result != VK_SUCCESS) { - InternalError(cmd_buffer, loc, "Unable to allocate descriptor sets."); - return; - } - +bool AllocateOutputBuffer(Validator &gpuav, VkCommandBuffer command_buffer, gpu::DeviceMemoryBlock &debug_printf_output_buffer, + const Location &loc) { // Allocate memory for the output block that the gpu will use to return values for printf - gpu::DeviceMemoryBlock output_block = {}; VkBufferCreateInfo buffer_info = vku::InitStructHelper(); - buffer_info.size = gpuav_settings.debug_printf_buffer_size; + buffer_info.size = gpuav.gpuav_settings.debug_printf_buffer_size; buffer_info.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; VmaAllocationCreateInfo alloc_info = {}; alloc_info.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; - result = vmaCreateBuffer(vma_allocator_, &buffer_info, &alloc_info, &output_block.buffer, &output_block.allocation, nullptr); + alloc_info.pool = gpuav.output_buffer_pool_; + VkResult result = vmaCreateBuffer(gpuav.vma_allocator_, &buffer_info, &alloc_info, &debug_printf_output_buffer.buffer, + &debug_printf_output_buffer.allocation, nullptr); if (result != VK_SUCCESS) { - InternalError(cmd_buffer, loc, "Unable to allocate device memory.", true); - return; + gpuav.InternalError(command_buffer, loc, "Unable to allocate device memory.", true); + return false; } // Clear the output block to zeros so that only printf values from the gpu will be present uint32_t *data; - result = vmaMapMemory(vma_allocator_, output_block.allocation, reinterpret_cast(&data)); + result = vmaMapMemory(gpuav.vma_allocator_, debug_printf_output_buffer.allocation, reinterpret_cast(&data)); if (result != VK_SUCCESS) { - InternalError(cmd_buffer, loc, "Unable to allocate map memory.", true); - return; - } - memset(data, 0, gpuav_settings.debug_printf_buffer_size); - vmaUnmapMemory(vma_allocator_, output_block.allocation); - - // Write the descriptor - VkDescriptorBufferInfo output_desc_buffer_info = {}; - output_desc_buffer_info.range = gpuav_settings.debug_printf_buffer_size; - output_desc_buffer_info.buffer = output_block.buffer; - output_desc_buffer_info.offset = 0; - - VkWriteDescriptorSet desc_writes = vku::InitStructHelper(); - desc_writes.descriptorCount = 1; - desc_writes.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; - desc_writes.pBufferInfo = &output_desc_buffer_info; - desc_writes.dstSet = desc_sets[0]; - desc_writes.dstBinding = debug_printf_binding_slot_; - DispatchUpdateDescriptorSets(device, 1, &desc_writes, 0, nullptr); - - const auto pipeline_layout = - pipeline_state ? pipeline_state->PipelineLayoutState() : Get(last_bound.desc_set_pipeline_layout); - if (pipeline_layout) { - // If GPL is used, it's possible the pipeline layout used at pipeline creation time is null. If CmdBindDescriptorSets has - // not been called yet (i.e., state.pipeline_null), then fall back to the layout associated with pre-raster state. - // PipelineLayoutState should be used for the purposes of determining the number of sets in the layout, but this layout - // may be a "pseudo layout" used to represent the union of pre-raster and fragment shader layouts, and therefore have a - // null handle. - const auto pipeline_layout_handle = (last_bound.desc_set_pipeline_layout) - ? last_bound.desc_set_pipeline_layout - : pipeline_state->PreRasterPipelineLayoutState()->VkHandle(); - if (pipeline_layout->set_layouts.size() <= instrumentation_desc_set_bind_index_) { - DispatchCmdBindDescriptorSets(cmd_buffer, bind_point, pipeline_layout_handle, instrumentation_desc_set_bind_index_, 1, - desc_sets.data(), 0, nullptr); - } - } else { - // If no pipeline layout was bound when using shader objects that don't use any descriptor set, bind the debug pipeline - // layout - DispatchCmdBindDescriptorSets(cmd_buffer, bind_point, GetInstrumentationPipelineLayout(), - instrumentation_desc_set_bind_index_, 1, desc_sets.data(), 0, nullptr); - } - // Record buffer and memory info in CB state tracking - cb_state->buffer_infos.emplace_back(output_block, desc_sets[0], desc_pool, bind_point, cb_state->action_command_count++); -} - -std::shared_ptr Validator::CreateCmdBufferState(VkCommandBuffer handle, - const VkCommandBufferAllocateInfo *allocate_info, - const vvl::CommandPool *pool) { - return std::static_pointer_cast(std::make_shared(*this, handle, allocate_info, pool)); -} - -CommandBuffer::CommandBuffer(Validator &dp, VkCommandBuffer handle, const VkCommandBufferAllocateInfo *allocate_info, - const vvl::CommandPool *pool) - : gpu_tracker::CommandBuffer(dp, handle, allocate_info, pool) {} - -CommandBuffer::~CommandBuffer() { Destroy(); } - -void CommandBuffer::Destroy() { - { - auto guard = WriteLock(); - ResetCBState(); + gpuav.InternalError(command_buffer, loc, "Unable to allocate map memory.", true); + return false; } - vvl::CommandBuffer::Destroy(); -} - -void CommandBuffer::Reset(const Location &loc) { - vvl::CommandBuffer::Reset(loc); - ResetCBState(); -} + memset(data, 0, gpuav.gpuav_settings.debug_printf_buffer_size); + vmaUnmapMemory(gpuav.vma_allocator_, debug_printf_output_buffer.allocation); -void CommandBuffer::ResetCBState() { - action_command_count = 0; - auto debug_printf = static_cast(&dev_data); - // Free the device memory and descriptor set(s) associated with a command buffer. - for (auto &buffer_info : buffer_infos) { - vmaDestroyBuffer(debug_printf->vma_allocator_, buffer_info.output_mem_block.buffer, - buffer_info.output_mem_block.allocation); - if (buffer_info.desc_set != VK_NULL_HANDLE) { - debug_printf->desc_set_manager_->PutBackDescriptorSet(buffer_info.desc_pool, buffer_info.desc_set); - } - } - buffer_infos.clear(); + return true; } } // namespace debug_printf +} // namespace gpuav \ No newline at end of file diff --git a/layers/gpu/debug_printf/debug_printf.h b/layers/gpu/debug_printf/debug_printf.h index f41cc5ab7f8..45232f56531 100644 --- a/layers/gpu/debug_printf/debug_printf.h +++ b/layers/gpu/debug_printf/debug_printf.h @@ -17,147 +17,22 @@ #pragma once -#include "gpu/resources/gpuav_subclasses.h" -#include "gpu/instrumentation/gpu_shader_instrumentor.h" -#include "gpu/resources/gpu_resources.h" - -namespace debug_printf { - +#include + +struct Location; +namespace gpu { +struct DeviceMemoryBlock; +} +namespace gpuav { +struct DebugPrintfBufferInfo; +class CommandBuffer; class Validator; -struct BufferInfo { - gpu::DeviceMemoryBlock output_mem_block; - VkDescriptorSet desc_set; - VkDescriptorPool desc_pool; - VkPipelineBindPoint pipeline_bind_point; - uint32_t action_command_index; - BufferInfo(gpu::DeviceMemoryBlock output_mem_block, VkDescriptorSet desc_set, VkDescriptorPool desc_pool, - VkPipelineBindPoint pipeline_bind_point, uint32_t action_command_index) - : output_mem_block(output_mem_block), - desc_set(desc_set), - desc_pool(desc_pool), - pipeline_bind_point(pipeline_bind_point), - action_command_index(action_command_index){}; -}; - -class CommandBuffer : public gpu_tracker::CommandBuffer { - public: - std::vector buffer_infos; - uint32_t action_command_count = 0; - CommandBuffer(Validator& dp, VkCommandBuffer handle, const VkCommandBufferAllocateInfo* create_info, - const vvl::CommandPool* pool); - ~CommandBuffer(); - - bool PreProcess(const Location& loc) final { return true; } - void PostProcess(VkQueue queue, const Location& loc) final; - - void Destroy() final; - void Reset(const Location& loc) final; - - private: - void ResetCBState(); -}; -} // namespace debug_printf - -VALSTATETRACK_DERIVED_STATE_OBJECT(VkCommandBuffer, debug_printf::CommandBuffer, vvl::CommandBuffer) - namespace debug_printf { -class Validator : public gpu::GpuShaderInstrumentor { - public: - using BaseClass = gpu::GpuShaderInstrumentor; - Validator() { - container_type = LayerObjectTypeDebugPrintf; - debug_printf_enabled = true; - } - - void PreCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, VkDevice* pDevice, const RecordObject& record_obj, - vku::safe_VkDeviceCreateInfo* modified_create_info) final; - void PostCreateDevice(const VkDeviceCreateInfo* pCreateInfo, const Location& loc) override; - void AnalyzeAndGenerateMessage(VkCommandBuffer command_buffer, VkQueue queue, BufferInfo& buffer_info, - uint32_t* const debug_output_buffer, const Location& loc); - void PreCallRecordCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, - uint32_t firstInstance, const RecordObject& record_obj) override; - void PreCallRecordCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, const VkMultiDrawInfoEXT* pVertexInfo, - uint32_t instanceCount, uint32_t firstInstance, uint32_t stride, - const RecordObject& record_obj) override; - void PreCallRecordCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, - uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance, - const RecordObject& record_obj) override; - void PreCallRecordCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, - const VkMultiDrawIndexedInfoEXT* pIndexInfo, uint32_t instanceCount, - uint32_t firstInstance, uint32_t stride, const int32_t* pVertexOffset, - const RecordObject& record_obj) override; - void PreCallRecordCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, - uint32_t stride, const RecordObject& record_obj) override; - void PreCallRecordCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, - uint32_t stride, const RecordObject& record_obj) override; - void PreCallRecordCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, - uint32_t stride, const RecordObject& record_obj) override; - void PreCallRecordCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, - uint32_t stride, const RecordObject& record_obj) override; - void PreCallRecordCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, - uint32_t stride, const RecordObject& record_obj) override; - void PreCallRecordCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, - uint32_t stride, const RecordObject& record_obj) override; - void PreCallRecordCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount, uint32_t firstInstance, - VkBuffer counterBuffer, VkDeviceSize counterBufferOffset, uint32_t counterOffset, - uint32_t vertexStride, const RecordObject& record_obj) override; - void PreCallRecordCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, uint32_t firstTask, - const RecordObject& record_obj) override; - void PreCallRecordCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - uint32_t drawCount, uint32_t stride, const RecordObject& record_obj) override; - void PreCallRecordCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, - uint32_t stride, const RecordObject& record_obj) override; - void PreCallRecordCmdDrawMeshTasksEXT(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, - uint32_t groupCountZ, const RecordObject& record_obj) override; - void PreCallRecordCmdDrawMeshTasksIndirectEXT(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - uint32_t drawCount, uint32_t stride, const RecordObject& record_obj) override; - void PreCallRecordCmdDrawMeshTasksIndirectCountEXT(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, - uint32_t stride, const RecordObject& record_obj) override; - void PreCallRecordCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z, - const RecordObject& record_obj) override; - void PreCallRecordCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - const RecordObject& record_obj) override; - void PreCallRecordCmdDispatchBase(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, uint32_t baseGroupZ, - uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ, - const RecordObject& record_obj) override; - void PreCallRecordCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, - uint32_t baseGroupZ, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ, - const RecordObject& record_obj) override; - void PreCallRecordCmdTraceRaysNV(VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, - VkDeviceSize raygenShaderBindingOffset, VkBuffer missShaderBindingTableBuffer, - VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride, - VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, - VkDeviceSize hitShaderBindingStride, VkBuffer callableShaderBindingTableBuffer, - VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride, - uint32_t width, uint32_t height, uint32_t depth, const RecordObject& record_obj) override; - void PreCallRecordCmdTraceRaysKHR(VkCommandBuffer commandBuffer, - const VkStridedDeviceAddressRegionKHR* pRaygenShaderBindingTable, - const VkStridedDeviceAddressRegionKHR* pMissShaderBindingTable, - const VkStridedDeviceAddressRegionKHR* pHitShaderBindingTable, - const VkStridedDeviceAddressRegionKHR* pCallableShaderBindingTable, uint32_t width, - uint32_t height, uint32_t depth, const RecordObject& record_obj) override; - void PreCallRecordCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer, - const VkStridedDeviceAddressRegionKHR* pRaygenShaderBindingTable, - const VkStridedDeviceAddressRegionKHR* pMissShaderBindingTable, - const VkStridedDeviceAddressRegionKHR* pHitShaderBindingTable, - const VkStridedDeviceAddressRegionKHR* pCallableShaderBindingTable, - VkDeviceAddress indirectDeviceAddress, const RecordObject& record_obj) override; - void PreCallRecordCmdTraceRaysIndirect2KHR(VkCommandBuffer commandBuffer, VkDeviceAddress indirectDeviceAddress, - const RecordObject& record_obj) override; - void PreCallRecordCmdExecuteGeneratedCommandsEXT(VkCommandBuffer commandBuffer, VkBool32 isPreprocessed, - const VkGeneratedCommandsInfoEXT* pGeneratedCommandsInfo, - const RecordObject& record_obj) override; - void AllocateDebugPrintfResources(const VkCommandBuffer cmd_buffer, const VkPipelineBindPoint bind_point, const Location& loc); - - std::shared_ptr CreateCmdBufferState(VkCommandBuffer cb, const VkCommandBufferAllocateInfo* create_info, - const vvl::CommandPool* pool) final; -}; +bool AllocateOutputBuffer(Validator& gpuav, VkCommandBuffer command_buffer, gpu::DeviceMemoryBlock& debug_printf_output_buffer, + const Location& loc); +void AnalyzeAndGenerateMessage(Validator& gpuav, VkCommandBuffer command_buffer, VkQueue queue, + gpuav::DebugPrintfBufferInfo& buffer_info, uint32_t* const debug_output_buffer, const Location& loc); } // namespace debug_printf + +} // namespace gpuav \ No newline at end of file diff --git a/layers/gpu/descriptor_validation/gpuav_descriptor_validation.cpp b/layers/gpu/descriptor_validation/gpuav_descriptor_validation.cpp index f2308b0fce5..1a27376bd92 100644 --- a/layers/gpu/descriptor_validation/gpuav_descriptor_validation.cpp +++ b/layers/gpu/descriptor_validation/gpuav_descriptor_validation.cpp @@ -61,9 +61,7 @@ void UpdateBoundPipeline(Validator &gpuav, CommandBuffer &cb_state, VkPipelineBi void UpdateBoundDescriptors(Validator &gpuav, CommandBuffer &cb_state, VkPipelineBindPoint pipeline_bind_point, const Location &loc) { - if (!gpuav.gpuav_settings.shader_instrumentation.bindless_descriptor) { - return; - } + if (!gpuav.gpuav_settings.shader_instrumentation.bindless_descriptor) return; const auto lv_bind_point = ConvertToLvlBindPoint(pipeline_bind_point); auto const &last_bound = cb_state.lastBound[lv_bind_point]; diff --git a/layers/gpu/instrumentation/gpu_shader_instrumentor.cpp b/layers/gpu/instrumentation/gpu_shader_instrumentor.cpp index 1d2b30d77c9..91b0ba5e96f 100644 --- a/layers/gpu/instrumentation/gpu_shader_instrumentor.cpp +++ b/layers/gpu/instrumentation/gpu_shader_instrumentor.cpp @@ -17,6 +17,7 @@ #include "gpu/instrumentation/gpu_shader_instrumentor.h" +#include "gpu/shaders/gpu_shaders_constants.h" #include "gpu/spirv/module.h" #include "chassis/chassis_modification_state.h" #include "gpu/shaders/gpu_error_codes.h" @@ -24,6 +25,7 @@ #include "utils/vk_layer_utils.h" #include "state_tracker/descriptor_sets.h" #include "state_tracker/shader_object_state.h" +#include "gpu/resources/gpuav_subclasses.h" #include "vk_layer_config.h" #include @@ -167,8 +169,8 @@ WriteLockGuard GpuShaderInstrumentor::WriteLock() { std::shared_ptr GpuShaderInstrumentor::CreateQueue(VkQueue handle, uint32_t family_index, uint32_t queue_index, VkDeviceQueueCreateFlags flags, const VkQueueFamilyProperties &queueFamilyProperties) { - return std::static_pointer_cast(std::make_shared(*this, handle, family_index, queue_index, - flags, queueFamilyProperties, timeline_khr_)); + return std::static_pointer_cast( + std::make_shared(*this, handle, family_index, queue_index, flags, queueFamilyProperties, timeline_khr_)); } // These are the common things required for anything that deals with shader instrumentation @@ -361,8 +363,9 @@ void GpuShaderInstrumentor::PreCallRecordDestroyDevice(VkDevice device, const Vk BaseClass::PreCallRecordDestroyDevice(device, pAllocator, record_obj); // State Tracker can end up making vma calls through callbacks - don't destroy allocator until ST is done - if (output_buffer_pool_) { + if (output_buffer_pool_ != VK_NULL_HANDLE) { vmaDestroyPool(vma_allocator_, output_buffer_pool_); + output_buffer_pool_ = VK_NULL_HANDLE; } if (vma_allocator_) { vmaDestroyAllocator(vma_allocator_); @@ -452,7 +455,7 @@ void GpuShaderInstrumentor::PreCallRecordCreatePipelineLayout(VkDevice device, c const VkAllocationCallbacks *pAllocator, VkPipelineLayout *pPipelineLayout, const RecordObject &record_obj, chassis::CreatePipelineLayout &chassis_state) { - if (gpuav_settings.shader_instrumentation_enabled) { + if (gpuav_settings.IsShaderInstrumentationEnabled() || gpuav_settings.debug_printf_enabled) { if (chassis_state.modified_create_info.setLayoutCount > instrumentation_desc_set_bind_index_) { std::ostringstream strm; strm << "pCreateInfo::setLayoutCount (" << chassis_state.modified_create_info.setLayoutCount @@ -547,7 +550,7 @@ void GpuShaderInstrumentor::PreCallRecordCreateShadersEXT(VkDevice device, uint3 const RecordObject &record_obj, chassis::ShaderObject &chassis_state) { BaseClass::PreCallRecordCreateShadersEXT(device, createInfoCount, pCreateInfos, pAllocator, pShaders, record_obj, chassis_state); - if (!gpuav_settings.shader_instrumentation_enabled) return; + if (!gpuav_settings.IsShaderInstrumentationEnabled() && !gpuav_settings.debug_printf_enabled) return; chassis_state.modified_create_infos.reserve(createInfoCount); @@ -597,7 +600,7 @@ void GpuShaderInstrumentor::PostCallRecordCreateShadersEXT(VkDevice device, uint const RecordObject &record_obj, chassis::ShaderObject &chassis_state) { BaseClass::PostCallRecordCreateShadersEXT(device, createInfoCount, pCreateInfos, pAllocator, pShaders, record_obj, chassis_state); - if (!gpuav_settings.shader_instrumentation_enabled) return; + if (!gpuav_settings.IsShaderInstrumentationEnabled() && !gpuav_settings.debug_printf_enabled) return; for (uint32_t i = 0; i < createInfoCount; ++i) { auto &instrumentation_data = chassis_state.instrumentations_data[i]; @@ -631,7 +634,7 @@ void GpuShaderInstrumentor::PreCallRecordCreateGraphicsPipelines(VkDevice device chassis::CreateGraphicsPipelines &chassis_state) { BaseClass::PreCallRecordCreateGraphicsPipelines(device, pipelineCache, count, pCreateInfos, pAllocator, pPipelines, record_obj, pipeline_states, chassis_state); - if (!gpuav_settings.shader_instrumentation_enabled) return; + if (!gpuav_settings.IsShaderInstrumentationEnabled() && !gpuav_settings.debug_printf_enabled) return; chassis_state.shader_instrumentations_metadata.resize(count); chassis_state.modified_create_infos.resize(count); @@ -669,7 +672,7 @@ void GpuShaderInstrumentor::PreCallRecordCreateComputePipelines(VkDevice device, chassis::CreateComputePipelines &chassis_state) { BaseClass::PreCallRecordCreateComputePipelines(device, pipelineCache, count, pCreateInfos, pAllocator, pPipelines, record_obj, pipeline_states, chassis_state); - if (!gpuav_settings.shader_instrumentation_enabled) return; + if (!gpuav_settings.IsShaderInstrumentationEnabled() && !gpuav_settings.debug_printf_enabled) return; chassis_state.shader_instrumentations_metadata.resize(count); chassis_state.modified_create_infos.resize(count); @@ -703,7 +706,7 @@ void GpuShaderInstrumentor::PreCallRecordCreateRayTracingPipelinesNV(VkDevice de chassis::CreateRayTracingPipelinesNV &chassis_state) { BaseClass::PreCallRecordCreateRayTracingPipelinesNV(device, pipelineCache, count, pCreateInfos, pAllocator, pPipelines, record_obj, pipeline_states, chassis_state); - if (!gpuav_settings.shader_instrumentation_enabled) return; + if (!gpuav_settings.IsShaderInstrumentationEnabled() && !gpuav_settings.debug_printf_enabled) return; chassis_state.shader_instrumentations_metadata.resize(count); chassis_state.modified_create_infos.resize(count); @@ -735,7 +738,7 @@ void GpuShaderInstrumentor::PreCallRecordCreateRayTracingPipelinesKHR( const RecordObject &record_obj, PipelineStates &pipeline_states, chassis::CreateRayTracingPipelinesKHR &chassis_state) { BaseClass::PreCallRecordCreateRayTracingPipelinesKHR(device, deferredOperation, pipelineCache, count, pCreateInfos, pAllocator, pPipelines, record_obj, pipeline_states, chassis_state); - if (!gpuav_settings.shader_instrumentation_enabled) return; + if (!gpuav_settings.IsShaderInstrumentationEnabled() && !gpuav_settings.debug_printf_enabled) return; chassis_state.shader_instrumentations_metadata.resize(count); chassis_state.modified_create_infos.resize(count); @@ -780,7 +783,7 @@ void GpuShaderInstrumentor::PostCallRecordCreateGraphicsPipelines(VkDevice devic chassis::CreateGraphicsPipelines &chassis_state) { BaseClass::PostCallRecordCreateGraphicsPipelines(device, pipelineCache, count, pCreateInfos, pAllocator, pPipelines, record_obj, pipeline_states, chassis_state); - if (!gpuav_settings.shader_instrumentation_enabled) return; + if (!gpuav_settings.IsShaderInstrumentationEnabled() && !gpuav_settings.debug_printf_enabled) return; for (uint32_t i = 0; i < count; ++i) { UtilCopyCreatePipelineFeedbackData(pCreateInfos[i], chassis_state.modified_create_infos[i]); @@ -806,7 +809,7 @@ void GpuShaderInstrumentor::PostCallRecordCreateComputePipelines(VkDevice device chassis::CreateComputePipelines &chassis_state) { BaseClass::PostCallRecordCreateComputePipelines(device, pipelineCache, count, pCreateInfos, pAllocator, pPipelines, record_obj, pipeline_states, chassis_state); - if (!gpuav_settings.shader_instrumentation_enabled) return; + if (!gpuav_settings.IsShaderInstrumentationEnabled() && !gpuav_settings.debug_printf_enabled) return; for (uint32_t i = 0; i < count; ++i) { UtilCopyCreatePipelineFeedbackData(pCreateInfos[i], chassis_state.modified_create_infos[i]); @@ -823,7 +826,7 @@ void GpuShaderInstrumentor::PostCallRecordCreateRayTracingPipelinesNV( PipelineStates &pipeline_states, chassis::CreateRayTracingPipelinesNV &chassis_state) { BaseClass::PostCallRecordCreateRayTracingPipelinesNV(device, pipelineCache, count, pCreateInfos, pAllocator, pPipelines, record_obj, pipeline_states, chassis_state); - if (!gpuav_settings.shader_instrumentation_enabled) return; + if (!gpuav_settings.IsShaderInstrumentationEnabled() && !gpuav_settings.debug_printf_enabled) return; for (uint32_t i = 0; i < count; ++i) { UtilCopyCreatePipelineFeedbackData(pCreateInfos[i], chassis_state.modified_create_infos[i]); @@ -841,7 +844,7 @@ void GpuShaderInstrumentor::PostCallRecordCreateRayTracingPipelinesKHR( std::shared_ptr chassis_state) { BaseClass::PostCallRecordCreateRayTracingPipelinesKHR(device, deferredOperation, pipelineCache, count, pCreateInfos, pAllocator, pPipelines, record_obj, pipeline_states, chassis_state); - if (!gpuav_settings.shader_instrumentation_enabled) return; + if (!gpuav_settings.IsShaderInstrumentationEnabled() && !gpuav_settings.debug_printf_enabled) return; const bool is_operation_deferred = deferredOperation != VK_NULL_HANDLE && record_obj.result == VK_OPERATION_DEFERRED_KHR; @@ -1368,33 +1371,34 @@ bool GpuShaderInstrumentor::InstrumentShader(const vvl::span &in gpu::spirv::Module module(input_spirv, debug_report, module_settings); - // For now, we don't yet support (or have tested) combining GPU-AV and DebugPrintf, so have 2 paths here - const bool is_debug_printf = debug_printf_enabled; - + GpuAVSettings::ShaderInstrumentation &shader_instrumentation = gpuav_settings.shader_instrumentation; bool modified = false; - if (is_debug_printf) { - modified |= module.RunPassDebugPrintf(debug_printf_binding_slot_); - } else { - GpuAVSettings::ShaderInstrumentation &shader_instrumentation = gpuav_settings.shader_instrumentation; - // If descriptor indexing is enabled, enable length checks and updated descriptor checks - if (shader_instrumentation.bindless_descriptor) { - modified |= module.RunPassBindlessDescriptor(); - modified |= module.RunPassNonBindlessOOBBuffer(); - modified |= module.RunPassNonBindlessOOBTexelBuffer(); - } - if (shader_instrumentation.buffer_device_address) { - modified |= module.RunPassBufferDeviceAddress(); - } + // If descriptor indexing is enabled, enable length checks and updated descriptor checks + if (shader_instrumentation.bindless_descriptor) { + modified |= module.RunPassBindlessDescriptor(); + modified |= module.RunPassNonBindlessOOBBuffer(); + modified |= module.RunPassNonBindlessOOBTexelBuffer(); + } - if (shader_instrumentation.ray_query) { - modified |= module.RunPassRayQuery(); - } + if (shader_instrumentation.buffer_device_address) { + modified |= module.RunPassBufferDeviceAddress(); + } - // If there were GLSL written function injected, we will grab them and link them in here - for (const auto &info : module.link_info_) { - module.LinkFunction(info); - } + if (shader_instrumentation.ray_query) { + modified |= module.RunPassRayQuery(); + } + + // If there were GLSL written function injected, we will grab them and link them in here + for (const auto &info : module.link_info_) { + module.LinkFunction(info); + } + + // DebugPrintf goes at the end for 2 reasons: + // 1. We use buffer device address in it and we don't want to validate the inside of this pass + // 2. We might want to debug the above passes and want to inject our own debug printf calls + if (gpuav_settings.debug_printf_enabled) { + modified |= module.RunPassDebugPrintf(gpuav::glsl::kBindingInstDebugPrintf); } // If nothing was instrumented, leave early to save time @@ -1430,7 +1434,7 @@ bool GpuShaderInstrumentor::InstrumentShader(const vvl::span &in // Run Dead Code elimination // If DebugPrintf is the only thing, there will be nothing to eliminate so don't waste time on it - if (!is_debug_printf) { + if (!gpuav_settings.debug_printf_only) { using namespace spvtools; OptimizerOptions opt_options; opt_options.set_run_validator(false); @@ -1493,19 +1497,19 @@ void GpuShaderInstrumentor::InternalError(LogObjectList objlist, const Location vmaFreeStatsString(vma_allocator_, stats_string); } - char const *layer_name = debug_printf_enabled ? "DebugPrintf" : "GPU-AV"; - char const *vuid = debug_printf_enabled ? "UNASSIGNED-DEBUG-PRINTF" : "UNASSIGNED-GPU-Assisted-Validation"; + char const *layer_name = gpuav_settings.debug_printf_only ? "DebugPrintf" : "GPU-AV"; + char const *vuid = gpuav_settings.debug_printf_only ? "UNASSIGNED-DEBUG-PRINTF" : "UNASSIGNED-GPU-Assisted-Validation"; LogError(vuid, objlist, loc, "Internal Error, %s is being disabled. Details:\n%s", layer_name, error_message.c_str()); // Once we encounter an internal issue disconnect everything. // This prevents need to check "if (aborted)" (which is awful when we easily forget to check somewhere and the user gets spammed // with errors making it hard to see the first error with the real source of the problem). - ReleaseDeviceDispatchObject(this->container_type); + ReleaseDeviceDispatchObject(LayerObjectTypeGpuAssisted); } void GpuShaderInstrumentor::InternalWarning(LogObjectList objlist, const Location &loc, const char *const specific_message) const { - char const *vuid = debug_printf_enabled ? "WARNING-DEBUG-PRINTF" : "WARNING-GPU-Assisted-Validation"; + char const *vuid = gpuav_settings.debug_printf_only ? "WARNING-DEBUG-PRINTF" : "WARNING-GPU-Assisted-Validation"; LogWarning(vuid, objlist, loc, "Internal Warning: %s", specific_message); } @@ -1755,12 +1759,7 @@ std::string GpuShaderInstrumentor::GenerateDebugInfoMessage( return ss.str(); } - std::string prefix; - if (debug_printf_enabled) { - prefix = "Debug shader printf message generated "; - } else { - prefix = "Shader validation error occurred "; - } + std::string prefix = gpuav_settings.debug_printf_only ? "Debug shader printf message generated " : "Shader validation error occurred "; // Create message with file information obtained from the OpString pointed to by the discovered OpLine. bool found_opstring = false; diff --git a/layers/gpu/instrumentation/gpu_shader_instrumentor.h b/layers/gpu/instrumentation/gpu_shader_instrumentor.h index aac5c725033..4f888fa65b1 100644 --- a/layers/gpu/instrumentation/gpu_shader_instrumentor.h +++ b/layers/gpu/instrumentation/gpu_shader_instrumentor.h @@ -18,7 +18,7 @@ #include "containers/custom_containers.h" #include "generated/chassis.h" -#include "gpu/resources/gpuav_subclasses.h" +#include "state_tracker/cmd_buffer_state.h" #include "gpu/resources/gpu_resources.h" #include "gpu/spirv/instruction.h" #include "vma/vma.h" @@ -66,7 +66,8 @@ struct GpuAssistedShaderTracker { std::vector instrumented_spirv; }; -// Interface common to both GPU-AV and DebugPrintF. +// Historically this was an common interface to both GPU-AV and DebugPrintf before the were merged together. +// We still keep this as encapsulates the complex code around shader instrumentation. // Handles shader instrumentation (reserve a descriptor slot, create descriptor // sets, pipeline layout, hook into pipeline creation, etc...) class GpuShaderInstrumentor : public ValidationStateTracker { @@ -235,14 +236,6 @@ class GpuShaderInstrumentor : public ValidationStateTracker { DeviceMemoryBlock indices_buffer_{}; unsigned int indices_buffer_alignment_ = 0; - // DebugPrintf takes the first available slot in the set - uint32_t debug_printf_binding_slot_ = 0; - - // These are here as temp variables until GPU-AV and DebugPrintf are fully merged into a single Validation Object. - // Once merged, the single Validation Object can use settings to detect this - bool debug_printf_enabled = false; - bool gpuav_enabled = false; - private: void Cleanup(); // These are objects used to inject our descriptor set into the command buffer diff --git a/layers/gpu/instrumentation/gpuav_instrumentation.cpp b/layers/gpu/instrumentation/gpuav_instrumentation.cpp index 292174e331e..92902306063 100644 --- a/layers/gpu/instrumentation/gpuav_instrumentation.cpp +++ b/layers/gpu/instrumentation/gpuav_instrumentation.cpp @@ -22,6 +22,7 @@ #include "gpu/error_message/gpuav_vuids.h" #include "gpu/resources/gpu_shader_resources.h" #include "gpu/shaders/gpu_error_header.h" +#include "gpu/debug_printf/debug_printf.h" #include "state_tracker/shader_object_state.h" namespace gpuav { @@ -146,9 +147,7 @@ static VkPipelineLayout CreateInstrumentationPipelineLayout(Validator &gpuav, Vk void PreCallSetupShaderInstrumentationResources(Validator &gpuav, CommandBuffer &cb_state, VkPipelineBindPoint bind_point, const Location &loc) { - if (!gpuav.gpuav_settings.shader_instrumentation_enabled) { - return; - } + if (!gpuav.gpuav_settings.IsShaderInstrumentationEnabled() && !gpuav.gpuav_settings.debug_printf_enabled) return; assert(bind_point == VK_PIPELINE_BIND_POINT_GRAPHICS || bind_point == VK_PIPELINE_BIND_POINT_COMPUTE || bind_point == VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR); @@ -168,13 +167,35 @@ void PreCallSetupShaderInstrumentationResources(Validator &gpuav, CommandBuffer return; } + gpu::DeviceMemoryBlock debug_printf_output_buffer = {}; + if (!debug_printf::AllocateOutputBuffer(gpuav, cb_state.VkHandle(), debug_printf_output_buffer, loc)) { + return; + } + cb_state.debug_printf_buffer_infos.emplace_back(debug_printf_output_buffer, bind_point, cb_state.action_command_count); + // Update instrumentation descriptor set { // Pathetic way of trying to make sure we take care of updating all // bindings of the instrumentation descriptor set - assert(gpuav.instrumentation_bindings_.size() == 6); + assert(gpuav.instrumentation_bindings_.size() == 7); std::vector desc_writes = {}; + // DebugPrintf output buffer + VkDescriptorBufferInfo debug_printf_desc_buffer_info = {}; + { + debug_printf_desc_buffer_info.range = gpuav.gpuav_settings.debug_printf_buffer_size; + debug_printf_desc_buffer_info.buffer = debug_printf_output_buffer.buffer; + debug_printf_desc_buffer_info.offset = 0; + + VkWriteDescriptorSet wds = vku::InitStructHelper(); + wds.dstBinding = glsl::kBindingInstDebugPrintf; + wds.descriptorCount = 1; + wds.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; + wds.pBufferInfo = &debug_printf_desc_buffer_info; + wds.dstSet = instrumentation_desc_set; + desc_writes.emplace_back(wds); + } + // Error output buffer VkDescriptorBufferInfo error_output_desc_buffer_info = {}; { @@ -270,12 +291,15 @@ void PreCallSetupShaderInstrumentationResources(Validator &gpuav, CommandBuffer } uint32_t operation_index = 0; - if (bind_point == VK_PIPELINE_BIND_POINT_GRAPHICS) - operation_index = cb_state.draw_index++; - else if (bind_point == VK_PIPELINE_BIND_POINT_COMPUTE) - operation_index = cb_state.compute_index++; - else if (bind_point == VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR) - operation_index = cb_state.trace_rays_index++; + if (bind_point == VK_PIPELINE_BIND_POINT_GRAPHICS) { + operation_index = cb_state.draw_index; + } + else if (bind_point == VK_PIPELINE_BIND_POINT_COMPUTE) { + operation_index = cb_state.compute_index; + } + else if (bind_point == VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR) { + operation_index = cb_state.trace_rays_index; + } const bool uses_shader_object = last_bound.pipeline_state == nullptr; @@ -398,9 +422,7 @@ void PreCallSetupShaderInstrumentationResources(Validator &gpuav, CommandBuffer void PostCallSetupShaderInstrumentationResources(Validator &gpuav, CommandBuffer &cb_state, VkPipelineBindPoint bind_point, const Location &loc) { - if (!gpuav.gpuav_settings.shader_instrumentation_enabled) { - return; - } + if (!gpuav.gpuav_settings.IsShaderInstrumentationEnabled() && !gpuav.gpuav_settings.debug_printf_enabled) return; assert(bind_point == VK_PIPELINE_BIND_POINT_GRAPHICS || bind_point == VK_PIPELINE_BIND_POINT_COMPUTE || bind_point == VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR); diff --git a/layers/gpu/resources/gpuav_subclasses.cpp b/layers/gpu/resources/gpuav_subclasses.cpp index 0e3ede658d2..e02b4ba4ac4 100644 --- a/layers/gpu/resources/gpuav_subclasses.cpp +++ b/layers/gpu/resources/gpuav_subclasses.cpp @@ -23,6 +23,7 @@ #include "gpu/descriptor_validation/gpuav_image_layout.h" #include "gpu/descriptor_validation/gpuav_descriptor_validation.h" #include "gpu/shaders/gpu_error_header.h" +#include "gpu/debug_printf/debug_printf.h" namespace gpuav { @@ -121,37 +122,38 @@ void AccelerationStructureNV::NotifyInvalidate(const NodeList &invalid_nodes, bo CommandBuffer::CommandBuffer(Validator &gpuav, VkCommandBuffer handle, const VkCommandBufferAllocateInfo *pCreateInfo, const vvl::CommandPool *pool) - : gpu_tracker::CommandBuffer(gpuav, handle, pCreateInfo, pool), + : vvl::CommandBuffer(gpuav, handle, pCreateInfo, pool), gpu_resources_manager(gpuav.vma_allocator_, *gpuav.desc_set_manager_), state_(gpuav) { Location loc(vvl::Func::vkAllocateCommandBuffers); AllocateResources(loc); } -static bool AllocateErrorLogsBuffer(Validator &gpuav, gpu::DeviceMemoryBlock &error_logs_mem, const Location &loc) { +static bool AllocateErrorLogsBuffer(Validator &gpuav, VkCommandBuffer command_buffer, gpu::DeviceMemoryBlock &error_output_buffer, + const Location &loc) { VkBufferCreateInfo buffer_info = vku::InitStructHelper(); buffer_info.size = glsl::kErrorBufferByteSize; buffer_info.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; VmaAllocationCreateInfo alloc_info = {}; alloc_info.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; alloc_info.pool = gpuav.output_buffer_pool_; - VkResult result = vmaCreateBuffer(gpuav.vma_allocator_, &buffer_info, &alloc_info, &error_logs_mem.buffer, - &error_logs_mem.allocation, nullptr); + VkResult result = vmaCreateBuffer(gpuav.vma_allocator_, &buffer_info, &alloc_info, &error_output_buffer.buffer, + &error_output_buffer.allocation, nullptr); if (result != VK_SUCCESS) { - gpuav.InternalError(gpuav.device, loc, "Unable to allocate device memory for error output buffer.", true); + gpuav.InternalError(command_buffer, loc, "Unable to allocate device memory for error output buffer.", true); return false; } uint32_t *output_buffer_ptr; - result = vmaMapMemory(gpuav.vma_allocator_, error_logs_mem.allocation, reinterpret_cast(&output_buffer_ptr)); + result = vmaMapMemory(gpuav.vma_allocator_, error_output_buffer.allocation, reinterpret_cast(&output_buffer_ptr)); if (result == VK_SUCCESS) { memset(output_buffer_ptr, 0, glsl::kErrorBufferByteSize); if (gpuav.gpuav_settings.shader_instrumentation.bindless_descriptor) { output_buffer_ptr[cst::stream_output_flags_offset] = cst::inst_buffer_oob_enabled; } - vmaUnmapMemory(gpuav.vma_allocator_, error_logs_mem.allocation); + vmaUnmapMemory(gpuav.vma_allocator_, error_output_buffer.allocation); } else { - gpuav.InternalError(gpuav.device, loc, "Unable to map device memory allocated for error output buffer.", true); + gpuav.InternalError(command_buffer, loc, "Unable to map device memory allocated for error output buffer.", true); return false; } @@ -178,7 +180,7 @@ void CommandBuffer::AllocateResources(const Location &loc) { } // Error output buffer - if (!AllocateErrorLogsBuffer(*gpuav, error_output_buffer_, loc)) { + if (!AllocateErrorLogsBuffer(*gpuav, VkHandle(), error_output_buffer_, loc)) { return; } @@ -388,8 +390,14 @@ void CommandBuffer::Reset(const Location &loc) { void CommandBuffer::ResetCBState() { auto gpuav = static_cast(&dev_data); + // Free the device memory and descriptor set(s) associated with a command buffer. + for (auto &buffer_info : debug_printf_buffer_infos) { + buffer_info.output_mem_block.Destroy(gpuav->vma_allocator_); + } + debug_printf_buffer_infos.clear(); + // Free the device memory and descriptor set(s) associated with a command buffer. gpu_resources_manager.DestroyResources(); per_command_error_loggers.clear(); @@ -423,6 +431,7 @@ void CommandBuffer::ResetCBState() { draw_index = 0; compute_index = 0; trace_rays_index = 0; + action_command_count = 0; } void CommandBuffer::ClearCmdErrorsCountsBuffer(const Location &loc) const { @@ -438,6 +447,17 @@ void CommandBuffer::ClearCmdErrorsCountsBuffer(const Location &loc) const { vmaUnmapMemory(gpuav->vma_allocator_, cmd_errors_counts_buffer_.allocation); } +void CommandBuffer::UpdateCommandCount(VkPipelineBindPoint bind_point) { + action_command_count++; + if (bind_point == VK_PIPELINE_BIND_POINT_GRAPHICS) { + draw_index++; + } else if (bind_point == VK_PIPELINE_BIND_POINT_COMPUTE) { + compute_index++; + } else if (bind_point == VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR) { + trace_rays_index++; + } +} + bool CommandBuffer::PreProcess(const Location &loc) { auto gpuav = static_cast(&dev_data); @@ -458,6 +478,19 @@ bool CommandBuffer::NeedsPostProcess() { return !error_output_buffer_.IsNull(); // For the given command buffer, map its debug data buffers and read their contents for analysis. void CommandBuffer::PostProcess(VkQueue queue, const Location &loc) { + auto gpuav = static_cast(&dev_data); + + // For the given command buffer, map its debug data buffers and read their contents for analysis. + for (auto &buffer_info : debug_printf_buffer_infos) { + char *data; + + VkResult result = vmaMapMemory(gpuav->vma_allocator_, buffer_info.output_mem_block.allocation, (void **)&data); + if (result == VK_SUCCESS) { + debug_printf::AnalyzeAndGenerateMessage(*gpuav, VkHandle(), queue, buffer_info, (uint32_t *)data, loc); + vmaUnmapMemory(gpuav->vma_allocator_, buffer_info.output_mem_block.allocation); + } + } + // CommandBuffer::Destroy can happen on an other thread, // so when getting here after acquiring command buffer's lock, // make sure there are still things to process @@ -465,7 +498,6 @@ void CommandBuffer::PostProcess(VkQueue queue, const Location &loc) { return; } - auto gpuav = static_cast(&dev_data); bool skip = false; uint32_t *error_output_buffer_ptr = nullptr; VkResult result = @@ -478,6 +510,7 @@ void CommandBuffer::PostProcess(VkQueue queue, const Location &loc) { // we provide via the descriptor. So, we process only the number of words that can fit in the // buffer. const uint32_t total_words = error_output_buffer_ptr[cst::stream_output_size_offset]; + // A zero here means that the shader instrumentation didn't write anything. if (total_words != 0) { uint32_t *const error_records_start = &error_output_buffer_ptr[cst::stream_output_data_offset]; @@ -525,15 +558,6 @@ void CommandBuffer::PostProcess(VkQueue queue, const Location &loc) { } } -} // namespace gpuav - - -namespace gpu_tracker { - -CommandBuffer::CommandBuffer(gpu::GpuShaderInstrumentor &shader_instrumentor, VkCommandBuffer handle, - const VkCommandBufferAllocateInfo *pCreateInfo, const vvl::CommandPool *pool) - : vvl::CommandBuffer(shader_instrumentor, handle, pCreateInfo, pool) {} - Queue::Queue(gpu::GpuShaderInstrumentor &shader_instrumentor, VkQueue q, uint32_t family_index, uint32_t queue_index, VkDeviceQueueCreateFlags flags, const VkQueueFamilyProperties &queueFamilyProperties, bool timeline_khr) : vvl::Queue(shader_instrumentor, q, family_index, queue_index, flags, queueFamilyProperties), @@ -687,4 +711,5 @@ void Queue::Retire(vvl::QueueSubmission &submission) { retiring_.clear(); } } -} // namespace gpu_tracker + +} // namespace gpuav \ No newline at end of file diff --git a/layers/gpu/resources/gpuav_subclasses.h b/layers/gpu/resources/gpuav_subclasses.h index 2d977b3ab40..9f5223faa07 100644 --- a/layers/gpu/resources/gpuav_subclasses.h +++ b/layers/gpu/resources/gpuav_subclasses.h @@ -36,47 +36,23 @@ namespace gpu { class GpuShaderInstrumentor; } -namespace gpu_tracker { - -class Queue : public vvl::Queue { - public: - Queue(gpu::GpuShaderInstrumentor &shader_instrumentor_, VkQueue q, uint32_t family_index, uint32_t queue_index, - VkDeviceQueueCreateFlags flags, const VkQueueFamilyProperties &queueFamilyProperties, bool timeline_khr); - virtual ~Queue(); - - protected: - vvl::PreSubmitResult PreSubmit(std::vector &&submissions) override; - void PostSubmit(vvl::QueueSubmission &) override; - void SubmitBarrier(const Location &loc, uint64_t seq); - void Retire(vvl::QueueSubmission &) override; - - gpu::GpuShaderInstrumentor &shader_instrumentor_; - VkCommandPool barrier_command_pool_{VK_NULL_HANDLE}; - VkCommandBuffer barrier_command_buffer_{VK_NULL_HANDLE}; - VkSemaphore barrier_sem_{VK_NULL_HANDLE}; - std::deque>> retiring_; - const bool timeline_khr_; -}; - -class CommandBuffer : public vvl::CommandBuffer { - public: - CommandBuffer(gpu::GpuShaderInstrumentor &shader_instrumentor_, VkCommandBuffer handle, - const VkCommandBufferAllocateInfo *pCreateInfo, const vvl::CommandPool *pool); - - virtual bool PreProcess(const Location &loc) = 0; - virtual void PostProcess(VkQueue queue, const Location &loc) = 0; -}; -} // namespace gpu_tracker - -VALSTATETRACK_DERIVED_STATE_OBJECT(VkQueue, gpu_tracker::Queue, vvl::Queue) -VALSTATETRACK_DERIVED_STATE_OBJECT(VkCommandBuffer, gpu_tracker::CommandBuffer, vvl::CommandBuffer) - namespace gpuav { class Validator; struct DescBindingInfo; -class CommandBuffer : public gpu_tracker::CommandBuffer { +struct DebugPrintfBufferInfo { + gpu::DeviceMemoryBlock output_mem_block; + VkPipelineBindPoint pipeline_bind_point; + uint32_t action_command_index; + DebugPrintfBufferInfo(gpu::DeviceMemoryBlock output_mem_block, VkPipelineBindPoint pipeline_bind_point, + uint32_t action_command_index) + : output_mem_block(output_mem_block), + pipeline_bind_point(pipeline_bind_point), + action_command_index(action_command_index){}; +}; + +class CommandBuffer : public vvl::CommandBuffer { public: // per vkCmdBindDescriptorSet() state std::vector di_input_buffer_list; @@ -84,13 +60,14 @@ class CommandBuffer : public gpu_tracker::CommandBuffer { uint32_t draw_index = 0; uint32_t compute_index = 0; uint32_t trace_rays_index = 0; + uint32_t action_command_count = 0; CommandBuffer(Validator &gpuav, VkCommandBuffer handle, const VkCommandBufferAllocateInfo *pCreateInfo, const vvl::CommandPool *pool); ~CommandBuffer(); - bool PreProcess(const Location &loc) final; - void PostProcess(VkQueue queue, const Location &loc) final; + bool PreProcess(const Location &loc); + void PostProcess(VkQueue queue, const Location &loc); [[nodiscard]] bool ValidateBindlessDescriptorSets(const Location &loc); const VkDescriptorSetLayout &GetInstrumentationDescriptorSetLayout() const { @@ -126,6 +103,7 @@ class CommandBuffer : public gpu_tracker::CommandBuffer { const gpu::DeviceMemoryBlock &GetBdaRangesSnapshot() const { return bda_ranges_snapshot_; } void ClearCmdErrorsCountsBuffer(const Location &loc) const; + void UpdateCommandCount(VkPipelineBindPoint bind_point); void Destroy() final; void Reset(const Location &loc) final; @@ -136,6 +114,8 @@ class CommandBuffer : public gpu_tracker::CommandBuffer { stdext::inplace_function; std::vector per_command_error_loggers; + std::vector debug_printf_buffer_infos; + private: void AllocateResources(const Location &loc); void ResetCBState(); @@ -162,6 +142,26 @@ class CommandBuffer : public gpu_tracker::CommandBuffer { uint32_t bda_ranges_snapshot_version_ = 0; }; +class Queue : public vvl::Queue { + public: + Queue(gpu::GpuShaderInstrumentor &shader_instrumentor_, VkQueue q, uint32_t family_index, uint32_t queue_index, + VkDeviceQueueCreateFlags flags, const VkQueueFamilyProperties &queueFamilyProperties, bool timeline_khr); + virtual ~Queue(); + + protected: + vvl::PreSubmitResult PreSubmit(std::vector &&submissions) override; + void PostSubmit(vvl::QueueSubmission &) override; + void SubmitBarrier(const Location &loc, uint64_t seq); + void Retire(vvl::QueueSubmission &) override; + + gpu::GpuShaderInstrumentor &shader_instrumentor_; + VkCommandPool barrier_command_pool_{VK_NULL_HANDLE}; + VkCommandBuffer barrier_command_buffer_{VK_NULL_HANDLE}; + VkSemaphore barrier_sem_{VK_NULL_HANDLE}; + std::deque>> retiring_; + const bool timeline_khr_; +}; + class Buffer : public vvl::Buffer { public: Buffer(ValidationStateTracker &dev_data, VkBuffer buff, const VkBufferCreateInfo *pCreateInfo, DescriptorHeap &desc_heap_); diff --git a/layers/gpu/shaders/gpu_shaders_constants.h b/layers/gpu/shaders/gpu_shaders_constants.h index 0220150f513..1d405863a6d 100644 --- a/layers/gpu/shaders/gpu_shaders_constants.h +++ b/layers/gpu/shaders/gpu_shaders_constants.h @@ -46,15 +46,17 @@ const uint kLinkShaderId = 0x0DEAD001; // This is just a placeholder, honestly could be anything, will be replaced when linking to the runtime descriptor set choosen const int kInstDefaultDescriptorSet = 7; -// Inside the descriptor set used by instrumentation validation, -// binding #0 is reserved for the output, but each check that requires additional input -// must reserve its own binding slot -const int kBindingInstErrorBuffer = 0; -const int kBindingInstBindlessDescriptor = 1; -const int kBindingInstBufferDeviceAddress = 2; -const int kBindingInstActionIndex = 3; -const int kBindingInstCmdResourceIndex = 4; -const int kBindingInstCmdErrorsCount = 5; +// Binding index inside the descriptor set used by instrumentation validation. +// Set to front as people might want to use only DebugPrintf and this can allow us to reduce overhead not binding the other buffers +const int kBindingInstDebugPrintf = 0; +// binding #1 is reserved for the output all non-DebugPrintf shaders write out too. +const int kBindingInstErrorBuffer = 1; +// Each check that requires additional input/output to be sent must reserve its own binding slot +const int kBindingInstBindlessDescriptor = 2; +const int kBindingInstBufferDeviceAddress = 3; +const int kBindingInstActionIndex = 4; +const int kBindingInstCmdResourceIndex = 5; +const int kBindingInstCmdErrorsCount = 6; // Diagnostic calls // --- diff --git a/layers/gpu/spirv/module.h b/layers/gpu/spirv/module.h index eea41cb968f..4961384562f 100644 --- a/layers/gpu/spirv/module.h +++ b/layers/gpu/spirv/module.h @@ -88,7 +88,7 @@ class Module { bool RunPassNonBindlessOOBTexelBuffer(); bool RunPassBufferDeviceAddress(); bool RunPassRayQuery(); - bool RunPassDebugPrintf(uint32_t binding_slot = 0); + bool RunPassDebugPrintf(uint32_t binding_slot); void AddInterfaceVariables(uint32_t id, spv::StorageClass storage_class); diff --git a/layers/layer_options.cpp b/layers/layer_options.cpp index 921c4d797f2..d79ab178451 100644 --- a/layers/layer_options.cpp +++ b/layers/layer_options.cpp @@ -135,7 +135,8 @@ const char *VK_LAYER_VALIDATE_BEST_PRACTICES_AMD = "validate_best_practices_amd" const char *VK_LAYER_VALIDATE_BEST_PRACTICES_IMG = "validate_best_practices_img"; const char *VK_LAYER_VALIDATE_BEST_PRACTICES_NVIDIA = "validate_best_practices_nvidia"; const char *VK_LAYER_VALIDATE_SYNC = "validate_sync"; -const char *VK_LAYER_VALIDATE_GPU_BASED = "validate_gpu_based"; +// These were deprecated after the 1.3.296 SDK release (because it was a flag and now is a boolean) +const char *DEPRECATED_VK_LAYER_VALIDATE_GPU_BASED = "validate_gpu_based"; // Corresponding to VkValidationFeatureDisableEXT // --- @@ -167,14 +168,19 @@ const char *VK_LAYER_FINE_GRAINED_LOCKING = "fine_grained_locking"; // Debug settings used for internal development const char *VK_LAYER_DEBUG_DISABLE_SPIRV_VAL = "debug_disable_spirv_val"; -// DebugPrintf +// DebugPrintf (which is now part of GPU-AV internally) // --- +// Quick, single setting to turn on DebugPrintf +const char *VK_LAYER_PRINTF_ONLY_PRESET = "printf_only_preset"; +// Was added a new way to set things without having to use VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT +const char *VK_LAYER_PRINTF_ENABLE = "printf_enable"; const char *VK_LAYER_PRINTF_TO_STDOUT = "printf_to_stdout"; const char *VK_LAYER_PRINTF_VERBOSE = "printf_verbose"; const char *VK_LAYER_PRINTF_BUFFER_SIZE = "printf_buffer_size"; // GPU-AV // --- +const char *VK_LAYER_GPUAV_ENABLE = "gpuav_enable"; const char *VK_LAYER_GPUAV_SHADER_INSTRUMENTATION = "gpuav_shader_instrumentation"; const char *VK_LAYER_GPUAV_DESCRIPTOR_CHECKS = "gpuav_descriptor_checks"; const char *VK_LAYER_GPUAV_WARN_ON_ROBUST_OOB = "gpuav_warn_on_robust_oob"; @@ -633,7 +639,7 @@ static void ProcessDebugReportSettings(ConfigAndEnvSettings *settings_data, VkuL } // Before creating the debug callback, see if other settings interfere - if (settings_data->enables[debug_printf_validation]) { + if (settings_data->gpuav_settings->debug_printf_enabled) { if (settings_data->gpuav_settings->debug_printf_to_stdout && (debug_action & VK_DBG_LAYER_ACTION_LOG_MSG)) { if (is_stdout) { setting_warnings.emplace_back( @@ -806,11 +812,12 @@ void ProcessConfigAndEnvSettings(ConfigAndEnvSettings *settings_data) { } GpuAVSettings &gpuav_settings = *settings_data->gpuav_settings; + bool shader_instrumentation_enabled = true; if (vkuHasLayerSetting(layer_setting_set, VK_LAYER_GPUAV_SHADER_INSTRUMENTATION)) { - vkuGetLayerSettingValue(layer_setting_set, VK_LAYER_GPUAV_SHADER_INSTRUMENTATION, - gpuav_settings.shader_instrumentation_enabled); + vkuGetLayerSettingValue(layer_setting_set, VK_LAYER_GPUAV_SHADER_INSTRUMENTATION, shader_instrumentation_enabled); } - if (!gpuav_settings.shader_instrumentation_enabled) { + + if (!shader_instrumentation_enabled) { gpuav_settings.DisableShaderInstrumentationAndOptions(); } else { if (vkuHasLayerSetting(layer_setting_set, VK_LAYER_GPUAV_DESCRIPTOR_CHECKS)) { @@ -874,10 +881,11 @@ void ProcessConfigAndEnvSettings(ConfigAndEnvSettings *settings_data) { } } + bool buffers_validation_enabled = true; if (vkuHasLayerSetting(layer_setting_set, VK_LAYER_GPUAV_BUFFERS_VALIDATION)) { - vkuGetLayerSettingValue(layer_setting_set, VK_LAYER_GPUAV_BUFFERS_VALIDATION, gpuav_settings.buffers_validation_enabled); + vkuGetLayerSettingValue(layer_setting_set, VK_LAYER_GPUAV_BUFFERS_VALIDATION, buffers_validation_enabled); } - if (!gpuav_settings.buffers_validation_enabled) { + if (!buffers_validation_enabled) { gpuav_settings.SetBufferValidationEnabled(false); } else { if (vkuHasLayerSetting(layer_setting_set, VK_LAYER_GPUAV_INDIRECT_DRAWS_BUFFERS)) { @@ -940,6 +948,11 @@ void ProcessConfigAndEnvSettings(ConfigAndEnvSettings *settings_data) { gpuav_settings.debug_max_instrumented_count); } + // Debug Printf - (which we bundle into GPU-AV internally) + if (vkuHasLayerSetting(layer_setting_set, VK_LAYER_PRINTF_ENABLE)) { + vkuGetLayerSettingValue(layer_setting_set, VK_LAYER_PRINTF_ENABLE, gpuav_settings.debug_printf_enabled); + } + if (vkuHasLayerSetting(layer_setting_set, VK_LAYER_GPUAV_DEBUG_PRINT_INSTRUMENTATION_INFO)) { vkuGetLayerSettingValue(layer_setting_set, VK_LAYER_GPUAV_DEBUG_PRINT_INSTRUMENTATION_INFO, gpuav_settings.debug_print_instrumentation_info); @@ -990,15 +1003,6 @@ void ProcessConfigAndEnvSettings(ConfigAndEnvSettings *settings_data) { SetValidationFlags(settings_data->disables, validation_flags_ext); } - // if app is setting VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT, we can use this to disable it for debugging - if (vkuHasLayerSetting(layer_setting_set, VK_LAYER_GPUAV_DEBUG_DISABLE_ALL)) { - bool disable_gpuav = false; - vkuGetLayerSettingValue(layer_setting_set, VK_LAYER_GPUAV_DEBUG_DISABLE_ALL, disable_gpuav); - if (disable_gpuav) { - settings_data->enables[gpu_validation] = false; - } - } - const bool use_fine_grained_settings = disables.empty() && enables.empty(); // Only read the legacy enables flags when used, not their replacement. @@ -1012,11 +1016,20 @@ void ProcessConfigAndEnvSettings(ConfigAndEnvSettings *settings_data) { VK_LAYER_VALIDATE_BEST_PRACTICES_NVIDIA); SetValidationSetting(layer_setting_set, settings_data->enables, sync_validation, VK_LAYER_VALIDATE_SYNC); - if (vkuHasLayerSetting(layer_setting_set, VK_LAYER_VALIDATE_GPU_BASED)) { + // Before GPU-AV and DebugPrintf were megered, we used this enum to set GPU-AV and DebugPrintf in vkconfig. + // This code should in theory be dead since removing it from vkconfig, but keep just incase for a bit + if (vkuHasLayerSetting(layer_setting_set, DEPRECATED_VK_LAYER_VALIDATE_GPU_BASED)) { std::string setting_value; - vkuGetLayerSettingValue(layer_setting_set, VK_LAYER_VALIDATE_GPU_BASED, setting_value); - settings_data->enables[gpu_validation] = setting_value == "GPU_BASED_GPU_ASSISTED"; - settings_data->enables[debug_printf_validation] = setting_value == "GPU_BASED_DEBUG_PRINTF"; + vkuGetLayerSettingValue(layer_setting_set, DEPRECATED_VK_LAYER_VALIDATE_GPU_BASED, setting_value); + if (setting_value == "GPU_BASED_GPU_ASSISTED") { + settings_data->enables[gpu_validation] = true; + setting_warnings.emplace_back("Deprecated " + std::string(DEPRECATED_VK_LAYER_VALIDATE_GPU_BASED) + + " setting was set, use " + std::string(VK_LAYER_GPUAV_ENABLE) + " instead."); + } else if (setting_value == "GPU_BASED_DEBUG_PRINTF") { + settings_data->enables[debug_printf_validation] = true; + setting_warnings.emplace_back("Deprecated " + std::string(DEPRECATED_VK_LAYER_VALIDATE_GPU_BASED) + + " setting was set, use " + std::string(VK_LAYER_PRINTF_ENABLE) + " instead."); + } } } @@ -1036,6 +1049,54 @@ void ProcessConfigAndEnvSettings(ConfigAndEnvSettings *settings_data) { SetValidationSetting(layer_setting_set, settings_data->disables, shader_validation_caching, VK_LAYER_CHECK_SHADERS_CACHING); } + // This is the "original" way to use DebugPrintf before you could use it with GPU-AV + // In this case, we want to emulate supporting only for DebugPrintf with GPU-AV turned off + if (settings_data->enables[debug_printf_validation]) { + gpuav_settings.debug_printf_enabled = true; + if (!settings_data->enables[gpu_validation]) { + gpuav_settings.SetOnlyDebugPrintf(); + } + } + + // New way to override everything to make it easy to use DebugPrintf when VkConfig isn't available + if (vkuHasLayerSetting(layer_setting_set, VK_LAYER_PRINTF_ONLY_PRESET)) { + bool printf_only_preset = false; + vkuGetLayerSettingValue(layer_setting_set, VK_LAYER_PRINTF_VERBOSE, printf_only_preset); + if (printf_only_preset) { + gpuav_settings.SetOnlyDebugPrintf(); + + SetValidationFeatureDisable(settings_data->disables, VK_VALIDATION_FEATURE_DISABLE_ALL_EXT); + setting_warnings.emplace_back( + "Setting VK_VALIDATION_FEATURE_DISABLE_ALL_EXT so that only DebugPrintf will be used and everything is else is " + "turned off."); + } + } + + if (gpuav_settings.cache_instrumented_shaders && gpuav_settings.debug_printf_enabled) { + gpuav_settings.cache_instrumented_shaders = false; + setting_warnings.emplace_back( + "Debug Printf was enabled, disabling caching of instrumented shaders as it might accidentally not print out the " + "expected output."); + } + + // This is the "new and correct" way to set GPU-AV and/or DebugPrintf, it will turn on the old enable[gpu_validation] since the + // chassis is expecting it + if (vkuHasLayerSetting(layer_setting_set, VK_LAYER_GPUAV_ENABLE)) { + bool gpuav_enable = false; + vkuGetLayerSettingValue(layer_setting_set, VK_LAYER_GPUAV_ENABLE, gpuav_enable); + if (gpuav_enable) { + settings_data->enables[gpu_validation] = true; + } + } + // if app is setting VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT, we can use this to disable it for debugging + if (vkuHasLayerSetting(layer_setting_set, VK_LAYER_GPUAV_DEBUG_DISABLE_ALL)) { + bool disable_gpuav = false; + vkuGetLayerSettingValue(layer_setting_set, VK_LAYER_GPUAV_DEBUG_DISABLE_ALL, disable_gpuav); + if (disable_gpuav) { + settings_data->enables[gpu_validation] = false; + } + } + if (settings_data->enables[gpu_validation] && !settings_data->disables[core_checks]) { setting_warnings.emplace_back( "Both GPU Assisted Validation and Normal Core Check Validation are enabled, this is not recommend as it will be very " diff --git a/layers/layer_options.h b/layers/layer_options.h index a39d9ffccfe..9ecc9174962 100644 --- a/layers/layer_options.h +++ b/layers/layer_options.h @@ -69,6 +69,7 @@ enum EnableFlags { vendor_specific_amd, vendor_specific_img, vendor_specific_nvidia, + // DebugPrintf was merged with GPU-AV, so we now just use this funnel into the new settings debug_printf_validation, sync_validation, // Insert new enables above this line diff --git a/layers/stateless/sl_instance_device.cpp b/layers/stateless/sl_instance_device.cpp index 7b6dc17cb39..5c3a578d8da 100644 --- a/layers/stateless/sl_instance_device.cpp +++ b/layers/stateless/sl_instance_device.cpp @@ -183,12 +183,6 @@ bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceC "includes VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT but no " "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT or VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT."); } - if (gpu_assisted && debug_printf) { - skip |= LogError( - "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968", instance, - create_info_loc.pNext(Struct::VkValidationFeaturesEXT, Field::pEnabledValidationFeatures), - "includes both VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT and VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT."); - } } const auto *debug_report_callback = vku::FindStructInPNextChain(pCreateInfo->pNext); diff --git a/layers/vulkan/generated/chassis.cpp b/layers/vulkan/generated/chassis.cpp index 030257fb671..8ec916d4bea 100644 --- a/layers/vulkan/generated/chassis.cpp +++ b/layers/vulkan/generated/chassis.cpp @@ -61,7 +61,6 @@ bool wrap_handles = true; #include "core_checks/core_validation.h" #include "best_practices/best_practices_validation.h" #include "gpu/core/gpuav.h" -#include "gpu/debug_printf/debug_printf.h" #include "sync/sync_validation.h" // This header file must be included after the above validation object class definitions @@ -101,12 +100,9 @@ static std::vector CreateObjectDispatch(const CHECK_ENABLED& if (enables[best_practices]) { object_dispatch.emplace_back(new BestPractices); } - if (enables[gpu_validation]) { + if (enables[gpu_validation] || enables[debug_printf_validation]) { object_dispatch.emplace_back(new gpuav::Validator); } - if (enables[debug_printf_validation]) { - object_dispatch.emplace_back(new debug_printf::Validator); - } if (enables[sync_validation]) { object_dispatch.emplace_back(new SyncValidator); } @@ -135,12 +131,9 @@ static void InitDeviceObjectDispatch(ValidationObject* instance_interceptor, Val if (enables[best_practices]) { device_interceptor->object_dispatch.emplace_back(new BestPractices); } - if (enables[gpu_validation]) { + if (enables[gpu_validation] || enables[debug_printf_validation]) { device_interceptor->object_dispatch.emplace_back(new gpuav::Validator); } - if (enables[debug_printf_validation]) { - device_interceptor->object_dispatch.emplace_back(new debug_printf::Validator); - } if (enables[sync_validation]) { device_interceptor->object_dispatch.emplace_back(new SyncValidator); } diff --git a/layers/vulkan/generated/chassis.h b/layers/vulkan/generated/chassis.h index 39f2235d9e8..fbbd166e465 100644 --- a/layers/vulkan/generated/chassis.h +++ b/layers/vulkan/generated/chassis.h @@ -2236,7 +2236,6 @@ enum LayerObjectTypeId { LayerObjectTypeCoreValidation, // Instance or device core validation layer object LayerObjectTypeBestPractices, // Instance or device best practices layer object LayerObjectTypeGpuAssisted, // Instance or device gpu assisted validation layer object - LayerObjectTypeDebugPrintf, // Instance or device shader debug printf layer object LayerObjectTypeSyncValidation, // Instance or device synchronization validation layer object LayerObjectTypeMaxEnum, // Max enum count }; diff --git a/layers/vulkan/generated/chassis_dispatch_helper.h b/layers/vulkan/generated/chassis_dispatch_helper.h index 78423798fb3..57f36906e9f 100644 --- a/layers/vulkan/generated/chassis_dispatch_helper.h +++ b/layers/vulkan/generated/chassis_dispatch_helper.h @@ -1769,7 +1769,6 @@ void ValidationObject::InitObjectDispatchVectors() { typeid(&CoreChecks::name), \ typeid(&BestPractices::name), \ typeid(&gpuav::Validator::name), \ - typeid(&debug_printf::Validator::name), \ typeid(&SyncValidator::name)); auto init_object_dispatch_vector = [this](InterceptId id, @@ -1780,7 +1779,6 @@ void ValidationObject::InitObjectDispatchVectors() { const std::type_info& tcv_typeid, const std::type_info& tbp_typeid, const std::type_info& tga_typeid, - const std::type_info& tdp_typeid, const std::type_info& tsv_typeid) { for (auto item : this->object_dispatch) { auto intercept_vector = &this->intercept_vectors[id]; @@ -1803,9 +1801,6 @@ void ValidationObject::InitObjectDispatchVectors() { case LayerObjectTypeGpuAssisted: if (tga_typeid != vo_typeid) intercept_vector->push_back(item); break; - case LayerObjectTypeDebugPrintf: - if (tdp_typeid != vo_typeid) intercept_vector->push_back(item); - break; case LayerObjectTypeSyncValidation: if (tsv_typeid != vo_typeid) intercept_vector->push_back(item); break; diff --git a/layers/vulkan/generated/instrumentation_bindless_descriptor_comp.cpp b/layers/vulkan/generated/instrumentation_bindless_descriptor_comp.cpp index f33e903d89b..4c8a1b9018f 100644 --- a/layers/vulkan/generated/instrumentation_bindless_descriptor_comp.cpp +++ b/layers/vulkan/generated/instrumentation_bindless_descriptor_comp.cpp @@ -71,16 +71,16 @@ 0x00040047, 0x00000026, 0x00000006, 0x00000018, 0x00030047, 0x00000027, 0x00000002, 0x00050048, 0x00000027, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x00000027, 0x00000001, 0x00000023, 0x00000008, 0x00040047, 0x00000028, 0x00000006, 0x00000004, 0x00030047, 0x00000029, 0x00000002, 0x00050048, 0x00000029, 0x00000000, 0x00000023, 0x00000000, 0x00040047, - 0x0000002b, 0x00000021, 0x00000001, 0x00040047, 0x0000002b, 0x00000022, 0x00000007, 0x00040047, 0x000000c4, 0x00000006, + 0x0000002b, 0x00000021, 0x00000002, 0x00040047, 0x0000002b, 0x00000022, 0x00000007, 0x00040047, 0x000000c4, 0x00000006, 0x00000004, 0x00030047, 0x000000c5, 0x00000002, 0x00050048, 0x000000c5, 0x00000000, 0x00000023, 0x00000000, 0x00040047, - 0x000000c7, 0x00000021, 0x00000004, 0x00040047, 0x000000c7, 0x00000022, 0x00000007, 0x00040047, 0x000000cc, 0x00000006, + 0x000000c7, 0x00000021, 0x00000005, 0x00040047, 0x000000c7, 0x00000022, 0x00000007, 0x00040047, 0x000000cc, 0x00000006, 0x00000004, 0x00030047, 0x000000cd, 0x00000002, 0x00050048, 0x000000cd, 0x00000000, 0x00000023, 0x00000000, 0x00040047, - 0x000000cf, 0x00000021, 0x00000005, 0x00040047, 0x000000cf, 0x00000022, 0x00000007, 0x00040047, 0x000000dc, 0x00000006, + 0x000000cf, 0x00000021, 0x00000006, 0x00040047, 0x000000cf, 0x00000022, 0x00000007, 0x00040047, 0x000000dc, 0x00000006, 0x00000004, 0x00030047, 0x000000dd, 0x00000002, 0x00050048, 0x000000dd, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x000000dd, 0x00000001, 0x00000023, 0x00000004, 0x00050048, 0x000000dd, 0x00000002, 0x00000023, 0x00000008, 0x00040047, - 0x000000df, 0x00000021, 0x00000000, 0x00040047, 0x000000df, 0x00000022, 0x00000007, 0x00040047, 0x00000113, 0x00000006, + 0x000000df, 0x00000021, 0x00000001, 0x00040047, 0x000000df, 0x00000022, 0x00000007, 0x00040047, 0x00000113, 0x00000006, 0x00000004, 0x00030047, 0x00000114, 0x00000002, 0x00050048, 0x00000114, 0x00000000, 0x00000023, 0x00000000, 0x00040047, - 0x00000116, 0x00000021, 0x00000003, 0x00040047, 0x00000116, 0x00000022, 0x00000007, 0x00040015, 0x00000002, 0x00000020, + 0x00000116, 0x00000021, 0x00000004, 0x00040047, 0x00000116, 0x00000022, 0x00000007, 0x00040015, 0x00000002, 0x00000020, 0x00000000, 0x00040017, 0x00000003, 0x00000002, 0x00000004, 0x00020014, 0x00000004, 0x00090021, 0x00000005, 0x00000004, 0x00000002, 0x00000003, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00040020, 0x0000000e, 0x00000007, 0x00000002, 0x0004002b, 0x00000002, 0x00000010, 0x00000000, 0x00030027, 0x00000017, 0x000014e5, 0x00040017, 0x00000018, 0x00000002, diff --git a/layers/vulkan/generated/instrumentation_buffer_device_address_comp.cpp b/layers/vulkan/generated/instrumentation_buffer_device_address_comp.cpp index b9210b2b1ef..94f71e36930 100644 --- a/layers/vulkan/generated/instrumentation_buffer_device_address_comp.cpp +++ b/layers/vulkan/generated/instrumentation_buffer_device_address_comp.cpp @@ -57,16 +57,16 @@ 0x615f6563, 0x65726464, 0x00007373, 0x00000000, 0x00050048, 0x00000011, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x00000011, 0x00000001, 0x00000023, 0x00000008, 0x00040047, 0x00000012, 0x00000006, 0x00000010, 0x00030047, 0x00000013, 0x00000002, 0x00050048, 0x00000013, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x00000013, 0x00000001, 0x00000023, - 0x00000008, 0x00040047, 0x00000015, 0x00000021, 0x00000002, 0x00040047, 0x00000015, 0x00000022, 0x00000007, 0x00040047, + 0x00000008, 0x00040047, 0x00000015, 0x00000021, 0x00000003, 0x00040047, 0x00000015, 0x00000022, 0x00000007, 0x00040047, 0x00000069, 0x00000006, 0x00000004, 0x00030047, 0x0000006a, 0x00000002, 0x00050048, 0x0000006a, 0x00000000, 0x00000023, - 0x00000000, 0x00040047, 0x0000006c, 0x00000021, 0x00000004, 0x00040047, 0x0000006c, 0x00000022, 0x00000007, 0x00040047, + 0x00000000, 0x00040047, 0x0000006c, 0x00000021, 0x00000005, 0x00040047, 0x0000006c, 0x00000022, 0x00000007, 0x00040047, 0x00000071, 0x00000006, 0x00000004, 0x00030047, 0x00000072, 0x00000002, 0x00050048, 0x00000072, 0x00000000, 0x00000023, - 0x00000000, 0x00040047, 0x00000074, 0x00000021, 0x00000005, 0x00040047, 0x00000074, 0x00000022, 0x00000007, 0x00040047, + 0x00000000, 0x00040047, 0x00000074, 0x00000021, 0x00000006, 0x00040047, 0x00000074, 0x00000022, 0x00000007, 0x00040047, 0x00000084, 0x00000006, 0x00000004, 0x00030047, 0x00000085, 0x00000002, 0x00050048, 0x00000085, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x00000085, 0x00000001, 0x00000023, 0x00000004, 0x00050048, 0x00000085, 0x00000002, 0x00000023, - 0x00000008, 0x00040047, 0x00000087, 0x00000021, 0x00000000, 0x00040047, 0x00000087, 0x00000022, 0x00000007, 0x00040047, + 0x00000008, 0x00040047, 0x00000087, 0x00000021, 0x00000001, 0x00040047, 0x00000087, 0x00000022, 0x00000007, 0x00040047, 0x000000bf, 0x00000006, 0x00000004, 0x00030047, 0x000000c0, 0x00000002, 0x00050048, 0x000000c0, 0x00000000, 0x00000023, - 0x00000000, 0x00040047, 0x000000c2, 0x00000021, 0x00000003, 0x00040047, 0x000000c2, 0x00000022, 0x00000007, 0x00040015, + 0x00000000, 0x00040047, 0x000000c2, 0x00000021, 0x00000004, 0x00040047, 0x000000c2, 0x00000022, 0x00000007, 0x00040015, 0x00000002, 0x00000020, 0x00000000, 0x00040017, 0x00000003, 0x00000002, 0x00000004, 0x00040015, 0x00000004, 0x00000040, 0x00000000, 0x00020014, 0x00000005, 0x00080021, 0x00000006, 0x00000005, 0x00000002, 0x00000003, 0x00000004, 0x00000002, 0x00000002, 0x0004001e, 0x0000000e, 0x00000004, 0x00000004, 0x00040020, 0x0000000f, 0x00000007, 0x0000000e, 0x0004001e, diff --git a/layers/vulkan/generated/instrumentation_non_bindless_oob_buffer_comp.cpp b/layers/vulkan/generated/instrumentation_non_bindless_oob_buffer_comp.cpp index 251fb058bd8..2fd8d9bdefd 100644 --- a/layers/vulkan/generated/instrumentation_non_bindless_oob_buffer_comp.cpp +++ b/layers/vulkan/generated/instrumentation_non_bindless_oob_buffer_comp.cpp @@ -69,16 +69,16 @@ 0x00000029, 0x00000006, 0x00000018, 0x00030047, 0x0000002a, 0x00000002, 0x00050048, 0x0000002a, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x0000002a, 0x00000001, 0x00000023, 0x00000008, 0x00040047, 0x0000002b, 0x00000006, 0x00000004, 0x00030047, 0x0000002c, 0x00000002, 0x00050048, 0x0000002c, 0x00000000, 0x00000023, 0x00000000, 0x00040047, 0x0000002e, - 0x00000021, 0x00000001, 0x00040047, 0x0000002e, 0x00000022, 0x00000007, 0x00040047, 0x00000058, 0x00000006, 0x00000004, + 0x00000021, 0x00000002, 0x00040047, 0x0000002e, 0x00000022, 0x00000007, 0x00040047, 0x00000058, 0x00000006, 0x00000004, 0x00030047, 0x00000059, 0x00000002, 0x00050048, 0x00000059, 0x00000000, 0x00000023, 0x00000000, 0x00040047, 0x0000005b, - 0x00000021, 0x00000004, 0x00040047, 0x0000005b, 0x00000022, 0x00000007, 0x00040047, 0x00000060, 0x00000006, 0x00000004, + 0x00000021, 0x00000005, 0x00040047, 0x0000005b, 0x00000022, 0x00000007, 0x00040047, 0x00000060, 0x00000006, 0x00000004, 0x00030047, 0x00000061, 0x00000002, 0x00050048, 0x00000061, 0x00000000, 0x00000023, 0x00000000, 0x00040047, 0x00000063, - 0x00000021, 0x00000005, 0x00040047, 0x00000063, 0x00000022, 0x00000007, 0x00040047, 0x00000071, 0x00000006, 0x00000004, + 0x00000021, 0x00000006, 0x00040047, 0x00000063, 0x00000022, 0x00000007, 0x00040047, 0x00000071, 0x00000006, 0x00000004, 0x00030047, 0x00000072, 0x00000002, 0x00050048, 0x00000072, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x00000072, 0x00000001, 0x00000023, 0x00000004, 0x00050048, 0x00000072, 0x00000002, 0x00000023, 0x00000008, 0x00040047, 0x00000074, - 0x00000021, 0x00000000, 0x00040047, 0x00000074, 0x00000022, 0x00000007, 0x00040047, 0x000000ac, 0x00000006, 0x00000004, + 0x00000021, 0x00000001, 0x00040047, 0x00000074, 0x00000022, 0x00000007, 0x00040047, 0x000000ac, 0x00000006, 0x00000004, 0x00030047, 0x000000ad, 0x00000002, 0x00050048, 0x000000ad, 0x00000000, 0x00000023, 0x00000000, 0x00040047, 0x000000af, - 0x00000021, 0x00000003, 0x00040047, 0x000000af, 0x00000022, 0x00000007, 0x00040015, 0x00000002, 0x00000020, 0x00000000, + 0x00000021, 0x00000004, 0x00040047, 0x000000af, 0x00000022, 0x00000007, 0x00040015, 0x00000002, 0x00000020, 0x00000000, 0x00040017, 0x00000003, 0x00000002, 0x00000004, 0x00020014, 0x00000004, 0x000a0021, 0x00000005, 0x00000004, 0x00000002, 0x00000003, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00040020, 0x0000000f, 0x00000007, 0x00000002, 0x0004002b, 0x00000002, 0x00000011, 0x00000000, 0x0004002b, 0x00000002, 0x0000001b, 0x00000001, 0x00030027, 0x0000001d, diff --git a/layers/vulkan/generated/instrumentation_non_bindless_oob_texel_buffer_comp.cpp b/layers/vulkan/generated/instrumentation_non_bindless_oob_texel_buffer_comp.cpp index 9d85efcc173..e9b30041f78 100644 --- a/layers/vulkan/generated/instrumentation_non_bindless_oob_texel_buffer_comp.cpp +++ b/layers/vulkan/generated/instrumentation_non_bindless_oob_texel_buffer_comp.cpp @@ -69,16 +69,16 @@ 0x00000023, 0x00000000, 0x00040047, 0x00000029, 0x00000006, 0x00000018, 0x00030047, 0x0000002a, 0x00000002, 0x00050048, 0x0000002a, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x0000002a, 0x00000001, 0x00000023, 0x00000008, 0x00040047, 0x0000002b, 0x00000006, 0x00000004, 0x00030047, 0x0000002c, 0x00000002, 0x00050048, 0x0000002c, 0x00000000, 0x00000023, - 0x00000000, 0x00040047, 0x0000002e, 0x00000021, 0x00000001, 0x00040047, 0x0000002e, 0x00000022, 0x00000007, 0x00040047, + 0x00000000, 0x00040047, 0x0000002e, 0x00000021, 0x00000002, 0x00040047, 0x0000002e, 0x00000022, 0x00000007, 0x00040047, 0x00000059, 0x00000006, 0x00000004, 0x00030047, 0x0000005a, 0x00000002, 0x00050048, 0x0000005a, 0x00000000, 0x00000023, - 0x00000000, 0x00040047, 0x0000005c, 0x00000021, 0x00000004, 0x00040047, 0x0000005c, 0x00000022, 0x00000007, 0x00040047, + 0x00000000, 0x00040047, 0x0000005c, 0x00000021, 0x00000005, 0x00040047, 0x0000005c, 0x00000022, 0x00000007, 0x00040047, 0x00000061, 0x00000006, 0x00000004, 0x00030047, 0x00000062, 0x00000002, 0x00050048, 0x00000062, 0x00000000, 0x00000023, - 0x00000000, 0x00040047, 0x00000064, 0x00000021, 0x00000005, 0x00040047, 0x00000064, 0x00000022, 0x00000007, 0x00040047, + 0x00000000, 0x00040047, 0x00000064, 0x00000021, 0x00000006, 0x00040047, 0x00000064, 0x00000022, 0x00000007, 0x00040047, 0x00000072, 0x00000006, 0x00000004, 0x00030047, 0x00000073, 0x00000002, 0x00050048, 0x00000073, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x00000073, 0x00000001, 0x00000023, 0x00000004, 0x00050048, 0x00000073, 0x00000002, 0x00000023, - 0x00000008, 0x00040047, 0x00000075, 0x00000021, 0x00000000, 0x00040047, 0x00000075, 0x00000022, 0x00000007, 0x00040047, + 0x00000008, 0x00040047, 0x00000075, 0x00000021, 0x00000001, 0x00040047, 0x00000075, 0x00000022, 0x00000007, 0x00040047, 0x000000ac, 0x00000006, 0x00000004, 0x00030047, 0x000000ad, 0x00000002, 0x00050048, 0x000000ad, 0x00000000, 0x00000023, - 0x00000000, 0x00040047, 0x000000af, 0x00000021, 0x00000003, 0x00040047, 0x000000af, 0x00000022, 0x00000007, 0x00040015, + 0x00000000, 0x00040047, 0x000000af, 0x00000021, 0x00000004, 0x00040047, 0x000000af, 0x00000022, 0x00000007, 0x00040015, 0x00000002, 0x00000020, 0x00000000, 0x00040017, 0x00000003, 0x00000002, 0x00000004, 0x00020014, 0x00000004, 0x000a0021, 0x00000005, 0x00000004, 0x00000002, 0x00000003, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00040020, 0x0000000f, 0x00000007, 0x00000002, 0x0004002b, 0x00000002, 0x00000011, 0x00000000, 0x0004002b, 0x00000002, 0x0000001b, diff --git a/layers/vulkan/generated/instrumentation_ray_query_comp.cpp b/layers/vulkan/generated/instrumentation_ray_query_comp.cpp index 7f23ff678da..3247aaf3cf3 100644 --- a/layers/vulkan/generated/instrumentation_ray_query_comp.cpp +++ b/layers/vulkan/generated/instrumentation_ray_query_comp.cpp @@ -50,14 +50,14 @@ 0x00090005, 0x000000fd, 0x74736e69, 0x7463615f, 0x5f6e6f69, 0x65646e69, 0x75625f78, 0x72656666, 0x00000000, 0x00090047, 0x0000000f, 0x00000029, 0x74736e69, 0x7961725f, 0x6575715f, 0x635f7972, 0x00706d6f, 0x00000000, 0x00040047, 0x000000aa, 0x00000006, 0x00000004, 0x00030047, 0x000000ab, 0x00000002, 0x00050048, 0x000000ab, 0x00000000, 0x00000023, 0x00000000, - 0x00040047, 0x000000ad, 0x00000021, 0x00000004, 0x00040047, 0x000000ad, 0x00000022, 0x00000007, 0x00040047, 0x000000b4, + 0x00040047, 0x000000ad, 0x00000021, 0x00000005, 0x00040047, 0x000000ad, 0x00000022, 0x00000007, 0x00040047, 0x000000b4, 0x00000006, 0x00000004, 0x00030047, 0x000000b5, 0x00000002, 0x00050048, 0x000000b5, 0x00000000, 0x00000023, 0x00000000, - 0x00040047, 0x000000b7, 0x00000021, 0x00000005, 0x00040047, 0x000000b7, 0x00000022, 0x00000007, 0x00040047, 0x000000c4, + 0x00040047, 0x000000b7, 0x00000021, 0x00000006, 0x00040047, 0x000000b7, 0x00000022, 0x00000007, 0x00040047, 0x000000c4, 0x00000006, 0x00000004, 0x00030047, 0x000000c5, 0x00000002, 0x00050048, 0x000000c5, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x000000c5, 0x00000001, 0x00000023, 0x00000004, 0x00050048, 0x000000c5, 0x00000002, 0x00000023, 0x00000008, - 0x00040047, 0x000000c7, 0x00000021, 0x00000000, 0x00040047, 0x000000c7, 0x00000022, 0x00000007, 0x00040047, 0x000000fa, + 0x00040047, 0x000000c7, 0x00000021, 0x00000001, 0x00040047, 0x000000c7, 0x00000022, 0x00000007, 0x00040047, 0x000000fa, 0x00000006, 0x00000004, 0x00030047, 0x000000fb, 0x00000002, 0x00050048, 0x000000fb, 0x00000000, 0x00000023, 0x00000000, - 0x00040047, 0x000000fd, 0x00000021, 0x00000003, 0x00040047, 0x000000fd, 0x00000022, 0x00000007, 0x00040015, 0x00000002, + 0x00040047, 0x000000fd, 0x00000021, 0x00000004, 0x00040047, 0x000000fd, 0x00000022, 0x00000007, 0x00040015, 0x00000002, 0x00000020, 0x00000000, 0x00040017, 0x00000003, 0x00000002, 0x00000004, 0x00030016, 0x00000004, 0x00000020, 0x00040017, 0x00000005, 0x00000004, 0x00000003, 0x00020014, 0x00000006, 0x000a0021, 0x00000007, 0x00000006, 0x00000002, 0x00000003, 0x00000002, 0x00000005, 0x00000004, 0x00000005, 0x00000004, 0x00040020, 0x00000011, 0x00000007, 0x00000002, 0x0004002b, diff --git a/scripts/generators/layer_chassis_generator.py b/scripts/generators/layer_chassis_generator.py index 4252354e01d..53e9862115e 100644 --- a/scripts/generators/layer_chassis_generator.py +++ b/scripts/generators/layer_chassis_generator.py @@ -69,12 +69,7 @@ def getValidationLayerList(targetApiName: str) -> list[dict[str, str]]: { 'include': 'gpu/core/gpuav.h', 'class': 'gpuav::Validator', - 'enabled': 'enables[gpu_validation]' - }, - { - 'include': 'gpu/debug_printf/debug_printf.h', - 'class': 'debug_printf::Validator', - 'enabled': 'enables[debug_printf_validation]' + 'enabled': 'enables[gpu_validation] || enables[debug_printf_validation]' }, { 'include': 'sync/sync_validation.h', @@ -133,7 +128,6 @@ def genInitObjectDispatchVectorSource(targetApiName: str) -> str: typeid(&CoreChecks::name), \\ typeid(&BestPractices::name), \\ typeid(&gpuav::Validator::name), \\ - typeid(&debug_printf::Validator::name), \\ typeid(&SyncValidator::name)); auto init_object_dispatch_vector = [this](InterceptId id, @@ -144,7 +138,6 @@ def genInitObjectDispatchVectorSource(targetApiName: str) -> str: const std::type_info& tcv_typeid, const std::type_info& tbp_typeid, const std::type_info& tga_typeid, - const std::type_info& tdp_typeid, const std::type_info& tsv_typeid) { for (auto item : this->object_dispatch) { auto intercept_vector = &this->intercept_vectors[id]; @@ -167,9 +160,6 @@ def genInitObjectDispatchVectorSource(targetApiName: str) -> str: case LayerObjectTypeGpuAssisted: if (tga_typeid != vo_typeid) intercept_vector->push_back(item); break; - case LayerObjectTypeDebugPrintf: - if (tdp_typeid != vo_typeid) intercept_vector->push_back(item); - break; case LayerObjectTypeSyncValidation: if (tsv_typeid != vo_typeid) intercept_vector->push_back(item); break; @@ -383,7 +373,6 @@ class Pipeline; LayerObjectTypeCoreValidation, // Instance or device core validation layer object LayerObjectTypeBestPractices, // Instance or device best practices layer object LayerObjectTypeGpuAssisted, // Instance or device gpu assisted validation layer object - LayerObjectTypeDebugPrintf, // Instance or device shader debug printf layer object LayerObjectTypeSyncValidation, // Instance or device synchronization validation layer object LayerObjectTypeMaxEnum, // Max enum count }; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 97042e6e368..763db125f1d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -104,6 +104,7 @@ target_sources(vk_layer_validation_tests PRIVATE unit/gpu_av.cpp unit/gpu_av_buffer_device_address.cpp unit/gpu_av_buffer_device_address_positive.cpp + unit/gpu_av_debug_printf.cpp unit/gpu_av_descriptor_buffer_positive.cpp unit/gpu_av_descriptor_indexing.cpp unit/gpu_av_descriptor_indexing_positive.cpp diff --git a/tests/framework/layer_validation_tests.h b/tests/framework/layer_validation_tests.h index 34962ce799c..bd4b33d5ca2 100644 --- a/tests/framework/layer_validation_tests.h +++ b/tests/framework/layer_validation_tests.h @@ -256,6 +256,11 @@ class DebugPrintfTests : public VkLayerTest { void InitDebugPrintfFramework(void *p_next = nullptr, bool reserve_slot = false); }; +class GpuAVDebugPrintfTest : public virtual VkLayerTest { + public: + void InitGpuAvDebugPrintfFramework(void *p_next = nullptr); +}; + struct SyncValSettings; class VkSyncValTest : public VkLayerTest { public: diff --git a/tests/spirv/instrumentation.cpp b/tests/spirv/instrumentation.cpp index 3ffe912e72e..c16ec97ab19 100644 --- a/tests/spirv/instrumentation.cpp +++ b/tests/spirv/instrumentation.cpp @@ -19,6 +19,7 @@ static constexpr uint32_t kDefaultShaderId = 23; static constexpr uint32_t kInstDefaultDescriptorSet = 3; +static constexpr uint32_t kInstDefaultDebugPrintfBinding = 0; static bool timer = false; static bool print_debug_info = false; @@ -169,7 +170,7 @@ int main(int argc, char** argv) { module.RunPassRayQuery(); } if (all_passes || debug_printf_pass) { - module.RunPassDebugPrintf(); + module.RunPassDebugPrintf(kInstDefaultDebugPrintfBinding); } for (const auto& info : module.link_info_) { diff --git a/tests/unit/gpu_av.cpp b/tests/unit/gpu_av.cpp index 8a25c65e427..9f3f013b8fb 100644 --- a/tests/unit/gpu_av.cpp +++ b/tests/unit/gpu_av.cpp @@ -69,14 +69,6 @@ TEST_F(NegativeGpuAV, ValidationFeatures) { m_errorMonitor->SetDesiredError("VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967"); vk::CreateInstance(&ici, nullptr, &instance); m_errorMonitor->VerifyFound(); - - VkValidationFeatureEnableEXT printf_enables[] = {VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT, - VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT}; - features.pEnabledValidationFeatures = printf_enables; - features.enabledValidationFeatureCount = 2; - m_errorMonitor->SetDesiredError("VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968"); - vk::CreateInstance(&ici, nullptr, &instance); - m_errorMonitor->VerifyFound(); } TEST_F(NegativeGpuAV, SelectInstrumentedShaders) { diff --git a/tests/unit/gpu_av_debug_printf.cpp b/tests/unit/gpu_av_debug_printf.cpp new file mode 100644 index 00000000000..b8bfe93580f --- /dev/null +++ b/tests/unit/gpu_av_debug_printf.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2024 The Khronos Group Inc. + * Copyright (c) 2024 Valve Corporation + * Copyright (c) 2024 LunarG, Inc. + * Copyright (c) 2024 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + */ + +#include "../framework/layer_validation_tests.h" +#include "../framework/pipeline_helper.h" +#include "../framework/descriptor_helper.h" +#include "../framework/gpu_av_helper.h" + +class NegativeGpuAVDebugPrintf : public GpuAVDebugPrintfTest {}; + +void GpuAVDebugPrintfTest::InitGpuAvDebugPrintfFramework(void *p_next) { + SetTargetApiVersion(VK_API_VERSION_1_1); + VkValidationFeatureEnableEXT enables[] = {VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT, + VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT}; + VkValidationFeaturesEXT features = vku::InitStructHelper(); + features.enabledValidationFeatureCount = 2; + features.disabledValidationFeatureCount = 0; + features.pEnabledValidationFeatures = enables; + RETURN_IF_SKIP(InitFramework(&features)); + if (!CanEnableGpuAV(*this)) { + GTEST_SKIP() << "Requirements for GPU-AV/Printf are not met"; + } +} + +TEST_F(NegativeGpuAVDebugPrintf, Basic) { + TEST_DESCRIPTION("Both trip a GPU-AV error while calling into DebugPrintf"); + SetTargetApiVersion(VK_API_VERSION_1_2); + AddRequiredExtensions(VK_KHR_SHADER_NON_SEMANTIC_INFO_EXTENSION_NAME); + AddDisabledFeature(vkt::Feature::robustBufferAccess); + RETURN_IF_SKIP(InitGpuAvDebugPrintfFramework()); + RETURN_IF_SKIP(InitState()); + + char const *shader_source = R"glsl( + #version 450 + #extension GL_EXT_debug_printf : enable + layout(set = 0, binding = 0) buffer foo_0 { + uint a; + uint b[]; + }; + void main() { + float myfloat = 3.1415f; + debugPrintfEXT("float == %f", myfloat); + a = b[32]; // OOB + } + )glsl"; + + vkt::Buffer buffer(*m_device, 16, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); + + OneOffDescriptorSet descriptor_set_0(m_device, {{0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_ALL, nullptr}}); + const vkt::PipelineLayout pipeline_layout(*m_device, {&descriptor_set_0.layout_, &descriptor_set_0.layout_}); + descriptor_set_0.WriteDescriptorBufferInfo(0, buffer.handle(), 0, 16, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER); + descriptor_set_0.UpdateDescriptorSets(); + + CreateComputePipelineHelper pipe(*this); + pipe.cp_ci_.layout = pipeline_layout.handle(); + pipe.cs_ = std::make_unique(this, shader_source, VK_SHADER_STAGE_COMPUTE_BIT, SPV_ENV_VULKAN_1_2); + pipe.CreateComputePipeline(); + + m_command_buffer.begin(); + vk::CmdBindPipeline(m_command_buffer.handle(), VK_PIPELINE_BIND_POINT_COMPUTE, pipe.Handle()); + vk::CmdBindDescriptorSets(m_command_buffer.handle(), VK_PIPELINE_BIND_POINT_COMPUTE, pipeline_layout.handle(), 0, 1, + &descriptor_set_0.set_, 0, nullptr); + vk::CmdDispatch(m_command_buffer.handle(), 1, 1, 1); + m_command_buffer.end(); + + m_errorMonitor->SetDesiredError("VUID-vkCmdDispatch-storageBuffers-06936"); + m_errorMonitor->SetDesiredFailureMsg(kInformationBit, "float == 3.141500"); + m_default_queue->Submit(m_command_buffer); + m_default_queue->Wait(); + m_errorMonitor->VerifyFound(); +} \ No newline at end of file