<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jun 30, 2017 at 4:31 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="">On Fri, Jun 30, 2017 at 4:25 PM, Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br>
> On June 30, 2017 3:28:51 PM Connor Abbott <<a href="mailto:cwabbott0@gmail.com">cwabbott0@gmail.com</a>> wrote:<br>
><br>
>> Now, that we're handling the pointers explicitly, can't we delete the<br>
>> code in vtn_ssa_value()<br>
>> to implicitly load pointers? I'd expect to see that in this patch.<br>
><br>
><br>
> Almost.  It's still used to implement some glsl.450 functions which take a<br>
> variable rather than an SSA vale as an input.  I'm happy to fix those up or<br>
> at least to move the hack to glsl_450 but it'll have to be a separate patch.<br>
<br>
</span>Ok... at least you should change the comment there that says "This is<br>
needed for function parameters" though. And making those cases aware<br>
of pointers vs. SSA would be nice. It would probably make the code<br>
less confusing too, since it would match the spec.<br><div class="HOEnZb"><div class="h5"></div></div></blockquote><div><br></div><div>I've sent a 17.5/18 which fixes the problem so it can be deleted in this one.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
><br>
><br>
>> On Thu, Jun 29, 2017 at 10:33 AM, Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br>
>> wrote:<br>
>>><br>
>>> Now that we have proper pointer types, we can be more sensible about the<br>
>>> way we set up function arguments and deal with the two cases of pointer<br>
>>> vs. SSA parameters distinctly.<br>
>>> ---<br>
>>>  src/compiler/spirv/vtn_cfg.c | 62<br>
>>> +++++++++++++++++++++++++-----<wbr>--------------<br>
>>>  1 file changed, 35 insertions(+), 27 deletions(-)<br>
>>><br>
>>> diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c<br>
>>> index 83e77e2..f53572b 100644<br>
>>> --- a/src/compiler/spirv/vtn_cfg.c<br>
>>> +++ b/src/compiler/spirv/vtn_cfg.c<br>
>>> @@ -65,6 +65,7 @@ vtn_cfg_handle_prepass_<wbr>instruction(struct vtn_builder<br>
>>> *b, SpvOp opcode,<br>
>>>        func->return_type = func_type->return_type->type;<br>
>>><br>
>>>        b->func->impl = nir_function_impl_create(func)<wbr>;<br>
>>> +      b->nb.cursor = nir_before_cf_list(&b->func-><wbr>impl->body);<br>
>>><br>
>>>        b->func_param_idx = 0;<br>
>>>        break;<br>
>>> @@ -77,43 +78,50 @@ vtn_cfg_handle_prepass_<wbr>instruction(struct vtn_builder<br>
>>> *b, SpvOp opcode,<br>
>>><br>
>>>     case SpvOpFunctionParameter: {<br>
>>>        struct vtn_type *type = vtn_value(b, w[1],<br>
>>> vtn_value_type_type)->type;<br>
>>> -      if (type->base_type == vtn_base_type_pointer) {<br>
>>> -         type = type->deref;<br>
>>> -         assert(type->base_type != vtn_base_type_pointer);<br>
>>> -      }<br>
>>><br>
>>>        assert(b->func_param_idx < b->func->impl->num_params);<br>
>>>        nir_variable *param = b->func->impl->params[b->func_<wbr>param_idx++];<br>
>>><br>
>>> -      assert(type->type == param->type);<br>
>>> +      if (type->base_type == vtn_base_type_pointer) {<br>
>>> +         struct vtn_variable *vtn_var = rzalloc(b, struct vtn_variable);<br>
>>> +         vtn_var->type = type->deref;<br>
>>> +         vtn_var->var = param;<br>
>>> +<br>
>>> +         assert(vtn_var->type->type == param->type);<br>
>>> +<br>
>>> +         struct vtn_type *without_array = vtn_var->type;<br>
>>> +         while(glsl_type_is_array(<wbr>without_array->type))<br>
>>> +            without_array = without_array->array_element;<br>
>>> +<br>
>>> +         if (glsl_type_is_image(without_<wbr>array->type)) {<br>
>>> +            vtn_var->mode = vtn_variable_mode_image;<br>
>>> +            param->interface_type = without_array->type;<br>
>>> +         } else if (glsl_type_is_sampler(without_<wbr>array->type)) {<br>
>>> +            vtn_var->mode = vtn_variable_mode_sampler;<br>
>>> +            param->interface_type = without_array->type;<br>
>>> +         } else {<br>
>>> +            vtn_var->mode = vtn_variable_mode_param;<br>
>>> +         }<br>
>>><br>
>>> -      struct vtn_variable *vtn_var = rzalloc(b, struct vtn_variable);<br>
>>> -      vtn_var->type = type;<br>
>>> -      vtn_var->var = param;<br>
>>> +         struct vtn_value *val =<br>
>>> +            vtn_push_value(b, w[2], vtn_value_type_pointer);<br>
>>><br>
>>> -      struct vtn_type *without_array = type;<br>
>>> -      while(glsl_type_is_array(<wbr>without_array->type))<br>
>>> -         without_array = without_array->array_element;<br>
>>> +         /* Name the parameter so it shows up nicely in NIR */<br>
>>> +         param->name = ralloc_strdup(param, val->name);<br>
>>><br>
>>> -      if (glsl_type_is_image(without_<wbr>array->type)) {<br>
>>> -         vtn_var->mode = vtn_variable_mode_image;<br>
>>> -         param->interface_type = without_array->type;<br>
>>> -      } else if (glsl_type_is_sampler(without_<wbr>array->type)) {<br>
>>> -         vtn_var->mode = vtn_variable_mode_sampler;<br>
>>> -         param->interface_type = without_array->type;<br>
>>> +         val->pointer = rzalloc(b, struct vtn_pointer);<br>
>>> +         val->pointer->mode = vtn_var->mode;<br>
>>> +         val->pointer->type = type;<br>
>>> +         val->pointer->var = vtn_var;<br>
>>>        } else {<br>
>>> -         vtn_var->mode = vtn_variable_mode_param;<br>
>>> -      }<br>
>>> +         /* We're a regular SSA value. */<br>
>>> +         struct vtn_value *val = vtn_push_value(b, w[2],<br>
>>> vtn_value_type_ssa);<br>
>>><br>
>>> -      struct vtn_value *val = vtn_push_value(b, w[2],<br>
>>> vtn_value_type_pointer);<br>
>>> +         /* Name the parameter so it shows up nicely in NIR */<br>
>>> +         param->name = ralloc_strdup(param, val->name);<br>
>>><br>
>>> -      /* Name the parameter so it shows up nicely in NIR */<br>
>>> -      param->name = ralloc_strdup(param, val->name);<br>
>>> -<br>
>>> -      val->pointer = rzalloc(b, struct vtn_pointer);<br>
>>> -      val->pointer->mode = vtn_var->mode;<br>
>>> -      val->pointer->type = type;<br>
>>> -      val->pointer->var = vtn_var;<br>
>>> +         val->ssa = vtn_local_load(b, nir_deref_var_create(b, param));<br>
>>> +      }<br>
>>>        break;<br>
>>>     }<br>
>>><br>
>>> --<br>
>>> 2.5.0.400.gff86faf<br>
>>><br>
>>> ______________________________<wbr>_________________<br>
>>> mesa-dev mailing list<br>
>>> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
>>> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
><br>
><br>
><br>
</div></div></blockquote></div><br></div></div>