From: Michel Dänzer <michel.daen...@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") v2: * Add comment above pipe_resource_next_reference [Samuel Pitoiset] Signed-off-by: Michel Dänzer <michel.daen...@amd.com> --- src/gallium/auxiliary/util/u_inlines.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index 6a3d5043cf..30df1acd46 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -129,6 +129,19 @@ pipe_surface_release(struct pipe_context *pipe, struct pipe_surface **ptr) *ptr = NULL; } +/* The purpose of this function is to avoid recursion in pipe_resource_reference, + * which would prevent it from being inlined. + */ +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)) + old_tex->screen->resource_destroy(old_tex->screen, old_tex); + *ptr = tex; +} static inline void pipe_resource_reference(struct pipe_resource **ptr, struct pipe_resource *tex) @@ -137,7 +150,7 @@ pipe_resource_reference(struct pipe_resource **ptr, struct pipe_resource *tex) if (pipe_reference_described(&(*ptr)->reference, &tex->reference, (debug_reference_descriptor)debug_describe_resource)) { - pipe_resource_reference(&old_tex->next, NULL); + pipe_resource_next_reference(&old_tex->next, NULL); old_tex->screen->resource_destroy(old_tex->screen, old_tex); } *ptr = tex; -- 2.11.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev