Skip to content
Snippets Groups Projects
Commit ad5fe81c authored by Pierre-Eric Pelloux-Prayer's avatar Pierre-Eric Pelloux-Prayer Committed by Eric Engestrom
Browse files

vbo/dlist: fix loopback crash

The original code incorrectly adjusted only when Loopback
was false, while primitives' start value is actually
modified unconditionnally.

Fixes: 32535942 ("vbo/dlist: rework buffer sizes")
Closes: mesa/mesa#5754


Acked-by: default avatarMarek Olšák <marek.olsak@amd.com>
Part-of: <mesa/mesa!14243>
(cherry picked from commit 7a1d3d3a)
parent 72a680be
No related branches found
No related tags found
Loading
......@@ -1831,7 +1831,7 @@
"description": "vbo/dlist: fix loopback crash",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "3253594268028efdca17cb9d2b2e423b353c8aa5"
},
......
......@@ -813,12 +813,14 @@ compile_vertex_list(struct gl_context *ctx)
free(temp_vertices_buffer);
}
/* Since we're append the indices to an existing buffer, we need to adjust the start value of each
/* Since we append the indices to an existing buffer, we need to adjust the start value of each
* primitive (not the indices themselves). */
save->current_bo_bytes_used += align(save->current_bo_bytes_used, 4) - save->current_bo_bytes_used;
int indices_offset = save->current_bo_bytes_used / 4;
for (int i = 0; i < merged_prim_count; i++) {
merged_prims[i].start += indices_offset;
if (!ctx->ListState.Current.UseLoopback) {
save->current_bo_bytes_used += align(save->current_bo_bytes_used, 4) - save->current_bo_bytes_used;
int indices_offset = save->current_bo_bytes_used / 4;
for (int i = 0; i < merged_prim_count; i++) {
merged_prims[i].start += indices_offset;
}
}
/* Then upload the indices. */
......@@ -933,20 +935,16 @@ end:
_glapi_set_dispatch(ctx->Exec);
/* _vbo_loopback_vertex_list doesn't use the index buffer, so we have to
* use buffer_in_ram instead of current_bo which contains all vertices instead
* of the deduplicated vertices only in the !UseLoopback case.
* use buffer_in_ram (which contains all vertices) instead of current_bo
* (which contains deduplicated vertices *when* UseLoopback is false).
*
* The problem is that the VAO offset is based on current_bo's layout,
* so we have to use a temp value.
*/
struct gl_vertex_array_object *vao = node->VAO[VP_MODE_SHADER];
GLintptr original = vao->BufferBinding[0].Offset;
if (!ctx->ListState.Current.UseLoopback) {
GLintptr new_offset = 0;
/* 'start_offset' has been added to all primitives 'start', so undo it here. */
new_offset -= start_offset * stride;
vao->BufferBinding[0].Offset = new_offset;
}
/* 'start_offset' has been added to all primitives 'start', so undo it here. */
vao->BufferBinding[0].Offset = -(GLintptr)(start_offset * stride);
_vbo_loopback_vertex_list(ctx, node, save->vertex_store->buffer_in_ram);
vao->BufferBinding[0].Offset = original;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment