summaryrefslogtreecommitdiffstats
path: root/src/amd
diff options
context:
space:
mode:
Diffstat (limited to 'src/amd')
-rw-r--r--src/amd/vulkan/radv_device.c80
-rw-r--r--src/amd/vulkan/radv_private.h4
2 files changed, 48 insertions, 36 deletions
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 9ee8ae2beb0..79534fbd5fc 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -414,6 +414,16 @@ radv_handle_per_app_options(struct radv_instance *instance,
}
}
+static int radv_get_instance_extension_index(const char *name)
+{
+ for (unsigned i = 0; i < RADV_INSTANCE_EXTENSION_COUNT; ++i) {
+ if (strcmp(name, radv_instance_extensions[i].extensionName) == 0)
+ return i;
+ }
+ return -1;
+}
+
+
VkResult radv_CreateInstance(
const VkInstanceCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
@@ -441,12 +451,6 @@ VkResult radv_CreateInstance(
VK_VERSION_PATCH(client_version));
}
- for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
- const char *ext_name = pCreateInfo->ppEnabledExtensionNames[i];
- if (!radv_instance_extension_supported(ext_name))
- return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT);
- }
-
instance = vk_zalloc2(&default_alloc, pAllocator, sizeof(*instance), 8,
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (!instance)
@@ -462,6 +466,18 @@ VkResult radv_CreateInstance(
instance->apiVersion = client_version;
instance->physicalDeviceCount = -1;
+ for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
+ const char *ext_name = pCreateInfo->ppEnabledExtensionNames[i];
+ int index = radv_get_instance_extension_index(ext_name);
+
+ if (index < 0 || !radv_supported_instance_extensions.extensions[index]) {
+ vk_free2(&default_alloc, pAllocator, instance);
+ return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT);
+ }
+
+ instance->enabled_extensions.extensions[index] = true;
+ }
+
result = vk_debug_report_instance_init(&instance->debug_report_callbacks);
if (result != VK_SUCCESS) {
vk_free2(&default_alloc, pAllocator, instance);
@@ -1091,6 +1107,15 @@ radv_device_init_gs_info(struct radv_device *device)
}
}
+static int radv_get_device_extension_index(const char *name)
+{
+ for (unsigned i = 0; i < RADV_DEVICE_EXTENSION_COUNT; ++i) {
+ if (strcmp(name, radv_device_extensions[i].extensionName) == 0)
+ return i;
+ }
+ return -1;
+}
+
VkResult radv_CreateDevice(
VkPhysicalDevice physicalDevice,
const VkDeviceCreateInfo* pCreateInfo,
@@ -1103,15 +1128,6 @@ VkResult radv_CreateDevice(
bool keep_shader_info = false;
- for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
- const char *ext_name = pCreateInfo->ppEnabledExtensionNames[i];
- if (!radv_physical_device_extension_supported(physical_device, ext_name))
- return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT);
-
- if (strcmp(ext_name, VK_AMD_SHADER_INFO_EXTENSION_NAME) == 0)
- keep_shader_info = true;
- }
-
/* Check enabled features */
if (pCreateInfo->pEnabledFeatures) {
VkPhysicalDeviceFeatures supported_features;
@@ -1141,6 +1157,19 @@ VkResult radv_CreateDevice(
else
device->alloc = physical_device->instance->alloc;
+ for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
+ const char *ext_name = pCreateInfo->ppEnabledExtensionNames[i];
+ int index = radv_get_device_extension_index(ext_name);
+ if (index < 0 || !physical_device->supported_extensions.extensions[index]) {
+ vk_free(&device->alloc, device);
+ return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT);
+ }
+
+ device->enabled_extensions.extensions[index] = true;
+ }
+
+ keep_shader_info = device->enabled_extensions.AMD_shader_info;
+
mtx_init(&device->shader_slab_mutex, mtx_plain);
list_inithead(&device->shader_slabs);
@@ -2243,16 +2272,6 @@ VkResult radv_DeviceWaitIdle(
return VK_SUCCESS;
}
-bool
-radv_instance_extension_supported(const char *name)
-{
- for (unsigned i = 0; i < RADV_INSTANCE_EXTENSION_COUNT; ++i) {
- if (strcmp(name, radv_instance_extensions[i].extensionName) == 0)
- return radv_supported_instance_extensions.extensions[i];
- }
- return false;
-}
-
VkResult radv_EnumerateInstanceExtensionProperties(
const char* pLayerName,
uint32_t* pPropertyCount,
@@ -2271,17 +2290,6 @@ VkResult radv_EnumerateInstanceExtensionProperties(
return vk_outarray_status(&out);
}
-bool
-radv_physical_device_extension_supported(struct radv_physical_device *device,
- const char *name)
-{
- for (unsigned i = 0; i < RADV_DEVICE_EXTENSION_COUNT; ++i) {
- if (strcmp(name, radv_device_extensions[i].extensionName) == 0)
- return device->supported_extensions.extensions[i];
- }
- return false;
-}
-
VkResult radv_EnumerateDeviceExtensionProperties(
VkPhysicalDevice physicalDevice,
const char* pLayerName,
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 335c8417e77..18665557eda 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -303,6 +303,8 @@ struct radv_instance {
uint64_t perftest_flags;
struct vk_debug_report_instance debug_report_callbacks;
+
+ struct radv_instance_extension_table enabled_extensions;
};
VkResult radv_init_wsi(struct radv_physical_device *physical_device);
@@ -639,6 +641,8 @@ struct radv_device {
/* For detecting VM faults reported by dmesg. */
uint64_t dmesg_timestamp;
+
+ struct radv_device_extension_table enabled_extensions;
};
struct radv_device_memory {