anv/extensions: Add support for multiple API versions
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
This commit is contained in:
@@ -29,18 +29,34 @@ import copy
|
|||||||
import re
|
import re
|
||||||
import xml.etree.cElementTree as et
|
import xml.etree.cElementTree as et
|
||||||
|
|
||||||
MAX_API_VERSION = '1.0.57'
|
def _bool_to_c_expr(b):
|
||||||
|
if b is True:
|
||||||
|
return 'true';
|
||||||
|
elif b is False:
|
||||||
|
return 'false';
|
||||||
|
else:
|
||||||
|
return b;
|
||||||
|
|
||||||
class Extension:
|
class Extension:
|
||||||
def __init__(self, name, ext_version, enable):
|
def __init__(self, name, ext_version, enable):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.ext_version = int(ext_version)
|
self.ext_version = int(ext_version)
|
||||||
if enable is True:
|
self.enable = _bool_to_c_expr(enable)
|
||||||
self.enable = 'true';
|
|
||||||
elif enable is False:
|
class ApiVersion:
|
||||||
self.enable = 'false';
|
def __init__(self, max_patch_version, enable):
|
||||||
else:
|
self.max_patch_version = max_patch_version
|
||||||
self.enable = enable;
|
self.enable = _bool_to_c_expr(enable)
|
||||||
|
|
||||||
|
# Supported API versions. Each one is the maximum patch version for the given
|
||||||
|
# version. Version come in increasing order and each version is available if
|
||||||
|
# it's provided "enable" condition is true and all previous versions are
|
||||||
|
# available.
|
||||||
|
API_VERSIONS = [
|
||||||
|
ApiVersion('1.0.57', True),
|
||||||
|
]
|
||||||
|
|
||||||
|
MAX_API_VERSION = None # Computed later
|
||||||
|
|
||||||
# On Android, we disable all surface and swapchain extensions. Android's Vulkan
|
# On Android, we disable all surface and swapchain extensions. Android's Vulkan
|
||||||
# loader implements VK_KHR_surface and VK_KHR_swapchain, and applications
|
# loader implements VK_KHR_surface and VK_KHR_swapchain, and applications
|
||||||
@@ -132,4 +148,9 @@ class VkVersion:
|
|||||||
|
|
||||||
return self.__int_ver().__cmp__(other.__int_ver())
|
return self.__int_ver().__cmp__(other.__int_ver())
|
||||||
|
|
||||||
MAX_API_VERSION = VkVersion(MAX_API_VERSION)
|
|
||||||
|
MAX_API_VERSION = VkVersion('0.0.0')
|
||||||
|
for version in API_VERSIONS:
|
||||||
|
version.max_patch_version = VkVersion(version.max_patch_version)
|
||||||
|
assert version.max_patch_version > MAX_API_VERSION
|
||||||
|
MAX_API_VERSION = version.max_patch_version
|
||||||
|
@@ -147,9 +147,17 @@ const struct anv_instance_extension_table anv_instance_extensions_supported = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
anv_physical_device_api_version(struct anv_physical_device *dev)
|
anv_physical_device_api_version(struct anv_physical_device *device)
|
||||||
{
|
{
|
||||||
return ${MAX_API_VERSION.c_vk_version()};
|
uint32_t version = 0;
|
||||||
|
|
||||||
|
%for version in API_VERSIONS:
|
||||||
|
if (!(${version.enable}))
|
||||||
|
return version;
|
||||||
|
version = ${version.max_patch_version.c_vk_version()};
|
||||||
|
|
||||||
|
%endfor
|
||||||
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
const VkExtensionProperties anv_device_extensions[ANV_DEVICE_EXTENSION_COUNT] = {
|
const VkExtensionProperties anv_device_extensions[ANV_DEVICE_EXTENSION_COUNT] = {
|
||||||
@@ -188,6 +196,7 @@ if __name__ == '__main__':
|
|||||||
assert ext.type == 'instance' or ext.type == 'device'
|
assert ext.type == 'instance' or ext.type == 'device'
|
||||||
|
|
||||||
template_env = {
|
template_env = {
|
||||||
|
'API_VERSIONS': API_VERSIONS,
|
||||||
'MAX_API_VERSION': MAX_API_VERSION,
|
'MAX_API_VERSION': MAX_API_VERSION,
|
||||||
'instance_extensions': [e for e in EXTENSIONS if e.type == 'instance'],
|
'instance_extensions': [e for e in EXTENSIONS if e.type == 'instance'],
|
||||||
'device_extensions': [e for e in EXTENSIONS if e.type == 'device'],
|
'device_extensions': [e for e in EXTENSIONS if e.type == 'device'],
|
||||||
|
Reference in New Issue
Block a user