summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample.c36
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample.h13
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c25
3 files changed, 42 insertions, 32 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
index f01a878777f..6a684a9a0bf 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
@@ -235,7 +235,7 @@ lp_build_rho(struct lp_build_sample_context *bld,
rho_vec = lp_build_max(float_size_bld, rho_x, rho_y);
- float_size = lp_build_int_to_float(float_size_bld, bld->uint_size);
+ float_size = lp_build_int_to_float(float_size_bld, bld->int_size);
rho_vec = lp_build_mul(float_size_bld, rho_vec, float_size);
@@ -583,18 +583,22 @@ lp_build_get_const_mipmap_level(struct lp_build_sample_context *bld,
* Return max(1, base_size >> level);
*/
static LLVMValueRef
-lp_build_minify(struct lp_build_sample_context *bld,
+lp_build_minify(struct lp_build_context *bld,
LLVMValueRef base_size,
LLVMValueRef level)
{
- if (level == bld->int_coord_bld.zero) {
+ assert(lp_check_value(bld->type, base_size));
+ assert(lp_check_value(bld->type, level));
+
+ if (level == bld->zero) {
/* if we're using mipmap level zero, no minification is needed */
return base_size;
}
else {
LLVMValueRef size =
LLVMBuildLShr(bld->builder, base_size, level, "minify");
- size = lp_build_max(&bld->int_coord_bld, size, bld->int_coord_bld.one);
+ assert(bld->type.sign);
+ size = lp_build_max(bld, size, bld->one);
return size;
}
}
@@ -634,15 +638,29 @@ lp_build_mipmap_level_sizes(struct lp_build_sample_context *bld,
{
const unsigned dims = bld->dims;
LLVMValueRef ilevel_vec;
+ LLVMValueRef size_vec;
+ LLVMValueRef width, height, depth;
+ LLVMTypeRef i32t = LLVMInt32Type();
- ilevel_vec = lp_build_broadcast_scalar(&bld->int_coord_bld, ilevel);
+ ilevel_vec = lp_build_broadcast_scalar(&bld->int_size_bld, ilevel);
/*
* Compute width, height, depth at mipmap level 'ilevel'
*/
- *out_width_vec = lp_build_minify(bld, bld->width_vec, ilevel_vec);
+ size_vec = lp_build_minify(&bld->int_size_bld, bld->int_size, ilevel_vec);
+
+ if (dims <= 1) {
+ width = size_vec;
+ }
+ else {
+ width = LLVMBuildExtractElement(bld->builder, size_vec,
+ LLVMConstInt(i32t, 0, 0), "");
+ }
+ *out_width_vec = lp_build_broadcast_scalar(&bld->int_coord_bld, width);
if (dims >= 2) {
- *out_height_vec = lp_build_minify(bld, bld->height_vec, ilevel_vec);
+ height = LLVMBuildExtractElement(bld->builder, size_vec,
+ LLVMConstInt(i32t, 1, 0), "");
+ *out_height_vec = lp_build_broadcast_scalar(&bld->int_coord_bld, height);
*row_stride_vec = lp_build_get_level_stride_vec(bld,
bld->row_stride_array,
ilevel);
@@ -651,7 +669,9 @@ lp_build_mipmap_level_sizes(struct lp_build_sample_context *bld,
bld->img_stride_array,
ilevel);
if (dims == 3) {
- *out_depth_vec = lp_build_minify(bld, bld->depth_vec, ilevel_vec);
+ depth = LLVMBuildExtractElement(bld->builder, size_vec,
+ LLVMConstInt(i32t, 2, 0), "");
+ *out_depth_vec = lp_build_broadcast_scalar(&bld->int_coord_bld, depth);
}
}
}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
index 44c8fc57647..d1a1aa143d8 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
@@ -206,8 +206,8 @@ struct lp_build_sample_context
struct lp_build_context int_coord_bld;
/** Unsigned integer texture size */
- struct lp_type uint_size_type;
- struct lp_build_context uint_size_bld;
+ struct lp_type int_size_type;
+ struct lp_build_context int_size_bld;
/** Unsigned integer texture size */
struct lp_type float_size_type;
@@ -225,13 +225,8 @@ struct lp_build_sample_context
LLVMValueRef img_stride_array;
LLVMValueRef data_array;
- /** Unsigned vector with texture width, height, depth */
- LLVMValueRef uint_size;
-
- /* width, height, depth as uint vectors */
- LLVMValueRef width_vec;
- LLVMValueRef height_vec;
- LLVMValueRef depth_vec;
+ /** Integer vector with texture width, height, depth */
+ LLVMValueRef int_size;
};
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
index 158c6e6a79f..b8cf938acfe 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
@@ -1170,7 +1170,7 @@ lp_build_sample_soa(LLVMBuilderRef builder,
bld.int_coord_type = lp_int_type(type);
bld.float_size_type = lp_type_float(32);
bld.float_size_type.length = dims > 1 ? 4 : 1;
- bld.uint_size_type = lp_uint_type(bld.float_size_type);
+ bld.int_size_type = lp_int_type(bld.float_size_type);
bld.texel_type = type;
float_vec_type = lp_type_float_vec(32);
@@ -1181,7 +1181,7 @@ lp_build_sample_soa(LLVMBuilderRef builder,
lp_build_context_init(&bld.coord_bld, builder, bld.coord_type);
lp_build_context_init(&bld.uint_coord_bld, builder, bld.uint_coord_type);
lp_build_context_init(&bld.int_coord_bld, builder, bld.int_coord_type);
- lp_build_context_init(&bld.uint_size_bld, builder, bld.uint_size_type);
+ lp_build_context_init(&bld.int_size_bld, builder, bld.int_size_type);
lp_build_context_init(&bld.float_size_bld, builder, bld.float_size_type);
lp_build_context_init(&bld.texel_bld, builder, bld.texel_type);
@@ -1198,28 +1198,23 @@ lp_build_sample_soa(LLVMBuilderRef builder,
t = coords[1];
r = coords[2];
- /* width, height, depth as single uint vector */
+ /* width, height, depth as single int vector */
if (dims <= 1) {
- bld.uint_size = bld.width;
+ bld.int_size = bld.width;
}
else {
- bld.uint_size = LLVMBuildInsertElement(builder, bld.uint_size_bld.undef,
- bld.width, LLVMConstInt(i32t, 0, 0), "");
+ bld.int_size = LLVMBuildInsertElement(builder, bld.int_size_bld.undef,
+ bld.width, LLVMConstInt(i32t, 0, 0), "");
if (dims >= 2) {
- bld.uint_size = LLVMBuildInsertElement(builder, bld.uint_size,
- bld.height, LLVMConstInt(i32t, 1, 0), "");
+ bld.int_size = LLVMBuildInsertElement(builder, bld.int_size,
+ bld.height, LLVMConstInt(i32t, 1, 0), "");
if (dims >= 3) {
- bld.uint_size = LLVMBuildInsertElement(builder, bld.uint_size,
- bld.depth, LLVMConstInt(i32t, 2, 0), "");
+ bld.int_size = LLVMBuildInsertElement(builder, bld.int_size,
+ bld.depth, LLVMConstInt(i32t, 2, 0), "");
}
}
}
- /* width, height, depth as uint vectors */
- bld.width_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, bld.width);
- bld.height_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, bld.height);
- bld.depth_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, bld.depth);
-
if (0) {
/* For debug: no-op texture sampling */
lp_build_sample_nop(bld.texel_type, texel_out);