[Mesa-dev] [PATCH 1/4] vulkan: Add central copy of entrypoints/extensions code.

Chad Versace chadversary at chromium.org
Thu Aug 9 17:49:47 UTC 2018


On Wed 08 Aug 2018, Bas Nieuwenhuizen wrote:
> ---
>  src/vulkan/Makefile.am                |   3 +
>  src/vulkan/util/meson.build           |   2 +
>  src/vulkan/util/vk_entrypoints_gen.py | 515 ++++++++++++++++++++++++++
>  src/vulkan/util/vk_extensions.py      |  92 +++++
>  src/vulkan/util/vk_extensions_gen.py  | 205 ++++++++++
>  5 files changed, 817 insertions(+)
>  create mode 100644 src/vulkan/util/vk_entrypoints_gen.py
>  create mode 100644 src/vulkan/util/vk_extensions.py
>  create mode 100644 src/vulkan/util/vk_extensions_gen.py


> +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 c_vk_version(self):
> +        patch = self.patch if self.patch is not None else 0
> +        ver_list = [str(self.major), str(self.minor), str(patch)]
> +        return 'VK_MAKE_VERSION(' + ', '.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):

Patch 3 replaces __cmp__ here with __gt__. Was that on purpose?

> +        # 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())


More information about the mesa-dev mailing list