Skip to content

Commit b495e81

Browse files
gpu: Fix/Improve shader error messages
1 parent b45db11 commit b495e81

16 files changed

+1137
-355
lines changed

BUILD.gn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ vvl_sources = [
191191
"layers/gpu/debug_printf/debug_printf.cpp",
192192
"layers/gpu/debug_printf/debug_printf.h",
193193
"layers/gpu/error_message/gpuav_error_message.cpp",
194-
"layers/gpu/error_message/gpuav_error_message.h",
195194
"layers/gpu/error_message/gpuav_vuids.cpp",
196195
"layers/gpu/error_message/gpuav_vuids.h",
197196
"layers/gpu/instrumentation/gpu_shader_instrumentor.cpp",

docs/gpu_validation.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,16 @@ The array of combined image samplers is `tex` and has 6 samplers in the array.
142142
The complete validation error message issued when `tex_ind` indexes past the array is:
143143

144144
```terminal
145-
ERROR : VALIDATION - Message Id Number: 0 | Message Id Name: UNASSIGNED-Image descriptor index out of bounds
146-
Index of 6 used to index descriptor array of length 6. Command buffer (CubeDrawCommandBuf)(0xbc24b0).
147-
Pipeline (0x45). Shader Module (0x43). Shader Instruction Index = 108. Stage = Fragment.
148-
Fragment coord (x,y) = (419.5, 254.5). Shader validation error occurred in file:
149-
/home/user/src/Vulkan-ValidationLayers/external/Vulkan-Tools/cube/cube.frag at line 45.
150-
45: uFragColor = light * texture(tex[tex_ind], texcoord.xy);
145+
Validation Error: [ UNASSIGNED-Image descriptor index out of bounds ] | vkCmdDrawIndexed(): Index of 6 used to index descriptor array of length 6.
146+
Stage = Fragment. Fragment coord (x,y) = (419.5, 254.5)
147+
Command buffer (CubeDrawCommandBuf)(0xbc24b0)
148+
Draw Index 2
149+
Pipeline (0x45)
150+
Shader Module (0x43)
151+
Shader Instruction Index = 108
152+
Shader validation error occurred in file Vulkan-Tools/cube/cube.frag at line 45
153+
154+
uFragColor = light * texture(tex[tex_ind], texcoord.xy);
151155
```
152156
The VK_EXT_descriptor_indexing extension allows a shader to declare a descriptor array without specifying its size
153157
```glsl

layers/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ target_sources(vvl PRIVATE
244244
gpu/debug_printf/debug_printf.cpp
245245
gpu/debug_printf/debug_printf.h
246246
gpu/error_message/gpuav_error_message.cpp
247-
gpu/error_message/gpuav_error_message.h
248247
gpu/error_message/gpuav_vuids.cpp
249248
gpu/error_message/gpuav_vuids.h
250249
gpu/instrumentation/gpu_shader_instrumentor.cpp

layers/gpu/core/gpuav.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#pragma once
1919

20-
#include "gpu/error_message/gpuav_error_message.h"
2120
#include "gpu/descriptor_validation/gpuav_descriptor_set.h"
2221
#include "gpu/resources/gpu_resources.h"
2322
#include "gpu/instrumentation/gpu_shader_instrumentor.h"

layers/gpu/debug_printf/debug_printf.cpp

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -294,24 +294,24 @@ void Validator::AnalyzeAndGenerateMessage(VkCommandBuffer command_buffer, VkQueu
294294
uint32_t index = spvtools::kDebugOutputDataOffset;
295295
while (debug_output_buffer[index]) {
296296
std::stringstream shader_message;
297-
VkShaderModule shader_module_handle = VK_NULL_HANDLE;
298-
VkPipeline pipeline_handle = VK_NULL_HANDLE;
299-
VkShaderEXT shader_object_handle = VK_NULL_HANDLE;
300-
vvl::span<const uint32_t> instrumented_spirv;
301297

302298
OutputRecord *debug_record = reinterpret_cast<OutputRecord *>(&debug_output_buffer[index]);
303299
// Lookup the VkShaderModule handle and SPIR-V code used to create the shader, using the unique shader ID value returned
304300
// by the instrumented shader.
301+
const gpu::GpuAssistedShaderTracker *tracker_info = nullptr;
305302
auto it = shader_map_.find(debug_record->shader_id);
306303
if (it != shader_map_.end()) {
307-
shader_module_handle = it->second.shader_module;
308-
pipeline_handle = it->second.pipeline;
309-
shader_object_handle = it->second.shader_object;
310-
instrumented_spirv = it->second.instrumented_spirv;
304+
tracker_info = &it->second;
311305
}
312-
ASSERT_AND_RETURN(!instrumented_spirv.empty());
306+
307+
// without the instrumented spirv, there is nothing valuable to print out
308+
if (!tracker_info || tracker_info->instrumented_spirv.empty()) {
309+
InternalWarning(queue, loc, "Can't find instructions from any handles in shader_map");
310+
return;
311+
}
312+
313313
std::vector<spirv::Instruction> instructions;
314-
spirv::GenerateInstructions(instrumented_spirv, instructions);
314+
spirv::GenerateInstructions(tracker_info->instrumented_spirv, instructions);
315315

316316
// Search through the shader source for the printf format string for this invocation
317317
const std::string format_string = FindFormatString(instructions, debug_record->format_string_id);
@@ -378,20 +378,15 @@ void Validator::AnalyzeAndGenerateMessage(VkCommandBuffer command_buffer, VkQueu
378378
}
379379

380380
if (verbose) {
381-
std::string common_message;
382-
std::string filename_message;
383-
std::string source_message;
384-
UtilGenerateCommonMessage(debug_report, command_buffer, &debug_output_buffer[index], shader_module_handle,
385-
pipeline_handle, shader_object_handle, buffer_info.pipeline_bind_point, operation_index,
386-
common_message);
387-
UtilGenerateSourceMessages(instructions, &debug_output_buffer[index], true, filename_message, source_message);
381+
std::string debug_info_message =
382+
GenerateDebugInfoMessage(command_buffer, instructions, debug_record->instruction_position, tracker_info,
383+
buffer_info.pipeline_bind_point, operation_index);
388384
if (use_stdout) {
389-
std::cout << "WARNING-DEBUG-PRINTF " << shader_message.str().c_str() << "\n"
390-
<< common_message.c_str() << " " << filename_message.c_str() << " " << source_message.c_str();
385+
std::cout << "WARNING-DEBUG-PRINTF " << shader_message.str() << "\n" << debug_info_message;
391386
} else {
392-
LogInfo("WARNING-DEBUG-PRINTF", queue, loc, "%s\n%s%s%s", shader_message.str().c_str(), common_message.c_str(),
393-
filename_message.c_str(), source_message.c_str());
387+
LogInfo("WARNING-DEBUG-PRINTF", queue, loc, "%s\n%s", shader_message.str().c_str(), debug_info_message.c_str());
394388
}
389+
395390
} else {
396391
if (use_stdout) {
397392
std::cout << shader_message.str();

layers/gpu/debug_printf/debug_printf.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#pragma once
1919

2020
#include "gpu/core/gpu_state_tracker.h"
21-
#include "gpu/error_message/gpuav_error_message.h"
2221
#include "gpu/instrumentation/gpu_shader_instrumentor.h"
2322

2423
namespace debug_printf {

0 commit comments

Comments
 (0)