[Mesa-dev] Question about min_index/max_index calculation

Erico Nunes nunes.erico at gmail.com
Sat Mar 17 18:12:11 UTC 2018


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
decides to not calculate those. This happens because of
st_context.draw_needs_minmax_index being false after evaluating the
vertex data. In those cases, min_index gets to be 0 and max_index gets
to be 0xffffffff.
According to the gallium documentation, this seems to be on purpose
and apparently drivers should be able to handle the 0 and 0xffffffff
case and be able to render anyway. However, we haven't figured out a
way to do the render anyway with 0 and 0xffffffff.

For us it would be interesting to always have mesa calculate those
values for indexed drawing. We haven't been able to figure out a way
to do that without changing the mesa generic code. Is there some way
we could accomplish that in driver specific code?
Otherwise, can you provide some advice on how to best handle this?

Using mesa 17.3 and kmscube with the following patch is one way to
reproduce st_context.draw_needs_minmax_index not being set.
https://gist.githubusercontent.com/enunes/366398fbee3d194deb3a46ef9c2ca78d/raw/82a2c8084236e35635b7a247609213d0068974e3/kmscube.patch
The only way that this works for us with the current implementation is
by hacking st_context.draw_needs_minmax_index to be always true in
some way.

Thanks

Erico


More information about the mesa-dev mailing list