diff options
author | Marek Olšák <[email protected]> | 2018-09-21 21:30:09 -0400 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2018-10-06 21:50:09 -0400 |
commit | 77903c8cfbaa609d132ea5e5fbca062e0b2f0808 (patch) | |
tree | 0e56f3dcaf89f5cd1135cbf325fc3fb0d7222264 /src | |
parent | fa023f293eb48d1d2e3c6efb89f4192c4a565fed (diff) |
ac: add ac_build_round
Diffstat (limited to 'src')
-rw-r--r-- | src/amd/common/ac_llvm_build.c | 19 | ||||
-rw-r--r-- | src/amd/common/ac_llvm_build.h | 1 | ||||
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c | 4 |
4 files changed, 20 insertions, 6 deletions
diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c index 81158940b8d..d11c12fcd13 100644 --- a/src/amd/common/ac_llvm_build.c +++ b/src/amd/common/ac_llvm_build.c @@ -558,6 +558,22 @@ LLVMValueRef ac_build_expand_to_vec4(struct ac_llvm_context *ctx, return ac_build_gather_values(ctx, chan, 4); } +LLVMValueRef ac_build_round(struct ac_llvm_context *ctx, LLVMValueRef value) +{ + unsigned type_size = ac_get_type_size(LLVMTypeOf(value)); + const char *name; + + if (type_size == 2) + name = "llvm.rint.f16"; + else if (type_size == 4) + name = "llvm.rint.f32"; + else + name = "llvm.rint.f64"; + + return ac_build_intrinsic(ctx, name, LLVMTypeOf(value), &value, 1, + AC_FUNC_ATTR_READNONE); +} + LLVMValueRef ac_build_fdiv(struct ac_llvm_context *ctx, LLVMValueRef num, @@ -675,8 +691,7 @@ ac_prepare_cube_coords(struct ac_llvm_context *ctx, LLVMValueRef invma; if (is_array && !is_lod) { - LLVMValueRef tmp = coords_arg[3]; - tmp = ac_build_intrinsic(ctx, "llvm.rint.f32", ctx->f32, &tmp, 1, 0); + LLVMValueRef tmp = ac_build_round(ctx, coords_arg[3]); /* Section 8.9 (Texture Functions) of the GLSL 4.50 spec says: * diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h index 73f8a6b70cd..65235fb7352 100644 --- a/src/amd/common/ac_llvm_build.h +++ b/src/amd/common/ac_llvm_build.h @@ -175,6 +175,7 @@ ac_build_gather_values(struct ac_llvm_context *ctx, LLVMValueRef ac_build_expand_to_vec4(struct ac_llvm_context *ctx, LLVMValueRef value, unsigned num_channels); +LLVMValueRef ac_build_round(struct ac_llvm_context *ctx, LLVMValueRef value); LLVMValueRef ac_build_fdiv(struct ac_llvm_context *ctx, diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 312383db36c..ffc64a79d95 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -3311,7 +3311,7 @@ static LLVMValueRef apply_round_slice(struct ac_llvm_context *ctx, LLVMValueRef coord) { coord = ac_to_float(ctx, coord); - coord = ac_build_intrinsic(ctx, "llvm.rint.f32", ctx->f32, &coord, 1, 0); + coord = ac_build_round(ctx, coord); coord = ac_to_integer(ctx, coord); return coord; } diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c index cabc448a082..8c44831bccb 100644 --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c @@ -1446,9 +1446,7 @@ static void build_tex_intrinsic(const struct lp_build_tgsi_action *action, opcode != TGSI_OPCODE_TXF_LZ && ctx->screen->info.chip_class <= VI) { unsigned array_coord = target == TGSI_TEXTURE_1D_ARRAY ? 1 : 2; - args.coords[array_coord] = - ac_build_intrinsic(&ctx->ac, "llvm.rint.f32", ctx->f32, - &args.coords[array_coord], 1, 0); + args.coords[array_coord] = ac_build_round(&ctx->ac, args.coords[array_coord]); } /* 1D textures are allocated and used as 2D on GFX9. */ |