<div dir="ltr"><div>Acked-by: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>></div><div><br></div><div>Marek<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 22, 2019 at 12:35 AM Timothy Arceri <<a href="mailto:tarceri@itsqueeze.com">tarceri@itsqueeze.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This fixes the arb_gpu_shader5 interpolateAt* tests that contain<br>
structs.<br>
---<br>
<br>
 Extra piglit tests for structs:<br>
<br>
 <a href="https://patchwork.freedesktop.org/patch/279466/" rel="noreferrer" target="_blank">https://patchwork.freedesktop.org/patch/279466/</a><br>
<br>
 src/amd/common/ac_nir_to_llvm.c | 25 +++++++++++++------------<br>
 1 file changed, 13 insertions(+), 12 deletions(-)<br>
<br>
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c<br>
index 161a8b2c34..ea0da850f2 100644<br>
--- a/src/amd/common/ac_nir_to_llvm.c<br>
+++ b/src/amd/common/ac_nir_to_llvm.c<br>
@@ -2924,12 +2924,10 @@ static LLVMValueRef visit_interp(struct ac_nir_context *ctx,<br>
<br>
        }<br>
<br>
-       LLVMValueRef array_idx = ctx->ac.i32_0;<br>
+       LLVMValueRef attrib_idx = ctx->ac.i32_0;<br>
        while(deref_instr->deref_type != nir_deref_type_var) {<br>
                if (deref_instr->deref_type == nir_deref_type_array) {<br>
-                       unsigned array_size = glsl_get_aoa_size(deref_instr->type);<br>
-                       if (!array_size)<br>
-                               array_size = 1;<br>
+                       unsigned array_size = glsl_count_attribute_slots(deref_instr->type, false);<br>
<br>
                        LLVMValueRef offset;<br>
                        nir_const_value *const_value = nir_src_as_const_value(deref_instr->arr.index);<br>
@@ -2942,23 +2940,26 @@ static LLVMValueRef visit_interp(struct ac_nir_context *ctx,<br>
                                                      LLVMConstInt(ctx->ac.i32, array_size, false), "");<br>
                        }<br>
<br>
-                       array_idx = LLVMBuildAdd(ctx->ac.builder, array_idx, offset, "");<br>
+                       attrib_idx = LLVMBuildAdd(ctx->ac.builder, attrib_idx, offset, "");<br>
                        deref_instr = nir_src_as_deref(deref_instr->parent);<br>
+               } else if (deref_instr->deref_type == nir_deref_type_struct) {<br>
+                       LLVMValueRef offset;<br>
+                       unsigned sidx = deref_instr->strct.index;<br>
+                       deref_instr = nir_src_as_deref(deref_instr->parent);<br>
+                       offset = LLVMConstInt(ctx->ac.i32, glsl_get_record_location_offset(deref_instr->type, sidx), false);<br>
+                       attrib_idx = LLVMBuildAdd(ctx->ac.builder, attrib_idx, offset, "");<br>
                } else {<br>
                        unreachable("Unsupported deref type");<br>
                }<br>
<br>
        }<br>
<br>
-       unsigned input_array_size = glsl_get_aoa_size(var->type);<br>
-       if (!input_array_size)<br>
-               input_array_size = 1;<br>
-<br>
+       unsigned attrib_size = glsl_count_attribute_slots(var->type, false);<br>
        for (chan = 0; chan < 4; chan++) {<br>
-               LLVMValueRef gather = LLVMGetUndef(LLVMVectorType(ctx->ac.f32, input_array_size));<br>
+               LLVMValueRef gather = LLVMGetUndef(LLVMVectorType(ctx->ac.f32, attrib_size));<br>
                LLVMValueRef llvm_chan = LLVMConstInt(ctx->ac.i32, chan, false);<br>
<br>
-               for (unsigned idx = 0; idx < input_array_size; ++idx) {<br>
+               for (unsigned idx = 0; idx < attrib_size; ++idx) {<br>
                        LLVMValueRef v, attr_number;<br>
<br>
                        attr_number = LLVMConstInt(ctx->ac.i32, input_base + idx, false);<br>
@@ -2981,7 +2982,7 @@ static LLVMValueRef visit_interp(struct ac_nir_context *ctx,<br>
                                                        LLVMConstInt(ctx->ac.i32, idx, false), "");<br>
                }<br>
<br>
-               result[chan] = LLVMBuildExtractElement(ctx->ac.builder, gather, array_idx, "");<br>
+               result[chan] = LLVMBuildExtractElement(ctx->ac.builder, gather, attrib_idx, "");<br>
<br>
        }<br>
        return ac_build_varying_gather_values(&ctx->ac, result, instr->num_components,<br>
-- <br>
2.20.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">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/mailman/listinfo/mesa-dev</a><br>
</blockquote></div>