From: Marek Olšák Date: Wed, 11 Mar 2020 23:28:44 +0000 (-0400) Subject: gallium/u_vbuf: simplify the first if statement in u_vbuf_upload_buffers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e4959add2f44517b2227521af5aaf2919aaa6c3b;p=mesa.git gallium/u_vbuf: simplify the first if statement in u_vbuf_upload_buffers Acked-by: Alyssa Rosenzweig Reviewed-by: Mathias Fröhlich Tested-by: Marge Bot Part-of: --- 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; }