diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index 8337573829a..53fbdd214da 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -148,25 +148,37 @@ zink_get_vendor(struct pipe_screen *pscreen) static const char * zink_get_device_vendor(struct pipe_screen *pscreen) { - struct zink_screen *screen = zink_screen(pscreen); - static char buf[1000]; - snprintf(buf, sizeof(buf), "Unknown (vendor-id: 0x%04x)", screen->info.props.vendorID); - return buf; + return zink_screen(pscreen)->vendor_name; } static const char * zink_get_name(struct pipe_screen *pscreen) { - struct zink_screen *screen = zink_screen(pscreen); + return zink_screen(pscreen)->device_name; +} + +static int +zink_set_driver_strings(struct zink_screen *screen) +{ + char buf[1000]; const char *driver_name = vk_DriverId_to_str(zink_driverid(screen)) + strlen("VK_DRIVER_ID_"); - static char buf[1000]; - snprintf(buf, sizeof(buf), "zink Vulkan %d.%d(%s (%s))", - VK_VERSION_MAJOR(screen->info.device_version), - VK_VERSION_MINOR(screen->info.device_version), - screen->info.props.deviceName, - strstr(vk_DriverId_to_str(zink_driverid(screen)), "VK_DRIVER_ID_") ? driver_name : "Driver Unknown" - ); - return buf; + int written = snprintf(buf, sizeof(buf), "zink Vulkan %d.%d(%s (%s))", + VK_VERSION_MAJOR(screen->info.device_version), + VK_VERSION_MINOR(screen->info.device_version), + screen->info.props.deviceName, + strstr(vk_DriverId_to_str(zink_driverid(screen)), "VK_DRIVER_ID_") ? driver_name : "Driver Unknown" + ); + if (written < 0) + return written; + assert(written < sizeof(buf)); + screen->device_name = ralloc_strdup(screen, buf); + + written = snprintf(buf, sizeof(buf), "Unknown (vendor-id: 0x%04x)", screen->info.props.vendorID); + if (written < 0) + return written; + assert(written < sizeof(buf)); + screen->vendor_name = ralloc_strdup(screen, buf); + return 0; } static void @@ -3381,6 +3393,11 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev goto fail; } + if (zink_set_driver_strings(screen)) { + mesa_loge("ZINK: failed to set driver strings\n"); + goto fail; + } + memset(&screen->heap_map, UINT8_MAX, sizeof(screen->heap_map)); for (enum zink_heap i = 0; i < ZINK_HEAP_MAX; i++) { for (unsigned j = 0; j < screen->info.mem_props.memoryTypeCount; j++) { diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index e8def6aad3f..09f9507bf17 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -1384,6 +1384,9 @@ struct zink_format_props { struct zink_screen { struct pipe_screen base; + const char *vendor_name; + const char *device_name; + struct util_dl_library *loader_lib; PFN_vkGetInstanceProcAddr vk_GetInstanceProcAddr; PFN_vkGetDeviceProcAddr vk_GetDeviceProcAddr;