nv50,nvc0: clear internal vbo masks based on the trailing slots
authorIlia Mirkin <imirkin@alum.mit.edu>
Fri, 5 Feb 2021 16:08:40 +0000 (11:08 -0500)
committerMarge Bot <eric+marge@anholt.net>
Fri, 5 Feb 2021 21:37:51 +0000 (21:37 +0000)
Fixes: 0278d1fa323c (gallium: add unbind_num_trailing_slots to set_vertex_buffers)
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8882>

src/gallium/drivers/nouveau/nv50/nv50_state.c
src/gallium/drivers/nouveau/nvc0/nvc0_state.c

index ca2fe487b35442284ffacca0b10f62ce19154130..72f0a9aaceb1d48c1e89fcc9de68321960043732 100644 (file)
@@ -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;
    }
 
index 452c7f072a53e34b5bea85b452f57385b7e025b1..9676016c5b7741d916d8dacdfc2b037fb4a34a51 100644 (file)
@@ -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;
     }