anv: Use tables for instance extension wrangling
This lets us move a bunch of stuff out of codegen and back into anv_device.c which is a bit nicer. Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
This commit is contained in:
@@ -476,6 +476,24 @@ static const VkAllocationCallbacks default_alloc = {
|
||||
.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,
|
||||
@@ -522,8 +540,17 @@ VkResult anv_CreateInstance(
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,8 @@ struct anv_instance_extension_table {
|
||||
};
|
||||
};
|
||||
|
||||
extern const struct anv_instance_extension_table anv_instance_extensions_supported;
|
||||
|
||||
|
||||
#define ANV_DEVICE_EXTENSION_COUNT ${len(device_extensions)}
|
||||
|
||||
@@ -132,36 +134,11 @@ const VkExtensionProperties anv_instance_extensions[ANV_INSTANCE_EXTENSION_COUNT
|
||||
%endfor
|
||||
};
|
||||
|
||||
bool
|
||||
anv_instance_extension_supported(const char *name)
|
||||
{
|
||||
const struct anv_instance_extension_table anv_instance_extensions_supported = {
|
||||
%for ext in instance_extensions:
|
||||
if (strcmp(name, "${ext.name}") == 0)
|
||||
return ${ext.enable};
|
||||
.${ext.name[3:]} = ${ext.enable},
|
||||
%endfor
|
||||
return false;
|
||||
}
|
||||
|
||||
VkResult anv_EnumerateInstanceExtensionProperties(
|
||||
const char* pLayerName,
|
||||
uint32_t* pPropertyCount,
|
||||
VkExtensionProperties* pProperties)
|
||||
{
|
||||
VK_OUTARRAY_MAKE(out, pProperties, pPropertyCount);
|
||||
|
||||
%for ext in instance_extensions:
|
||||
if (${ext.enable}) {
|
||||
vk_outarray_append(&out, prop) {
|
||||
*prop = (VkExtensionProperties) {
|
||||
.extensionName = "${ext.name}",
|
||||
.specVersion = ${ext.ext_version},
|
||||
};
|
||||
}
|
||||
}
|
||||
%endfor
|
||||
|
||||
return vk_outarray_status(&out);
|
||||
}
|
||||
};
|
||||
|
||||
uint32_t
|
||||
anv_physical_device_api_version(struct anv_physical_device *dev)
|
||||
|
||||
@@ -803,7 +803,6 @@ struct anv_instance {
|
||||
VkResult anv_init_wsi(struct anv_physical_device *physical_device);
|
||||
void anv_finish_wsi(struct anv_physical_device *physical_device);
|
||||
|
||||
bool anv_instance_extension_supported(const char *name);
|
||||
uint32_t anv_physical_device_api_version(struct anv_physical_device *dev);
|
||||
bool anv_physical_device_extension_supported(struct anv_physical_device *dev,
|
||||
const char *name);
|
||||
|
||||
Reference in New Issue
Block a user