ac/nir: Use instance_rate_inputs per attribute, not per variable.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Mon, 22 Jan 2018 08:01:29 +0000 (09:01 +0100)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Tue, 23 Jan 2018 11:58:48 +0000 (12:58 +0100)
This did the wrong thing if we had e.g. an array for which only some
of the attributes use the instance index. Tripped up some new CTS
tests.

CC: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/amd/common/ac_nir_to_llvm.c

index 9ba324a5132cc1e2bde39b0d06743be73635a4ee..cc3af77386369fcfcd2005968ef0966028763288 100644 (file)
@@ -5311,21 +5311,20 @@ handle_vs_input_decl(struct nir_to_llvm_context *ctx,
 
        variable->data.driver_location = idx * 4;
 
-       if (ctx->options->key.vs.instance_rate_inputs & (1u << index)) {
-               buffer_index = LLVMBuildAdd(ctx->builder, ctx->abi.instance_id,
-                                           ctx->abi.start_instance, "");
-               if (ctx->options->key.vs.as_ls) {
-                       ctx->shader_info->vs.vgpr_comp_cnt =
-                               MAX2(2, ctx->shader_info->vs.vgpr_comp_cnt);
-               } else {
-                       ctx->shader_info->vs.vgpr_comp_cnt =
-                               MAX2(1, ctx->shader_info->vs.vgpr_comp_cnt);
-               }
-       } else
-               buffer_index = LLVMBuildAdd(ctx->builder, ctx->abi.vertex_id,
-                                           ctx->abi.base_vertex, "");
-
        for (unsigned i = 0; i < attrib_count; ++i, ++idx) {
+               if (ctx->options->key.vs.instance_rate_inputs & (1u << (index + i))) {
+                       buffer_index = LLVMBuildAdd(ctx->builder, ctx->abi.instance_id,
+                                                   ctx->abi.start_instance, "");
+                       if (ctx->options->key.vs.as_ls) {
+                               ctx->shader_info->vs.vgpr_comp_cnt =
+                                       MAX2(2, ctx->shader_info->vs.vgpr_comp_cnt);
+                       } else {
+                               ctx->shader_info->vs.vgpr_comp_cnt =
+                                       MAX2(1, ctx->shader_info->vs.vgpr_comp_cnt);
+                       }
+               } else
+                       buffer_index = LLVMBuildAdd(ctx->builder, ctx->abi.vertex_id,
+                                                   ctx->abi.base_vertex, "");
                t_offset = LLVMConstInt(ctx->ac.i32, index + i, false);
 
                t_list = ac_build_load_to_sgpr(&ctx->ac, t_list_ptr, t_offset);