[Mesa-dev] [PATCH] gallium/util: Allow pipe_resource_reference to be inlined again

Marek Olšák maraeo at gmail.com
Tue Jun 13 22:40:36 UTC 2017


On Tue, Jun 13, 2017 at 1:08 PM, Gustaw Smolarczyk <wielkiegie at gmail.com> wrote:
> 2017-06-13 12:07 GMT+02:00 Michel Dänzer <michel at daenzer.net>:
>> On 13/06/17 06:51 PM, Timothy Arceri wrote:
>>> On 13/06/17 19:22, Michel Dänzer wrote:
>>>> From: Michel Dänzer <michel.daenzer at amd.com>
>>>>
>>>> It calling itself recursively prevented it from being inlined, resulting
>>>> in a copy being generated in every compilation unit referencing it. This
>>>> bloated the text segment of the Gallium mega-driver *_dri.so by ~5%,
>>>> and might also have impacted performance.
>>>>
>>>> Fixes: ecd6fce2611e ("mesa/st: support lowering multi-planar YUV")
>>>> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
>>>> ---
>>>>   src/gallium/auxiliary/util/u_inlines.h | 13 ++++++++++++-
>>>>   1 file changed, 12 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/src/gallium/auxiliary/util/u_inlines.h
>>>> b/src/gallium/auxiliary/util/u_inlines.h
>>>> index 6a3d5043cf..9a08779f2a 100644
>>>> --- a/src/gallium/auxiliary/util/u_inlines.h
>>>> +++ b/src/gallium/auxiliary/util/u_inlines.h
>>>> @@ -131,13 +131,24 @@ pipe_surface_release(struct pipe_context *pipe,
>>>> struct pipe_surface **ptr)
>>>>       static inline void
>>>> +pipe_resource_next_reference(struct pipe_resource **ptr, struct
>>>> pipe_resource *tex)
>>>> +{
>>>> +   struct pipe_resource *old_tex = *ptr;
>>>> +
>>>> +   if (pipe_reference_described(&(*ptr)->reference, &tex->reference,
>>>> +
>>>> (debug_reference_descriptor)debug_describe_resource))
>>>
>>> Why don't we need to call pipe_resource_next_reference(&old_tex->next,
>>> NULL) again here?
>>
>> Good catch, thanks. I'll work on a v3 patch fixing this tomorrow.
>>
>
> Hello,
>
> If pipe_resource_next_reference is not meant to be inlined, maybe put
> it in a source file?

If it's not meant to be inlined, the caller can check next != NULL
before calling it.

Marek


More information about the mesa-dev mailing list