amd/common: save an instruction in the build_cube_select sequence
Avoid a v_cndmask: the absolute value is free due to input modifiers. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
This commit is contained in:
parent
5be5c1e0fa
commit
a6ea4c1b93
|
@ -438,12 +438,13 @@ build_cube_intrinsic(struct ac_llvm_context *ctx,
|
||||||
* selcoords.ma; i.e., a positive out_ma means that coords is pointed towards
|
* selcoords.ma; i.e., a positive out_ma means that coords is pointed towards
|
||||||
* the selcoords major axis.
|
* the selcoords major axis.
|
||||||
*/
|
*/
|
||||||
static void build_cube_select(LLVMBuilderRef builder,
|
static void build_cube_select(struct ac_llvm_context *ctx,
|
||||||
const struct cube_selection_coords *selcoords,
|
const struct cube_selection_coords *selcoords,
|
||||||
const LLVMValueRef *coords,
|
const LLVMValueRef *coords,
|
||||||
LLVMValueRef *out_st,
|
LLVMValueRef *out_st,
|
||||||
LLVMValueRef *out_ma)
|
LLVMValueRef *out_ma)
|
||||||
{
|
{
|
||||||
|
LLVMBuilderRef builder = ctx->builder;
|
||||||
LLVMTypeRef f32 = LLVMTypeOf(coords[0]);
|
LLVMTypeRef f32 = LLVMTypeOf(coords[0]);
|
||||||
LLVMValueRef is_ma_positive;
|
LLVMValueRef is_ma_positive;
|
||||||
LLVMValueRef sgn_ma;
|
LLVMValueRef sgn_ma;
|
||||||
|
@ -480,9 +481,9 @@ static void build_cube_select(LLVMBuilderRef builder,
|
||||||
/* Select ma */
|
/* Select ma */
|
||||||
tmp = LLVMBuildSelect(builder, is_ma_z, coords[2],
|
tmp = LLVMBuildSelect(builder, is_ma_z, coords[2],
|
||||||
LLVMBuildSelect(builder, is_ma_y, coords[1], coords[0], ""), "");
|
LLVMBuildSelect(builder, is_ma_y, coords[1], coords[0], ""), "");
|
||||||
sgn = LLVMBuildSelect(builder, is_ma_positive,
|
tmp = ac_build_intrinsic(ctx, "llvm.fabs.f32",
|
||||||
LLVMConstReal(f32, 2.0), LLVMConstReal(f32, -2.0), "");
|
ctx->f32, &tmp, 1, AC_FUNC_ATTR_READNONE);
|
||||||
*out_ma = LLVMBuildFMul(builder, tmp, sgn, "");
|
*out_ma = LLVMBuildFMul(builder, tmp, LLVMConstReal(f32, 2.0), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -570,7 +571,7 @@ ac_prepare_cube_coords(struct ac_llvm_context *ctx,
|
||||||
* seems awfully quiet about how textureGrad for cube
|
* seems awfully quiet about how textureGrad for cube
|
||||||
* maps should be handled.
|
* maps should be handled.
|
||||||
*/
|
*/
|
||||||
build_cube_select(builder, &selcoords, &derivs_arg[axis * 3],
|
build_cube_select(ctx, &selcoords, &derivs_arg[axis * 3],
|
||||||
deriv_st, &deriv_ma);
|
deriv_st, &deriv_ma);
|
||||||
|
|
||||||
deriv_ma = LLVMBuildFMul(builder, deriv_ma, invma, "");
|
deriv_ma = LLVMBuildFMul(builder, deriv_ma, invma, "");
|
||||||
|
|
Loading…
Reference in New Issue