u_vbuf: use single vertex buffer if it's not possible to have multiple

Put CONST, VERTEX and INSTANCE attributes into one vertex buffer if
necessary due to hardware constraints.

Signed-off-by: Wladimir J. van der Laan <laanwj@gmail.com>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2807>
This commit is contained in:
Wladimir J. van der Laan 2013-10-03 12:32:12 +02:00 committed by Marge Bot
parent 18a8c3f7f1
commit 87a6029ccf
1 changed files with 20 additions and 1 deletions

View File

@ -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];