diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2021-01-14 15:45:20 -0800 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2021-01-20 00:29:04 +0000 |
commit | bd6120f562d57e150aa2071f9108f538858311a6 (patch) | |
tree | c6b10d847c4f406677a07658cd1d0b74695c4488 /src/mesa/tnl/t_draw.c | |
parent | 14ae5069da896cc93953e935051a76884800cac9 (diff) |
tnl: Try not to botch index buffer munging when start > 0.
Commit 4c751ad67aa2bbde5897030495f86e31c9e1fda7 (vbo/dlist: use a shared
index buffer) caused multiple draws to use the same index buffer, and
began setting the primitive's `start` field to the offset needed to
access the right portion of the index buffer.
Unfortunately, t_rebase_prims completely botches handling this case.
Say for example we had start = 40, min_index = 6, max_index = 11.
The actual indexes in the buffer are ib[40..45]. t_rebase_prims,
however, would allocate an index buffer containing only 6 elements,
and populate them with <ib[0..5] - min_index>. For one, this reads
the wrong source data, leading to garbage index values. For another,
it stores the new index buffer in the wrong spot, so drawing will try
and read elements [40..45] of an array of length 6, and crash.
This patch makes t_rebase_prims allocate a larger index buffer, with
the blank space at the beginning, and try to copy the correct section
of index buffer data over. This only works if `start` is the same for
all primitives, however, so if we detect different ones, we recurse
to rebase and call draw() separately for each different start value.
Fixes: 4c751ad67aa ("vbo/dlist: use a shared index buffer")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4082
Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8522>
Diffstat (limited to 'src/mesa/tnl/t_draw.c')
0 files changed, 0 insertions, 0 deletions