freedreno/a6xx: Set index buffer size to bo size
authorKristian H. Kristensen <hoegsberg@google.com>
Tue, 16 Jun 2020 18:39:07 +0000 (11:39 -0700)
committerMarge Bot <eric+marge@anholt.net>
Fri, 19 Jun 2020 19:25:34 +0000 (19:25 +0000)
The number of vertices may be out of bound and if we use it for
computing index buffer size we may get too big a size.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5552>

src/gallium/drivers/freedreno/a6xx/fd6_draw.c

index 0279b2ee872cec04012fd914934b539a2e226d4d..f8b87b76f1391c2fc864605e29b09c91753455da 100644 (file)
@@ -82,7 +82,7 @@ draw_emit(struct fd_ringbuffer *ring,
                assert(!info->has_user_indices);
 
                struct pipe_resource *idx_buffer = info->index.resource;
-               uint32_t idx_size = info->index_size * info->count;
+               uint32_t idx_size = idx_buffer->width0 - index_offset;
                uint32_t idx_offset = index_offset + info->start * info->index_size;
 
                OUT_PKT(ring, CP_DRAW_INDX_OFFSET,