[Mesa-dev] [RFC 6/7] xa: move surface to ref/unref api

Rob Clark robdclark at gmail.com
Tue May 28 09:24:23 PDT 2013


On Tue, May 28, 2013 at 11:56 AM, Brian Paul <brianp at vmware.com> wrote:
> On 05/28/2013 08:13 AM, Rob Clark wrote:
>>
>> From: Jerome Glisse <jglisse at redhat.com>
>>
>> This make ddx life easier.
>>
>> Signed-off-by: Jerome Glisse <jglisse at redhat.com>
>> ---
>>   src/gallium/state_trackers/xa/xa_priv.h    |  1 +
>>   src/gallium/state_trackers/xa/xa_tracker.c | 19 +++++++++++++++++--
>>   src/gallium/state_trackers/xa/xa_tracker.h |  3 ++-
>>   3 files changed, 20 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/gallium/state_trackers/xa/xa_priv.h
>> b/src/gallium/state_trackers/xa/xa_priv.h
>> index 2ab11b8..ee182e7 100644
>> --- a/src/gallium/state_trackers/xa/xa_priv.h
>> +++ b/src/gallium/state_trackers/xa/xa_priv.h
>> @@ -59,6 +59,7 @@ struct xa_format_descriptor {
>>   };
>>
>>   struct xa_surface {
>> +    int refcount;
>>       struct pipe_resource template;
>>       struct xa_tracker *xa;
>>       struct pipe_resource *tex;
>> diff --git a/src/gallium/state_trackers/xa/xa_tracker.c
>> b/src/gallium/state_trackers/xa/xa_tracker.c
>> index 945ed36..6ce711cb 100644
>> --- a/src/gallium/state_trackers/xa/xa_tracker.c
>> +++ b/src/gallium/state_trackers/xa/xa_tracker.c
>> @@ -328,6 +328,7 @@ surface_create(struct xa_tracker *xa,
>>       if (!srf->tex)
>>         goto out_no_tex;
>>
>> +    srf->refcount = 1;
>>       srf->xa = xa;
>>       srf->flags = flags;
>>       srf->fdesc = fdesc;
>> @@ -451,11 +452,25 @@ xa_surface_redefine(struct xa_surface *srf,
>>       return XA_ERR_NONE;
>>   }
>>
>> -XA_EXPORT void
>> -xa_surface_destroy(struct xa_surface *srf)
>> +XA_EXPORT struct xa_surface*
>> +xa_surface_ref(struct xa_surface *srf)
>> +{
>> +    if (srf == NULL) {
>> +       return NULL;
>> +    }
>> +    srf->refcount++;
>> +    return srf;
>> +}
>> +
>> +XA_EXPORT struct xa_surface*
>> +xa_surface_unref(struct xa_surface *srf)
>>   {
>> +    if (srf == NULL || --srf->refcount) {
>> +       return NULL;
>> +    }
>>       pipe_resource_reference(&srf->tex, NULL);
>>       free(srf);
>> +    return NULL;
>>   }
>
>
> Looks like this function always returns NULL.  Can it be void?
>

yeah, probably should be void

BR,
-R

>
>>
>>   XA_EXPORT void
>> diff --git a/src/gallium/state_trackers/xa/xa_tracker.h
>> b/src/gallium/state_trackers/xa/xa_tracker.h
>> index 4d2452e..a06edd9 100644
>> --- a/src/gallium/state_trackers/xa/xa_tracker.h
>> +++ b/src/gallium/state_trackers/xa/xa_tracker.h
>> @@ -176,7 +176,8 @@ extern struct xa_surface *
>> xa_surface_from_handle(struct xa_tracker *xa,
>>
>>   enum xa_formats xa_surface_format(const struct xa_surface *srf);
>>
>> -extern void xa_surface_destroy(struct xa_surface *srf);
>> +extern struct xa_surface *xa_surface_ref(struct xa_surface *srf);
>> +extern struct xa_surface *xa_surface_unref(struct xa_surface *srf);
>>
>>   extern int xa_surface_redefine(struct xa_surface *srf,
>>                                int width,
>>
>


More information about the mesa-dev mailing list