<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 14, 2015 at 1:10 PM, Connor Abbott <span dir="ltr"><<a href="mailto:cwabbott0@gmail.com" target="_blank">cwabbott0@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Fri, Jan 9, 2015 at 8:27 PM, Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br>
><br>
><br>
> On Fri, Jan 9, 2015 at 4:38 PM, Connor Abbott <<a href="mailto:cwabbott0@gmail.com">cwabbott0@gmail.com</a>> wrote:<br>
>><br>
>> >>>> +      case nir_intrinsic_copy_var:<br>
>> >>>> +         unreachable("There should be no copies whatsoever at this<br>
>> >>>> point");<br>
>> >>>> +         break;<br>
>> >>><br>
>> >>><br>
>> >>> Are you sure about this? My impression is that lower_variables will<br>
>> >>> lower<br>
>> >>> copies involving things that aren't indirectly referenced, but if you<br>
>> >>> have<br>
>> >>> something like:<br>
>> >>><br>
>> >>> foo[i] = ...<br>
>> >>> bar[*] = foo[*];<br>
>> >>> ... = bar[i];<br>
>> >>><br>
>> >>> then the copy in the middle won't get lowered, unless there's<br>
>> >>> something<br>
>> >>> else I'm missing that will lower it.<br>
>> >><br>
>> >><br>
>> >> Yeah, there may be something missing there.  I have a pass lying around<br>
>> >> somewhere that lowers all copies.  Unfortunately, I've never actually<br>
>> >> seen<br>
>> >> this happen in the wild so It's untested.  I'll try and cook something<br>
>> >> up<br>
>> >> that I think is reliable.<br>
>> ><br>
>> ><br>
>> > Ok, more info.  Right now, GLSL IR is lowering all truely indirect<br>
>> > accesses<br>
>> > to if-ladders right now so we can never hit this.  Once we can handle<br>
>> > indirects in the backends or generate the if-ladders in NIR, we will<br>
>> > need<br>
>> > this.  Until then, let's leave it as-is to reduce the ammount of<br>
>> > untested<br>
>> > code.<br>
>> > --Jason<br>
>><br>
>> Huh, that's weird... it lowers input/output indirect accesses to<br>
>> if-ladders, but not temporary indirect references, right? So wouldn't<br>
>> something like:<br>
><br>
><br>
> It appears to lower locals as well.<br>
><br>
>><br>
>><br>
>> uniform int i;<br>
>> uniform bool f; /* false */<br>
>> in vec4 in_array[20];<br>
>> out vec4 color;<br>
>><br>
>> void main()<br>
>> {<br>
>>    vec4 foo[20], bar[20], temp[20];<br>
>>    foo = in_array;<br>
>>    foo[i] = 0.0f;<br>
>>    while (f) {<br>
>>       temp = foo;<br>
>>       temp[i] = 1.0f;<br>
>>       foo = bar;<br>
>>       bar = temp;<br>
>>    }<br>
>>    bar[i] = 2.0f;<br>
>>    color = bar[0];<br>
>> }<br>
>><br>
>> where GLSL IR can't eliminate the copies and doesn't turn the indirect<br>
>> references into if-ladders, and we can't lower them to SSA values,<br>
>> trigger the bug? If GLSL did turn everything into if-ladders, then<br>
>> this entire pass as well as half of lower_variables would be dead<br>
>> code...<br>
><br>
><br>
> I think we have a lot of dead code...<br>
><br>
<br>
</div></div>That's for sure! I thought about this a little more, and while you may<br>
not like it, I think we should still have the code to lower the<br>
remaining wildcard copies, even if it's dead code for now. Right now,<br>
I'd say more than half of the variable lowering code is currently<br>
dead, so I'm not so swayed by the "but it's more dead code!" argument<br>
-- we already have a *lot* of dead code, so let's at least fix a known<br>
bug in it rather than making it even more confusing. I think that the<br>
only way it would make sense to not go all the way is if we stripped<br>
out everything else, but that doesn't make that much sense after I<br>
went through all this work to review it all.<br>
</blockquote></div><br></div><div class="gmail_extra">Agreed.  I'll put a pass together.  It shouldn't take me long.<br></div></div>