vulkan/cmd_queue: Do not generate unreachable vk_free_* calls.

CID: 1503117
CID: 1503118
CID: 1503119
CID: 1503120
CID: 1503121
CID: 1503122
CID: 1503123
CID: 1503124
CID: 1503125
CID: 1503126
CID: 1503127
CID: 1503128
CID: 1503129
CID: 1503130
CID: 1503131
CID: 1503132
CID: 1503133
CID: 1503134
CID: 1503135
CID: 1503136
CID: 1503137
CID: 1503138
CID: 1503139
CID: 1503140
CID: 1503141
CID: 1503142
CID: 1503143
CID: 1503144
CID: 1503145
CID: 1503146
CID: 1503147
CID: 1503148
CID: 1503149
CID: 1503150
CID: 1503151
CID: 1503152
CID: 1503153
CID: 1503154
CID: 1503155
CID: 1503156
CID: 1503157
CID: 1503158
CID: 1503159
CID: 1503160
CID: 1503161
CID: 1503162
CID: 1503163
CID: 1503164
CID: 1503165
CID: 1503166
CID: 1503167
CID: 1503168
CID: 1503169
CID: 1503170
CID: 1503171
CID: 1503172
CID: 1503173
CID: 1503174
CID: 1503175
CID: 1503176
CID: 1503177
CID: 1503178
CID: 1503179
CID: 1503180
CID: 1503181
CID: 1503182
CID: 1503183
CID: 1503184
CID: 1503185
CID: 1503186
CID: 1503187
CID: 1503188
CID: 1503189
CID: 1503190

Signed-off-by: Kostiantyn Lazukin <kostiantyn.lazukin@globallogic.com>
Signed-off-by: Oleksii Bozhenko <oleksii.bozhenko@globallogic.com>

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15549>
This commit is contained in:
Kostiantyn Lazukin 2022-03-24 00:52:22 +02:00 committed by Marge Bot
parent d689ef7482
commit 31675fc766

View file

@ -248,22 +248,25 @@ void vk_enqueue_${to_underscore(c.name)}(struct vk_cmd_queue *queue
struct vk_cmd_queue_entry *cmd = vk_zalloc(queue->alloc,
sizeof(*cmd), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!cmd) goto err;
if (!cmd) { queue->error = VK_ERROR_OUT_OF_HOST_MEMORY; return; }
cmd->type = ${to_enum_name(c.name)};
\
<% need_error_handling = False %>
% for p in c.params[1:]:
% if p.len:
if (${p.name}) {
${get_array_copy(c, p)}
}
}\
<% need_error_handling = True %>
% elif '[' in p.decl:
memcpy(cmd->u.${to_struct_field_name(c.name)}.${to_field_name(p.name)}, ${p.name},
sizeof(*${p.name}) * ${get_array_len(p)});
% elif p.type == "void":
cmd->u.${to_struct_field_name(c.name)}.${to_field_name(p.name)} = (${remove_suffix(p.decl.replace("const", ""), p.name)}) ${p.name};
% elif '*' in p.decl:
${get_struct_copy("cmd->u.%s.%s" % (to_struct_field_name(c.name), to_field_name(p.name)), p.name, p.type, 'sizeof(%s)' % p.type, types)}
${get_struct_copy("cmd->u.%s.%s" % (to_struct_field_name(c.name), to_field_name(p.name)), p.name, p.type, 'sizeof(%s)' % p.type, types)}\
<% need_error_handling = True %>
% else:
cmd->u.${to_struct_field_name(c.name)}.${to_field_name(p.name)} = ${p.name};
% endif
@ -272,10 +275,12 @@ void vk_enqueue_${to_underscore(c.name)}(struct vk_cmd_queue *queue
list_addtail(&cmd->cmd_link, &queue->cmds);
return;
% if need_error_handling:
err:
queue->error = VK_ERROR_OUT_OF_HOST_MEMORY;
if (cmd)
vk_free_${to_underscore(c.name)}(queue, cmd);
% endif
}
% endif
% if c.guard is not None: