[Mesa-dev] [PATCH 06/15] vulkan: util: add macros to extract extension/offset number from enums

Jason Ekstrand jason at jlekstrand.net
Tue Sep 19 18:58:27 UTC 2017


On Tue, Sep 19, 2017 at 7:21 AM, Lionel Landwerlin <
lionel.g.landwerlin at intel.com> wrote:

> On 15/09/17 22:34, Jason Ekstrand wrote:
>
> On Fri, Sep 15, 2017 at 7:10 AM, Lionel Landwerlin <
> lionel.g.landwerlin at intel.com> wrote:
>
>> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
>> ---
>>  src/vulkan/util/vk_util.h | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/src/vulkan/util/vk_util.h b/src/vulkan/util/vk_util.h
>> index 2ed601f881e..a152984d14d 100644
>> --- a/src/vulkan/util/vk_util.h
>> +++ b/src/vulkan/util/vk_util.h
>> @@ -199,4 +199,11 @@ __vk_find_struct(void *start, VkStructureType sType)
>>
>>  uint32_t vk_get_driver_version(void);
>>
>> +#define VK_EXT_OFFSET (1000000000UL)
>> +#define vk_enum_extension(__enum) \
>> +   ((__enum) >= VK_EXT_OFFSET ? ((((__enum) - VK_EXT_OFFSET) / 1000UL) +
>> 1) : 0)
>> +#define vk_enum_offset(__enum) \
>> +   ((__enum) >= VK_EXT_OFFSET ? \
>> +    ((__enum) - VK_EXT_OFFSET - ((vk_enum_extension(__enum) - 1) *
>> 1000)) : (__enum))
>>
>
> Can't this just be ((__enum) >= VK_EXT_OFFSET ? ((__enum) % 1000) : 0)
>
>
> Duh! Even __enum % 1000..
>

I'd like to allow for an enum that grows to > 1000 in core.  I doubt we'll
see an extension with > 1000 enums. :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170919/8858eff3/attachment.html>


More information about the mesa-dev mailing list