vulkan/cmd_queue: Generate enqueue_if_not_primary entrypoints

These check the command buffer level and enqueue the command if it's not
a primary but uses vk_device::command_dispatch_table for primaries.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14406>
This commit is contained in:
Jason Ekstrand 2022-03-09 14:47:29 -06:00 committed by Marge Bot
parent 8f29c833da
commit 3cffffc441
2 changed files with 17 additions and 1 deletions

View File

@ -120,7 +120,7 @@ vk_cmd_enqueue_entrypoints = custom_target(
command : [
prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
'--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@',
'--prefix', 'vk_cmd_enqueue',
'--prefix', 'vk_cmd_enqueue', '--prefix', 'vk_cmd_enqueue_unless_primary',
],
depend_files : vk_entrypoints_gen_depend_files,
)

View File

@ -192,6 +192,7 @@ TEMPLATE_C = Template(COPYRIGHT + """
#include "vk_cmd_enqueue_entrypoints.h"
#include "vk_command_buffer.h"
#include "vk_dispatch_table.h"
#include "vk_device.h"
const char *vk_cmd_queue_type_names[] = {
% for c in commands:
@ -331,6 +332,21 @@ vk_cmd_enqueue_${c.name}(${c.decl_params()})
${c.call_params(1)});
% endif
}
VKAPI_ATTR void VKAPI_CALL
vk_cmd_enqueue_unless_primary_${c.name}(${c.decl_params()})
{
VK_FROM_HANDLE(vk_command_buffer, cmd_buffer, commandBuffer);
if (cmd_buffer->level == VK_COMMAND_BUFFER_LEVEL_PRIMARY) {
const struct vk_device_dispatch_table *disp =
cmd_buffer->base.device->command_dispatch_table;
disp->${c.name}(${c.call_params()});
} else {
vk_cmd_enqueue_${c.name}(${c.call_params()});
}
}
% if c.guard is not None:
#endif // ${c.guard}
% endif