diff options
author | Timothy Arceri <[email protected]> | 2019-01-22 16:11:03 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2019-01-23 10:41:37 +1100 |
commit | 678ef2a4a51dc184152d5ce5f1e3194164cc333a (patch) | |
tree | f4149f4261248be06bf6595a58de3957593fd6ce /src | |
parent | 559e5b0408c3fda2aa05d477f2738746cb9d0d5d (diff) |
ac/nir_to_llvm: fix interpolateAt* for structs
This fixes the arb_gpu_shader5 interpolateAt* tests that contain
structs.
Acked-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 686e8b4935e..f509fc31dff 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -2924,12 +2924,10 @@ static LLVMValueRef visit_interp(struct ac_nir_context *ctx, } - LLVMValueRef array_idx = ctx->ac.i32_0; + LLVMValueRef attrib_idx = ctx->ac.i32_0; while(deref_instr->deref_type != nir_deref_type_var) { if (deref_instr->deref_type == nir_deref_type_array) { - unsigned array_size = glsl_get_aoa_size(deref_instr->type); - if (!array_size) - array_size = 1; + unsigned array_size = glsl_count_attribute_slots(deref_instr->type, false); LLVMValueRef offset; nir_const_value *const_value = nir_src_as_const_value(deref_instr->arr.index); @@ -2942,23 +2940,26 @@ static LLVMValueRef visit_interp(struct ac_nir_context *ctx, LLVMConstInt(ctx->ac.i32, array_size, false), ""); } - array_idx = LLVMBuildAdd(ctx->ac.builder, array_idx, offset, ""); + attrib_idx = LLVMBuildAdd(ctx->ac.builder, attrib_idx, offset, ""); deref_instr = nir_src_as_deref(deref_instr->parent); + } else if (deref_instr->deref_type == nir_deref_type_struct) { + LLVMValueRef offset; + unsigned sidx = deref_instr->strct.index; + deref_instr = nir_src_as_deref(deref_instr->parent); + offset = LLVMConstInt(ctx->ac.i32, glsl_get_record_location_offset(deref_instr->type, sidx), false); + attrib_idx = LLVMBuildAdd(ctx->ac.builder, attrib_idx, offset, ""); } else { unreachable("Unsupported deref type"); } } - unsigned input_array_size = glsl_get_aoa_size(var->type); - if (!input_array_size) - input_array_size = 1; - + unsigned attrib_size = glsl_count_attribute_slots(var->type, false); for (chan = 0; chan < 4; chan++) { - LLVMValueRef gather = LLVMGetUndef(LLVMVectorType(ctx->ac.f32, input_array_size)); + LLVMValueRef gather = LLVMGetUndef(LLVMVectorType(ctx->ac.f32, attrib_size)); LLVMValueRef llvm_chan = LLVMConstInt(ctx->ac.i32, chan, false); - for (unsigned idx = 0; idx < input_array_size; ++idx) { + for (unsigned idx = 0; idx < attrib_size; ++idx) { LLVMValueRef v, attr_number; attr_number = LLVMConstInt(ctx->ac.i32, input_base + idx, false); @@ -2981,7 +2982,7 @@ static LLVMValueRef visit_interp(struct ac_nir_context *ctx, LLVMConstInt(ctx->ac.i32, idx, false), ""); } - result[chan] = LLVMBuildExtractElement(ctx->ac.builder, gather, array_idx, ""); + result[chan] = LLVMBuildExtractElement(ctx->ac.builder, gather, attrib_idx, ""); } return ac_build_varying_gather_values(&ctx->ac, result, instr->num_components, |