[Mesa-dev] [PATCH] i965: Shrink stage_prog_data param array length

Jason Ekstrand jason at jlekstrand.net
Mon May 30 20:12:49 UTC 2016


On Mon, May 30, 2016 at 9:50 AM, Emil Velikov <emil.l.velikov at gmail.com>
wrote:

> On 29 May 2016 at 07:01, Jordan Justen <jordan.l.justen at intel.com> wrote:
> > It appears we were over-allocating these arrays.
> >
> > Previously we would use nir->num_uniforms directly for scalar
> > programs, and multiply it by 4 for vec4 programs.
> >
> > Instead we should have been dividing by 4 in both cases to convert
> > from bytes to a gl_constant_value count. The size of gl_constant_value
> > is 4 bytes.
> >
> > Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> > ---
> >  Jenkins results looked good with this change.
> >
> >  src/mesa/drivers/dri/i965/brw_cs.c  | 2 +-
> >  src/mesa/drivers/dri/i965/brw_gs.c  | 4 +---
> >  src/mesa/drivers/dri/i965/brw_tcs.c | 4 +---
> >  src/mesa/drivers/dri/i965/brw_tes.c | 4 +---
> >  src/mesa/drivers/dri/i965/brw_vs.c  | 4 +---
> >  src/mesa/drivers/dri/i965/brw_wm.c  | 2 +-
> >  6 files changed, 6 insertions(+), 14 deletions(-)
> >
> > diff --git a/src/mesa/drivers/dri/i965/brw_cs.c
> b/src/mesa/drivers/dri/i965/brw_cs.c
> > index 0ab9ebd..a9cbde9 100644
> > --- a/src/mesa/drivers/dri/i965/brw_cs.c
> > +++ b/src/mesa/drivers/dri/i965/brw_cs.c
> > @@ -91,7 +91,7 @@ brw_codegen_cs_prog(struct brw_context *brw,
> >      * prog_data associated with the compiled program, and which will be
> freed
> >      * by the state cache.
> >      */
> > -   int param_count = cp->program.Base.nir->num_uniforms;
> > +   int param_count = cp->program.Base.nir->num_uniforms / 4;
> >
> Shouldn't one use sizeof(union gl_constant_value) over the hardcoded 4 ?
>

Yes and no.  The fact that gl_constant_value is 4 bytes is very tightly
intertwined with the rest of the code.  if gl_constant_value ever became 8
bytes it's very questionable as to whether or not we would want this to
change automatically.

--Jason


>
> -Emil
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160530/c66cc624/attachment.html>


More information about the mesa-dev mailing list