Skip to content

Commit 513ef99

Browse files
committed
The VkColorCube app doesn't log failure status
The failure status code being returned via the GPA calls aren't being logged by the VkColorCube app. It does log that what it's trying to do failed, but not why it failed (according to the GPA implementation). In my case a C++ exception was being thrown and that fact was just not surfaced at all. Also changed the textual string for kGpaStatusErrorException to mention it's specifically a C++ exception, as otherwise the word "exception" is generic/vague and could be interepreted as such.
1 parent fa13e2a commit 513ef99

File tree

3 files changed

+52
-28
lines changed

3 files changed

+52
-28
lines changed

source/examples/vulkan/vk_color_cube/vk_color_cube.cc

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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.

source/examples/vulkan/vk_color_cube/vk_color_cube.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,6 @@ class AMDVulkanDemo : public gpa_example::GpaSampleApp
142142
/// Default window height.
143143
const uint32_t kDefaultWindowHeight = 300;
144144

145-
/// Note that GPA sample IDs are client defined. However, the Vulkan GPA
146-
/// extension assigns an ID to each sample (they are not client defined).
147-
/// The GPA library manages the mapping between them. These are the former.
148-
static constexpr GpaUInt32 kGpaSampleIdCube = 0;
149-
static constexpr GpaUInt32 kGpaSampleIdWireframe = 1;
150-
static constexpr GpaUInt32 kGpaSampleIdCubeAndWireframe = 2;
151-
152145
#ifdef ANDROID
153146
inline void SetWindow(ANativeWindow* native_window)
154147
{
@@ -249,7 +242,7 @@ class AMDVulkanDemo : public gpa_example::GpaSampleApp
249242

250243
/// Sample Id that the application (not GPA) assigns to the cube.
251244
/// The cube will have this same sample_id in all passes.
252-
const GpaUInt32 gpa_sample_id = kGpaSampleIdCube;
245+
const GpaUInt32 gpa_sample_id = 0;
253246
} cube_;
254247

255248
/// @brief Container for objects related to drawing the wireframe.
@@ -263,7 +256,7 @@ class AMDVulkanDemo : public gpa_example::GpaSampleApp
263256

264257
/// Sample Id that the application (not GPA) assigns to the wireframe.
265258
/// The wireframe will have this same sample_id in all passes.
266-
const GpaUInt32 gpa_sample_id = kGpaSampleIdWireframe;
259+
const GpaUInt32 gpa_sample_id = 1;
267260
} wire_frame_;
268261

269262
/// @brief Container for objects related to drawing the cube and wireframe.
@@ -286,7 +279,7 @@ class AMDVulkanDemo : public gpa_example::GpaSampleApp
286279

287280
/// Sample Id that the application (not GPA) assigns to the cube wireframe.
288281
/// The combined cube + wireframe sample will have this same sample_id in all passes.
289-
const GpaUInt32 gpa_sample_id = kGpaSampleIdCubeAndWireframe;
282+
const GpaUInt32 gpa_sample_id = 2;
290283
} cube_and_wire_frame_;
291284
};
292285

@@ -394,6 +387,12 @@ class AMDVulkanDemo : public gpa_example::GpaSampleApp
394387
/// @param [in] gpa_pass_index If GPA is enabled for these command buffers, this indicates which profile pass is being built; ignored if enable_gpa is false.
395388
void PreBuildCommandBuffers(PrebuiltPerFrameResources* prebuilt_resources, VkFramebuffer frame_buffer, bool enable_gpa, uint32_t gpa_pass_index);
396389

390+
/// @brief Log the textual representation of a failure status code
391+
///
392+
/// @param [in] status the failure code
393+
/// @param [in] msg optional additional context. Should not contain trailing punctuation.
394+
void LogStatus(GpaStatus status, const char* msg=nullptr);
395+
397396
/// GPA helper.
398397
GpaHelper gpu_perf_api_helper_;
399398

source/gpu_perf_api_common/gpu_perf_api.cc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ extern IGpaImplementor* gpa_imp; ///< GPA implementor instance.
4747
} \
4848
if (index >= num_counters) \
4949
{ \
50-
GPA_LOG_ERROR("Parameter %s is %d but must be less than %d.", #index, index, num_counters); \
50+
GPA_LOG_ERROR("Parameter index is %d but must be less than %d.", index, num_counters); \
5151
return kGpaStatusErrorIndexOutOfRange; \
5252
}
5353

@@ -493,6 +493,15 @@ GPA_LIB_DECL GpaStatus GpaGetDeviceGeneration(GpaContextId gpa_context_id, GpaHw
493493
case GDT_HW_GENERATION_GFX11:
494494
*hardware_generation = kGpaHwGenerationGfx11;
495495
break;
496+
case GDT_HW_GENERATION_GFX104:
497+
*hardware_generation = kGpaHwGenerationGfx104;
498+
break;
499+
case GDT_HW_GENERATION_GFX401:
500+
*hardware_generation = kGpaHwGenerationGfx401;
501+
break;
502+
case GDT_HW_GENERATION_GFX402:
503+
*hardware_generation = kGpaHwGenerationGfx402;
504+
break;
496505
case GDT_HW_GENERATION_LAST:
497506
*hardware_generation = kGpaHwGenerationLast;
498507
break;
@@ -847,6 +856,8 @@ GPA_LIB_DECL GpaStatus GpaDeleteSession(GpaSessionId gpa_session_id)
847856

848857
GPA_LIB_DECL GpaStatus GpaBeginSession(GpaSessionId gpa_session_id)
849858
{
859+
GPA_LOG_ERROR("jjjjjjjjjjjjj GpaBeginSession");
860+
850861
try
851862
{
852863
PROFILE_FUNCTION(GpaBeginSession);
@@ -1657,7 +1668,7 @@ static const char* kErrorString[] = {
16571668
GPA_ENUM_STRING_VAL(kGpaStatusErrorTimeout, "GPA Error: Attempt to Retrieve Data Failed due to Timeout."),
16581669
GPA_ENUM_STRING_VAL(kGpaStatusErrorLibAlreadyLoaded, "GPA Error: Library Is Already Loaded."),
16591670
GPA_ENUM_STRING_VAL(kGpaStatusErrorOtherSessionActive, "GPA Error: Other Session Is Active."),
1660-
GPA_ENUM_STRING_VAL(kGpaStatusErrorException, "GPA Error: Exception Occurred.")};
1671+
GPA_ENUM_STRING_VAL(kGpaStatusErrorException, "GPA Error: C++ Exception Occurred.")};
16611672

16621673
/// Size of kErrorString array.
16631674
static size_t kErrorStringSize = sizeof(kErrorString) / sizeof(const char*);

0 commit comments

Comments
 (0)