[Mesa-dev] [PATCH] compiler/glsl: Fix uniform location counting.
Manolova, Plamena
plamena.manolova at intel.com
Thu Feb 11 18:05:23 UTC 2016
Thanks, this if-statement looks tidier the way you suggested. I'll update
the patch.
On Thu, Feb 11, 2016 at 7:13 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> On Thu, Feb 11, 2016 at 11:31 AM, Plamena Manolova
> <plamena.manolova at intel.com> wrote:
> > + struct empty_uniform_block *current_block = NULL;
> > + unsigned prev_location = -1;
> > +
> > + for (unsigned i = 0; i < prog->NumUniformRemapTable; i++) {
> > + /* We found empty space in UniformRemapTable. */
> > + if (prog->UniformRemapTable[i] == NULL) {
> > + /* We've found the beginning of new continous block of empty
> slots */
> > + if ((i == 0) || !current_block || (i != prev_location + 1)) {
>
> You could delete prev_location entirely and transform this into
>
> if (!current_block || current_block->start + current_block->slots != i)
>
> > + current_block = ralloc(NULL, struct empty_uniform_block);
> > + current_block->start = i;
> > + current_block->slots = 1;
>
> And depending on how clever you want to get, you could change the
> above to rzalloc, not touch slots here, and drop the continue. Then
> the slots++ will magically increment it to 1. Up to you if you find
> this more or less readable though, I don't have a strong preference
> either way.
>
> > + list_addtail(¤t_block->link,
> &prog->EmptyUniformLocations);
> > + prev_location = i;
> > + continue;
> > + }
> > +
> > + /* The current block continues, so we simply increment its
> slots */
> > + current_block->slots++;
> > + prev_location = i;
> > + }
> > }
> ---------------------------------------------------------------------
> Intel Corporation (UK) Limited
> Registered No. 1134945 (England)
> Registered Office: Pipers Way, Swindon SN3 1RJ
> VAT No: 860 2173 47
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160211/49202cb3/attachment-0001.html>
More information about the mesa-dev
mailing list