ac/nir: Handle loading data from compact arrays.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Mon, 1 Jan 2018 23:04:14 +0000 (00:04 +0100)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Wed, 3 Jan 2018 23:14:23 +0000 (00:14 +0100)
Fixes: f4e499ec791 "radv: add initial non-conformant radv vulkan driver"
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/amd/common/ac_nir_to_llvm.c

index d9f2cb408c3e4942830b97b93b3ad6b81e708e4b..864f58b56d0a831dd609a348b63358ce64b46d6a 100644 (file)
@@ -3120,6 +3120,7 @@ static LLVMValueRef visit_load_var(struct ac_nir_context *ctx,
        LLVMValueRef indir_index;
        LLVMValueRef ret;
        unsigned const_index;
+       unsigned stride = instr->variables[0]->var->data.compact ? 1 : 4;
        bool vs_in = ctx->stage == MESA_SHADER_VERTEX &&
                     instr->variables[0]->var->data.mode == nir_var_shader_in;
        get_deref_offset(ctx, instr->variables[0], vs_in, NULL, NULL,
@@ -3155,13 +3156,13 @@ static LLVMValueRef visit_load_var(struct ac_nir_context *ctx,
                                count -= chan / 4;
                                LLVMValueRef tmp_vec = ac_build_gather_values_extended(
                                                &ctx->ac, ctx->abi->inputs + idx + chan, count,
-                                               4, false, true);
+                                               stride, false, true);
 
                                values[chan] = LLVMBuildExtractElement(ctx->ac.builder,
                                                                       tmp_vec,
                                                                       indir_index, "");
                        } else
-                               values[chan] = ctx->abi->inputs[idx + chan + const_index * 4];
+                               values[chan] = ctx->abi->inputs[idx + chan + const_index * stride];
                }
                break;
        case nir_var_local:
@@ -3172,13 +3173,13 @@ static LLVMValueRef visit_load_var(struct ac_nir_context *ctx,
                                count -= chan / 4;
                                LLVMValueRef tmp_vec = ac_build_gather_values_extended(
                                                &ctx->ac, ctx->locals + idx + chan, count,
-                                               4, true, true);
+                                               stride, true, true);
 
                                values[chan] = LLVMBuildExtractElement(ctx->ac.builder,
                                                                       tmp_vec,
                                                                       indir_index, "");
                        } else {
-                               values[chan] = LLVMBuildLoad(ctx->ac.builder, ctx->locals[idx + chan + const_index * 4], "");
+                               values[chan] = LLVMBuildLoad(ctx->ac.builder, ctx->locals[idx + chan + const_index * stride], "");
                        }
                }
                break;
@@ -3201,14 +3202,14 @@ static LLVMValueRef visit_load_var(struct ac_nir_context *ctx,
                                count -= chan / 4;
                                LLVMValueRef tmp_vec = ac_build_gather_values_extended(
                                                &ctx->ac, ctx->outputs + idx + chan, count,
-                                               4, true, true);
+                                               stride, true, true);
 
                                values[chan] = LLVMBuildExtractElement(ctx->ac.builder,
                                                                       tmp_vec,
                                                                       indir_index, "");
                        } else {
                                values[chan] = LLVMBuildLoad(ctx->ac.builder,
-                                                    ctx->outputs[idx + chan + const_index * 4],
+                                                    ctx->outputs[idx + chan + const_index * stride],
                                                     "");
                        }
                }