Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ vvl_sources = [
"layers/gpuav/core/gpuav_validation_pipeline.cpp",
"layers/gpuav/debug_printf/debug_printf.cpp",
"layers/gpuav/debug_printf/debug_printf.h",
"layers/gpuav/debug_descriptor/debug_descriptor.cpp",
"layers/gpuav/debug_descriptor/debug_descriptor.h",
"layers/gpuav/descriptor_validation/gpuav_descriptor_set.cpp",
"layers/gpuav/descriptor_validation/gpuav_descriptor_set.h",
"layers/gpuav/descriptor_validation/gpuav_descriptor_validation.cpp",
Expand Down Expand Up @@ -263,6 +265,8 @@ vvl_sources = [
"layers/gpuav/spirv/sanitizer_pass.h",
"layers/gpuav/spirv/shared_memory_data_race_pass.h",
"layers/gpuav/spirv/shared_memory_data_race_pass.cpp",
"layers/gpuav/spirv/debug_descriptor_pass.cpp",
"layers/gpuav/spirv/debug_descriptor_pass.h",
"layers/gpuav/spirv/debug_printf_pass.cpp",
"layers/gpuav/spirv/debug_printf_pass.h",
"layers/gpuav/spirv/type_manager.cpp",
Expand Down
2 changes: 2 additions & 0 deletions layers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ target_sources(vvl PRIVATE
gpuav/descriptor_validation/gpuav_descriptor_set.h
gpuav/debug_printf/debug_printf.cpp
gpuav/debug_printf/debug_printf.h
gpuav/debug_descriptor/debug_descriptor.cpp
gpuav/debug_descriptor/debug_descriptor.h
gpuav/instrumentation/gpuav_shader_instrumentor.cpp
gpuav/instrumentation/gpuav_shader_instrumentor.h
gpuav/instrumentation/gpuav_instrumentation.h
Expand Down
80 changes: 80 additions & 0 deletions layers/VkLayer_khronos_validation.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
{ "key": "thread_safety", "value": false },
{ "key": "validate_sync", "value": false },
{ "key": "printf_enable", "value": false },
{ "key": "debug_descriptor", "value": false },
{ "key": "gpuav_enable", "value": false },
{ "key": "validate_best_practices", "value": false },
{ "key": "report_flags", "value": [ "error", "warn" ] },
Expand Down Expand Up @@ -113,6 +114,7 @@
{ "key": "thread_safety", "value": false },
{ "key": "validate_sync", "value": false },
{ "key": "printf_enable", "value": false },
{ "key": "debug_descriptor", "value": false },
{ "key": "gpuav_enable", "value": false },
{ "key": "validate_best_practices", "value": false },
{ "key": "report_flags", "value": [ "error" ] },
Expand Down Expand Up @@ -140,6 +142,7 @@
{ "key": "thread_safety", "value": false },
{ "key": "validate_sync", "value": false },
{ "key": "printf_enable", "value": false },
{ "key": "debug_descriptor", "value": false },
{ "key": "gpuav_enable", "value": false },
{ "key": "validate_best_practices", "value": true },
{ "key": "report_flags", "value": [ "error", "warn", "perf" ] },
Expand Down Expand Up @@ -167,6 +170,7 @@
{ "key": "thread_safety", "value": true },
{ "key": "validate_sync", "value": true },
{ "key": "printf_enable", "value": false },
{ "key": "debug_descriptor", "value": false },
{ "key": "gpuav_enable", "value": false },
{ "key": "validate_best_practices", "value": false },
{ "key": "report_flags", "value": [ "error" ] },
Expand Down Expand Up @@ -194,6 +198,7 @@
{ "key": "thread_safety", "value": false },
{ "key": "validate_sync", "value": false },
{ "key": "printf_enable", "value": false },
{ "key": "debug_descriptor", "value": false },
{ "key": "gpuav_enable", "value": true },
{ "key": "gpuav_shader_instrumentation", "value": true },
{ "key": "gpuav_select_instrumented_shaders", "value": false },
Expand Down Expand Up @@ -225,6 +230,7 @@
{ "key": "validate_sync", "value": false },
{ "key": "gpuav_enable", "value": false },
{ "key": "printf_enable", "value": true },
{ "key": "debug_descriptor", "value": false },
{ "key": "validate_best_practices", "value": false },
{ "key": "report_flags", "value": [ "error", "warn", "info" ] },
{ "key": "debug_action", "value": [] },
Expand Down Expand Up @@ -252,6 +258,7 @@
{ "key": "validate_sync", "value": false },
{ "key": "gpuav_enable", "value": false },
{ "key": "printf_enable", "value": false },
{ "key": "debug_descriptor", "value": false },
{ "key": "validate_best_practices", "value": false },
{ "key": "report_flags", "value": [ "warn" ] },
{ "key": "debug_action", "value": [ "VK_DBG_LAYER_ACTION_LOG_MSG", "VK_DBG_LAYER_ACTION_DEBUG_OUTPUT" ] },
Expand Down Expand Up @@ -631,6 +638,79 @@
}
]
},
{
"key": "debug_descriptor",
"label": "Debug Descriptor",
"description": "[Used for VK_EXT_descriptor_buffer and VK_EXT_descriptor_heap] Enable DebugDescriptor and will print anything that uses NonSemantic.DebugDescriptor in their SPIR-V",
"view": "DEBUG",
"type": "BOOL",
"default": false,
"platforms": [ "WINDOWS", "LINUX" ],
"settings": [
{
"key": "debug_descriptor_to_stdout",
"label": "Redirect DebugDescriptor messages to stdout",
"description": "Enable redirection of Debug Descriptor messages from the debug callback to stdout",
"view": "DEBUG",
"type": "BOOL",
"default": true,
"dependence": {
"mode": "ALL",
"settings": [
{ "key": "debug_descriptor", "value": true }
]
},
"messages": [
{
"key": "debug_descriptor_msg3",
"title": "Debug Descriptor without 'info' level message severity flag",
"version": 1,
"description": "Enabling Debug Descriptor output redirection to the debug callback, but 'info' level message severity is disabled, so messages won't be shown.",
"informative": "Adding 'info' level to 'Message Severity'",
"severity": "INFORMATION",
"conditions": [
{ "setting": { "key": "debug_descriptor", "value": true }},
{ "setting": { "key": "debug_descriptor_to_stdout", "value": false }},
{ "setting": { "key": "report_flags", "value": ["info"]}, "operator": "NOT" }
],
"actions": {
"default": "BUTTON0",
"BUTTON0": {
"type": "OK",
"changes": [
{ "setting": { "key": "report_flags", "value": ["info"]}, "operator": "APPEND" }
]
}
}
}
]
}
],
"messages": [
{
"key": "debug_descriptor_msg1",
"title": "Warning: Debug Descriptor without info level message severity flag",
"version": 1,
"description": "Enabling Debug Descriptor, with output directed to the debug callback, but info level message severity is disabled, so messages won't be shown.",
"informative": "Adding 'info' level to 'Message Severity'",
"severity": "INFORMATION",
"conditions": [
{ "setting": { "key": "debug_descriptor", "value": true }},
{ "setting": { "key": "debug_descriptor_to_stdout", "value": false }},
{ "setting": { "key": "report_flags", "value": ["info"]}, "operator": "NOT" }
],
"actions": {
"default": "BUTTON0",
"BUTTON0": {
"type": "OK",
"changes": [
{ "setting": { "key": "report_flags", "value": ["info"] }, "operator": "APPEND" }
]
}
}
}
]
},
{
"key": "gpuav_enable",
"label": "GPU Assisted Validation",
Expand Down
5 changes: 3 additions & 2 deletions layers/gpuav/core/gpuav_features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,11 @@ void Instance::AddFeatures(VkPhysicalDevice physical_device, vku::safe_VkDeviceC
}
}

