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

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Thu Aug 9 23:06:52 UTC 2018


On Thu, Aug 9, 2018 at 7:49 PM, Chad Versace <chadversary at chromium.org> wrote:
> 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?

No, a rebase error, the __cmp__ here effectively reverts an upstream
patch in the copied file, but my fixup ended up in the wrong patch.

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