@@ -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 ();
0 commit comments