summaryrefslogtreecommitdiffstats
path: root/src/intel/vulkan/anv_device.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2018-01-16 18:08:09 -0800
committerJason Ekstrand <[email protected]>2018-01-23 00:15:40 -0800
commit1f79d986afa5a92d7c7d85882714c7feeddc5d14 (patch)
tree013cbf83e968096832e9b06047679a7f5370a18e /src/intel/vulkan/anv_device.c
parente3d27542aec33c7e0c2048a46a8a3cf71f09e907 (diff)
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 <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_device.c')
-rw-r--r--src/intel/vulkan/anv_device.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index e70ddf17998..8fcc73eaba1 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -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];
+ }
}
}