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:
#ifdef ${c.guard}
% endif
VKAPI_ATTR ${c.return_type} VKAPI_CALL lvp_${c.name} (VkCommandBuffer commandBuffer
% for p in c.params[1:]:
, ${p.decl}
% endfor
)
VKAPI_ATTR ${c.return_type} VKAPI_CALL lvp_${c.name}(${c.decl_params()})
{
LVP_FROM_HANDLE(lvp_cmd_buffer, cmd_buffer, commandBuffer);
vk_enqueue_${to_underscore(c.name)}(&cmd_buffer->queue
% for p in c.params[1:]:
, ${p.name}
% endfor
);
% if len(c.params) == 1:
vk_enqueue_${to_underscore(c.name)}(&cmd_buffer->queue);
% else:
vk_enqueue_${to_underscore(c.name)}(&cmd_buffer->queue,
${c.call_params(start=1)});
% endif
% if c.return_type == 'VkResult':
return VK_SUCCESS;
% endif

View File

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