anv: Only advertise enabled entrypoints

The Vulkan spec annoyingly requires us to track what core version and
what all extensions are enabled and only advertise those entrypoints.
Any call to vkGet*ProcAddr for an entrypoint for an extension the client
has not explicitly enabled is supposed to return NULL.

Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
This commit is contained in:
Jason Ekstrand
2018-01-16 18:08:09 -08:00
parent e3d27542ae
commit 1f79d986af
3 changed files with 74 additions and 6 deletions

View File

@@ -574,7 +574,19 @@ VkResult anv_CreateInstance(
instance->apiVersion = client_version;
instance->enabled_extensions = enabled_extensions;
instance->dispatch = anv_dispatch_table;
for (unsigned i = 0; i < ARRAY_SIZE(instance->dispatch.entrypoints); i++) {
/* Vulkan requires that entrypoints for extensions which have not been
* enabled must not be advertised.
*/
if (!anv_entrypoint_is_enabled(i, instance->apiVersion,
&instance->enabled_extensions, NULL)) {
instance->dispatch.entrypoints[i] = NULL;
} else {
instance->dispatch.entrypoints[i] = anv_dispatch_table.entrypoints[i];
}
}
instance->physicalDeviceCount = -1;
result = vk_debug_report_instance_init(&instance->debug_report_callbacks);
@@ -1289,10 +1301,18 @@ anv_device_init_dispatch(struct anv_device *device)
}
for (unsigned i = 0; i < ARRAY_SIZE(device->dispatch.entrypoints); i++) {
if (genX_table->entrypoints[i])
/* Vulkan requires that entrypoints for extensions which have not been
* enabled must not be advertised.
*/
if (!anv_entrypoint_is_enabled(i, device->instance->apiVersion,
&device->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
} else {
device->dispatch.entrypoints[i] = anv_dispatch_table.entrypoints[i];
}
}
}