summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2010-10-08 18:24:54 +0100
committerJosé Fonseca <[email protected]>2010-10-08 19:11:52 +0100
commitf5b5fb32d3a9eb8667f91907bcf065fe8bd4988d (patch)
tree52f0022851e8a52778bcb55e3a9db7dfe2d64a9f /src/gallium
parent5b24d69fcd6359dc959ec465c7e77b4626a27e72 (diff)
gallivm: Move into the as much of the second level code as possible.
Also, pass more stuff trhough the sample build context, instead of arguments.
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample.c34
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample.h29
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c114
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample_aos.h9
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c153
5 files changed, 120 insertions, 219 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
index f23ede33197..f01a878777f 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
@@ -190,7 +190,7 @@ lp_build_rho(struct lp_build_sample_context *bld,
{
struct lp_build_context *float_size_bld = &bld->float_size_bld;
struct lp_build_context *float_bld = &bld->float_bld;
- const int dims = texture_dims(bld->static_state->target);
+ const unsigned dims = bld->dims;
LLVMTypeRef i32t = LLVMInt32Type();
LLVMValueRef index0 = LLVMConstInt(i32t, 0, 0);
LLVMValueRef index1 = LLVMConstInt(i32t, 1, 0);
@@ -355,9 +355,6 @@ lp_build_lod_selector(struct lp_build_sample_context *bld,
const LLVMValueRef ddy[4],
LLVMValueRef lod_bias, /* optional */
LLVMValueRef explicit_lod, /* optional */
- LLVMValueRef width,
- LLVMValueRef height,
- LLVMValueRef depth,
unsigned mip_filter,
LLVMValueRef *out_lod_ipart,
LLVMValueRef *out_lod_fpart)
@@ -561,12 +558,12 @@ lp_build_linear_mip_levels(struct lp_build_sample_context *bld,
*/
LLVMValueRef
lp_build_get_mipmap_level(struct lp_build_sample_context *bld,
- LLVMValueRef data_array, LLVMValueRef level)
+ LLVMValueRef level)
{
LLVMValueRef indexes[2], data_ptr;
indexes[0] = LLVMConstInt(LLVMInt32Type(), 0, 0);
indexes[1] = level;
- data_ptr = LLVMBuildGEP(bld->builder, data_array, indexes, 2, "");
+ data_ptr = LLVMBuildGEP(bld->builder, bld->data_array, indexes, 2, "");
data_ptr = LLVMBuildLoad(bld->builder, data_ptr, "");
return data_ptr;
}
@@ -574,10 +571,10 @@ lp_build_get_mipmap_level(struct lp_build_sample_context *bld,
LLVMValueRef
lp_build_get_const_mipmap_level(struct lp_build_sample_context *bld,
- LLVMValueRef data_array, int level)
+ int level)
{
LLVMValueRef lvl = LLVMConstInt(LLVMInt32Type(), level, 0);
- return lp_build_get_mipmap_level(bld, data_array, lvl);
+ return lp_build_get_mipmap_level(bld, lvl);
}
@@ -628,19 +625,14 @@ lp_build_get_level_stride_vec(struct lp_build_sample_context *bld,
*/
void
lp_build_mipmap_level_sizes(struct lp_build_sample_context *bld,
- unsigned dims,
- LLVMValueRef width_vec,
- LLVMValueRef height_vec,
- LLVMValueRef depth_vec,
LLVMValueRef ilevel,
- LLVMValueRef row_stride_array,
- LLVMValueRef img_stride_array,
LLVMValueRef *out_width_vec,
LLVMValueRef *out_height_vec,
LLVMValueRef *out_depth_vec,
LLVMValueRef *row_stride_vec,
LLVMValueRef *img_stride_vec)
{
+ const unsigned dims = bld->dims;
LLVMValueRef ilevel_vec;
ilevel_vec = lp_build_broadcast_scalar(&bld->int_coord_bld, ilevel);
@@ -648,18 +640,18 @@ lp_build_mipmap_level_sizes(struct lp_build_sample_context *bld,
/*
* Compute width, height, depth at mipmap level 'ilevel'
*/
- *out_width_vec = lp_build_minify(bld, width_vec, ilevel_vec);
+ *out_width_vec = lp_build_minify(bld, bld->width_vec, ilevel_vec);
if (dims >= 2) {
- *out_height_vec = lp_build_minify(bld, height_vec, ilevel_vec);
+ *out_height_vec = lp_build_minify(bld, bld->height_vec, ilevel_vec);
*row_stride_vec = lp_build_get_level_stride_vec(bld,
- row_stride_array,
- ilevel);
+ bld->row_stride_array,
+ ilevel);
if (dims == 3 || bld->static_state->target == PIPE_TEXTURE_CUBE) {
*img_stride_vec = lp_build_get_level_stride_vec(bld,
- img_stride_array,
- ilevel);
+ bld->img_stride_array,
+ ilevel);
if (dims == 3) {
- *out_depth_vec = lp_build_minify(bld, depth_vec, ilevel_vec);
+ *out_depth_vec = lp_build_minify(bld, bld->depth_vec, ilevel_vec);
}
}
}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
index e5d7f10778f..44c8fc57647 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
@@ -179,6 +179,9 @@ struct lp_build_sample_context
const struct util_format_description *format_desc;
+ /* See texture_dims() */
+ unsigned dims;
+
/** regular scalar float type */
struct lp_type float_type;
struct lp_build_context float_bld;
@@ -214,8 +217,21 @@ struct lp_build_sample_context
struct lp_type texel_type;
struct lp_build_context texel_bld;
+ /* Common dynamic state values */
+ LLVMValueRef width;
+ LLVMValueRef height;
+ LLVMValueRef depth;
+ LLVMValueRef row_stride_array;
+ 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;
};
@@ -292,9 +308,6 @@ lp_build_lod_selector(struct lp_build_sample_context *bld,
const LLVMValueRef ddy[4],
LLVMValueRef lod_bias, /* optional */
LLVMValueRef explicit_lod, /* optional */
- LLVMValueRef width,
- LLVMValueRef height,
- LLVMValueRef depth,
unsigned mip_filter,
LLVMValueRef *out_lod_ipart,
LLVMValueRef *out_lod_fpart);
@@ -315,22 +328,16 @@ lp_build_linear_mip_levels(struct lp_build_sample_context *bld,
LLVMValueRef
lp_build_get_mipmap_level(struct lp_build_sample_context *bld,
- LLVMValueRef data_array, LLVMValueRef level);
+ LLVMValueRef level);
LLVMValueRef
lp_build_get_const_mipmap_level(struct lp_build_sample_context *bld,
- LLVMValueRef data_array, int level);
+ int level);
void
lp_build_mipmap_level_sizes(struct lp_build_sample_context *bld,
- unsigned dims,
- LLVMValueRef width_vec,
- LLVMValueRef height_vec,
- LLVMValueRef depth_vec,
LLVMValueRef ilevel,
- LLVMValueRef row_stride_array,
- LLVMValueRef img_stride_array,
LLVMValueRef *out_width_vec,
LLVMValueRef *out_height_vec,
LLVMValueRef *out_depth_vec,
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c
index 293237c5b1e..e7410448c04 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c
@@ -265,7 +265,7 @@ lp_build_sample_image_nearest(struct lp_build_sample_context *bld,
LLVMValueRef *colors_lo,
LLVMValueRef *colors_hi)
{
- const int dims = texture_dims(bld->static_state->target);
+ const unsigned dims = bld->dims;
LLVMBuilderRef builder = bld->builder;
struct lp_build_context i32, h16, u8n;
LLVMTypeRef i32_vec_type, h16_vec_type, u8n_vec_type;
@@ -429,7 +429,7 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld,
LLVMValueRef *colors_lo,
LLVMValueRef *colors_hi)
{
- const int dims = texture_dims(bld->static_state->target);
+ const unsigned dims = bld->dims;
LLVMBuilderRef builder = bld->builder;
struct lp_build_context i32, h16, u8n;
LLVMTypeRef i32_vec_type, h16_vec_type, u8n_vec_type;
@@ -781,27 +781,34 @@ lp_build_sample_mipmap(struct lp_build_sample_context *bld,
LLVMValueRef s,
LLVMValueRef t,
LLVMValueRef r,
+ LLVMValueRef ilevel0,
+ LLVMValueRef ilevel1,
LLVMValueRef lod_fpart,
- LLVMValueRef width0_vec,
- LLVMValueRef width1_vec,
- LLVMValueRef height0_vec,
- LLVMValueRef height1_vec,
- LLVMValueRef depth0_vec,
- LLVMValueRef depth1_vec,
- LLVMValueRef row_stride0_vec,
- LLVMValueRef row_stride1_vec,
- LLVMValueRef img_stride0_vec,
- LLVMValueRef img_stride1_vec,
- LLVMValueRef data_ptr0,
- LLVMValueRef data_ptr1,
LLVMValueRef colors_lo_var,
LLVMValueRef colors_hi_var)
{
LLVMBuilderRef builder = bld->builder;
+ LLVMValueRef width0_vec;
+ LLVMValueRef width1_vec;
+ LLVMValueRef height0_vec;
+ LLVMValueRef height1_vec;
+ LLVMValueRef depth0_vec;
+ LLVMValueRef depth1_vec;
+ LLVMValueRef row_stride0_vec;
+ LLVMValueRef row_stride1_vec;
+ LLVMValueRef img_stride0_vec;
+ LLVMValueRef img_stride1_vec;
+ LLVMValueRef data_ptr0;
+ LLVMValueRef data_ptr1;
LLVMValueRef colors0_lo, colors0_hi;
LLVMValueRef colors1_lo, colors1_hi;
+
/* sample the first mipmap level */
+ lp_build_mipmap_level_sizes(bld, ilevel0,
+ &width0_vec, &height0_vec, &depth0_vec,
+ &row_stride0_vec, &img_stride0_vec);
+ data_ptr0 = lp_build_get_mipmap_level(bld, ilevel0);
if (img_filter == PIPE_TEX_FILTER_NEAREST) {
lp_build_sample_image_nearest(bld,
width0_vec, height0_vec, depth0_vec,
@@ -846,6 +853,10 @@ lp_build_sample_mipmap(struct lp_build_sample_context *bld,
lp_build_context_init(&h16_bld, builder, lp_type_ufixed(16));
/* sample the second mipmap level */
+ lp_build_mipmap_level_sizes(bld, ilevel1,
+ &width1_vec, &height1_vec, &depth1_vec,
+ &row_stride1_vec, &img_stride1_vec);
+ data_ptr1 = lp_build_get_mipmap_level(bld, ilevel1);
if (img_filter == PIPE_TEX_FILTER_NEAREST) {
lp_build_sample_image_nearest(bld,
width1_vec, height1_vec, depth1_vec,
@@ -897,15 +908,6 @@ lp_build_sample_aos(struct lp_build_sample_context *bld,
const LLVMValueRef *ddy,
LLVMValueRef lod_bias, /* optional */
LLVMValueRef explicit_lod, /* optional */
- LLVMValueRef width,
- LLVMValueRef height,
- LLVMValueRef depth,
- LLVMValueRef width_vec,
- LLVMValueRef height_vec,
- LLVMValueRef depth_vec,
- LLVMValueRef row_stride_array,
- LLVMValueRef img_stride_array,
- LLVMValueRef data_array,
LLVMValueRef texel_out[4])
{
struct lp_build_context *int_bld = &bld->int_bld;
@@ -913,18 +915,15 @@ lp_build_sample_aos(struct lp_build_sample_context *bld,
const unsigned mip_filter = bld->static_state->min_mip_filter;
const unsigned min_filter = bld->static_state->min_img_filter;
const unsigned mag_filter = bld->static_state->mag_img_filter;
- const int dims = texture_dims(bld->static_state->target);
+ const unsigned dims = bld->dims;
LLVMValueRef lod_ipart = NULL, lod_fpart = NULL;
LLVMValueRef ilevel0, ilevel1 = NULL;
- LLVMValueRef width0_vec = NULL, height0_vec = NULL, depth0_vec = NULL;
- LLVMValueRef width1_vec = NULL, height1_vec = NULL, depth1_vec = NULL;
- LLVMValueRef row_stride0_vec = NULL, row_stride1_vec = NULL;
- LLVMValueRef img_stride0_vec = NULL, img_stride1_vec = NULL;
- LLVMValueRef data_ptr0, data_ptr1 = NULL;
LLVMValueRef packed, packed_lo, packed_hi;
LLVMValueRef unswizzled[4];
LLVMValueRef face_ddx[4], face_ddy[4];
struct lp_build_context h16_bld;
+ LLVMTypeRef i32t = LLVMInt32Type();
+ LLVMValueRef i32t_zero = LLVMConstInt(i32t, 0, 0);
/* we only support the common/simple wrap modes at this time */
assert(lp_is_simple_wrap_mode(bld->static_state->wrap_s));
@@ -969,11 +968,10 @@ lp_build_sample_aos(struct lp_build_sample_context *bld,
*/
lp_build_lod_selector(bld, unit, ddx, ddy,
lod_bias, explicit_lod,
- width, height, depth,
mip_filter,
&lod_ipart, &lod_fpart);
} else {
- lod_ipart = LLVMConstInt(LLVMInt32Type(), 0, 0);
+ lod_ipart = i32t_zero;
}
/*
@@ -994,7 +992,7 @@ lp_build_sample_aos(struct lp_build_sample_context *bld,
lp_build_nearest_mip_level(bld, unit, lod_ipart, &ilevel0);
}
else {
- ilevel0 = LLVMConstInt(LLVMInt32Type(), 0, 0);
+ ilevel0 = i32t_zero;
}
break;
case PIPE_TEX_MIPFILTER_NEAREST:
@@ -1010,28 +1008,6 @@ lp_build_sample_aos(struct lp_build_sample_context *bld,
break;
}
- /* compute image size(s) of source mipmap level(s) */
- lp_build_mipmap_level_sizes(bld, dims, width_vec, height_vec, depth_vec,
- ilevel0,
- row_stride_array, img_stride_array,
- &width0_vec, &height0_vec, &depth0_vec,
- &row_stride0_vec, &img_stride0_vec);
- if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) {
- lp_build_mipmap_level_sizes(bld, dims, width_vec, height_vec, depth_vec,
- ilevel1,
- row_stride_array, img_stride_array,
- &width1_vec, &height1_vec, &depth1_vec,
- &row_stride1_vec, &img_stride1_vec);
- }
-
- /*
- * Get pointer(s) to image data for mipmap level(s).
- */
- data_ptr0 = lp_build_get_mipmap_level(bld, data_array, ilevel0);
- if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) {
- data_ptr1 = lp_build_get_mipmap_level(bld, data_array, ilevel1);
- }
-
/*
* Get/interpolate texture colors.
*/
@@ -1043,13 +1019,8 @@ lp_build_sample_aos(struct lp_build_sample_context *bld,
/* no need to distinquish between minification and magnification */
lp_build_sample_mipmap(bld,
min_filter, mip_filter,
- s, t, r, lod_fpart,
- width0_vec, width1_vec,
- height0_vec, height1_vec,
- depth0_vec, depth1_vec,
- row_stride0_vec, row_stride1_vec,
- img_stride0_vec, img_stride1_vec,
- data_ptr0, data_ptr1,
+ s, t, r,
+ ilevel0, ilevel1, lod_fpart,
packed_lo, packed_hi);
}
else {
@@ -1069,14 +1040,10 @@ lp_build_sample_aos(struct lp_build_sample_context *bld,
lp_build_if(&if_ctx, flow_ctx, builder, minify);
{
/* Use the minification filter */
- lp_build_sample_mipmap(bld, min_filter, mip_filter,
- s, t, r, lod_fpart,
- width0_vec, width1_vec,
- height0_vec, height1_vec,
- depth0_vec, depth1_vec,
- row_stride0_vec, row_stride1_vec,
- img_stride0_vec, img_stride1_vec,
- data_ptr0, data_ptr1,
+ lp_build_sample_mipmap(bld,
+ min_filter, mip_filter,
+ s, t, r,
+ ilevel0, ilevel1, lod_fpart,
packed_lo, packed_hi);
}
lp_build_else(&if_ctx);
@@ -1084,13 +1051,8 @@ lp_build_sample_aos(struct lp_build_sample_context *bld,
/* Use the magnification filter */
lp_build_sample_mipmap(bld,
mag_filter, PIPE_TEX_MIPFILTER_NONE,
- s, t, r, NULL,
- width_vec, NULL,
- height_vec, NULL,
- depth_vec, NULL,
- row_stride0_vec, NULL,
- img_stride0_vec, NULL,
- data_ptr0, NULL,
+ s, t, r,
+ i32t_zero, NULL, NULL,
packed_lo, packed_hi);
}
lp_build_endif(&if_ctx);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_aos.h b/src/gallium/auxiliary/gallivm/lp_bld_sample_aos.h
index e1045bbbc21..5d9ecac4d50 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample_aos.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_aos.h
@@ -50,15 +50,6 @@ lp_build_sample_aos(struct lp_build_sample_context *bld,
const LLVMValueRef *ddy,
LLVMValueRef lod_bias, /* optional */
LLVMValueRef explicit_lod, /* optional */
- LLVMValueRef width,
- LLVMValueRef height,
- LLVMValueRef depth,
- LLVMValueRef width_vec,
- LLVMValueRef height_vec,
- LLVMValueRef depth_vec,
- LLVMValueRef row_stride_array,
- LLVMValueRef img_stride_array,
- LLVMValueRef data_array,
LLVMValueRef texel_out[4]);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
index 886df7c29c0..158c6e6a79f 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
@@ -82,7 +82,7 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld,
LLVMValueRef texel_out[4])
{
const struct lp_sampler_static_state *static_state = bld->static_state;
- const int dims = texture_dims(static_state->target);
+ const unsigned dims = bld->dims;
struct lp_build_context *int_coord_bld = &bld->int_coord_bld;
LLVMValueRef offset;
LLVMValueRef i, j;
@@ -565,7 +565,7 @@ lp_build_sample_image_nearest(struct lp_build_sample_context *bld,
LLVMValueRef r,
LLVMValueRef colors_out[4])
{
- const int dims = texture_dims(bld->static_state->target);
+ const unsigned dims = bld->dims;
LLVMValueRef x, y, z;
/*
@@ -628,7 +628,7 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld,
LLVMValueRef r,
LLVMValueRef colors_out[4])
{
- const int dims = texture_dims(bld->static_state->target);
+ const unsigned dims = bld->dims;
LLVMValueRef x0, y0, z0, x1, y1, z1;
LLVMValueRef s_fpart, t_fpart, r_fpart;
LLVMValueRef neighbors[2][2][4];
@@ -790,26 +790,32 @@ lp_build_sample_mipmap(struct lp_build_sample_context *bld,
LLVMValueRef s,
LLVMValueRef t,
LLVMValueRef r,
+ LLVMValueRef ilevel0,
+ LLVMValueRef ilevel1,
LLVMValueRef lod_fpart,
- LLVMValueRef width0_vec,
- LLVMValueRef width1_vec,
- LLVMValueRef height0_vec,
- LLVMValueRef height1_vec,
- LLVMValueRef depth0_vec,
- LLVMValueRef depth1_vec,
- LLVMValueRef row_stride0_vec,
- LLVMValueRef row_stride1_vec,
- LLVMValueRef img_stride0_vec,
- LLVMValueRef img_stride1_vec,
- LLVMValueRef data_ptr0,
- LLVMValueRef data_ptr1,
LLVMValueRef *colors_out)
{
LLVMBuilderRef builder = bld->builder;
+ LLVMValueRef width0_vec;
+ LLVMValueRef width1_vec;
+ LLVMValueRef height0_vec;
+ LLVMValueRef height1_vec;
+ LLVMValueRef depth0_vec;
+ LLVMValueRef depth1_vec;
+ LLVMValueRef row_stride0_vec;
+ LLVMValueRef row_stride1_vec;
+ LLVMValueRef img_stride0_vec;
+ LLVMValueRef img_stride1_vec;
+ LLVMValueRef data_ptr0;
+ LLVMValueRef data_ptr1;
LLVMValueRef colors0[4], colors1[4];
unsigned chan;
/* sample the first mipmap level */
+ lp_build_mipmap_level_sizes(bld, ilevel0,
+ &width0_vec, &height0_vec, &depth0_vec,
+ &row_stride0_vec, &img_stride0_vec);
+ data_ptr0 = lp_build_get_mipmap_level(bld, ilevel0);
if (img_filter == PIPE_TEX_FILTER_NEAREST) {
lp_build_sample_image_nearest(bld, unit,
width0_vec, height0_vec, depth0_vec,
@@ -847,6 +853,10 @@ lp_build_sample_mipmap(struct lp_build_sample_context *bld,
lp_build_if(&if_ctx, flow_ctx, builder, need_lerp);
{
/* sample the second mipmap level */
+ lp_build_mipmap_level_sizes(bld, ilevel1,
+ &width1_vec, &height1_vec, &depth1_vec,
+ &row_stride1_vec, &img_stride1_vec);
+ data_ptr1 = lp_build_get_mipmap_level(bld, ilevel1);
if (img_filter == PIPE_TEX_FILTER_NEAREST) {
lp_build_sample_image_nearest(bld, unit,
width1_vec, height1_vec, depth1_vec,
@@ -895,15 +905,6 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
const LLVMValueRef *ddy,
LLVMValueRef lod_bias, /* optional */
LLVMValueRef explicit_lod, /* optional */
- LLVMValueRef width,
- LLVMValueRef height,
- LLVMValueRef depth,
- LLVMValueRef width_vec,
- LLVMValueRef height_vec,
- LLVMValueRef depth_vec,
- LLVMValueRef row_stride_array,
- LLVMValueRef img_stride_array,
- LLVMValueRef data_array,
LLVMValueRef *colors_out)
{
struct lp_build_context *int_bld = &bld->int_bld;
@@ -911,16 +912,12 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
const unsigned mip_filter = bld->static_state->min_mip_filter;
const unsigned min_filter = bld->static_state->min_img_filter;
const unsigned mag_filter = bld->static_state->mag_img_filter;
- const int dims = texture_dims(bld->static_state->target);
LLVMValueRef lod_ipart = NULL, lod_fpart = NULL;
LLVMValueRef ilevel0, ilevel1 = NULL;
- LLVMValueRef width0_vec = NULL, height0_vec = NULL, depth0_vec = NULL;
- LLVMValueRef width1_vec = NULL, height1_vec = NULL, depth1_vec = NULL;
- LLVMValueRef row_stride0_vec = NULL, row_stride1_vec = NULL;
- LLVMValueRef img_stride0_vec = NULL, img_stride1_vec = NULL;
- LLVMValueRef data_ptr0, data_ptr1 = NULL;
LLVMValueRef face_ddx[4], face_ddy[4];
LLVMValueRef texels[4];
+ LLVMTypeRef i32t = LLVMInt32Type();
+ LLVMValueRef i32t_zero = LLVMConstInt(i32t, 0, 0);
unsigned chan;
/*
@@ -962,11 +959,10 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
*/
lp_build_lod_selector(bld, unit, ddx, ddy,
lod_bias, explicit_lod,
- width, height, depth,
mip_filter,
&lod_ipart, &lod_fpart);
} else {
- lod_ipart = LLVMConstInt(LLVMInt32Type(), 0, 0);
+ lod_ipart = i32t_zero;
}
/*
@@ -987,7 +983,7 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
lp_build_nearest_mip_level(bld, unit, lod_ipart, &ilevel0);
}
else {
- ilevel0 = LLVMConstInt(LLVMInt32Type(), 0, 0);
+ ilevel0 = i32t_zero;
}
break;
case PIPE_TEX_MIPFILTER_NEAREST:
@@ -1003,28 +999,6 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
break;
}
- /* compute image size(s) of source mipmap level(s) */
- lp_build_mipmap_level_sizes(bld, dims, width_vec, height_vec, depth_vec,
- ilevel0,
- row_stride_array, img_stride_array,
- &width0_vec, &height0_vec, &depth0_vec,
- &row_stride0_vec, &img_stride0_vec);
- if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) {
- lp_build_mipmap_level_sizes(bld, dims, width_vec, height_vec, depth_vec,
- ilevel1,
- row_stride_array, img_stride_array,
- &width1_vec, &height1_vec, &depth1_vec,
- &row_stride1_vec, &img_stride1_vec);
- }
-
- /*
- * Get pointer(s) to image data for mipmap level(s).
- */
- data_ptr0 = lp_build_get_mipmap_level(bld, data_array, ilevel0);
- if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) {
- data_ptr1 = lp_build_get_mipmap_level(bld, data_array, ilevel1);
- }
-
/*
* Get/interpolate texture colors.
*/
@@ -1038,13 +1012,8 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
/* no need to distinquish between minification and magnification */
lp_build_sample_mipmap(bld, unit,
min_filter, mip_filter,
- s, t, r, lod_fpart,
- width0_vec, width1_vec,
- height0_vec, height1_vec,
- depth0_vec, depth1_vec,
- row_stride0_vec, row_stride1_vec,
- img_stride0_vec, img_stride1_vec,
- data_ptr0, data_ptr1,
+ s, t, r,
+ ilevel0, ilevel1, lod_fpart,
texels);
}
else {
@@ -1066,13 +1035,8 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
/* Use the minification filter */
lp_build_sample_mipmap(bld, unit,
min_filter, mip_filter,
- s, t, r, lod_fpart,
- width0_vec, width1_vec,
- height0_vec, height1_vec,
- depth0_vec, depth1_vec,
- row_stride0_vec, row_stride1_vec,
- img_stride0_vec, img_stride1_vec,
- data_ptr0, data_ptr1,
+ s, t, r,
+ ilevel0, ilevel1, lod_fpart,
texels);
}
lp_build_else(&if_ctx);
@@ -1080,13 +1044,8 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
/* Use the magnification filter */
lp_build_sample_mipmap(bld, unit,
mag_filter, PIPE_TEX_MIPFILTER_NONE,
- s, t, r, NULL,
- width_vec, NULL,
- height_vec, NULL,
- depth_vec, NULL,
- row_stride0_vec, NULL,
- img_stride0_vec, NULL,
- data_ptr0, NULL,
+ s, t, r,
+ i32t_zero, NULL, NULL,
texels);
}
lp_build_endif(&if_ctx);
@@ -1183,11 +1142,7 @@ lp_build_sample_soa(LLVMBuilderRef builder,
unsigned dims = texture_dims(static_state->target);
struct lp_build_sample_context bld;
LLVMTypeRef i32t = LLVMInt32Type();
- LLVMValueRef width, width_vec;
- LLVMValueRef height, height_vec;
- LLVMValueRef depth, depth_vec;
- LLVMValueRef row_stride_array, img_stride_array;
- LLVMValueRef data_array;
+
LLVMValueRef s;
LLVMValueRef t;
LLVMValueRef r;
@@ -1206,6 +1161,7 @@ lp_build_sample_soa(LLVMBuilderRef builder,
bld.static_state = static_state;
bld.dynamic_state = dynamic_state;
bld.format_desc = util_format_description(static_state->format);
+ bld.dims = dims;
bld.float_type = lp_type_float(32);
bld.int_type = lp_type_int(32);
@@ -1230,12 +1186,12 @@ lp_build_sample_soa(LLVMBuilderRef builder,
lp_build_context_init(&bld.texel_bld, builder, bld.texel_type);
/* Get the dynamic state */
- width = dynamic_state->width(dynamic_state, builder, unit);
- height = dynamic_state->height(dynamic_state, builder, unit);
- depth = dynamic_state->depth(dynamic_state, builder, unit);
- row_stride_array = dynamic_state->row_stride(dynamic_state, builder, unit);
- img_stride_array = dynamic_state->img_stride(dynamic_state, builder, unit);
- data_array = dynamic_state->data_ptr(dynamic_state, builder, unit);
+ bld.width = dynamic_state->width(dynamic_state, builder, unit);
+ bld.height = dynamic_state->height(dynamic_state, builder, unit);
+ bld.depth = dynamic_state->depth(dynamic_state, builder, unit);
+ bld.row_stride_array = dynamic_state->row_stride(dynamic_state, builder, unit);
+ bld.img_stride_array = dynamic_state->img_stride(dynamic_state, builder, unit);
+ bld.data_array = dynamic_state->data_ptr(dynamic_state, builder, unit);
/* Note that data_array is an array[level] of pointers to texture images */
s = coords[0];
@@ -1244,25 +1200,25 @@ lp_build_sample_soa(LLVMBuilderRef builder,
/* width, height, depth as single uint vector */
if (dims <= 1) {
- bld.uint_size = width;
+ bld.uint_size = bld.width;
}
else {
bld.uint_size = LLVMBuildInsertElement(builder, bld.uint_size_bld.undef,
- width, LLVMConstInt(i32t, 0, 0), "");
+ bld.width, LLVMConstInt(i32t, 0, 0), "");
if (dims >= 2) {
bld.uint_size = LLVMBuildInsertElement(builder, bld.uint_size,
- height, LLVMConstInt(i32t, 1, 0), "");
+ bld.height, LLVMConstInt(i32t, 1, 0), "");
if (dims >= 3) {
bld.uint_size = LLVMBuildInsertElement(builder, bld.uint_size,
- depth, LLVMConstInt(i32t, 2, 0), "");
+ bld.depth, LLVMConstInt(i32t, 2, 0), "");
}
}
}
/* width, height, depth as uint vectors */
- width_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, width);
- height_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, height);
- depth_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, depth);
+ 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 */
@@ -1274,10 +1230,7 @@ lp_build_sample_soa(LLVMBuilderRef builder,
/* do sampling/filtering with fixed pt arithmetic */
lp_build_sample_aos(&bld, unit, s, t, r, ddx, ddy,
lod_bias, explicit_lod,
- width, height, depth,
- width_vec, height_vec, depth_vec,
- row_stride_array, img_stride_array,
- data_array, texel_out);
+ texel_out);
}
else {
@@ -1295,10 +1248,6 @@ lp_build_sample_soa(LLVMBuilderRef builder,
lp_build_sample_general(&bld, unit, s, t, r, ddx, ddy,
lod_bias, explicit_lod,
- width, height, depth,
- width_vec, height_vec, depth_vec,
- row_stride_array, img_stride_array,
- data_array,
texel_out);
}