diff options
author | Marek Olšák <[email protected]> | 2020-03-11 19:28:44 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-03-17 19:13:57 +0000 |
commit | e4959add2f44517b2227521af5aaf2919aaa6c3b (patch) | |
tree | 4e9ddf58aac2f20e7646a98fe7150d7ea61519bb /src | |
parent | 99a29a20d2e7b931c5ee6478665f0784eca2c0d8 (diff) |
gallium/u_vbuf: simplify the first if statement in u_vbuf_upload_buffers
Acked-by: Alyssa Rosenzweig <[email protected]>
Reviewed-by: Mathias Fröhlich <[email protected]>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4153>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4153>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/auxiliary/util/u_vbuf.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c index f88c92dd6ac..f47d93ac3f1 100644 --- a/src/gallium/auxiliary/util/u_vbuf.c +++ b/src/gallium/auxiliary/util/u_vbuf.c @@ -174,6 +174,7 @@ struct u_vbuf { /* The vertex buffer slot index where translated vertices have been * stored in. */ unsigned fallback_vbs[VB_NUM]; + unsigned fallback_vbs_mask; /* Which buffer is a user buffer. */ uint32_t user_vb_mask; /* each bit describes a corresp. buffer */ @@ -556,6 +557,7 @@ u_vbuf_translate_find_free_vb_slots(struct u_vbuf *mgr, return FALSE; memset(fallback_vbs, ~0, sizeof(fallback_vbs)); + mgr->fallback_vbs_mask = 0; /* Find free slots for each type if needed. */ unused_vb_mask_orig = unused_vb_mask; @@ -570,6 +572,7 @@ u_vbuf_translate_find_free_vb_slots(struct u_vbuf *mgr, index = ffs(unused_vb_mask) - 1; fallback_vbs[type] = index; + mgr->fallback_vbs_mask |= 1 << index; unused_vb_mask &= ~(1 << index); /*printf("found slot=%i for type=%i\n", index, type);*/ } @@ -581,6 +584,7 @@ u_vbuf_translate_find_free_vb_slots(struct u_vbuf *mgr, uint32_t index = ffs(unused_vb_mask_orig) - 1; /* When sharing one vertex buffer use per-vertex frequency for everything. */ fallback_vbs[VB_VERTEX] = index; + mgr->fallback_vbs_mask = 1 << index; mask[VB_VERTEX] = mask[VB_VERTEX] | mask[VB_CONST] | mask[VB_INSTANCE]; mask[VB_CONST] = 0; mask[VB_INSTANCE] = 0; @@ -763,11 +767,11 @@ static void u_vbuf_translate_end(struct u_vbuf *mgr) if (vb != ~0u) { pipe_resource_reference(&mgr->real_vertex_buffer[vb].buffer.resource, NULL); mgr->fallback_vbs[i] = ~0; - - /* This will cause the buffer to be unbound in the driver later. */ - mgr->dirty_real_vb_mask |= 1 << vb; } } + /* This will cause the buffer to be unbound in the driver later. */ + mgr->dirty_real_vb_mask |= mgr->fallback_vbs_mask; + mgr->fallback_vbs_mask = 0; } static void * @@ -966,9 +970,7 @@ u_vbuf_upload_buffers(struct u_vbuf *mgr, unsigned instance_div, first, size, index_bit; /* Skip the buffers generated by translate. */ - if (index == mgr->fallback_vbs[VB_VERTEX] || - index == mgr->fallback_vbs[VB_INSTANCE] || - index == mgr->fallback_vbs[VB_CONST]) { + if ((1 << index) & mgr->fallback_vbs_mask) { continue; } |