vulkan,lavapipe: Simplify command recording code-gen

The Entrypoint class already has utilities for gettingt he parameter
list as either declarations or as comma-separated argument names for a
call.  Use that instead of hand-rolling it.  The only modification we
need to make is to add the ability to start the list somewhere other
than at the beginning.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14919>
This commit is contained in:
Jason Ekstrand 2022-02-07 17:52:25 -06:00 committed by Marge Bot
parent cb781fc350
commit 4c61c8a0b8
2 changed files with 11 additions and 15 deletions

View File

@ -68,20 +68,16 @@ TEMPLATE_C = Template(COPYRIGHT + """
% if c.guard is not None: % if c.guard is not None:
#ifdef ${c.guard} #ifdef ${c.guard}
% endif % endif
VKAPI_ATTR ${c.return_type} VKAPI_CALL lvp_${c.name} (VkCommandBuffer commandBuffer VKAPI_ATTR ${c.return_type} VKAPI_CALL lvp_${c.name}(${c.decl_params()})
% for p in c.params[1:]:
, ${p.decl}
% endfor
)
{ {
LVP_FROM_HANDLE(lvp_cmd_buffer, cmd_buffer, commandBuffer); LVP_FROM_HANDLE(lvp_cmd_buffer, cmd_buffer, commandBuffer);
vk_enqueue_${to_underscore(c.name)}(&cmd_buffer->queue % if len(c.params) == 1:
% for p in c.params[1:]: vk_enqueue_${to_underscore(c.name)}(&cmd_buffer->queue);
, ${p.name} % else:
% endfor vk_enqueue_${to_underscore(c.name)}(&cmd_buffer->queue,
); ${c.call_params(start=1)});
% endif
% if c.return_type == 'VkResult': % if c.return_type == 'VkResult':
return VK_SUCCESS; return VK_SUCCESS;
% endif % endif

View File

@ -59,11 +59,11 @@ class Entrypoint(EntrypointBase):
def is_device_entrypoint(self): def is_device_entrypoint(self):
return self.params[0].type in ('VkDevice', 'VkCommandBuffer', 'VkQueue') return self.params[0].type in ('VkDevice', 'VkCommandBuffer', 'VkQueue')
def decl_params(self): def decl_params(self, start=0):
return ', '.join(p.decl for p in self.params) return ', '.join(p.decl for p in self.params[start:])
def call_params(self): def call_params(self, start=0):
return ', '.join(p.name for p in self.params) return ', '.join(p.name for p in self.params[start:])
class EntrypointAlias(EntrypointBase): class EntrypointAlias(EntrypointBase):
def __init__(self, name, entrypoint): def __init__(self, name, entrypoint):