From 87a6029ccf531d5d7400664d89ca2356760f87ec Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 3 Oct 2013 12:32:12 +0200 Subject: [PATCH] u_vbuf: use single vertex buffer if it's not possible to have multiple MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Put CONST, VERTEX and INSTANCE attributes into one vertex buffer if necessary due to hardware constraints. Signed-off-by: Wladimir J. van der Laan Signed-off-by: Paul Cercueil Reviewed-by: Marek Olšák Part-of: --- src/gallium/auxiliary/util/u_vbuf.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c index 8e67cd965f8..f0a21f43648 100644 --- a/src/gallium/auxiliary/util/u_vbuf.c +++ b/src/gallium/auxiliary/util/u_vbuf.c @@ -541,16 +541,24 @@ u_vbuf_translate_find_free_vb_slots(struct u_vbuf *mgr, uint32_t unused_vb_mask = mgr->ve->incompatible_vb_mask_all | mgr->incompatible_vb_mask | ~mgr->enabled_vb_mask; + uint32_t unused_vb_mask_orig; + boolean insufficient_buffers = false; + + /* No vertex buffers available at all */ + if (!unused_vb_mask) + return FALSE; memset(fallback_vbs, ~0, sizeof(fallback_vbs)); /* Find free slots for each type if needed. */ + unused_vb_mask_orig = unused_vb_mask; for (type = 0; type < VB_NUM; type++) { if (mask[type]) { uint32_t index; if (!unused_vb_mask) { - return FALSE; + insufficient_buffers = true; + break; } index = ffs(unused_vb_mask) - 1; @@ -560,6 +568,17 @@ u_vbuf_translate_find_free_vb_slots(struct u_vbuf *mgr, } } + if (insufficient_buffers) { + /* not enough vbs for all types supported by the hardware, they will have to share one + * buffer */ + 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; + mask[VB_VERTEX] = mask[VB_VERTEX] | mask[VB_CONST] | mask[VB_INSTANCE]; + mask[VB_CONST] = 0; + mask[VB_INSTANCE] = 0; + } + for (type = 0; type < VB_NUM; type++) { if (mask[type]) { mgr->dirty_real_vb_mask |= 1 << fallback_vbs[type]; -- 2.30.2