[Mesa-dev] [PATCH 1/4] r600g/compute: Don't leak cbufs in compute state

Marek Olšák maraeo at gmail.com
Mon Nov 17 10:09:25 PST 2014


Not sure if that's the right place, but this framebuffer state is set
by the driver and not a state tracker. Compute shader read-write
resources (buffers, images) are implemented by the CB block on r600
and are referred to as RAT (random access target) in the register
docs. The first 0-7 binding slots are shared with colorbuffers and the
8-11 slots are dedicated to compute resources only. For GL extensions
that add read-write buffers and images, the maximum number of
read-write resources is (12 - number_of_colorbuffers) and they are
only supported in the pixel shader.

This craziness doesn't exist on SI, instead, TC just can do stores there.

Marek

On Mon, Nov 17, 2014 at 8:45 AM, Michel Dänzer <michel at daenzer.net> wrote:
> On 14.11.2014 19:37, Marek Olšák wrote:
>> surface_destroy should never be called directly, because surfaces have
>> a reference counter. For unreferencing resources, use
>> pipe_surface_reference(&pointer, NULL). It will call surface_destroy
>> if needed.
>
> Indeed, if this was the right place for this, it could be done both
> easier and more robustly:
>
>                for (int i = 0; i < fb_state->nr_cbufs; i++)
>                        pipe_surface_reference(&fb_state->cbufs[i], NULL);
>
>
>> On Fri, Nov 14, 2014 at 12:43 AM, Aaron Watry <awatry at gmail.com> wrote:
>>> Walk the array of cbufs backwards and free all of them.
>>>
>>> v3: Rebase on top of changes since Aug 2014
>>>
>>> Signed-off-by: Aaron Watry <awatry at gmail.com>
>>> ---
>>>   src/gallium/drivers/r600/evergreen_compute.c | 9 +++++++++
>>>   1 file changed, 9 insertions(+)
>>>
>>> diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c
>>> index 90fdd79..4334743 100644
>>> --- a/src/gallium/drivers/r600/evergreen_compute.c
>>> +++ b/src/gallium/drivers/r600/evergreen_compute.c
>>> @@ -252,6 +252,15 @@ void evergreen_delete_compute_state(struct pipe_context *ctx, void* state)
>>>          if (!shader)
>>>                  return;
>>>
>>> +       if (shader->ctx){
>>> +               struct pipe_framebuffer_state *fb_state = &shader->ctx->framebuffer.state;
>>> +               for (int i = fb_state->nr_cbufs - 1; fb_state->nr_cbufs > 0 ; i--){
>>> +                       shader->ctx->b.b.surface_destroy(ctx, fb_state->cbufs[i]);
>>> +                       fb_state->cbufs[i] = NULL;
>>> +                       fb_state->nr_cbufs--;
>>> +               }
>>> +       }
>>> +
>>>          FREE(shader);
>>>   }
>>>
>>> --
>>> 2.1.0
>>>
>>> _______________________________________________
>>> mesa-dev mailing list
>>> mesa-dev at lists.freedesktop.org
>>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>>
>
>
> --
> Earthling Michel Dänzer            |                  http://www.amd.com
> Libre software enthusiast          |                Mesa and X developer


More information about the mesa-dev mailing list