mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-28 16:50:10 +01:00
util: Extend vk_enum_to_str with bitmasks
vk_enum_to_str only generates literals for enums with type: @type="enum", but many enums have type: @type="bitmask" and were not taken into account here. Main changes: Empty enums are now always skipped For bitmasks skipped *MAX_ENUM value Signed-off-by: Illia Abernikhin <illia.abernikhin@globallogic.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8173 Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21146>
This commit is contained in:
parent
e29a964d02
commit
dea36fce6a
1 changed files with 38 additions and 0 deletions
|
|
@ -89,6 +89,29 @@ C_TEMPLATE = Template(textwrap.dedent(u"""\
|
|||
% endif
|
||||
%endfor
|
||||
|
||||
% for enum in bitmasks:
|
||||
|
||||
% if enum.guard:
|
||||
#ifdef ${enum.guard}
|
||||
% endif
|
||||
const char *
|
||||
vk_${enum.name[2:]}_to_str(${enum.name} input)
|
||||
{
|
||||
switch((int64_t)input) {
|
||||
% for v in sorted(enum.values.keys()):
|
||||
case ${v}:
|
||||
return "${enum.values[v]}";
|
||||
% endfor
|
||||
default:
|
||||
return "Unknown ${enum.name} value.";
|
||||
}
|
||||
}
|
||||
|
||||
% if enum.guard:
|
||||
#endif
|
||||
% endif
|
||||
%endfor
|
||||
|
||||
size_t vk_structure_type_size(const struct VkBaseInStructure *item)
|
||||
{
|
||||
switch((int)item->sType) {
|
||||
|
|
@ -149,6 +172,16 @@ H_TEMPLATE = Template(textwrap.dedent(u"""\
|
|||
% endif
|
||||
% endfor
|
||||
|
||||
% for enum in bitmasks:
|
||||
% if enum.guard:
|
||||
#ifdef ${enum.guard}
|
||||
% endif
|
||||
const char * vk_${enum.name[2:]}_to_str(${enum.name} input);
|
||||
% if enum.guard:
|
||||
#endif
|
||||
% endif
|
||||
% endfor
|
||||
|
||||
size_t vk_structure_type_size(const struct VkBaseInStructure *item);
|
||||
|
||||
const char * vk_ObjectType_to_ObjectName(VkObjectType type);
|
||||
|
|
@ -248,6 +281,8 @@ def CamelCase_to_SHOUT_CASE(s):
|
|||
return (s[:1] + re.sub(r'(?<![A-Z])([A-Z])', r'_\1', s[1:])).upper()
|
||||
|
||||
def compute_max_enum_name(s):
|
||||
if s == "VkSwapchainImageUsageFlagBitsANDROID":
|
||||
return "VK_SWAPCHAIN_IMAGE_USAGE_FLAG_BITS_MAX_ENUM"
|
||||
max_enum_name = CamelCase_to_SHOUT_CASE(s)
|
||||
last_prefix = max_enum_name.rsplit('_', 1)[-1]
|
||||
# Those special prefixes need to be always at the end
|
||||
|
|
@ -465,6 +500,9 @@ def parse_xml(enum_factory, ext_factory, struct_factory, bitmask_factory,
|
|||
enum = enum_factory.get(value.attrib['name'])
|
||||
if enum is not None:
|
||||
enum.set_guard(define)
|
||||
enum = bitmask_factory.get(value.attrib['name'])
|
||||
if enum is not None:
|
||||
enum.set_guard(define)
|
||||
|
||||
obj_type_enum = enum_factory.get("VkObjectType")
|
||||
obj_types = obj_type_factory("VkObjectType")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue