6
6
// ==============================================================================
7
7
8
8
#include " examples/vulkan/vk_color_cube/gpa_helper.h"
9
+ #include " examples/vulkan/vk_color_cube/vk_util.h"
9
10
10
11
#include < assert.h>
11
12
@@ -80,29 +81,29 @@ void GpaHelper::PrintGPACounterInfo(GpaContextId context_id) const
80
81
81
82
if (kGpaStatusOk != gpa_status)
82
83
{
83
- std::cout << " ERROR: Failed to get device and revision id.\n " ;
84
+ AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to get device and revision id." ) ;
84
85
return ;
85
86
}
86
87
87
88
gpa_status = gpa_function_table_->GpaGetDeviceName (context_id, &device_name_ptr);
88
89
89
90
if (kGpaStatusOk != gpa_status)
90
91
{
91
- std::cout << " ERROR: Failed to get the device name.\n " ;
92
+ AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to get the device name." ) ;
92
93
return ;
93
94
}
94
95
std::string device_name_string (device_name_ptr);
95
96
96
- std::cout << " Device Id: " << std::showbase << std::hex << device_id << std::endl ;
97
- std::cout << " Revision Id: " << FormatRevisionId (revision_id) << std::endl ;
98
- std::cout << " Device Name: " << device_name_string.c_str () << std::endl ;
97
+ AMDVulkanDemoVkUtils::Log ( " Device Id: 0x%04X " , device_id) ;
98
+ AMDVulkanDemoVkUtils::Log ( " Revision Id: %s " , FormatRevisionId (revision_id). c_str ()) ;
99
+ AMDVulkanDemoVkUtils::Log ( " Device Name: %s " , device_name_string.c_str ()) ;
99
100
100
101
GpaUInt32 num_counters = 0 ;
101
102
gpa_status = gpa_function_table_->GpaGetNumCounters (context_id, &num_counters);
102
103
103
104
if (kGpaStatusOk != gpa_status)
104
105
{
105
- std::cout << " ERROR: Failed to get the number of available counters." << std::endl ;
106
+ AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to get the number of available counters." ) ;
106
107
return ;
107
108
}
108
109
@@ -119,11 +120,11 @@ void GpaHelper::PrintGPACounterInfo(GpaContextId context_id) const
119
120
120
121
if (kGpaStatusOk == name_status && kGpaStatusOk == group_status && kGpaStatusOk == description_status)
121
122
{
122
- std::cout << counter_index << " : " << name << " \" " << group << " \" - " << description << std::endl ;
123
+ AMDVulkanDemoVkUtils::Log ( " %d: %s \" %s \" - %s " , counter_index, name, group, description) ;
123
124
}
124
125
else
125
126
{
126
- std::cout << " ERROR: Failed to get counter name, group, or description." << std::endl ;
127
+ AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to get counter name, group, or description." ) ;
127
128
}
128
129
}
129
130
}
@@ -233,6 +234,11 @@ void GpaHelper::gpaLoggingCallback(GpaLoggingType type, const char* msg)
233
234
}
234
235
235
236
gpa_log_file_stream << log_message << std::endl;
237
+
238
+ #ifdef ANDROID
239
+ // Write the message to logcat
240
+ AMDVulkanDemoVkUtils::Log (" %s" , log_message.c_str ());
241
+ #endif
236
242
}
237
243
238
244
bool GpaHelper::CounterValueCompare (unsigned int profile_set,
@@ -655,36 +661,35 @@ void GpaHelper::PrintGpaSampleResults(GpaContextId context_id,
655
661
656
662
if (kGpaStatusOk != gpa_status)
657
663
{
658
- std::cout << " ERROR: Failed to get device and revision id.\n " ;
664
+ AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to get device and revision id." ) ;
659
665
return ;
660
666
}
661
667
662
668
gpa_status = gpa_function_table_->GpaGetDeviceName (context_id, &device_name_ptr);
663
669
664
670
if (kGpaStatusOk != gpa_status)
665
671
{
666
- std::cout << " ERROR: Failed to get the device name.\n " ;
672
+ AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to get the device name." ) ;
667
673
return ;
668
674
}
669
675
670
676
GpaHwGeneration hardware_generation = kGpaHwGenerationNone ;
671
677
gpa_status = gpa_function_table_->GpaGetDeviceGeneration (context_id, &hardware_generation);
672
678
if (kGpaStatusOk != gpa_status)
673
679
{
674
- std::cout << " ERROR: Failed to get the device generation.\n " ;
680
+ AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to get the device generation." ) ;
675
681
return ;
676
682
}
677
683
678
684
std::string device_name_string (device_name_ptr);
679
685
680
686
if (output_to_console)
681
687
{
682
- std::cout << " --------------------------------------------------" << std::endl;
683
- std::cout << " Device Id: " << std::showbase << std::hex << device_id << std::endl;
684
- std::cout << " Revision Id: " << FormatRevisionId (revision_id) << std::endl;
685
- std::cout << " Device Name: " << device_name_string.c_str () << std::endl;
686
- std::cout << " --------------------------------------------------" << std::endl;
687
- std::cout << " Profile " << profile_set << " , Sample ID: " << sample_id << std::endl;
688
+ AMDVulkanDemoVkUtils::Log (" Device Id: 0x%04X" , device_id);
689
+ AMDVulkanDemoVkUtils::Log (" Revision Id: %s" , FormatRevisionId (revision_id).c_str ());
690
+ AMDVulkanDemoVkUtils::Log (" Device Name: %s" , device_name_string.c_str ());
691
+ AMDVulkanDemoVkUtils::Log (" --------------------------------------------------" );
692
+ AMDVulkanDemoVkUtils::Log (" Profile %d, Sample ID: %d" , profile_set, sample_id);
688
693
}
689
694
690
695
std::stringstream csv_header;
@@ -698,23 +703,23 @@ void GpaHelper::PrintGpaSampleResults(GpaContextId context_id,
698
703
699
704
if (kGpaStatusOk != gpa_status)
700
705
{
701
- std::cout << " ERROR: Failed to get GPA sample result size." << std::endl ;
706
+ AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to get GPA sample result size." ) ;
702
707
return ;
703
708
}
704
709
705
710
GpaUInt64* results_buffer = (GpaUInt64*)malloc (sample_result_size_in_bytes);
706
711
707
712
if (results_buffer == nullptr )
708
713
{
709
- std::cout << " ERROR: Failed to allocate memory for GPA results." << std::endl ;
714
+ AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to allocate memory for GPA results." ) ;
710
715
return ;
711
716
}
712
717
713
718
gpa_status = gpa_function_table_->GpaGetSampleResult (session_id, sample_id, sample_result_size_in_bytes, results_buffer);
714
719
715
720
if (kGpaStatusOk != gpa_status)
716
721
{
717
- std::cout << " ERROR: Failed to get GPA sample results." << std::endl ;
722
+ AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to get GPA sample results." ) ;
718
723
}
719
724
else
720
725
{
@@ -723,7 +728,7 @@ void GpaHelper::PrintGpaSampleResults(GpaContextId context_id,
723
728
724
729
if (kGpaStatusOk != gpa_status)
725
730
{
726
- std::cout << " ERROR: Failed to get the number of enabled counters from GPA." << std::endl ;
731
+ AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to get the number of enabled counters from GPA." ) ;
727
732
}
728
733
else
729
734
{
@@ -740,7 +745,7 @@ void GpaHelper::PrintGpaSampleResults(GpaContextId context_id,
740
745
741
746
if (kGpaStatusOk != gpa_status)
742
747
{
743
- std::cout << " ERROR: Failed to get the exposed GPA counter id of the enabled counter at index " << counter_index << " . " << std::endl ;
748
+ AMDVulkanDemoVkUtils::Log ( " ERROR: Failed to get the exposed GPA counter id of the enabled counter at index %d " , counter_index) ;
744
749
}
745
750
else
746
751
{
0 commit comments