From 1c6f85cdd99554bb54736473f82b68e81cec0b2a Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Fri, 12 Mar 2021 04:52:42 -0700 Subject: [PATCH] nv2a: Round inline array attr offsets to natural boundary --- hw/xbox/nv2a/pgraph.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/hw/xbox/nv2a/pgraph.c b/hw/xbox/nv2a/pgraph.c index 0d4c3b70ff..8d12d4593d 100644 --- a/hw/xbox/nv2a/pgraph.c +++ b/hw/xbox/nv2a/pgraph.c @@ -5863,18 +5863,22 @@ static unsigned int pgraph_bind_inline_array(NV2AState *d) unsigned int offset = 0; for (i=0; ivertex_attributes[i]; - if (attribute->count) { - attribute->inline_array_offset = offset; - - NV2A_DPRINTF("bind inline attribute %d size=%d, count=%d\n", - i, attribute->size, attribute->count); - offset += attribute->size * attribute->count; - assert(offset % 4 == 0); + if (attribute->count == 0) { + continue; } + + /* FIXME: Double check */ + offset = ROUND_UP(offset, attribute->size); + attribute->inline_array_offset = offset; + NV2A_DPRINTF("bind inline attribute %d size=%d, count=%d\n", + i, attribute->size, attribute->count); + offset += attribute->size * attribute->count; + offset = ROUND_UP(offset, attribute->size); } unsigned int vertex_size = offset; unsigned int index_count = pg->inline_array_length*4 / vertex_size; + assert((index_count*vertex_size) == (pg->inline_array_length*4)); NV2A_DPRINTF("draw inline array %d, %d\n", vertex_size, index_count);