* for scaled integer texcoords.
* \param block_length is the length of the pixel block along the
* coordinate axis
- * \param coord the incoming texcoord (s,t,r or q) scaled to the texture size
+ * \param coord the incoming texcoord (s,t or r) scaled to the texture size
+ * \param coord_f the incoming texcoord (s,t or r) as float vec
* \param length the texture size along one dimension
* \param stride pixel stride along the coordinate axis (in bytes)
+ * \param offset the texel offset along the coord axis
* \param is_pot if TRUE, length is a power of two
* \param wrap_mode one of PIPE_TEX_WRAP_x
* \param out_offset byte offset for the wrapped coordinate
LLVMValueRef coord_f,
LLVMValueRef length,
LLVMValueRef stride,
+ LLVMValueRef offset,
boolean is_pot,
unsigned wrap_mode,
LLVMValueRef *out_offset,
else {
struct lp_build_context *coord_bld = &bld->coord_bld;
LLVMValueRef length_f = lp_build_int_to_float(coord_bld, length);
+ if (offset) {
+ offset = lp_build_int_to_float(coord_bld, offset);
+ offset = lp_build_div(coord_bld, offset, length_f);
+ coord_f = lp_build_add(coord_bld, coord_f, offset);
+ }
coord = lp_build_fract_safe(coord_bld, coord_f);
coord = lp_build_mul(coord_bld, coord, length_f);
coord = lp_build_itrunc(coord_bld, coord);
/**
* Build LLVM code for texture coord wrapping, for nearest filtering,
* for float texcoords.
- * \param coord the incoming texcoord (s,t,r or q)
+ * \param coord the incoming texcoord (s,t or r)
* \param length the texture size along one dimension
+ * \param offset the texel offset along the coord axis
* \param is_pot if TRUE, length is a power of two
* \param wrap_mode one of PIPE_TEX_WRAP_x
* \param icoord the texcoord after wrapping, as int
lp_build_sample_wrap_nearest_float(struct lp_build_sample_context *bld,
LLVMValueRef coord,
LLVMValueRef length,
+ LLVMValueRef offset,
boolean is_pot,
unsigned wrap_mode,
LLVMValueRef *icoord)
switch(wrap_mode) {
case PIPE_TEX_WRAP_REPEAT:
+ if (offset) {
+ /* this is definitely not ideal for POT case */
+ offset = lp_build_int_to_float(coord_bld, offset);
+ offset = lp_build_div(coord_bld, offset, length);
+ coord = lp_build_add(coord_bld, coord, offset);
+ }
/* take fraction, unnormalize */
coord = lp_build_fract_safe(coord_bld, coord);
coord = lp_build_mul(coord_bld, coord, length);
/* scale coord to length */
coord = lp_build_mul(coord_bld, coord, length);
}
+ if (offset) {
+ offset = lp_build_int_to_float(coord_bld, offset);
+ coord = lp_build_add(coord_bld, coord, offset);
+ }
coord = lp_build_clamp(coord_bld, coord, coord_bld->zero,
length_minus_one);
*icoord = lp_build_itrunc(coord_bld, coord);
* for scaled integer texcoords.
* \param block_length is the length of the pixel block along the
* coordinate axis
- * \param coord0 the incoming texcoord (s,t,r or q) scaled to the texture size
+ * \param coord0 the incoming texcoord (s,t or r) scaled to the texture size
+ * \param coord_f the incoming texcoord (s,t or r) as float vec
* \param length the texture size along one dimension
* \param stride pixel stride along the coordinate axis (in bytes)
+ * \param offset the texel offset along the coord axis
* \param is_pot if TRUE, length is a power of two
* \param wrap_mode one of PIPE_TEX_WRAP_x
* \param offset0 resulting relative offset for coord0
LLVMValueRef coord_f,
LLVMValueRef length,
LLVMValueRef stride,
+ LLVMValueRef offset,
boolean is_pot,
unsigned wrap_mode,
LLVMValueRef *offset0,
LLVMValueRef mask;
LLVMValueRef weight;
LLVMValueRef length_f = lp_build_int_to_float(&bld->coord_bld, length);
+ if (offset) {
+ offset = lp_build_int_to_float(&bld->coord_bld, offset);
+ offset = lp_build_div(&bld->coord_bld, offset, length_f);
+ coord_f = lp_build_add(&bld->coord_bld, coord_f, offset);
+ }
lp_build_coord_repeat_npot_linear(bld, coord_f,
length, length_f,
&coord0, &weight);
else {
LLVMValueRef weight;
LLVMValueRef length_f = lp_build_int_to_float(&bld->coord_bld, length);
+ if (offset) {
+ offset = lp_build_int_to_float(&bld->coord_bld, offset);
+ offset = lp_build_div(&bld->coord_bld, offset, length_f);
+ coord_f = lp_build_add(&bld->coord_bld, coord_f, offset);
+ }
lp_build_coord_repeat_npot_linear(bld, coord_f,
length, length_f,
&coord0, &weight);
* for float texcoords.
* \param block_length is the length of the pixel block along the
* coordinate axis
- * \param coord the incoming texcoord (s,t,r or q)
+ * \param coord the incoming texcoord (s,t or r)
* \param length the texture size along one dimension
+ * \param offset the texel offset along the coord axis
* \param is_pot if TRUE, length is a power of two
* \param wrap_mode one of PIPE_TEX_WRAP_x
* \param coord0 the first texcoord after wrapping, as int
unsigned block_length,
LLVMValueRef coord,
LLVMValueRef length,
+ LLVMValueRef offset,
boolean is_pot,
unsigned wrap_mode,
LLVMValueRef *coord0,
if (is_pot) {
/* mul by size and subtract 0.5 */
coord = lp_build_mul(coord_bld, coord, length);
+ if (offset) {
+ offset = lp_build_int_to_float(coord_bld, offset);
+ coord = lp_build_add(coord_bld, coord, offset);
+ }
if (!force_nearest)
coord = lp_build_sub(coord_bld, coord, half);
*coord1 = lp_build_add(coord_bld, coord, coord_bld->one);
}
else {
LLVMValueRef mask;
+ if (offset) {
+ offset = lp_build_int_to_float(coord_bld, offset);
+ offset = lp_build_div(coord_bld, offset, length);
+ coord = lp_build_add(coord_bld, coord, offset);
+ }
/* wrap with normalized floats is just fract */
coord = lp_build_fract(coord_bld, coord);
/* unnormalize */
/* mul by tex size */
coord = lp_build_mul(coord_bld, coord, length);
}
+ if (offset) {
+ offset = lp_build_int_to_float(coord_bld, offset);
+ coord = lp_build_add(coord_bld, coord, offset);
+ }
/* subtract 0.5 */
if (!force_nearest) {
coord = lp_build_sub(coord_bld, coord, half);
LLVMValueRef s,
LLVMValueRef t,
LLVMValueRef r,
+ const LLVMValueRef *offsets,
LLVMValueRef *colors_lo,
LLVMValueRef *colors_hi)
{
if (dims >= 3)
r_ipart = LLVMBuildAShr(builder, r, i32_c8, "");
+ /* add texel offsets */
+ if (offsets[0]) {
+ s_ipart = lp_build_add(&i32, s_ipart, offsets[0]);
+ if (dims >= 2) {
+ t_ipart = lp_build_add(&i32, t_ipart, offsets[1]);
+ if (dims >= 3) {
+ r_ipart = lp_build_add(&i32, r_ipart, offsets[2]);
+ }
+ }
+ }
+
/* get pixel, row, image strides */
x_stride = lp_build_const_vec(bld->gallivm,
bld->int_coord_bld.type,
lp_build_sample_wrap_nearest_int(bld,
bld->format_desc->block.width,
s_ipart, s_float,
- width_vec, x_stride,
+ width_vec, x_stride, offsets[0],
bld->static_texture_state->pot_width,
bld->static_sampler_state->wrap_s,
&x_offset, &x_subcoord);
lp_build_sample_wrap_nearest_int(bld,
bld->format_desc->block.height,
t_ipart, t_float,
- height_vec, row_stride_vec,
+ height_vec, row_stride_vec, offsets[1],
bld->static_texture_state->pot_height,
bld->static_sampler_state->wrap_t,
&y_offset, &y_subcoord);
lp_build_sample_wrap_nearest_int(bld,
1, /* block length (depth) */
r_ipart, r_float,
- depth_vec, img_stride_vec,
+ depth_vec, img_stride_vec, offsets[2],
bld->static_texture_state->pot_depth,
bld->static_sampler_state->wrap_r,
&z_offset, &z_subcoord);
LLVMValueRef s,
LLVMValueRef t,
LLVMValueRef r,
+ const LLVMValueRef *offsets,
LLVMValueRef *colors_lo,
LLVMValueRef *colors_hi)
{
/* Do texcoord wrapping */
lp_build_sample_wrap_nearest_float(bld,
- s, width_vec,
+ s, width_vec, offsets[0],
bld->static_texture_state->pot_width,
bld->static_sampler_state->wrap_s,
&x_icoord);
if (dims >= 2) {
lp_build_sample_wrap_nearest_float(bld,
- t, height_vec,
+ t, height_vec, offsets[1],
bld->static_texture_state->pot_height,
bld->static_sampler_state->wrap_t,
&y_icoord);
if (dims >= 3) {
lp_build_sample_wrap_nearest_float(bld,
- r, depth_vec,
+ r, depth_vec, offsets[2],
bld->static_texture_state->pot_depth,
bld->static_sampler_state->wrap_r,
&z_icoord);
LLVMValueRef s,
LLVMValueRef t,
LLVMValueRef r,
+ const LLVMValueRef *offsets,
LLVMValueRef *colors_lo,
LLVMValueRef *colors_hi)
{
if (dims >= 3)
r_ipart = LLVMBuildAShr(builder, r, i32_c8, "");
+ /* add texel offsets */
+ if (offsets[0]) {
+ s_ipart = lp_build_add(&i32, s_ipart, offsets[0]);
+ if (dims >= 2) {
+ t_ipart = lp_build_add(&i32, t_ipart, offsets[1]);
+ if (dims >= 3) {
+ r_ipart = lp_build_add(&i32, r_ipart, offsets[2]);
+ }
+ }
+ }
+
/* compute fractional part (AND with 0xff) */
i32_c255 = lp_build_const_int_vec(bld->gallivm, i32.type, 255);
s_fpart = LLVMBuildAnd(builder, s, i32_c255, "");
lp_build_sample_wrap_linear_int(bld,
bld->format_desc->block.width,
s_ipart, &s_fpart, s_float,
- width_vec, x_stride,
+ width_vec, x_stride, offsets[0],
bld->static_texture_state->pot_width,
bld->static_sampler_state->wrap_s,
&x_offset0, &x_offset1,
lp_build_sample_wrap_linear_int(bld,
bld->format_desc->block.height,
t_ipart, &t_fpart, t_float,
- height_vec, y_stride,
+ height_vec, y_stride, offsets[1],
bld->static_texture_state->pot_height,
bld->static_sampler_state->wrap_t,
&y_offset0, &y_offset1,
lp_build_sample_wrap_linear_int(bld,
bld->format_desc->block.height,
r_ipart, &r_fpart, r_float,
- depth_vec, z_stride,
+ depth_vec, z_stride, offsets[2],
bld->static_texture_state->pot_depth,
bld->static_sampler_state->wrap_r,
&z_offset0, &z_offset1,
LLVMValueRef s,
LLVMValueRef t,
LLVMValueRef r,
+ const LLVMValueRef *offsets,
LLVMValueRef *colors_lo,
LLVMValueRef *colors_hi)
{
/* do texcoord wrapping and compute texel offsets */
lp_build_sample_wrap_linear_float(bld,
bld->format_desc->block.width,
- s, width_vec,
+ s, width_vec, offsets[0],
bld->static_texture_state->pot_width,
bld->static_sampler_state->wrap_s,
&x_icoord0, &x_icoord1,
if (dims >= 2) {
lp_build_sample_wrap_linear_float(bld,
bld->format_desc->block.height,
- t, height_vec,
+ t, height_vec, offsets[1],
bld->static_texture_state->pot_height,
bld->static_sampler_state->wrap_t,
&y_icoord0, &y_icoord1,
if (dims >= 3) {
lp_build_sample_wrap_linear_float(bld,
bld->format_desc->block.height,
- r, depth_vec,
+ r, depth_vec, offsets[2],
bld->static_texture_state->pot_depth,
bld->static_sampler_state->wrap_r,
&z_icoord0, &z_icoord1,
LLVMValueRef s,
LLVMValueRef t,
LLVMValueRef r,
+ const LLVMValueRef *offsets,
LLVMValueRef ilevel0,
LLVMValueRef ilevel1,
LLVMValueRef lod_fpart,
lp_build_sample_image_nearest_afloat(bld,
size0,
row_stride0_vec, img_stride0_vec,
- data_ptr0, mipoff0, s, t, r,
+ data_ptr0, mipoff0, s, t, r, offsets,
&colors0_lo, &colors0_hi);
}
else {
lp_build_sample_image_linear_afloat(bld,
size0,
row_stride0_vec, img_stride0_vec,
- data_ptr0, mipoff0, s, t, r,
+ data_ptr0, mipoff0, s, t, r, offsets,
&colors0_lo, &colors0_hi);
}
}
lp_build_sample_image_nearest(bld,
size0,
row_stride0_vec, img_stride0_vec,
- data_ptr0, mipoff0, s, t, r,
+ data_ptr0, mipoff0, s, t, r, offsets,
&colors0_lo, &colors0_hi);
}
else {
lp_build_sample_image_linear(bld,
size0,
row_stride0_vec, img_stride0_vec,
- data_ptr0, mipoff0, s, t, r,
+ data_ptr0, mipoff0, s, t, r, offsets,
&colors0_lo, &colors0_hi);
}
}
lp_build_sample_image_nearest_afloat(bld,
size1,
row_stride1_vec, img_stride1_vec,
- data_ptr1, mipoff1, s, t, r,
+ data_ptr1, mipoff1, s, t, r, offsets,
&colors1_lo, &colors1_hi);
}
else {
lp_build_sample_image_linear_afloat(bld,
size1,
row_stride1_vec, img_stride1_vec,
- data_ptr1, mipoff1, s, t, r,
+ data_ptr1, mipoff1, s, t, r, offsets,
&colors1_lo, &colors1_hi);
}
}
lp_build_sample_image_nearest(bld,
size1,
row_stride1_vec, img_stride1_vec,
- data_ptr1, mipoff1, s, t, r,
+ data_ptr1, mipoff1, s, t, r, offsets,
&colors1_lo, &colors1_hi);
}
else {
lp_build_sample_image_linear(bld,
size1,
row_stride1_vec, img_stride1_vec,
- data_ptr1, mipoff1, s, t, r,
+ data_ptr1, mipoff1, s, t, r, offsets,
&colors1_lo, &colors1_hi);
}
}
LLVMValueRef s,
LLVMValueRef t,
LLVMValueRef r,
+ const LLVMValueRef *offsets,
LLVMValueRef lod_ipart,
LLVMValueRef lod_fpart,
LLVMValueRef ilevel0,
/* no need to distinguish between minification and magnification */
lp_build_sample_mipmap(bld,
min_filter, mip_filter,
- s, t, r,
+ s, t, r, offsets,
ilevel0, ilevel1, lod_fpart,
packed_lo, packed_hi);
}
/* Use the minification filter */
lp_build_sample_mipmap(bld,
min_filter, mip_filter,
- s, t, r,
+ s, t, r, offsets,
ilevel0, ilevel1, lod_fpart,
packed_lo, packed_hi);
}
/* Use the magnification filter */
lp_build_sample_mipmap(bld,
mag_filter, PIPE_TEX_MIPFILTER_NONE,
- s, t, r,
+ s, t, r, offsets,
ilevel0, NULL, NULL,
packed_lo, packed_hi);
}
LLVMValueRef coord,
LLVMValueRef length,
LLVMValueRef length_f,
+ LLVMValueRef offset,
boolean is_pot,
unsigned wrap_mode,
LLVMValueRef *x0_out,
/* mul by size and subtract 0.5 */
coord = lp_build_mul(coord_bld, coord, length_f);
coord = lp_build_sub(coord_bld, coord, half);
+ if (offset) {
+ offset = lp_build_int_to_float(coord_bld, offset);
+ coord = lp_build_add(coord_bld, coord, offset);
+ }
/* convert to int, compute lerp weight */
lp_build_ifloor_fract(coord_bld, coord, &coord0, &weight);
coord1 = lp_build_add(int_coord_bld, coord0, int_coord_bld->one);
}
else {
LLVMValueRef mask;
+ if (offset) {
+ offset = lp_build_int_to_float(coord_bld, offset);
+ offset = lp_build_div(coord_bld, offset, length_f);
+ coord = lp_build_add(coord_bld, coord, offset);
+ }
lp_build_coord_repeat_npot_linear(bld, coord,
length, length_f,
&coord0, &weight);
/* scale coord to length */
coord = lp_build_mul(coord_bld, coord, length_f);
}
+ if (offset) {
+ offset = lp_build_int_to_float(coord_bld, offset);
+ coord = lp_build_add(coord_bld, coord, offset);
+ }
/* clamp to [0, length] */
coord = lp_build_clamp(coord_bld, coord, coord_bld->zero, length_f);
/* mul by tex size */
coord = lp_build_mul(coord_bld, coord, length_f);
}
+ if (offset) {
+ offset = lp_build_int_to_float(coord_bld, offset);
+ coord = lp_build_add(coord_bld, coord, offset);
+ }
+
/* clamp to length max */
coord = lp_build_min(coord_bld, coord, length_f);
/* subtract 0.5 */
/* scale coord to length */
coord = lp_build_mul(coord_bld, coord, length_f);
}
+ if (offset) {
+ offset = lp_build_int_to_float(coord_bld, offset);
+ coord = lp_build_add(coord_bld, coord, offset);
+ }
/* was: clamp to [-0.5, length + 0.5], then sub 0.5 */
/* can skip clamp (though might not work for very large coord values */
coord = lp_build_sub(coord_bld, coord, half);
/* scale coord to length */
coord = lp_build_mul(coord_bld, coord, length_f);
coord = lp_build_sub(coord_bld, coord, half);
+ if (offset) {
+ offset = lp_build_int_to_float(coord_bld, offset);
+ coord = lp_build_add(coord_bld, coord, offset);
+ }
/* convert to int, compute lerp weight */
lp_build_ifloor_fract(coord_bld, coord, &coord0, &weight);
break;
case PIPE_TEX_WRAP_MIRROR_CLAMP:
- coord = lp_build_abs(coord_bld, coord);
-
if (bld->static_sampler_state->normalized_coords) {
/* scale coord to length */
coord = lp_build_mul(coord_bld, coord, length_f);
}
+ if (offset) {
+ offset = lp_build_int_to_float(coord_bld, offset);
+ coord = lp_build_add(coord_bld, coord, offset);
+ }
+ coord = lp_build_abs(coord_bld, coord);
/* clamp to [0, length] */
coord = lp_build_min(coord_bld, coord, length_f);
LLVMValueRef min, max;
struct lp_build_context abs_coord_bld = bld->coord_bld;
abs_coord_bld.type.sign = FALSE;
- coord = lp_build_abs(coord_bld, coord);
if (bld->static_sampler_state->normalized_coords) {
/* scale coord to length */
coord = lp_build_mul(coord_bld, coord, length_f);
}
+ if (offset) {
+ offset = lp_build_int_to_float(coord_bld, offset);
+ coord = lp_build_add(coord_bld, coord, offset);
+ }
+ coord = lp_build_abs(coord_bld, coord);
/* clamp to [0.5, length - 0.5] */
min = half;
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
{
- coord = lp_build_abs(coord_bld, coord);
-
if (bld->static_sampler_state->normalized_coords) {
/* scale coord to length */
coord = lp_build_mul(coord_bld, coord, length_f);
}
+ if (offset) {
+ offset = lp_build_int_to_float(coord_bld, offset);
+ coord = lp_build_add(coord_bld, coord, offset);
+ }
+ coord = lp_build_abs(coord_bld, coord);
/* was: clamp to [-0.5, length + 0.5] then sub 0.5 */
/* skip clamp - always positive, and other side
* Build LLVM code for texture wrap mode for nearest filtering.
* \param coord the incoming texcoord (nominally in [0,1])
* \param length the texture size along one dimension, as int vector
+ * \param length_f the texture size along one dimension, as float vector
+ * \param offset texel offset along one dimension (as int vector)
* \param is_pot if TRUE, length is a power of two
* \param wrap_mode one of PIPE_TEX_WRAP_x
*/
LLVMValueRef coord,
LLVMValueRef length,
LLVMValueRef length_f,
+ LLVMValueRef offset,
boolean is_pot,
unsigned wrap_mode)
{
if (is_pot) {
coord = lp_build_mul(coord_bld, coord, length_f);
icoord = lp_build_ifloor(coord_bld, coord);
+ if (offset) {
+ icoord = lp_build_add(int_coord_bld, icoord, offset);
+ }
icoord = LLVMBuildAnd(builder, icoord, length_minus_one, "");
}
else {
+ if (offset) {
+ offset = lp_build_int_to_float(coord_bld, offset);
+ offset = lp_build_div(coord_bld, offset, length_f);
+ coord = lp_build_add(coord_bld, coord, offset);
+ }
/* take fraction, unnormalize */
coord = lp_build_fract_safe(coord_bld, coord);
coord = lp_build_mul(coord_bld, coord, length_f);
/* floor */
/* use itrunc instead since we clamp to 0 anyway */
icoord = lp_build_itrunc(coord_bld, coord);
+ if (offset) {
+ icoord = lp_build_add(int_coord_bld, icoord, offset);
+ }
/* clamp to [0, length - 1]. */
icoord = lp_build_clamp(int_coord_bld, icoord, int_coord_bld->zero,
}
/* no clamp necessary, border masking will handle this */
icoord = lp_build_ifloor(coord_bld, coord);
+ if (offset) {
+ icoord = lp_build_add(int_coord_bld, icoord, offset);
+ }
break;
case PIPE_TEX_WRAP_MIRROR_REPEAT:
+ if (offset) {
+ offset = lp_build_int_to_float(coord_bld, offset);
+ offset = lp_build_div(coord_bld, offset, length_f);
+ coord = lp_build_add(coord_bld, coord, offset);
+ }
/* compute mirror function */
coord = lp_build_coord_mirror(bld, coord);
case PIPE_TEX_WRAP_MIRROR_CLAMP:
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
- coord = lp_build_abs(coord_bld, coord);
-
if (bld->static_sampler_state->normalized_coords) {
/* scale coord to length */
coord = lp_build_mul(coord_bld, coord, length_f);
}
+ if (offset) {
+ offset = lp_build_int_to_float(coord_bld, offset);
+ coord = lp_build_add(coord_bld, coord, offset);
+ }
+ coord = lp_build_abs(coord_bld, coord);
/* itrunc == ifloor here */
icoord = lp_build_itrunc(coord_bld, coord);
break;
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
- coord = lp_build_abs(coord_bld, coord);
-
if (bld->static_sampler_state->normalized_coords) {
/* scale coord to length */
coord = lp_build_mul(coord_bld, coord, length_f);
}
+ if (offset) {
+ offset = lp_build_int_to_float(coord_bld, offset);
+ coord = lp_build_add(coord_bld, coord, offset);
+ }
+ coord = lp_build_abs(coord_bld, coord);
/* itrunc == ifloor here */
icoord = lp_build_itrunc(coord_bld, coord);
LLVMValueRef s,
LLVMValueRef t,
LLVMValueRef r,
+ const LLVMValueRef *offsets,
LLVMValueRef colors_out[4])
{
const unsigned dims = bld->dims;
/*
* Compute integer texcoords.
*/
- x = lp_build_sample_wrap_nearest(bld, s, width_vec, flt_width_vec,
+ x = lp_build_sample_wrap_nearest(bld, s, width_vec, flt_width_vec, offsets[0],
bld->static_texture_state->pot_width,
bld->static_sampler_state->wrap_s);
lp_build_name(x, "tex.x.wrapped");
if (dims >= 2) {
- y = lp_build_sample_wrap_nearest(bld, t, height_vec, flt_height_vec,
+ y = lp_build_sample_wrap_nearest(bld, t, height_vec, flt_height_vec, offsets[1],
bld->static_texture_state->pot_height,
bld->static_sampler_state->wrap_t);
lp_build_name(y, "tex.y.wrapped");
if (dims == 3) {
- z = lp_build_sample_wrap_nearest(bld, r, depth_vec, flt_depth_vec,
+ z = lp_build_sample_wrap_nearest(bld, r, depth_vec, flt_depth_vec, offsets[2],
bld->static_texture_state->pot_depth,
bld->static_sampler_state->wrap_r);
lp_build_name(z, "tex.z.wrapped");
LLVMValueRef s,
LLVMValueRef t,
LLVMValueRef r,
+ const LLVMValueRef *offsets,
LLVMValueRef colors_out[4])
{
const unsigned dims = bld->dims;
/*
* Compute integer texcoords.
*/
- lp_build_sample_wrap_linear(bld, s, width_vec, flt_width_vec,
+ lp_build_sample_wrap_linear(bld, s, width_vec, flt_width_vec, offsets[0],
bld->static_texture_state->pot_width,
bld->static_sampler_state->wrap_s,
&x0, &x1, &s_fpart);
lp_build_name(x1, "tex.x1.wrapped");
if (dims >= 2) {
- lp_build_sample_wrap_linear(bld, t, height_vec, flt_height_vec,
+ lp_build_sample_wrap_linear(bld, t, height_vec, flt_height_vec, offsets[1],
bld->static_texture_state->pot_height,
bld->static_sampler_state->wrap_t,
&y0, &y1, &t_fpart);
lp_build_name(y1, "tex.y1.wrapped");
if (dims == 3) {
- lp_build_sample_wrap_linear(bld, r, depth_vec, flt_depth_vec,
+ lp_build_sample_wrap_linear(bld, r, depth_vec, flt_depth_vec, offsets[2],
bld->static_texture_state->pot_depth,
bld->static_sampler_state->wrap_r,
&z0, &z1, &r_fpart);
LLVMValueRef s,
LLVMValueRef t,
LLVMValueRef r,
+ const LLVMValueRef *offsets,
LLVMValueRef ilevel0,
LLVMValueRef ilevel1,
LLVMValueRef lod_fpart,
lp_build_sample_image_nearest(bld, sampler_unit,
size0,
row_stride0_vec, img_stride0_vec,
- data_ptr0, mipoff0, s, t, r,
+ data_ptr0, mipoff0, s, t, r, offsets,
colors0);
}
else {
lp_build_sample_image_linear(bld, sampler_unit,
size0,
row_stride0_vec, img_stride0_vec,
- data_ptr0, mipoff0, s, t, r,
+ data_ptr0, mipoff0, s, t, r, offsets,
colors0);
}
lp_build_sample_image_nearest(bld, sampler_unit,
size1,
row_stride1_vec, img_stride1_vec,
- data_ptr1, mipoff1, s, t, r,
+ data_ptr1, mipoff1, s, t, r, offsets,
colors1);
}
else {
lp_build_sample_image_linear(bld, sampler_unit,
size1,
row_stride1_vec, img_stride1_vec,
- data_ptr1, mipoff1, s, t, r,
+ data_ptr1, mipoff1, s, t, r, offsets,
colors1);
}
LLVMValueRef s,
LLVMValueRef t,
LLVMValueRef r,
+ const LLVMValueRef *offsets,
LLVMValueRef lod_ipart,
LLVMValueRef lod_fpart,
LLVMValueRef ilevel0,
/* no need to distinguish between minification and magnification */
lp_build_sample_mipmap(bld, sampler_unit,
min_filter, mip_filter,
- s, t, r,
+ s, t, r, offsets,
ilevel0, ilevel1, lod_fpart,
texels);
}
/* Use the minification filter */
lp_build_sample_mipmap(bld, sampler_unit,
min_filter, mip_filter,
- s, t, r,
+ s, t, r, offsets,
ilevel0, ilevel1, lod_fpart,
texels);
}
/* Use the magnification filter */
lp_build_sample_mipmap(bld, sampler_unit,
mag_filter, PIPE_TEX_MIPFILTER_NONE,
- s, t, r,
+ s, t, r, offsets,
ilevel0, NULL, NULL,
texels);
}
if (use_aos) {
/* do sampling/filtering with fixed pt arithmetic */
lp_build_sample_aos(&bld, sampler_index,
- s, t, r,
+ s, t, r, offsets,
lod_ipart, lod_fpart,
ilevel0, ilevel1,
texel_out);
else {
lp_build_sample_general(&bld, sampler_index,
- s, t, r,
+ s, t, r, offsets,
lod_ipart, lod_fpart,
ilevel0, ilevel1,
texel_out);
LLVMValueRef lod_iparts, lod_fparts = NULL;
LLVMValueRef ilevel0s, ilevel1s = NULL;
LLVMValueRef indexi = lp_build_const_int32(gallivm, i);
+ LLVMValueRef offsets4[4] = { NULL };
s4 = lp_build_extract_range(gallivm, s, 4*i, 4);
t4 = lp_build_extract_range(gallivm, t, 4*i, 4);
r4 = lp_build_extract_range(gallivm, r, 4*i, 4);
+
+ if (offsets[0]) {
+ offsets4[0] = lp_build_extract_range(gallivm, offsets[0], 4*i, 4);
+ if (dims > 1) {
+ offsets4[1] = lp_build_extract_range(gallivm, offsets[1], 4*i, 4);
+ if (dims > 2) {
+ offsets4[2] = lp_build_extract_range(gallivm, offsets[2], 4*i, 4);
+ }
+ }
+ }
lod_iparts = LLVMBuildExtractElement(builder, lod_ipart, indexi, "");
ilevel0s = LLVMBuildExtractElement(builder, ilevel0, indexi, "");
if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) {
if (use_aos) {
/* do sampling/filtering with fixed pt arithmetic */
lp_build_sample_aos(&bld4, sampler_index,
- s4, t4, r4,
+ s4, t4, r4, offsets4,
lod_iparts, lod_fparts,
ilevel0s, ilevel1s,
texelout4);
else {
lp_build_sample_general(&bld4, sampler_index,
- s4, t4, r4,
+ s4, t4, r4, offsets4,
lod_iparts, lod_fparts,
ilevel0s, ilevel1s,
texelout4);