diff --git a/src/gallium/drivers/crocus/crocus_screen.c b/src/gallium/drivers/crocus/crocus_screen.c index 3e85b7d6c50..c1e0cf3a294 100644 --- a/src/gallium/drivers/crocus/crocus_screen.c +++ b/src/gallium/drivers/crocus/crocus_screen.c @@ -127,14 +127,10 @@ static const char * crocus_get_name(struct pipe_screen *pscreen) { struct crocus_screen *screen = (struct crocus_screen *)pscreen; + const struct intel_device_info *devinfo = &screen->devinfo; static char buf[128]; - const char *name = intel_get_device_name(screen->pci_id); - - if (!name) - name = "Intel Unknown"; - - snprintf(buf, sizeof(buf), "Mesa %s", name); + snprintf(buf, sizeof(buf), "Mesa %s", devinfo->name); return buf; } diff --git a/src/gallium/drivers/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c index e5fe4ac0315..f9df596dade 100644 --- a/src/gallium/drivers/iris/iris_screen.c +++ b/src/gallium/drivers/iris/iris_screen.c @@ -144,13 +144,10 @@ static const char * iris_get_name(struct pipe_screen *pscreen) { struct iris_screen *screen = (struct iris_screen *)pscreen; + const struct intel_device_info *devinfo = &screen->devinfo; static char buf[128]; - const char *name = intel_get_device_name(screen->pci_id); - if (!name) - name = "Intel Unknown"; - - snprintf(buf, sizeof(buf), "Mesa %s", name); + snprintf(buf, sizeof(buf), "Mesa %s", devinfo->name); return buf; } diff --git a/src/intel/dev/intel_dev_info.c b/src/intel/dev/intel_dev_info.c index 39da00b5cd3..2c067319b7a 100644 --- a/src/intel/dev/intel_dev_info.c +++ b/src/intel/dev/intel_dev_info.c @@ -72,7 +72,7 @@ main(int argc, char *argv[]) fprintf(stdout, "%s:\n", path); - fprintf(stdout, " name: %s\n", intel_get_device_name(devinfo.chipset_id)); + fprintf(stdout, " name: %s\n", devinfo.name); fprintf(stdout, " gen: %u\n", devinfo.ver); fprintf(stdout, " PCI id: 0x%x\n", devinfo.chipset_id); fprintf(stdout, " revision: %u\n", devinfo.revision); diff --git a/src/intel/dev/intel_device_info.c b/src/intel/dev/intel_device_info.c index c4279d29e74..442d7e9b41b 100644 --- a/src/intel/dev/intel_device_info.c +++ b/src/intel/dev/intel_device_info.c @@ -1249,6 +1249,21 @@ intel_get_device_info_from_pci_id(int pci_id, return false; } + switch (pci_id) { +#undef CHIPSET +#define CHIPSET(_id, _family, _fam_str, _name) \ + case _id: \ + /* sizeof(str_literal) includes the null */ \ + STATIC_ASSERT(sizeof(_name) + sizeof(_fam_str) + 2 <= \ + sizeof(devinfo->name)); \ + strncpy(devinfo->name, _name " (" _fam_str ")", sizeof(devinfo->name)); \ + break; +#include "pci_ids/i965_pci_ids.h" +#include "pci_ids/iris_pci_ids.h" + default: + strncpy(devinfo->name, "Intel Unknown", sizeof(devinfo->name)); + } + fill_masks(devinfo); /* From the Skylake PRM, 3DSTATE_PS::Scratch Space Base Pointer: @@ -1291,19 +1306,6 @@ intel_get_device_info_from_pci_id(int pci_id, return true; } -const char * -intel_get_device_name(int devid) -{ - switch (devid) { -#undef CHIPSET -#define CHIPSET(id, family, fam_str, name) case id: return name " (" fam_str ")"; break; -#include "pci_ids/i965_pci_ids.h" -#include "pci_ids/iris_pci_ids.h" - default: - return NULL; - } -} - /** * for gfx8/gfx9, SLICE_MASK/SUBSLICE_MASK can be used to compute the topology * (kernel 4.13+) diff --git a/src/intel/dev/intel_device_info.h b/src/intel/dev/intel_device_info.h index ebb779e3938..12a62b7690b 100644 --- a/src/intel/dev/intel_device_info.h +++ b/src/intel/dev/intel_device_info.h @@ -36,6 +36,7 @@ extern "C" { struct drm_i915_query_topology_info; +#define INTEL_DEVICE_MAX_NAME_SIZE 64 #define INTEL_DEVICE_MAX_SLICES (6) /* Maximum on gfx10 */ #define INTEL_DEVICE_MAX_SUBSLICES (8) /* Maximum on gfx11 */ #define INTEL_DEVICE_MAX_EUS_PER_SUBSLICE (16) /* Maximum on gfx12 */ @@ -278,6 +279,11 @@ struct intel_device_info */ uint32_t chipset_id; + /** + * holds the name of the device + */ + char name[INTEL_DEVICE_MAX_NAME_SIZE]; + /** * no_hw is true when the chipset_id pci device id has been overridden */ @@ -345,7 +351,6 @@ intel_device_info_num_dual_subslices(UNUSED } int intel_device_name_to_pci_device_id(const char *name); -const char *intel_get_device_name(int devid); static inline uint64_t intel_device_info_timebase_scale(const struct intel_device_info *devinfo, diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c index 5c0885ac631..fb0a9528f77 100644 --- a/src/intel/tools/aubinator.c +++ b/src/intel/tools/aubinator.c @@ -122,7 +122,7 @@ aubinator_init(void *user_data, int aub_pci_id, const char *app_name) fprintf(outfile, "Application name: %s\n", app_name); - fprintf(outfile, "Decoding as: %s\n", intel_get_device_name(pci_id)); + fprintf(outfile, "Decoding as: %s\n", devinfo.name); /* Throw in a new line before the first batch */ fprintf(outfile, "\n"); diff --git a/src/intel/tools/aubinator_viewer.cpp b/src/intel/tools/aubinator_viewer.cpp index 8d68fdf3f32..493eb9cf764 100644 --- a/src/intel/tools/aubinator_viewer.cpp +++ b/src/intel/tools/aubinator_viewer.cpp @@ -1006,7 +1006,7 @@ display_aubfile_window(struct window *win) ImGui::Text("Execbufs %u", context.file->n_execs); ImGui::Text("PCI ID: 0x%x", context.file->pci_id); ImGui::Text("Application name: %s", context.file->app_name); - ImGui::Text("%s", intel_get_device_name(context.file->pci_id)); + ImGui::Text("%s", context.file->devinfo.name); ImGui::SetNextWindowContentWidth(500); if (ImGui::BeginPopupModal("Help", NULL, ImGuiWindowFlags_AlwaysAutoResize)) { diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index f39b7f78573..deb9c89c56c 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -741,8 +741,6 @@ anv_physical_device_try_create(struct anv_instance *instance, goto fail_fd; } - const char *device_name = intel_get_device_name(devinfo.chipset_id); - if (devinfo.is_haswell) { mesa_logw("Haswell Vulkan support is incomplete"); } else if (devinfo.ver == 7 && !devinfo.is_baytrail) { @@ -753,7 +751,7 @@ anv_physical_device_try_create(struct anv_instance *instance, /* Gfx8-12 fully supported */ } else { result = vk_errorfi(instance, NULL, VK_ERROR_INCOMPATIBLE_DRIVER, - "Vulkan not yet supported on %s", device_name); + "Vulkan not yet supported on %s", devinfo.name); goto fail_fd; } @@ -782,7 +780,6 @@ anv_physical_device_try_create(struct anv_instance *instance, snprintf(device->path, ARRAY_SIZE(device->path), "%s", path); device->info = devinfo; - device->name = device_name; device->no_hw = device->info.no_hw; if (getenv("INTEL_NO_HW") != NULL) @@ -2042,7 +2039,7 @@ void anv_GetPhysicalDeviceProperties( }; snprintf(pProperties->deviceName, sizeof(pProperties->deviceName), - "%s", pdevice->name); + "%s", pdevice->info.name); memcpy(pProperties->pipelineCacheUUID, pdevice->pipeline_cache_uuid, VK_UUID_SIZE); } diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index c2971de764d..3717f1842fb 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -893,7 +893,6 @@ struct anv_physical_device { struct anv_instance * instance; bool no_hw; char path[20]; - const char * name; struct { uint16_t domain; uint8_t bus; diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 392c644a795..410412a94fa 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -106,7 +106,7 @@ const char * brw_get_renderer_string(const struct brw_screen *screen) { static char buf[128]; - const char *name = intel_get_device_name(screen->deviceID); + const char *name = screen->devinfo.name; if (!name) name = "Intel Unknown";