<html><head></head><body><div>On Sun, 2016-01-17 at 15:20 -0800, Jason Ekstrand wrote:</div><blockquote type="cite"><p dir="ltr"><br>
On Jan 17, 2016 2:45 PM, "Timothy Arceri" <<a href="mailto:t_arceri@yahoo.com.au">t_arceri@yahoo.com.au</a>> wrote:<br>
><br>
> On Mon, 2016-01-18 at 09:34 +1100, Timothy Arceri wrote:<br>
> > On Sun, 2016-01-17 at 08:27 -0800, Jason Ekstrand wrote:<br>
> > ><br>
> > > On Jan 16, 2016 9:15 PM, "Timothy Arceri" <<br>
> > > <a href="mailto:timothy.arceri@collabora.com">timothy.arceri@collabora.com</a>> wrote:<br>
> > > ><br>
> > > > From Section 7.9 (SUBROUTINE UNIFORM VARIABLES) of the OpenGL<br>
> > > > 4.5 Core spec:<br>
> > > ><br>
> > > > "The command<br>
> > > ><br>
> > > > void UniformSubroutinesuiv(enum shadertype, sizei count,<br>
> > > > const uint *indices);<br>
> > > ><br>
> > > > will load all active subroutine uniforms for shader stage<br>
> > > > shadertype with subroutine indices from indices, storing<br>
> > > > indices[i] into the uniform at location i. The indices for<br>
> > > > any locations between zero and the value of<br>
> > > > ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS minus one which are not<br>
> > > > used will be ignored."<br>
> > > ><br>
> > > > Cc: "11.0 11.1" <a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.freedesktop.org</a><br>
> > > > <a href="https://bugs.freedesktop.org/show_bug.cgi?id=93731">https://bugs.freedesktop.org/show_bug.cgi?id=93731</a><br>
> > > > ---<br>
> > > > src/mesa/main/shaderapi.c | 14 ++++++++++++++<br>
> > > > 1 file changed, 14 insertions(+)<br>
> > > ><br>
> > > > diff --git a/src/mesa/main/shaderapi.c<br>
> > > > b/src/mesa/main/shaderapi.c<br>
> > > > index cdc85f3..918c5f9 100644<br>
> > > > --- a/src/mesa/main/shaderapi.c<br>
> > > > +++ b/src/mesa/main/shaderapi.c<br>
> > > > @@ -2530,6 +2530,13 @@ _mesa_UniformSubroutinesuiv(GLenum<br>
> > > shadertype, GLsizei count,<br>
> > > > i = 0;<br>
> > > > do {<br>
> > > > struct gl_uniform_storage *uni = sh<br>
> > > ->SubroutineUniformRemapTable[i];<br>
> > > > + if (uni == NULL) {<br>
> > > > + if (++i < count)<br>
> > > > + continue;<br>
> > > > + else<br>
> > > > + break;<br>
> > > Just<br>
> > > i++;<br>
> > > continue;<br>
> > > Will do the same thing and without repeating the looping condition<br>
> > > or<br>
> > > making the user think about pre- vs. post-increment. I guess it<br>
> > > does<br>
> > > make them think about continues in a do-while, but you can't win<br>
> > > everything. :-)<br>
> ><br>
> > I don't feel great about imple+ if (uni == NULL) {> > > +<br>
> > if (++i < count)> > > + continue;> > > + else> ><br>
> > > + break;menting the possibility of an infinite<br>
> > loop. Sure the code above should work but this stuff doesn't really<br>
> > have extensive tests.<br>
> ><br>
> > What about at the very least:<br>
> ><br>
> > i++;<br>
> > assert(i < count);<br>
> > continue;<br>
><br>
> Actually no that wouldn't work, the spec makes it legal to attempt to<br>
> set inactive locations there is no guarantee that any of the locations<br>
> secified by the user are active in which case your suggestion would<br>
> send them into an infinite loop.</p></blockquote><div><br></div><blockquote type="cite">
<p dir="ltr">No, it wouldn't. What I suggested is identical to what you had before. A continue in a do-while loop jumps to the branching condition, not the top of the loop. The fact that you repeat the branching condition is redundant.</p></blockquote><div><br></div><div>My concern was that it could be possible for the last element of SubroutineUniformRemapTable to be NULL, however looking over the uniform linking code that doesn't seem possible. </div><div><br></div><blockquote type="cite">
<p dir="ltr">> If it makes people happy I'll just change this to:<br>
><br>
> if (uni == NULL) {<br>
> i++;<br>
> if (i < count)<br>
> continue;<br>
> else<br>
> break;<br>
> }<br>
><br>
> Which is what I had originally but IMO it just look ugly.<br>
><br>
> ><br>
> ><br>
> ><br>
> > > > + }<br>
> > > > +<br>
> > > > int uni_count = uni->array_elements ? uni->array_elements<br>
> > > > :<br>
> > > 1;<br>
> > > > int j, k;<br>
> > > ><br>
> > > > @@ -2557,6 +2564,13 @@ _mesa_UniformSubroutinesuiv(GLenum<br>
> > > shadertype, GLsizei count,<br>
> > > > i = 0;<br>
> > > > do {<br>
> > > > struct gl_uniform_storage *uni = sh<br>
> > > ->SubroutineUniformRemapTable[i];<br>
> > > > + if (uni == NULL) {<br>
> > > > + if (++i < count)<br>
> > > > + continue;<br>
> > > > + else<br>
> > > > + break;<br>
> > > > + }<br>
> > > > +<br>
> > > > int uni_count = uni->array_elements ? uni->array_elements<br>
> > > > :<br>
> > > 1;<br>
> > > ><br>
> > > > memcpy(&uni->storage[0], &indices[i],<br>
> > > > --<br>
> > > > 2.4.3<br>
> > > ><br>
> > > > _______________________________________________<br>
> > > > mesa-dev mailing list<br>
> > > > <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> > > > <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
> > > _______________________________________________<br>
> > > mesa-dev mailing list<br>
> > > <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> > > <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
> > _______________________________________________<br>
> > mesa-dev mailing list<br>
> > <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> > <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</p>
</blockquote></body></html>