ac: add helper ac_get_ip_type_string to remove duplication

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28607>
This commit is contained in:
Marek Olšák 2024-03-17 15:11:56 -04:00
parent 8597870dcb
commit 7de43c4fb8
5 changed files with 40 additions and 32 deletions

View File

@ -1754,22 +1754,10 @@ void ac_print_gpu_info(const struct radeon_info *info, FILE *f)
fprintf(f, " pcie_bandwidth = %1.1f GB/s\n", info->pcie_bandwidth_mbps / 1024.0);
fprintf(f, " clock_crystal_freq = %i KHz\n", info->clock_crystal_freq);
const char *ip_string[AMD_NUM_IP_TYPES] = {
[AMD_IP_GFX] = "GFX",
[AMD_IP_COMPUTE] = "COMP",
[AMD_IP_SDMA] = "SDMA",
[AMD_IP_UVD] = "UVD",
[AMD_IP_VCE] = "VCE",
[AMD_IP_UVD_ENC] = "UVD_ENC",
[AMD_IP_VCN_DEC] = "VCN_DEC",
[AMD_IP_VCN_ENC] = (info->vcn_ip_version >= VCN_4_0_0) ? "VCN" : "VCN_ENC",
[AMD_IP_VCN_JPEG] = "VCN_JPG",
[AMD_IP_VPE] = "VPE",
};
for (unsigned i = 0; i < AMD_NUM_IP_TYPES; i++) {
if (info->ip[i].num_queues) {
fprintf(f, " IP %-7s %2u.%u \tqueues:%u \talign:%u \tpad_dw:0x%x\n", ip_string[i],
fprintf(f, " IP %-7s %2u.%u \tqueues:%u \talign:%u \tpad_dw:0x%x\n",
ac_get_ip_type_string(info, i),
info->ip[i].ver_major, info->ip[i].ver_minor, info->ip[i].num_queues,
info->ip[i].ib_alignment, info->ip[i].ib_pad_dw_mask);
}
@ -1933,7 +1921,7 @@ void ac_print_gpu_info(const struct radeon_info *info, FILE *f)
fprintf(f, " has_tmz_support = %u\n", info->has_tmz_support);
for (unsigned i = 0; i < AMD_NUM_IP_TYPES; i++) {
if (info->max_submitted_ibs[i]) {
fprintf(f, " IP %-7s max_submitted_ibs = %u\n", ip_string[i],
fprintf(f, " IP %-7s max_submitted_ibs = %u\n", ac_get_ip_type_string(info, i),
info->max_submitted_ibs[i]);
}
}

View File

@ -973,20 +973,6 @@ void ac_parse_ib_chunk(struct ac_ib_parser *ib)
}
}
static const char *ip_name(const enum amd_ip_type ip)
{
switch (ip) {
case AMD_IP_GFX:
return "GFX";
case AMD_IP_COMPUTE:
return "COMPUTE";
case AMD_IP_SDMA:
return "SDMA";
default:
return "Unknown";
}
}
/**
* Parse and print an IB into a file.
*
@ -1005,9 +991,11 @@ static const char *ip_name(const enum amd_ip_type ip)
*/
void ac_parse_ib(struct ac_ib_parser *ib, const char *name)
{
fprintf(ib->f, "------------------ %s begin - %s ------------------\n", name, ip_name(ib->ip_type));
fprintf(ib->f, "------------------ %s begin - %s ------------------\n", name,
ac_get_ip_type_string(NULL, ib->ip_type));
ac_parse_ib_chunk(ib);
fprintf(ib->f, "------------------- %s end - %s -------------------\n\n", name, ip_name(ib->ip_type));
fprintf(ib->f, "------------------- %s end - %s -------------------\n\n", name,
ac_get_ip_type_string(NULL, ib->ip_type));
}

View File

@ -7,6 +7,7 @@
#include "amd_family.h"
#include "addrlib/src/amdgpu_asic_addr.h"
#include "util/macros.h"
#include "ac_gpu_info.h"
const char *ac_get_family_name(enum radeon_family family)
{
@ -235,3 +236,31 @@ const char *ac_get_llvm_processor_name(enum radeon_family family)
return "";
}
}
const char *ac_get_ip_type_string(const struct radeon_info *info, enum amd_ip_type ip_type)
{
switch (ip_type) {
case AMD_IP_GFX:
return "GFX";
case AMD_IP_COMPUTE:
return "COMPUTE";
case AMD_IP_SDMA:
return "SDMA";
case AMD_IP_UVD:
return "UVD";
case AMD_IP_VCE:
return "VCE";
case AMD_IP_UVD_ENC:
return "UVD_ENC";
case AMD_IP_VCN_DEC:
return "VCN_DEC";
case AMD_IP_VCN_ENC: /* equal to AMD_IP_VCN_UNIFIED */
return !info || info->vcn_ip_version >= VCN_4_0_0 ? "VCN" : "VCN_ENC";
case AMD_IP_VCN_JPEG:
return "VCN_JPEG";
case AMD_IP_VPE:
return "VPE";
default:
return "UNKNOWN_IP";
}
}

View File

@ -12,6 +12,8 @@
extern "C" {
#endif
struct radeon_info;
enum radeon_family
{
CHIP_UNKNOWN = 0,
@ -243,6 +245,7 @@ const char *ac_get_family_name(enum radeon_family family);
enum amd_gfx_level ac_get_gfx_level(enum radeon_family family);
unsigned ac_get_family_id(enum radeon_family family);
const char *ac_get_llvm_processor_name(enum radeon_family family);
const char *ac_get_ip_type_string(const struct radeon_info *info, enum amd_ip_type ip_type);
#ifdef __cplusplus
}

View File

@ -463,7 +463,7 @@ radv_dump_queue_state(struct radv_queue *queue, const char *dump_dir, FILE *f)
enum amd_ip_type ring = radv_queue_ring(queue);
struct radv_pipeline *pipeline;
fprintf(f, "AMD_IP_%s:\n", ring == AMD_IP_GFX ? "GFX" : "COMPUTE");
fprintf(f, "AMD_IP_%s:\n", ac_get_ip_type_string(&pdev->info, ring));
pipeline = radv_get_saved_pipeline(device, ring);
if (pipeline) {