[Mesa-dev] [PATCH 15/18] swrast: Defer _tnl_vertex_init until first use

Kenneth Graunke kenneth at whitecape.org
Mon Jul 6 13:33:03 PDT 2015


On Monday, July 06, 2015 11:33:20 AM Chris Wilson wrote:
> The vertices require a large chunk of memory, currently allocated during
> context creation. However, this memory is not required until use so we
> can defer the allocation until the first swrast_Wakeup().
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/mesa/swrast_setup/ss_context.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c
> index 74b1da3..028eccb 100644
> --- a/src/mesa/swrast_setup/ss_context.c
> +++ b/src/mesa/swrast_setup/ss_context.c
> @@ -59,10 +59,6 @@ _swsetup_CreateContext( struct gl_context *ctx )
>     swsetup->NewState = ~0;
>     _swsetup_trifuncs_init( ctx );
>  
> -   _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, 
> -		       sizeof(SWvertex) );
> -
> -
>     return GL_TRUE;
>  }
>  
> @@ -233,6 +229,11 @@ _swsetup_Wakeup( struct gl_context *ctx )
>     TNLcontext *tnl = TNL_CONTEXT(ctx);
>     SScontext *swsetup = SWSETUP_CONTEXT(ctx);
>  
> +   if (!(GET_VERTEX_STATE(ctx))->max_vertex_size)
> +      _tnl_init_vertices(ctx,
> +			 ctx->Const.MaxArrayLockSize + 12,
> +			 sizeof(SWvertex));
> +
>     tnl->Driver.Render.Start = _swsetup_RenderStart;
>     tnl->Driver.Render.Finish = _swsetup_RenderFinish;
>     tnl->Driver.Render.PrimitiveNotify = _swsetup_RenderPrimitive;
> 

Looks reasonable - this saves 2.59MB of memory in Piglit's glsl-cos
test.  (It's worth noting that in the commit message.)

I wonder if we can do better though by avoiding most of the
swrast context entirely...

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150706/b39c06e6/attachment.sig>


More information about the mesa-dev mailing list