lavapipe: Fix DGC vertex buffer handling

Fixes: 976dd26 ("lavapipe: NV_device_generated_commands")
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27019>
(cherry picked from commit 6d88c1bb6c)
This commit is contained in:
Konstantin Seurer 2024-01-11 09:32:42 +01:00 committed by Eric Engestrom
parent 13b0648cc5
commit 596cfa4424
2 changed files with 12 additions and 4 deletions

View file

@ -1164,7 +1164,7 @@
"description": "lavapipe: Fix DGC vertex buffer handling",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "976dd26004ff6b52e14c031398edae840ded005a",
"notes": null

View file

@ -3857,7 +3857,7 @@ process_sequence(struct rendering_state *state,
}
case VK_INDIRECT_COMMANDS_TOKEN_TYPE_VERTEX_BUFFER_NV: {
VkBindVertexBufferIndirectCommandNV *data = input;
cmd_size += sizeof(*cmd->u.bind_vertex_buffers.buffers) + sizeof(*cmd->u.bind_vertex_buffers.offsets);
cmd_size += sizeof(*cmd->u.bind_vertex_buffers2.buffers) + sizeof(*cmd->u.bind_vertex_buffers2.offsets);
cmd_size += sizeof(*cmd->u.bind_vertex_buffers2.sizes) + sizeof(*cmd->u.bind_vertex_buffers2.strides);
if (max_size < size + cmd_size)
abort();
@ -3866,12 +3866,20 @@ process_sequence(struct rendering_state *state,
cmd->u.bind_vertex_buffers2.binding_count = 1;
cmd->u.bind_vertex_buffers2.buffers = (void*)cmdptr;
cmd->u.bind_vertex_buffers2.offsets = (void*)(cmdptr + sizeof(*cmd->u.bind_vertex_buffers2.buffers));
uint32_t alloc_offset = sizeof(*cmd->u.bind_vertex_buffers2.buffers);
cmd->u.bind_vertex_buffers2.offsets = (void*)(cmdptr + alloc_offset);
alloc_offset += sizeof(*cmd->u.bind_vertex_buffers2.offsets);
cmd->u.bind_vertex_buffers2.sizes = (void*)(cmdptr + alloc_offset);
alloc_offset += sizeof(*cmd->u.bind_vertex_buffers2.sizes);
cmd->u.bind_vertex_buffers2.offsets[0] = 0;
cmd->u.bind_vertex_buffers2.buffers[0] = data->bufferAddress ? get_buffer(state, (void*)(uintptr_t)data->bufferAddress, (size_t*)&cmd->u.bind_vertex_buffers2.offsets[0]) : VK_NULL_HANDLE;
cmd->u.bind_vertex_buffers2.sizes[0] = data->size;
if (token->vertexDynamicStride) {
cmd->u.bind_vertex_buffers2.strides = (void*)(cmdptr + sizeof(*cmd->u.bind_vertex_buffers2.buffers) + sizeof(*cmd->u.bind_vertex_buffers2.offsets) + sizeof(*cmd->u.bind_vertex_buffers2.sizes));
cmd->u.bind_vertex_buffers2.strides = (void*)(cmdptr + alloc_offset);
cmd->u.bind_vertex_buffers2.strides[0] = data->stride;
} else {
cmd->u.bind_vertex_buffers2.strides = NULL;