if (gpuav_settings.debug_printf_enabled) {
if (gpuav_settings.debug_printf_enabled || gpuav_settings.debug_descriptor_enabled) {
if (!IsExtensionAvailable(VK_KHR_SHADER_NON_SEMANTIC_INFO_EXTENSION_NAME, available_extensions)) {
adjustment_warnings +=
"\tVK_KHR_shader_non_semantic_info is not available on selected device, Debug Printf may produce SPIR-V "
"\tVK_KHR_shader_non_semantic_info is not available on selected device, DebugPrintf/DebugDescriptor may produce "
"SPIR-V "
"that could fail to compile the shader\n";
} else {
vku::AddExtension(*modified_create_info, VK_KHR_SHADER_NON_SEMANTIC_INFO_EXTENSION_NAME);
Expand Down
2 changes: 2 additions & 0 deletions layers/gpuav/core/gpuav_record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "chassis/chassis_modification_state.h"
#include "gpuav/core/gpuav.h"
#include "gpuav/core/gpuav_constants.h"
#include "gpuav/debug_descriptor/debug_descriptor.h"
#include "gpuav/debug_printf/debug_printf.h"
#include "gpuav/descriptor_validation/gpuav_descriptor_validation.h"
#include "gpuav/instrumentation/descriptor_checks.h"
Expand Down Expand Up @@ -168,6 +169,7 @@ void Validator::PreCallRecordBeginCommandBuffer(VkCommandBuffer commandBuffer, c
RegisterSharedMemoryDataRaceValidation(*this, gpuav_cb_state);
RegisterSanitizer(*this, gpuav_cb_state);
debug_printf::RegisterDebugPrintf(*this, gpuav_cb_state);
debug_descriptor::RegisterDebugDescriptor(*this, gpuav_cb_state);
}

// Dedicated warning VUID that likely can be ignored.
Expand Down
6 changes: 5 additions & 1 deletion layers/gpuav/core/gpuav_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ bool GpuAVSettings::IsShaderInstrumentationEnabled() const {
shader_instrumentation.post_process_descriptor_indexing || shader_instrumentation.vertex_attribute_fetch_oob ||
shader_instrumentation.sanitizer || shader_instrumentation.shared_memory_data_race;
}
bool GpuAVSettings::IsSpirvModified() const { return IsShaderInstrumentationEnabled() || debug_printf_enabled; }
bool GpuAVSettings::IsSpirvModified() const {
return IsShaderInstrumentationEnabled() || debug_printf_enabled || debug_descriptor_enabled;
}

// Also disables shader caching and select shader instrumentation
void GpuAVSettings::DisableShaderInstrumentationAndOptions() {
Expand Down Expand Up @@ -137,6 +139,8 @@ void GpuAVSettings::TracyLogSettings() const {
VVL_TRACY_PRINT_GPUAV_SETTING(debug_printf_to_stdout);
VVL_TRACY_PRINT_GPUAV_SETTING(debug_printf_verbose);
VVL_TRACY_PRINT_GPUAV_SETTING(debug_printf_buffer_size);
VVL_TRACY_PRINT_GPUAV_SETTING(debug_descriptor_enabled);
VVL_TRACY_PRINT_GPUAV_SETTING(debug_descriptor_to_stdout);
Comment thread
spencer-lunarg marked this conversation as resolved.
#undef VVL_TRACY_PRINT_GPUAV_SETTING
#undef VVL_TRACY_PRINT_INSTRUMENTATION_SETTING
#endif
Expand Down
3 changes: 3 additions & 0 deletions layers/gpuav/core/gpuav_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,8 @@ struct GpuAVSettings {
bool debug_printf_verbose = false;
uint32_t debug_printf_buffer_size = 1024;

bool debug_descriptor_enabled = false;
bool debug_descriptor_to_stdout = false;

void TracyLogSettings() const;
};
10 changes: 10 additions & 0 deletions layers/gpuav/core/gpuav_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ void Validator::FinishDeviceSetup(const VkDeviceCreateInfo* pCreateInfo, const L
{glsl::kBindingInstCmdErrorsCount, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_ALL, nullptr},
// Vertex attribute fetch limits
{glsl::kBindingInstVertexAttributeFetchLimits, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT, nullptr},
// DebugDescriptor Output buffer
{glsl::kBindingInstDebugDescriptor, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_ALL, nullptr},
};
assert(instrumentation_bindings_.size() == glsl::kTotalBindings);

Expand Down Expand Up @@ -470,6 +472,14 @@ void Validator::InitSettings(const Location& loc) {
gpuav_settings.DisableShaderInstrumentationAndOptions();
}

if (gpuav_settings.debug_descriptor_enabled && !IsExtEnabled(extensions.vk_ext_descriptor_buffer) &&
!IsExtEnabled(extensions.vk_ext_descriptor_heap)) {
AdjustmentWarning(device, loc,
"VK_EXT_descriptor_buffer and VK_EXT_descriptor_heap were both not enabled, there is no need/reason to "
"use DebugDescriptor. [Disabling debug_descriptor_enabled]");
gpuav_settings.debug_descriptor_enabled = false;
}

// If we have turned off all the possible things to instrument, turn off everything fully
if (!gpuav_settings.IsShaderInstrumentationEnabled()) {
gpuav_settings.DisableShaderInstrumentationAndOptions();
Expand Down
36 changes: 36 additions & 0 deletions layers/gpuav/debug_descriptor/debug_descriptor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* Copyright (c) 2020-2026 The Khronos Group Inc.
* Copyright (c) 2020-2026 Valve Corporation
* Copyright (c) 2020-2026 LunarG, 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <vulkan/vulkan.h>
#include "gpuav/debug_descriptor/debug_descriptor.h"
#include "gpuav/resources/gpuav_state_trackers.h"
#include "gpuav/core/gpuav.h"

namespace gpuav {
namespace debug_descriptor {

void RegisterDebugDescriptor(Validator& gpuav, CommandBufferSubState& cb_state) {
if (!gpuav.gpuav_settings.debug_descriptor_enabled) {
return;
}

// TODO
printf("WORKING\n");
}

} // namespace debug_descriptor
} // namespace gpuav
28 changes: 28 additions & 0 deletions layers/gpuav/debug_descriptor/debug_descriptor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* Copyright (c) 2026 The Khronos Group Inc.
* Copyright (c) 2026 Valve Corporation
* Copyright (c) 2026 LunarG, 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

namespace gpuav {
class CommandBufferSubState;
class Validator;

namespace debug_descriptor {
void RegisterDebugDescriptor(Validator& gpuav, CommandBufferSubState& cb_state);
} // namespace debug_descriptor

} // namespace gpuav
8 changes: 8 additions & 0 deletions layers/gpuav/instrumentation/gpuav_shader_instrumentor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "gpuav/spirv/shared_memory_data_race_pass.h"
#include "gpuav/spirv/mesh_shading_pass.h"
#include "gpuav/spirv/debug_printf_pass.h"
#include "gpuav/spirv/debug_descriptor_pass.h"
#include "gpuav/spirv/post_process_descriptor_indexing_pass.h"
#include "gpuav/spirv/vertex_attribute_fetch_oob_pass.h"
#include "gpuav/spirv/sanitizer_pass.h"
Expand Down Expand Up @@ -1711,6 +1712,13 @@ bool GpuShaderInstrumentor::InstrumentShader(const vvl::span<const uint32_t>& in
modified |= log_error_pass.Run();
}

// Currently we don't link anything in this pass, could move after linking if desired
// If we do decide to link things, we need to add ABOVE the LogErrorPass
if (gpuav_settings.debug_descriptor_enabled) {
spirv::DebugDescriptorPass pass(module, glsl::kBindingInstDebugDescriptor);
modified |= pass.Run();
}

// If there were GLSL written function injected, we will grab them and link them in here
for (const auto& info : module.link_infos_) {
module.LinkFunctions(info);
Expand Down
3 changes: 2 additions & 1 deletion layers/gpuav/shaders/gpuav_shaders_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ const int kBindingInstActionIndex = 5;
const int kBindingInstCmdResourceIndex = 6;
const int kBindingInstCmdErrorsCount = 7;
const int kBindingInstVertexAttributeFetchLimits = 8;
const int kTotalBindings = 9;
const int kBindingInstDebugDescriptor = 9;
const int kTotalBindings = 10;

// Validation pipelines
// ---
Expand Down
2 changes: 2 additions & 0 deletions layers/gpuav/spirv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ target_sources(gpu_av_spirv PRIVATE
sanitizer_pass.cpp
shared_memory_data_race_pass.h
shared_memory_data_race_pass.cpp
debug_descriptor_pass.h
debug_descriptor_pass.cpp
debug_printf_pass.h
debug_printf_pass.cpp
post_process_descriptor_indexing_pass.h
Expand Down
Loading
Loading