zink: cache generated vendor and device name inside zink_screen
get_name and get_device_vendor are supposed to return immutable strings. This prevents the CL_DEVICE_NAME and CL_DEVICE_VENDOR queries from randomly failing. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30888>
This commit is contained in:
@@ -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++) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user