summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2013-10-03 12:32:12 +0200
committerLucas Stach <l.stach@pengutronix.de>2014-07-28 12:33:38 +0200
commitd0af0ba20147007135635d1512675a238027daa4 (patch)
tree2afe37ac3b8f5ec2c7e8d4355a070499445ec2e3
parent05b3e518ff34a10bdb1c52f51bae529b9fb6bf97 (diff)
downloadmesa-d0af0ba20147007135635d1512675a238027daa4.tar.gz
mesa-d0af0ba20147007135635d1512675a238027daa4.tar.xz
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.
-rw-r--r--src/gallium/auxiliary/util/u_vbuf.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c
index 49cc6683d7..799ff24d4c 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -177,7 +177,6 @@ struct u_vbuf {
/* The vertex buffer slot index where translated vertices have been
* stored in. */
unsigned fallback_vbs[VB_NUM];
-
/* Which buffer is a user buffer. */
uint32_t user_vb_mask; /* each bit describes a corresp. buffer */
/* Which buffer is incompatible (unaligned). */
@@ -476,24 +475,44 @@ 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 | extra_free_vb_mask) & mgr->allowed_vb_mask;
+ uint32_t unused_vb_mask_temp;
+ 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_temp = unused_vb_mask;
for (type = 0; type < VB_NUM; type++) {
if (mask[type]) {
uint32_t index;
- if (!unused_vb_mask) {
- return FALSE;
+ if (!unused_vb_mask_temp) {
+ insufficient_buffers = true;
+ break;
}
- index = ffs(unused_vb_mask) - 1;
+ index = ffs(unused_vb_mask_temp) - 1;
fallback_vbs[type] = index;
/*printf("found slot=%i for type=%i\n", index, type);*/
+ unused_vb_mask_temp &= ~(1<<index);
}
}
+ 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) - 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];