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);
* 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;
}
}
{
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);
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);
}
}
}
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;
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;
};
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);
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);
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);