intel_logw("Ivy Bridge Vulkan support is incomplete");
} else if (device->info.gen == 7 && device->info.is_baytrail) {
intel_logw("Bay Trail Vulkan support is incomplete");
- } else if (device->info.gen >= 8 && device->info.gen <= 9) {
- /* Broadwell, Cherryview, Skylake, Broxton, Kabylake, Coffelake is as
- * fully supported as anything */
- } else if (device->info.gen == 10) {
- intel_logw("Cannonlake Vulkan support is alpha");
+ } else if (device->info.gen >= 8 && device->info.gen <= 10) {
+ /* Gen8-10 fully supported */
} else {
result = vk_errorf(device->instance, device,
VK_ERROR_INCOMPATIBLE_DRIVER,
goto fail;
}
+ anv_physical_device_get_supported_extensions(device,
+ &device->supported_extensions);
+
device->local_fd = fd;
return VK_SUCCESS;
.pfnFree = default_free_func,
};
+VkResult anv_EnumerateInstanceExtensionProperties(
+ const char* pLayerName,
+ uint32_t* pPropertyCount,
+ VkExtensionProperties* pProperties)
+{
+ VK_OUTARRAY_MAKE(out, pProperties, pPropertyCount);
+
+ for (int i = 0; i < ANV_INSTANCE_EXTENSION_COUNT; i++) {
+ if (anv_instance_extensions_supported.extensions[i]) {
+ vk_outarray_append(&out, prop) {
+ *prop = anv_instance_extensions[i];
+ }
+ }
+ }
+
+ return vk_outarray_status(&out);
+}
+
VkResult anv_CreateInstance(
const VkInstanceCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkInstance* pInstance)
{
struct anv_instance *instance;
+ VkResult result;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO);
VK_VERSION_PATCH(client_version));
}
+ struct anv_instance_extension_table enabled_extensions = {};
for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
- const char *ext_name = pCreateInfo->ppEnabledExtensionNames[i];
- if (!anv_instance_extension_supported(ext_name))
+ int idx;
+ for (idx = 0; idx < ANV_INSTANCE_EXTENSION_COUNT; idx++) {
+ if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
+ anv_instance_extensions[idx].extensionName) == 0)
+ break;
+ }
+
+ if (idx >= ANV_INSTANCE_EXTENSION_COUNT)
return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT);
+
+ if (!anv_instance_extensions_supported.extensions[idx])
+ return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT);
+
+ enabled_extensions.extensions[idx] = true;
}
instance = vk_alloc2(&default_alloc, pAllocator, sizeof(*instance), 8,
instance->alloc = default_alloc;
instance->apiVersion = client_version;
- instance->physicalDeviceCount = -1;
+ instance->enabled_extensions = enabled_extensions;
- if (pthread_mutex_init(&instance->callbacks_mutex, NULL) != 0) {
- vk_free2(&default_alloc, pAllocator, instance);
- return vk_error(VK_ERROR_INITIALIZATION_FAILED);
+ 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 if (anv_dispatch_table.entrypoints[i] != NULL) {
+ instance->dispatch.entrypoints[i] = anv_dispatch_table.entrypoints[i];
+ } else {
+ instance->dispatch.entrypoints[i] =
+ anv_tramp_dispatch_table.entrypoints[i];
+ }
}
- list_inithead(&instance->callbacks);
+ instance->physicalDeviceCount = -1;
- /* Store report debug callback to be used during DestroyInstance. */
- if (ctor_cb) {
- instance->destroy_debug_cb.flags = ctor_cb->flags;
- instance->destroy_debug_cb.callback = ctor_cb->pfnCallback;
- instance->destroy_debug_cb.data = ctor_cb->pUserData;
+ result = vk_debug_report_instance_init(&instance->debug_report_callbacks);
+ if (result != VK_SUCCESS) {
+ vk_free2(&default_alloc, pAllocator, instance);
+ return vk_error(result);
}
_mesa_locale_init();
VG(VALGRIND_DESTROY_MEMPOOL(instance));
- pthread_mutex_destroy(&instance->callbacks_mutex);
+ vk_debug_report_instance_destroy(&instance->debug_report_callbacks);
_mesa_locale_fini();
.maxPerStageDescriptorStorageImages = 64,
.maxPerStageDescriptorInputAttachments = 64,
.maxPerStageResources = 250,
- .maxDescriptorSetSamplers = 256,
- .maxDescriptorSetUniformBuffers = 256,
+ .maxDescriptorSetSamplers = 6 * max_samplers, /* number of stages * maxPerStageDescriptorSamplers */
+ .maxDescriptorSetUniformBuffers = 6 * 64, /* number of stages * maxPerStageDescriptorUniformBuffers */
.maxDescriptorSetUniformBuffersDynamic = MAX_DYNAMIC_BUFFERS / 2,
- .maxDescriptorSetStorageBuffers = 256,
+ .maxDescriptorSetStorageBuffers = 6 * 64, /* number of stages * maxPerStageDescriptorStorageBuffers */
.maxDescriptorSetStorageBuffersDynamic = MAX_DYNAMIC_BUFFERS / 2,
- .maxDescriptorSetSampledImages = 256,
- .maxDescriptorSetStorageImages = 256,
+ .maxDescriptorSetSampledImages = 6 * max_samplers, /* number of stages * maxPerStageDescriptorSampledImages */
+ .maxDescriptorSetStorageImages = 6 * 64, /* number of stages * maxPerStageDescriptorStorageImages */
.maxDescriptorSetInputAttachments = 256,
.maxVertexInputAttributes = MAX_VBS,
.maxVertexInputBindings = MAX_VBS,
}
PFN_vkVoidFunction anv_GetInstanceProcAddr(
- VkInstance instance,
+ VkInstance _instance,
const char* pName)
{
- return anv_lookup_entrypoint(NULL, pName);
+ ANV_FROM_HANDLE(anv_instance, instance, _instance);
+
+ /* The Vulkan 1.0 spec for vkGetInstanceProcAddr has a table of exactly
+ * when we have to return valid function pointers, NULL, or it's left
+ * undefined. See the table for exact details.
+ */
+ if (pName == NULL)
+ return NULL;
+
+#define LOOKUP_ANV_ENTRYPOINT(entrypoint) \
+ if (strcmp(pName, "vk" #entrypoint) == 0) \
+ return (PFN_vkVoidFunction)anv_##entrypoint
+
+ LOOKUP_ANV_ENTRYPOINT(EnumerateInstanceExtensionProperties);
+ LOOKUP_ANV_ENTRYPOINT(EnumerateInstanceLayerProperties);
+ LOOKUP_ANV_ENTRYPOINT(CreateInstance);
+
+#undef LOOKUP_ANV_ENTRYPOINT
+
+ if (instance == NULL)
+ return NULL;
+
+ int idx = anv_get_entrypoint_index(pName);
+ if (idx < 0)
+ return NULL;
+
+ return instance->dispatch.entrypoints[idx];
}
/* With version 1+ of the loader interface the ICD should expose
const char* pName)
{
ANV_FROM_HANDLE(anv_device, device, _device);
- return anv_lookup_entrypoint(&device->info, pName);
+
+ if (!device || !pName)
+ return NULL;
+
+ int idx = anv_get_entrypoint_index(pName);
+ if (idx < 0)
+ return NULL;
+
+ return device->dispatch.entrypoints[idx];
+}
+
+VkResult
+anv_CreateDebugReportCallbackEXT(VkInstance _instance,
+ const VkDebugReportCallbackCreateInfoEXT* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkDebugReportCallbackEXT* pCallback)
+{
+ ANV_FROM_HANDLE(anv_instance, instance, _instance);
+ return vk_create_debug_report_callback(&instance->debug_report_callbacks,
+ pCreateInfo, pAllocator, &instance->alloc,
+ pCallback);
+}
+
+void
+anv_DestroyDebugReportCallbackEXT(VkInstance _instance,
+ VkDebugReportCallbackEXT _callback,
+ const VkAllocationCallbacks* pAllocator)
+{
+ ANV_FROM_HANDLE(anv_instance, instance, _instance);
+ vk_destroy_debug_report_callback(&instance->debug_report_callbacks,
+ _callback, pAllocator, &instance->alloc);
+}
+
+void
+anv_DebugReportMessageEXT(VkInstance _instance,
+ VkDebugReportFlagsEXT flags,
+ VkDebugReportObjectTypeEXT objectType,
+ uint64_t object,
+ size_t location,
+ int32_t messageCode,
+ const char* pLayerPrefix,
+ const char* pMessage)
+{
+ ANV_FROM_HANDLE(anv_instance, instance, _instance);
+ vk_debug_report(&instance->debug_report_callbacks, flags, objectType,
+ object, location, messageCode, pLayerPrefix, pMessage);
}
static void
anv_gem_munmap(map, device->trivial_batch_bo.size);
}
+VkResult anv_EnumerateDeviceExtensionProperties(
+ VkPhysicalDevice physicalDevice,
+ const char* pLayerName,
+ uint32_t* pPropertyCount,
+ VkExtensionProperties* pProperties)
+{
+ ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
+ VK_OUTARRAY_MAKE(out, pProperties, pPropertyCount);
+ (void)device;
+
+ for (int i = 0; i < ANV_DEVICE_EXTENSION_COUNT; i++) {
+ if (device->supported_extensions.extensions[i]) {
+ vk_outarray_append(&out, prop) {
+ *prop = anv_device_extensions[i];
+ }
+ }
+ }
+
+ return vk_outarray_status(&out);
+}
+
+static void
+anv_device_init_dispatch(struct anv_device *device)
+{
+ const struct anv_dispatch_table *genX_table;
+ switch (device->info.gen) {
+ case 10:
+ genX_table = &gen10_dispatch_table;
+ break;
+ case 9:
+ genX_table = &gen9_dispatch_table;
+ break;
+ case 8:
+ genX_table = &gen8_dispatch_table;
+ break;
+ case 7:
+ if (device->info.is_haswell)
+ genX_table = &gen75_dispatch_table;
+ else
+ genX_table = &gen7_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_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 {
+ device->dispatch.entrypoints[i] = anv_dispatch_table.entrypoints[i];
+ }
+ }
+}
+
VkResult anv_CreateDevice(
VkPhysicalDevice physicalDevice,
const VkDeviceCreateInfo* pCreateInfo,
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO);
+ struct anv_device_extension_table enabled_extensions = { };
for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
- const char *ext_name = pCreateInfo->ppEnabledExtensionNames[i];
- if (!anv_physical_device_extension_supported(physical_device, ext_name))
+ int idx;
+ for (idx = 0; idx < ANV_DEVICE_EXTENSION_COUNT; idx++) {
+ if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
+ anv_device_extensions[idx].extensionName) == 0)
+ break;
+ }
+
+ if (idx >= ANV_DEVICE_EXTENSION_COUNT)
return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT);
+
+ if (!physical_device->supported_extensions.extensions[idx])
+ return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT);
+
+ enabled_extensions.extensions[idx] = true;
}
/* Check enabled features */
device->robust_buffer_access = pCreateInfo->pEnabledFeatures &&
pCreateInfo->pEnabledFeatures->robustBufferAccess;
+ device->enabled_extensions = enabled_extensions;
+
+ anv_device_init_dispatch(device);
if (pthread_mutex_init(&device->mutex, NULL) != 0) {
result = vk_error(VK_ERROR_INITIALIZATION_FAILED);
goto fail_batch_bo_pool;
/* For the state pools we explicitly disable 48bit. */
- bo_flags = physical_device->has_exec_async ? EXEC_OBJECT_ASYNC : 0;
+ bo_flags = (physical_device->has_exec_async ? EXEC_OBJECT_ASYNC : 0) |
+ (physical_device->has_exec_capture ? EXEC_OBJECT_CAPTURE : 0);
result = anv_state_pool_init(&device->dynamic_state_pool, device, 16384,
bo_flags);
goto fail_bo_cache;
result = anv_state_pool_init(&device->instruction_state_pool, device, 16384,
- bo_flags |
- (physical_device->has_exec_capture ? EXEC_OBJECT_CAPTURE : 0));
+ bo_flags);
if (result != VK_SUCCESS)
goto fail_dynamic_state_pool;
case 10:
result = gen10_init_device_state(device);
break;
+ case 11:
+ result = gen11_init_device_state(device);
+ break;
default:
/* Shouldn't get here as we don't create physical devices for any other
* gens. */