<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 9, 2015 at 4:38 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"><span class="">>>>> +      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 lower<br>
>>> copies involving things that aren't indirectly referenced, but if you 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 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 seen<br>
>> this happen in the wild so It's untested.  I'll try and cook something up<br>
>> that I think is reliable.<br>
><br>
><br>
> Ok, more info.  Right now, GLSL IR is lowering all truely indirect 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 need<br>
> this.  Until then, let's leave it as-is to reduce the ammount of untested<br>
> code.<br>
> --Jason<br>
<br>
</span>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></blockquote><div><br></div><div>It appears to lower locals as well.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<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></blockquote><div><br></div><div>I think we have a lot of dead code... <br></div></div><br></div></div>