From 021bc4f868308630df6f8311db3932046219d086 Mon Sep 17 00:00:00 2001 From: Ilia Mirkin Date: Fri, 5 Feb 2021 11:08:40 -0500 Subject: [PATCH] nv50,nvc0: clear internal vbo masks based on the trailing slots Fixes: 0278d1fa323c (gallium: add unbind_num_trailing_slots to set_vertex_buffers) Signed-off-by: Ilia Mirkin Reviewed-by: Karol Herbst Part-of: --- src/gallium/drivers/nouveau/nv50/nv50_state.c | 12 +++++++++--- src/gallium/drivers/nouveau/nvc0/nvc0_state.c | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/nouveau/nv50/nv50_state.c b/src/gallium/drivers/nouveau/nv50/nv50_state.c index ca2fe487b35..72f0a9aaceb 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_state.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_state.c @@ -1091,10 +1091,16 @@ nv50_set_vertex_buffers(struct pipe_context *pipe, unbind_num_trailing_slots, take_ownership); + unsigned clear_mask = ~u_bit_consecutive(start_slot + count, unbind_num_trailing_slots); + nv50->vbo_user &= clear_mask; + nv50->vbo_constant &= clear_mask; + nv50->vtxbufs_coherent &= clear_mask; + if (!vb) { - nv50->vbo_user &= ~(((1ull << count) - 1) << start_slot); - nv50->vbo_constant &= ~(((1ull << count) - 1) << start_slot); - nv50->vtxbufs_coherent &= ~(((1ull << count) - 1) << start_slot); + clear_mask = ~u_bit_consecutive(start_slot, count); + nv50->vbo_user &= clear_mask; + nv50->vbo_constant &= clear_mask; + nv50->vtxbufs_coherent &= clear_mask; return; } diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c index 452c7f072a5..9676016c5b7 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c @@ -1012,10 +1012,16 @@ nvc0_set_vertex_buffers(struct pipe_context *pipe, unbind_num_trailing_slots, take_ownership); + unsigned clear_mask = ~u_bit_consecutive(start_slot + count, unbind_num_trailing_slots); + nvc0->vbo_user &= clear_mask; + nvc0->constant_vbos &= clear_mask; + nvc0->vtxbufs_coherent &= clear_mask; + if (!vb) { - nvc0->vbo_user &= ~(((1ull << count) - 1) << start_slot); - nvc0->constant_vbos &= ~(((1ull << count) - 1) << start_slot); - nvc0->vtxbufs_coherent &= ~(((1ull << count) - 1) << start_slot); + clear_mask = ~u_bit_consecutive(start_slot, count); + nvc0->vbo_user &= clear_mask; + nvc0->constant_vbos &= clear_mask; + nvc0->vtxbufs_coherent &= clear_mask; return; }