diff options
author | Marek Olšák <[email protected]> | 2017-02-24 00:52:07 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-03-03 15:29:30 +0100 |
commit | c6a3911e5d1dc7a324be6015cb685a27f8627b51 (patch) | |
tree | d50f21d039f6b15204a951150055831e2b4f84f4 /src | |
parent | ad18d7f040431ac64c349c2a764fd94d4152e573 (diff) |
radeonsi: remove last use of llvm.SI.resinfo
and move one function up to reuse the code.
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader.c | 97 |
1 files changed, 49 insertions, 48 deletions
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 19a06d4f3ae..5dc53fcf750 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -3989,12 +3989,42 @@ static void atomic_emit( LLVMBuildBitCast(builder, tmp, bld_base->base.elem_type, ""); } +static void set_tex_fetch_args(struct si_shader_context *ctx, + struct lp_build_emit_data *emit_data, + unsigned target, + LLVMValueRef res_ptr, LLVMValueRef samp_ptr, + LLVMValueRef *param, unsigned count, + unsigned dmask) +{ + struct gallivm_state *gallivm = &ctx->gallivm; + struct ac_image_args args = {}; + + /* Pad to power of two vector */ + while (count < util_next_power_of_two(count)) + param[count++] = LLVMGetUndef(ctx->i32); + + if (count > 1) + args.addr = lp_build_gather_values(gallivm, param, count); + else + args.addr = param[0]; + + args.resource = res_ptr; + args.sampler = samp_ptr; + args.dmask = dmask; + args.unorm = target == TGSI_TEXTURE_RECT || + target == TGSI_TEXTURE_SHADOWRECT; + args.da = tgsi_is_array_sampler(target); + + /* Ugly, but we seem to have no other choice right now. */ + STATIC_ASSERT(sizeof(args) <= sizeof(emit_data->args)); + memcpy(emit_data->args, &args, sizeof(args)); +} + static void resq_fetch_args( struct lp_build_tgsi_context * bld_base, struct lp_build_emit_data * emit_data) { struct si_shader_context *ctx = si_shader_context(bld_base); - struct gallivm_state *gallivm = bld_base->base.gallivm; const struct tgsi_full_instruction *inst = emit_data->inst; const struct tgsi_full_src_register *reg = &inst->Src[0]; @@ -4008,19 +4038,19 @@ static void resq_fetch_args( &emit_data->args[0]); emit_data->arg_count = 1; } else { - emit_data->args[0] = bld_base->uint_bld.zero; /* mip level */ + LLVMValueRef res_ptr; + unsigned image_target; + + if (inst->Memory.Texture == TGSI_TEXTURE_3D) + image_target = TGSI_TEXTURE_2D_ARRAY; + else + image_target = inst->Memory.Texture; + image_fetch_rsrc(bld_base, reg, false, inst->Memory.Texture, - &emit_data->args[1]); - emit_data->args[2] = lp_build_const_int32(gallivm, 15); /* dmask */ - emit_data->args[3] = bld_base->uint_bld.zero; /* unorm */ - emit_data->args[4] = bld_base->uint_bld.zero; /* r128 */ - emit_data->args[5] = tgsi_is_array_image(inst->Memory.Texture) ? - bld_base->uint_bld.one : bld_base->uint_bld.zero; /* da */ - emit_data->args[6] = bld_base->uint_bld.zero; /* glc */ - emit_data->args[7] = bld_base->uint_bld.zero; /* slc */ - emit_data->args[8] = bld_base->uint_bld.zero; /* tfe */ - emit_data->args[9] = bld_base->uint_bld.zero; /* lwe */ - emit_data->arg_count = 10; + &res_ptr); + set_tex_fetch_args(ctx, emit_data, image_target, + res_ptr, NULL, &bld_base->uint_bld.zero, 1, + 0xf); } } @@ -4029,6 +4059,7 @@ static void resq_emit( struct lp_build_tgsi_context *bld_base, struct lp_build_emit_data *emit_data) { + struct si_shader_context *ctx = si_shader_context(bld_base); struct gallivm_state *gallivm = bld_base->base.gallivm; LLVMBuilderRef builder = gallivm->builder; const struct tgsi_full_instruction *inst = emit_data->inst; @@ -4040,10 +4071,11 @@ static void resq_emit( } else if (inst->Memory.Texture == TGSI_TEXTURE_BUFFER) { out = get_buffer_size(bld_base, emit_data->args[0]); } else { - out = lp_build_intrinsic( - builder, "llvm.SI.getresinfo.i32", emit_data->dst_type, - emit_data->args, emit_data->arg_count, - LP_FUNC_ATTR_READNONE | LP_FUNC_ATTR_LEGACY); + struct ac_image_args args; + + memcpy(&args, emit_data->args, sizeof(args)); /* ugly */ + args.opcode = ac_image_get_resinfo; + out = ac_emit_image_opcode(&ctx->ac, &args); /* Divide the number of layers by 6 to get the number of cubes. */ if (inst->Memory.Texture == TGSI_TEXTURE_CUBE_ARRAY) { @@ -4059,37 +4091,6 @@ static void resq_emit( emit_data->output[emit_data->chan] = out; } -static void set_tex_fetch_args(struct si_shader_context *ctx, - struct lp_build_emit_data *emit_data, - unsigned target, - LLVMValueRef res_ptr, LLVMValueRef samp_ptr, - LLVMValueRef *param, unsigned count, - unsigned dmask) -{ - struct gallivm_state *gallivm = &ctx->gallivm; - struct ac_image_args args = {}; - - /* Pad to power of two vector */ - while (count < util_next_power_of_two(count)) - param[count++] = LLVMGetUndef(ctx->i32); - - if (count > 1) - args.addr = lp_build_gather_values(gallivm, param, count); - else - args.addr = param[0]; - - args.resource = res_ptr; - args.sampler = samp_ptr; - args.dmask = dmask; - args.unorm = target == TGSI_TEXTURE_RECT || - target == TGSI_TEXTURE_SHADOWRECT; - args.da = tgsi_is_array_sampler(target); - - /* Ugly, but we seem to have no other choice right now. */ - STATIC_ASSERT(sizeof(args) <= sizeof(emit_data->args)); - memcpy(emit_data->args, &args, sizeof(args)); -} - static const struct lp_build_tgsi_action tex_action; enum desc_type { |