diff options
author | Timothy Arceri <[email protected]> | 2019-01-09 15:07:51 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2019-01-17 10:35:36 +1100 |
commit | cb527d2c4c813d787a9ab79c973c067f87c5de1a (patch) | |
tree | 16e1589b9f03a0747466825b8ca68e049d681d2e /src/amd/common | |
parent | b12316cc925a7659d5edf62d62b8d7987fe7a657 (diff) |
ac/nir_to_llvm: add support for structs to get_sampler_desc()
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/amd/common')
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.c | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index a2069ebb44f..a82e0211d4f 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -3282,27 +3282,34 @@ static LLVMValueRef get_sampler_desc(struct ac_nir_context *ctx, base_index = tex_instr->sampler_index; } else { while(deref_instr->deref_type != nir_deref_type_var) { - unsigned array_size = glsl_get_aoa_size(deref_instr->type); - if (!array_size) - array_size = 1; - - assert(deref_instr->deref_type == nir_deref_type_array); - nir_const_value *const_value = nir_src_as_const_value(deref_instr->arr.index); - if (const_value) { - constant_index += array_size * const_value->u32[0]; - } else { - LLVMValueRef indirect = get_src(ctx, deref_instr->arr.index); - - indirect = LLVMBuildMul(ctx->ac.builder, indirect, - LLVMConstInt(ctx->ac.i32, array_size, false), ""); + 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; + + nir_const_value *const_value = nir_src_as_const_value(deref_instr->arr.index); + if (const_value) { + constant_index += array_size * const_value->u32[0]; + } else { + LLVMValueRef indirect = get_src(ctx, deref_instr->arr.index); + + indirect = LLVMBuildMul(ctx->ac.builder, indirect, + LLVMConstInt(ctx->ac.i32, array_size, false), ""); + + if (!index) + index = indirect; + else + index = LLVMBuildAdd(ctx->ac.builder, index, indirect, ""); + } - if (!index) - index = indirect; - else - index = LLVMBuildAdd(ctx->ac.builder, index, indirect, ""); + deref_instr = nir_src_as_deref(deref_instr->parent); + } else if (deref_instr->deref_type == nir_deref_type_struct) { + unsigned sidx = deref_instr->strct.index; + deref_instr = nir_src_as_deref(deref_instr->parent); + constant_index += glsl_get_record_location_offset(deref_instr->type, sidx); + } else { + unreachable("Unsupported deref type"); } - - deref_instr = nir_src_as_deref(deref_instr->parent); } descriptor_set = deref_instr->var->data.descriptor_set; |