From 4bf330471b3f71257833df75c4bad537f81c8480 Mon Sep 17 00:00:00 2001 From: Amol Surati <90980-asurati@users.noreply.gitlab.freedesktop.org> Date: Thu, 13 Jun 2024 06:47:20 +0530 Subject: [PATCH] nine: avoid using post-compacted indices with state expecting pre-compacted ones The commit 973e6f3b implemented compaction of the stream-number space. The functions `update_vertex_elements(_sw)` began using the post-compacted stream-numbers/indices when maintaining the `stream_usage_mask` and when reading from the arrays `vtxstride` and `stream_freq`. But, the `stream_instancedata_mask`, with which the `stream_usage_mask` is compared/bitwise-anded, maintains bits for the pre-compacted indices. Additionally, the information within the arrays is stored using the pre-compacted indices. The functions have a disagreement, regarding the type (pre- vs post- compacted) of indices, with the rest of the relevant source. This change removes the disagreement by having them use pre-compacted indices when maintaining the `stream_usage_mask` and when reading from the arrays. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11283 Fixes: 973e6f3b ("gallium: remove start_slot parameter from pipe_context::set_vertex_buffers") Reviewed-by: Axel Davy Part-of: --- src/gallium/frontends/nine/nine_state.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gallium/frontends/nine/nine_state.c b/src/gallium/frontends/nine/nine_state.c index 3aaff661eb3..8b8e1a992c0 100644 --- a/src/gallium/frontends/nine/nine_state.c +++ b/src/gallium/frontends/nine/nine_state.c @@ -901,9 +901,8 @@ update_vertex_elements(struct NineDevice9 *device) index = vdecl_index_map[n]; if (index >= 0) { ve.velems[n] = vdecl->elems[index]; - ve.velems[n].vertex_buffer_index = - vtxbuf_holes_map[ve.velems[n].vertex_buffer_index]; b = ve.velems[n].vertex_buffer_index; + ve.velems[n].vertex_buffer_index = vtxbuf_holes_map[b]; ve.velems[n].src_stride = context->vtxstride[b]; context->stream_usage_mask |= 1 << b; /* XXX wine just uses 1 here: */ @@ -3173,9 +3172,8 @@ update_vertex_elements_sw(struct NineDevice9 *device) index = vdecl_index_map[n]; if (index >= 0) { ve.velems[n] = vdecl->elems[index]; - ve.velems[n].vertex_buffer_index = - vtxbuf_holes_map[ve.velems[n].vertex_buffer_index]; b = ve.velems[n].vertex_buffer_index; + ve.velems[n].vertex_buffer_index = vtxbuf_holes_map[b]; /* XXX wine just uses 1 here: */ if (state->stream_freq[b] & D3DSTREAMSOURCE_INSTANCEDATA) ve.velems[n].instance_divisor = state->stream_freq[b] & 0x7FFFFF;