[Mesa-dev] [PATCH 13/42] radeonsi: use a bitmask for tracking dirty atoms
Marek Olšák
maraeo at gmail.com
Sun Aug 30 15:04:19 PDT 2015
On Sun, Aug 30, 2015 at 11:28 PM, Grazvydas Ignotas <notasas at gmail.com> wrote:
> 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?
Yes, we can get rid of it.
>
> 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).
No, a context can only be used by one thread at a time. Same as OpenGL.
Marek
More information about the mesa-dev
mailing list