@@ -372,15 +372,15 @@ bool AMDVulkanDemo::InitializeGpa()
372372 gpu_perf_api_helper_.gpa_function_table_ ->GpaRegisterLoggingCallback (gpa_log_types, gpu_perf_api_helper_.gpaLoggingCallback );
373373 if (status_register_callback != kGpaStatusOk )
374374 {
375- AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to register GPA logging callback. " );
375+ LogStatus (status_register_callback, " ERROR: Failed to register GPA logging callback" );
376376 return false ;
377377 }
378378
379379 GpaStatus status_gpa_initialize = gpu_perf_api_helper_.gpa_function_table_ ->GpaInitialize (kGpaInitializeDefaultBit );
380380
381381 if (status_gpa_initialize != kGpaStatusOk )
382382 {
383- AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to initialize GPA. " );
383+ LogStatus (status_gpa_initialize, " ERROR: Failed to initialize GPA" );
384384 return false ;
385385 }
386386
@@ -421,7 +421,6 @@ bool AMDVulkanDemo::InitializeGpa()
421421 if (kGpaStatusOk != status)
422422 {
423423 AMDVulkanDemoVkUtils::Log (" ERROR: GpaGetFuncTable failed with status %d" , status);
424- delete gpa_function_table;
425424 return false ;
426425 }
427426
@@ -440,7 +439,7 @@ bool AMDVulkanDemo::InitializeGpa()
440439 status = gpu_perf_api_helper_.gpa_function_table_ ->GpaRegisterLoggingCallback (gpa_log_types, gpu_perf_api_helper_.gpaLoggingCallback );
441440 if (status != kGpaStatusOk )
442441 {
443- AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to register GPA logging callback. " );
442+ LogStatus (status, " ERROR: Failed to register GPA logging callback" );
444443 return false ;
445444 }
446445
@@ -864,7 +863,7 @@ bool AMDVulkanDemo::InitializeVulkan()
864863
865864 if (gpa_open_context_status != kGpaStatusOk )
866865 {
867- AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to open GPA context. " );
866+ LogStatus (gpa_open_context_status, " ERROR: Failed to open GPA context" );
868867 return false ;
869868 }
870869
@@ -878,7 +877,7 @@ bool AMDVulkanDemo::InitializeVulkan()
878877 GpaStatus get_sample_types_status = gpu_perf_api_helper_.gpa_function_table_ ->GpaGetSupportedSampleTypes (gpa_context_id_, &sample_types);
879878 if (get_sample_types_status != kGpaStatusOk )
880879 {
881- AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to get supported GPA sample types. " );
880+ LogStatus (get_sample_types_status, " ERROR: Failed to get supported GPA sample types" );
882881 return false ;
883882 }
884883
@@ -887,7 +886,7 @@ bool AMDVulkanDemo::InitializeVulkan()
887886
888887 if (gpa_create_session_status != kGpaStatusOk )
889888 {
890- AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to create GPA session. " );
889+ LogStatus (gpa_create_session_status, " ERROR: Failed to create GPA session" );
891890 return false ;
892891 }
893892
@@ -914,6 +913,7 @@ bool AMDVulkanDemo::InitializeVulkan()
914913 if (gpa_status != kGpaStatusOk )
915914 {
916915 AMDVulkanDemoVkUtils::Log (" Failed to enable counter: %s" , it->c_str ());
916+ LogStatus (gpa_status);
917917 }
918918 success_enable_counter &= gpa_status == kGpaStatusOk ;
919919 }
@@ -941,7 +941,7 @@ bool AMDVulkanDemo::InitializeVulkan()
941941
942942 if (gpa_enable_all_counters_status != kGpaStatusOk )
943943 {
944- AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to enable all GPA counters. " );
944+ LogStatus (gpa_enable_all_counters_status, " ERROR: Failed to enable all GPA counters" );
945945 return false ;
946946 }
947947
@@ -950,7 +950,7 @@ bool AMDVulkanDemo::InitializeVulkan()
950950 GpaStatus gpa_get_pass_count_status = gpu_perf_api_helper_.gpa_function_table_ ->GpaGetPassCount (gpa_session_id_, &required_pass_count_);
951951 if (gpa_get_pass_count_status != kGpaStatusOk )
952952 {
953- AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to get the number of required GPA passes. " );
953+ LogStatus (gpa_get_pass_count_status, " ERROR: Failed to get the number of required GPA passes" );
954954 return false ;
955955 }
956956
@@ -965,7 +965,7 @@ bool AMDVulkanDemo::InitializeVulkan()
965965
966966 if (gpa_begin_session_status != kGpaStatusOk )
967967 {
968- AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to begin GPA session. " );
968+ LogStatus (gpa_begin_session_status, " ERROR: Failed to begin GPA session" );
969969 return false ;
970970 }
971971 }
@@ -1654,7 +1654,7 @@ bool AMDVulkanDemo::InitializeVulkan()
16541654
16551655 if (gpa_end_session_status != kGpaStatusOk )
16561656 {
1657- AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to end GPA session. " );
1657+ LogStatus (gpa_end_session_status, " ERROR: Failed to end GPA session" );
16581658 }
16591659 }
16601660
@@ -1814,9 +1814,10 @@ void AMDVulkanDemo::DrawScene()
18141814 // This example only renders one set of profiles (aka, only the number of passes needed to generate one set of results).
18151815 unsigned int profile_set = 0 ;
18161816
1817- gpu_perf_api_helper_.PrintGpaSampleResults (gpa_context_id_, gpa_session_id_, profile_set, AMDVulkanDemo::kGpaSampleIdCube , print_debug_output_, Verify (), ConfirmSuccess ());
1818- gpu_perf_api_helper_.PrintGpaSampleResults (gpa_context_id_, gpa_session_id_, profile_set, AMDVulkanDemo::kGpaSampleIdWireframe , print_debug_output_, Verify (), ConfirmSuccess ());
1819- gpu_perf_api_helper_.PrintGpaSampleResults (gpa_context_id_, gpa_session_id_, profile_set, AMDVulkanDemo::kGpaSampleIdCubeAndWireframe , print_debug_output_, Verify (), ConfirmSuccess ());
1817+ // NOTE: we can't loop over these because it is not guaranteed that the sample_ids will be 0-based and monotonically increasing.
1818+ gpu_perf_api_helper_.PrintGpaSampleResults (gpa_context_id_, gpa_session_id_, profile_set, 0 , print_debug_output_, Verify (), ConfirmSuccess ());
1819+ gpu_perf_api_helper_.PrintGpaSampleResults (gpa_context_id_, gpa_session_id_, profile_set, 1 , print_debug_output_, Verify (), ConfirmSuccess ());
1820+ gpu_perf_api_helper_.PrintGpaSampleResults (gpa_context_id_, gpa_session_id_, profile_set, 2 , print_debug_output_, Verify (), ConfirmSuccess ());
18201821
18211822 // Close the CSV file so that it actually gets saved out.
18221823 gpu_perf_api_helper_.CloseCSVFile ();
@@ -1842,7 +1843,7 @@ void AMDVulkanDemo::Destroy()
18421843
18431844 if (gpa_delete_session_status != kGpaStatusOk )
18441845 {
1845- AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to delete GPA session. " );
1846+ LogStatus (gpa_delete_session_status, " ERROR: Failed to delete GPA session" );
18461847 }
18471848 }
18481849
@@ -1852,7 +1853,7 @@ void AMDVulkanDemo::Destroy()
18521853
18531854 if (gpa_close_context_status != kGpaStatusOk )
18541855 {
1855- AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to close GPA Context. " );
1856+ LogStatus (gpa_close_context_status, " ERROR: Failed to close GPA Context" );
18561857 }
18571858 }
18581859 }
@@ -2358,6 +2359,19 @@ void AMDVulkanDemo::PreBuildCommandBuffers(PrebuiltPerFrameResources* prebuilt_r
23582359 }
23592360}
23602361
2362+ void AMDVulkanDemo::LogStatus (GpaStatus status, const char * msg)
2363+ {
2364+ auto status_as_str = gpu_perf_api_helper_.gpa_function_table_ ->GpaGetStatusAsStr (status);
2365+ if (msg != nullptr )
2366+ {
2367+ AMDVulkanDemoVkUtils::Log (" %s. %s" , msg, status_as_str);
2368+ }
2369+ else
2370+ {
2371+ AMDVulkanDemoVkUtils::Log (" %s" , status_as_str);
2372+ }
2373+ }
2374+
23612375#if defined(VK_USE_PLATFORM_WIN32_KHR)
23622376
23632377// / Window message processing callback.
0 commit comments