summaryrefslogtreecommitdiffstats
path: root/src/intel/vulkan/anv_extensions.py
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-08-01 11:09:50 -0700
committerJason Ekstrand <[email protected]>2017-08-02 09:13:13 -0700
commit7382d8a41684e6f7cd7a558469fcd2724c844982 (patch)
treec90018ee4a9edfe6480e2fc5bdac6ba18ed14b26 /src/intel/vulkan/anv_extensions.py
parenta25267654b08e2a34c673b905107c3cc3e856d0a (diff)
anv: Add MAX_API_VERSION to anv_extensions.py
The VkVersion class is probably overkill but it makes it really easy to compare versions in a way that's safe without the caller having to think about patch vs. no patch. Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_extensions.py')
-rw-r--r--src/intel/vulkan/anv_extensions.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/intel/vulkan/anv_extensions.py b/src/intel/vulkan/anv_extensions.py
index 0d243c6f138..7307cacbcac 100644
--- a/src/intel/vulkan/anv_extensions.py
+++ b/src/intel/vulkan/anv_extensions.py
@@ -25,10 +25,14 @@ COPYRIGHT = """\
"""
import argparse
+import copy
+import re
import xml.etree.cElementTree as et
from mako.template import Template
+MAX_API_VERSION = '1.0.54'
+
class Extension:
def __init__(self, name, ext_version, enable):
self.name = name
@@ -64,6 +68,45 @@ EXTENSIONS = [
Extension('VK_KHX_multiview', 1, True),
]
+class VkVersion:
+ def __init__(self, string):
+ split = string.split('.')
+ self.major = int(split[0])
+ self.minor = int(split[1])
+ if len(split) > 2:
+ assert len(split) == 3
+ self.patch = int(split[2])
+ else:
+ self.patch = None
+
+ # Sanity check. The range bits are required by the definition of the
+ # VK_MAKE_VERSION macro
+ assert self.major < 1024 and self.minor < 1024
+ assert self.patch is None or self.patch < 4096
+ assert(str(self) == string)
+
+ def __str__(self):
+ ver_list = [str(self.major), str(self.minor)]
+ if self.patch is not None:
+ ver_list.append(str(self.patch))
+ return '.'.join(ver_list)
+
+ def __int_ver(self):
+ # This is just an expansion of VK_VERSION
+ patch = self.patch if self.patch is not None else 0
+ return (self.major << 22) | (self.minor << 12) | patch
+
+ def __cmp__(self, other):
+ # If only one of them has a patch version, "ignore" it by making
+ # other's patch version match self.
+ if (self.patch is None) != (other.patch is None):
+ other = copy.copy(other)
+ other.patch = self.patch
+
+ return self.__int_ver().__cmp__(other.__int_ver())
+
+MAX_API_VERSION = VkVersion(MAX_API_VERSION)
+
def _init_exts_from_xml(xml):
""" Walk the Vulkan XML and fill out extra extension information. """