anv: Use resolve_device_entrypoint for dispatch init
There's no good reason to have the "which table do I use?" code duplicated twice. The only advantage to the way we were doing it before was that we could move the switch statement outside the loop. If this is ever an actual device initialization perf problem that someone cares about, we can optimize that when the time comes. For now, the duplicated cases are simply a platform-enabling pit-fall. Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5530>
This commit is contained in:
parent
e94a122642
commit
77c50891b6
|
@ -2491,55 +2491,6 @@ VkResult anv_EnumerateDeviceExtensionProperties(
|
|||
return vk_outarray_status(&out);
|
||||
}
|
||||
|
||||
static void
|
||||
anv_device_init_dispatch(struct anv_device *device)
|
||||
{
|
||||
const struct anv_instance *instance = device->physical->instance;
|
||||
|
||||
const struct anv_device_dispatch_table *genX_table;
|
||||
switch (device->info.gen) {
|
||||
case 12:
|
||||
genX_table = &gen12_device_dispatch_table;
|
||||
break;
|
||||
case 11:
|
||||
genX_table = &gen11_device_dispatch_table;
|
||||
break;
|
||||
case 10:
|
||||
genX_table = &gen10_device_dispatch_table;
|
||||
break;
|
||||
case 9:
|
||||
genX_table = &gen9_device_dispatch_table;
|
||||
break;
|
||||
case 8:
|
||||
genX_table = &gen8_device_dispatch_table;
|
||||
break;
|
||||
case 7:
|
||||
if (device->info.is_haswell)
|
||||
genX_table = &gen75_device_dispatch_table;
|
||||
else
|
||||
genX_table = &gen7_device_dispatch_table;
|
||||
break;
|
||||
default:
|
||||
unreachable("unsupported gen\n");
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(device->dispatch.entrypoints); i++) {
|
||||
/* Vulkan requires that entrypoints for extensions which have not been
|
||||
* enabled must not be advertised.
|
||||
*/
|
||||
if (!anv_device_entrypoint_is_enabled(i, instance->app_info.api_version,
|
||||
&instance->enabled_extensions,
|
||||
&device->enabled_extensions)) {
|
||||
device->dispatch.entrypoints[i] = NULL;
|
||||
} else if (genX_table->entrypoints[i]) {
|
||||
device->dispatch.entrypoints[i] = genX_table->entrypoints[i];
|
||||
} else {
|
||||
device->dispatch.entrypoints[i] =
|
||||
anv_device_dispatch_table.entrypoints[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
vk_priority_to_gen(int priority)
|
||||
{
|
||||
|
@ -2869,7 +2820,20 @@ VkResult anv_CreateDevice(
|
|||
device->robust_buffer_access = robust_buffer_access;
|
||||
device->enabled_extensions = enabled_extensions;
|
||||
|
||||
anv_device_init_dispatch(device);
|
||||
const struct anv_instance *instance = physical_device->instance;
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(device->dispatch.entrypoints); i++) {
|
||||
/* Vulkan requires that entrypoints for extensions which have not been
|
||||
* enabled must not be advertised.
|
||||
*/
|
||||
if (!anv_device_entrypoint_is_enabled(i, instance->app_info.api_version,
|
||||
&instance->enabled_extensions,
|
||||
&device->enabled_extensions)) {
|
||||
device->dispatch.entrypoints[i] = NULL;
|
||||
} else {
|
||||
device->dispatch.entrypoints[i] =
|
||||
anv_resolve_device_entrypoint(&device->info, i);
|
||||
}
|
||||
}
|
||||
|
||||
if (pthread_mutex_init(&device->mutex, NULL) != 0) {
|
||||
result = vk_error(VK_ERROR_INITIALIZATION_FAILED);
|
||||
|
|
|
@ -513,7 +513,7 @@ anv_get_device_entry_name(int index)
|
|||
return device_entry_name(index);
|
||||
}
|
||||
|
||||
static void * __attribute__ ((noinline))
|
||||
void * __attribute__ ((noinline))
|
||||
anv_resolve_device_entrypoint(const struct gen_device_info *devinfo, uint32_t index)
|
||||
{
|
||||
const struct anv_device_dispatch_table *genX_table;
|
||||
|
|
|
@ -4327,6 +4327,8 @@ anv_device_entrypoint_is_enabled(int index, uint32_t core_version,
|
|||
const struct anv_instance_extension_table *instance,
|
||||
const struct anv_device_extension_table *device);
|
||||
|
||||
void *anv_resolve_device_entrypoint(const struct gen_device_info *devinfo,
|
||||
uint32_t index);
|
||||
void *anv_lookup_entrypoint(const struct gen_device_info *devinfo,
|
||||
const char *name);
|
||||
|
||||
|
|
Loading…
Reference in New Issue