Mesa (main): freedreno+turnip: Get device name from device-info table
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jul 14 02:20:02 UTC 2021
Module: Mesa
Branch: main
Commit: 7c7722304b40df20380b5decbd533ab7a700690c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7c7722304b40df20380b5decbd533ab7a700690c
Author: Rob Clark <robdclark at chromium.org>
Date: Thu Jul 8 11:35:31 2021 -0700
freedreno+turnip: Get device name from device-info table
Signed-off-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11790>
---
src/freedreno/common/freedreno_dev_info.c | 11 ++++++
src/freedreno/common/freedreno_dev_info.h | 2 +
src/freedreno/common/freedreno_devices.py | 47 ++++++++++++++----------
src/freedreno/vulkan/tu_device.c | 3 +-
src/freedreno/vulkan/tu_private.h | 2 +-
src/gallium/drivers/freedreno/freedreno_screen.c | 4 +-
6 files changed, 43 insertions(+), 26 deletions(-)
diff --git a/src/freedreno/common/freedreno_dev_info.c b/src/freedreno/common/freedreno_dev_info.c
index 6e04d7ebde4..4334cb9570c 100644
--- a/src/freedreno/common/freedreno_dev_info.c
+++ b/src/freedreno/common/freedreno_dev_info.c
@@ -38,3 +38,14 @@ fd_dev_info(uint32_t gpu_id)
}
return NULL;
}
+
+const char *
+fd_dev_name(uint32_t gpu_id)
+{
+ for (int i = 0; i < fd_dev_ids_count; i++) {
+ if (gpu_id == fd_dev_ids[i].gpu_id) {
+ return fd_dev_ids[i].name;
+ }
+ }
+ return NULL;
+}
diff --git a/src/freedreno/common/freedreno_dev_info.h b/src/freedreno/common/freedreno_dev_info.h
index d87fb0d8b55..c61506dc672 100644
--- a/src/freedreno/common/freedreno_dev_info.h
+++ b/src/freedreno/common/freedreno_dev_info.h
@@ -107,6 +107,7 @@ struct fd_dev_info {
struct fd_dev_id {
uint32_t gpu_id;
+ const char *name;
const struct fd_dev_info *info;
};
@@ -122,6 +123,7 @@ struct fd_dev_id {
#define A6XX_CCU_GMEM_COLOR_SIZE (16 * 1024)
const struct fd_dev_info * fd_dev_info(uint32_t gpu_id);
+const char * fd_dev_name(uint32_t gpu_id);
#ifdef __cplusplus
} /* end of extern "C" */
diff --git a/src/freedreno/common/freedreno_devices.py b/src/freedreno/common/freedreno_devices.py
index 08cfc7b6262..119598aef79 100644
--- a/src/freedreno/common/freedreno_devices.py
+++ b/src/freedreno/common/freedreno_devices.py
@@ -51,6 +51,13 @@ def add_gpus(ids, info):
for id in ids:
s.gpus[id] = info
+class GPUId(object):
+ def __init__(self, gpu_id, name=None):
+ self.gpu_id = gpu_id
+ if name == None:
+ name = "FD%d" % gpu_id
+ self.name = name
+
class Struct(object):
"""A helper class that stringifies itself to a 'C' struct initializer
"""
@@ -123,10 +130,10 @@ class A6xxGPUInfo(GPUInfo):
# a2xx is really two sub-generations, a20x and a22x, but we don't currently
# capture that in the device-info tables
add_gpus([
- 200,
- 201,
- 205,
- 220,
+ GPUId(200),
+ GPUId(201),
+ GPUId(205),
+ GPUId(220),
], GPUInfo(
gmem_align_w = 32, gmem_align_h = 32,
tile_align_w = 32, tile_align_h = 32,
@@ -136,10 +143,10 @@ add_gpus([
))
add_gpus([
- 305,
- 307,
- 320,
- 330,
+ GPUId(305),
+ GPUId(307),
+ GPUId(320),
+ GPUId(330),
], GPUInfo(
gmem_align_w = 32, gmem_align_h = 32,
tile_align_w = 32, tile_align_h = 32,
@@ -149,9 +156,9 @@ add_gpus([
))
add_gpus([
- 405,
- 420,
- 430,
+ GPUId(405),
+ GPUId(420),
+ GPUId(430),
], GPUInfo(
gmem_align_w = 32, gmem_align_h = 32,
tile_align_w = 32, tile_align_h = 32,
@@ -161,9 +168,9 @@ add_gpus([
))
add_gpus([
- 510,
- 530,
- 540,
+ GPUId(510),
+ GPUId(530),
+ GPUId(540),
], GPUInfo(
gmem_align_w = 64, gmem_align_h = 32,
tile_align_w = 64, tile_align_h = 32,
@@ -206,8 +213,8 @@ a6xx_gen3 = dict(
)
add_gpus([
- 615,
- 618,
+ GPUId(615),
+ GPUId(618),
], A6xxGPUInfo(
a6xx_gen1,
num_sp_cores = 1,
@@ -218,7 +225,7 @@ add_gpus([
))
add_gpus([
- 630,
+ GPUId(630),
], A6xxGPUInfo(
a6xx_gen1,
num_sp_cores = 2,
@@ -229,7 +236,7 @@ add_gpus([
))
add_gpus([
- 640,
+ GPUId(640),
], A6xxGPUInfo(
a6xx_gen2,
num_sp_cores = 2,
@@ -240,7 +247,7 @@ add_gpus([
))
add_gpus([
- 650,
+ GPUId(650),
], A6xxGPUInfo(
a6xx_gen3,
num_sp_cores = 3,
@@ -285,7 +292,7 @@ static const struct fd_dev_info __info${s.info_index(info)} = ${str(info)};
const struct fd_dev_id fd_dev_ids[] = {
%for id, info in s.gpus.items():
- { ${id}, &__info${s.info_index(info)} },
+ { ${id.gpu_id}, "${id.name}", &__info${s.info_index(info)} },
%endfor
};
const unsigned fd_dev_ids_count = ${len(s.gpus)};
diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c
index 7651ca0e489..3db44572d74 100644
--- a/src/freedreno/vulkan/tu_device.c
+++ b/src/freedreno/vulkan/tu_device.c
@@ -192,8 +192,7 @@ tu_physical_device_init(struct tu_physical_device *device,
{
VkResult result = VK_SUCCESS;
- memset(device->name, 0, sizeof(device->name));
- sprintf(device->name, "FD%d", device->gpu_id);
+ device->name = fd_dev_name(device->gpu_id);
const struct fd_dev_info *info = fd_dev_info(device->gpu_id);
if (!info) {
diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h
index 514d28b701a..683eeb89725 100644
--- a/src/freedreno/vulkan/tu_private.h
+++ b/src/freedreno/vulkan/tu_private.h
@@ -194,7 +194,7 @@ struct tu_physical_device
struct tu_instance *instance;
- char name[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE];
+ const char *name;
uint8_t driver_uuid[VK_UUID_SIZE];
uint8_t device_uuid[VK_UUID_SIZE];
uint8_t cache_uuid[VK_UUID_SIZE];
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c
index 26fe62eae30..2e589facea7 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
@@ -107,9 +107,7 @@ bool fd_binning_enabled = true;
static const char *
fd_screen_get_name(struct pipe_screen *pscreen)
{
- static char buffer[128];
- snprintf(buffer, sizeof(buffer), "FD%03d", fd_screen(pscreen)->device_id);
- return buffer;
+ return fd_dev_name(fd_screen(pscreen)->gpu_id);
}
static const char *
More information about the mesa-commit
mailing list