vc4: Compute max_index instead of trusting the rest of userspace.
authorEric Anholt <eric@anholt.net>
Tue, 12 Aug 2014 22:01:30 +0000 (15:01 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 25 Sep 2014 03:51:15 +0000 (20:51 -0700)
commita04605a8ca55ee2ea3a1509bff2d8ff37e0a8477
tree06e9c73770ee5e2f87cf2b8afb1d5c19c5d41773
parent61cb08ab4fb7bf9266d6c6e70f3fb8cc4b9bb00c
vc4: Compute max_index instead of trusting the rest of userspace.

max_index was coming from either the user telling us as part of
glDrawRangeElements, or from an incidental calculation as part of some
sort of primitive conversion fallback.  Sometimes, it was just set to the
default "I don't know" ~0 value.

If it wasn't set to the actual max index, then the kernel would reject the
draw call for allowing out-of-bounds VBO reads.  So, compute the max index
from the sizes of the VBOs, which isn't too expensive (unlike mapping and
reading the index buffer) and is reliable.

Fixes piglit vao-element-array-buffer.
src/gallium/drivers/vc4/vc4_draw.c