[Mesa-dev] [PATCH 13/16] st/nine: Rework update_vertex_buffers
Ilia Mirkin
imirkin at alum.mit.edu
Fri Apr 24 14:48:21 PDT 2015
On Fri, Apr 24, 2015 at 4:09 PM, Axel Davy <axel.davy at ens.fr> wrote:
> Previous code was trying to optimise to call set_vertex_buffers on
> big packets, and thus avoids as many calls as possible.
>
> However in practice doing so won't be faster (drivers implement
> set_vertex_buffers by a loop over the buffers we want to bind)
>
> When we want to unbind a buffer, we were calling set_vertex_buffers
> on a buffer with vtxbuf->buffer = NULL. It works on some drivers,
> but not on all of them, because it isn't in Gallium spec.
> This patch fixes that.
>
> Signed-off-by: Axel Davy <axel.davy at ens.fr>
> ---
> src/gallium/state_trackers/nine/nine_state.c | 15 ++++-----------
> 1 file changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
> index 27800c6..6e01955 100644
> --- a/src/gallium/state_trackers/nine/nine_state.c
> +++ b/src/gallium/state_trackers/nine/nine_state.c
> @@ -631,7 +631,6 @@ update_vertex_buffers(struct NineDevice9 *device)
> uint32_t mask = state->changed.vtxbuf;
> unsigned i;
> unsigned start;
> - unsigned count = 0;
>
> DBG("mask=%x\n", mask);
>
> @@ -650,18 +649,12 @@ update_vertex_buffers(struct NineDevice9 *device)
>
> for (i = 0; mask; mask >>= 1, ++i) {
FWIW, not sure if it's faster, but you could do like
while (mask) {
i = ffs(mask) - 1;
...
mask &= ~(1 << i);
}
In practice, if all the bits tend to be consecutive starting at 0,
this will probably even be slower.
Either way, this is
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
> if (mask & 1) {
> - if (!count)
> - start = i;
> - ++count;
> - } else {
> - if (count)
> - pipe->set_vertex_buffers(pipe, start, count,
> - &state->vtxbuf[start]);
> - count = 0;
> + if (state->vtxbuf[i].buffer)
> + pipe->set_vertex_buffers(pipe, i, 1, &state->vtxbuf[i]);
> + else
> + pipe->set_vertex_buffers(pipe, i, 1, NULL);
> }
> }
> - if (count)
> - pipe->set_vertex_buffers(pipe, start, count, &state->vtxbuf[start]);
>
> state->changed.vtxbuf = 0;
> }
> --
> 2.1.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list