[Mesa-dev] [PATCH 13/42] radeonsi: use a bitmask for tracking dirty atoms
Grazvydas Ignotas
notasas at gmail.com
Sun Aug 30 14:28:20 PDT 2015
On Sun, Aug 30, 2015 at 10:11 PM, Marek Olšák <maraeo at gmail.com> wrote:
...
> diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c
> index 2ff58d1..81575b5 100644
> --- a/src/gallium/drivers/radeonsi/si_state_draw.c
> +++ b/src/gallium/drivers/radeonsi/si_state_draw.c
> @@ -729,7 +729,7 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
> {
> struct si_context *sctx = (struct si_context *)ctx;
> struct pipe_index_buffer ib = {};
> - unsigned i;
> + unsigned mask;
>
> if (!info->count && !info->indirect &&
> (info->indexed || !info->count_from_stream_output))
> @@ -821,12 +821,13 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
> si_need_cs_space(sctx, 0, TRUE);
>
> /* Emit states. */
> - for (i = 0; i < SI_NUM_ATOMS; i++) {
> - if (sctx->atoms.array[i]->dirty) {
> - sctx->atoms.array[i]->emit(&sctx->b, sctx->atoms.array[i]);
> - sctx->atoms.array[i]->dirty = false;
> - }
> + mask = sctx->dirty_atoms;
> + while (mask) {
> + struct r600_atom *atom = sctx->atoms.array[u_bit_scan(&mask)];
> +
> + atom->emit(&sctx->b, atom);
> }
> + sctx->dirty_atoms = 0;
It looks like sctx->atoms.array[i]->dirty is never cleared? Maybe we
should get rid of it then?
I wonder if multiple threads can end up touching the atoms? If so, we
might need to use atomic bit set/clear (__sync_or_and_fetch(), etc)
and something to read+clear sctx->dirty_atoms atomically above (xchg
instruction, not sure which helper in mesa could be used for this).
Gražvydas
More information about the mesa-dev
mailing list