[Mesa-dev] Question about min_index/max_index calculation

Ilia Mirkin imirkin at alum.mit.edu
Sat Mar 17 18:23:20 UTC 2018


On Sat, Mar 17, 2018 at 2:12 PM, Erico Nunes <nunes.erico at gmail.com> wrote:
> Hi all,
>
> I have been working to add indexed drawing/glDrawElements support to
> the mesa-lima driver currently in development
> (https://github.com/yuq/mesa-lima).
> For that implementation, it seems that we need to have the minimum and
> maximum index values from the index buffer available in order to set
> up a proper command stream.
> Mesa provides these values in pipe_draw_info.min_index and
> pipe_draw_info.max_index, however in some cases we noticed that it

Do you truly need these? Or would approximate values do?

For an approximation, you can use the sizes of the bound vbo's to
guess a min/max index. See
https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/vc4/vc4_draw.c#n183
for an example.

You can also scan through the index buffer yourself, although it's
obviously slow. There are helpers like u_vbuf_get_minmax_index (esp if
you're using the u_vbuf module). I don't know of any hardware that
really needs these to be exact though.

  -ilia


More information about the mesa-dev mailing list