summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2010-02-26 17:44:10 -0700
committerBrian Paul <brianp@vmware.com>2010-03-04 10:53:26 -0700
commit38110fd1c3a6c57d1ff089d546a3456ca1a78da8 (patch)
treefca4f935395a2bce7785cc7029b21895197f09f9 /src
parent8e7a8d65931a650534e0f5c4e0d8118cd6f7636e (diff)
gallivm: clarify unsigned vs. signed integer type construction
The lp_int_type() function was creating an unsigned type. So rename that function to lp_uint_type() and create new lp_int_type() that creates a signed type.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c38
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_type.c20
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_type.h4
3 files changed, 43 insertions, 19 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
index e268862282..64698c660e 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
@@ -70,8 +70,8 @@ struct lp_build_sample_context
struct lp_build_context coord_bld;
/** Integer coordinates */
- struct lp_type int_coord_type;
- struct lp_build_context int_coord_bld;
+ struct lp_type uint_coord_type;
+ struct lp_build_context uint_coord_bld;
/** Output texels type and build context */
struct lp_type texel_type;
@@ -90,7 +90,7 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld,
LLVMValueRef offset;
LLVMValueRef packed;
- offset = lp_build_sample_offset(&bld->int_coord_bld,
+ offset = lp_build_sample_offset(&bld->uint_coord_bld,
bld->format_desc,
x, y, y_stride,
data_ptr);
@@ -121,7 +121,7 @@ lp_build_sample_packed(struct lp_build_sample_context *bld,
{
LLVMValueRef offset;
- offset = lp_build_sample_offset(&bld->int_coord_bld,
+ offset = lp_build_sample_offset(&bld->uint_coord_bld,
bld->format_desc,
x, y, y_stride,
data_ptr);
@@ -145,10 +145,10 @@ lp_build_sample_wrap(struct lp_build_sample_context *bld,
boolean is_pot,
unsigned wrap_mode)
{
- struct lp_build_context *int_coord_bld = &bld->int_coord_bld;
+ struct lp_build_context *uint_coord_bld = &bld->uint_coord_bld;
LLVMValueRef length_minus_one;
- length_minus_one = lp_build_sub(int_coord_bld, length, int_coord_bld->one);
+ length_minus_one = lp_build_sub(uint_coord_bld, length, uint_coord_bld->one);
switch(wrap_mode) {
case PIPE_TEX_WRAP_REPEAT:
@@ -161,8 +161,8 @@ lp_build_sample_wrap(struct lp_build_sample_context *bld,
break;
case PIPE_TEX_WRAP_CLAMP:
- coord = lp_build_max(int_coord_bld, coord, int_coord_bld->zero);
- coord = lp_build_min(int_coord_bld, coord, length_minus_one);
+ coord = lp_build_max(uint_coord_bld, coord, uint_coord_bld->zero);
+ coord = lp_build_min(uint_coord_bld, coord, length_minus_one);
break;
case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
@@ -174,8 +174,8 @@ lp_build_sample_wrap(struct lp_build_sample_context *bld,
/* FIXME */
_debug_printf("llvmpipe: failed to translate texture wrap mode %s\n",
util_dump_tex_wrap(wrap_mode, TRUE));
- coord = lp_build_max(int_coord_bld, coord, int_coord_bld->zero);
- coord = lp_build_min(int_coord_bld, coord, length_minus_one);
+ coord = lp_build_max(uint_coord_bld, coord, uint_coord_bld->zero);
+ coord = lp_build_min(uint_coord_bld, coord, length_minus_one);
break;
default:
@@ -249,8 +249,8 @@ lp_build_sample_2d_linear_soa(struct lp_build_sample_context *bld,
x0 = lp_build_sample_wrap(bld, x0, width, bld->static_state->pot_width, bld->static_state->wrap_s);
y0 = lp_build_sample_wrap(bld, y0, height, bld->static_state->pot_height, bld->static_state->wrap_t);
- x1 = lp_build_add(&bld->int_coord_bld, x0, bld->int_coord_bld.one);
- y1 = lp_build_add(&bld->int_coord_bld, y0, bld->int_coord_bld.one);
+ x1 = lp_build_add(&bld->uint_coord_bld, x0, bld->uint_coord_bld.one);
+ y1 = lp_build_add(&bld->uint_coord_bld, y0, bld->uint_coord_bld.one);
x1 = lp_build_sample_wrap(bld, x1, width, bld->static_state->pot_width, bld->static_state->wrap_s);
y1 = lp_build_sample_wrap(bld, y1, height, bld->static_state->pot_height, bld->static_state->wrap_t);
@@ -358,8 +358,8 @@ lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld,
x0 = lp_build_sample_wrap(bld, x0, width, bld->static_state->pot_width, bld->static_state->wrap_s);
y0 = lp_build_sample_wrap(bld, y0, height, bld->static_state->pot_height, bld->static_state->wrap_t);
- x1 = lp_build_add(&bld->int_coord_bld, x0, bld->int_coord_bld.one);
- y1 = lp_build_add(&bld->int_coord_bld, y0, bld->int_coord_bld.one);
+ x1 = lp_build_add(&bld->uint_coord_bld, x0, bld->uint_coord_bld.one);
+ y1 = lp_build_add(&bld->uint_coord_bld, y0, bld->uint_coord_bld.one);
x1 = lp_build_sample_wrap(bld, x1, width, bld->static_state->pot_width, bld->static_state->wrap_s);
y1 = lp_build_sample_wrap(bld, y1, height, bld->static_state->pot_height, bld->static_state->wrap_t);
@@ -545,10 +545,10 @@ lp_build_sample_soa(LLVMBuilderRef builder,
bld.dynamic_state = dynamic_state;
bld.format_desc = util_format_description(static_state->format);
bld.coord_type = type;
- bld.int_coord_type = lp_int_type(type);
+ bld.uint_coord_type = lp_uint_type(type);
bld.texel_type = type;
lp_build_context_init(&bld.coord_bld, builder, bld.coord_type);
- lp_build_context_init(&bld.int_coord_bld, builder, bld.int_coord_type);
+ lp_build_context_init(&bld.uint_coord_bld, builder, bld.uint_coord_type);
lp_build_context_init(&bld.texel_bld, builder, bld.texel_type);
/* Get the dynamic state */
@@ -561,9 +561,9 @@ lp_build_sample_soa(LLVMBuilderRef builder,
t = coords[1];
p = coords[2];
- width = lp_build_broadcast_scalar(&bld.int_coord_bld, width);
- height = lp_build_broadcast_scalar(&bld.int_coord_bld, height);
- stride = lp_build_broadcast_scalar(&bld.int_coord_bld, stride);
+ width = lp_build_broadcast_scalar(&bld.uint_coord_bld, width);
+ height = lp_build_broadcast_scalar(&bld.uint_coord_bld, height);
+ stride = lp_build_broadcast_scalar(&bld.uint_coord_bld, stride);
if(static_state->target == PIPE_TEXTURE_1D)
t = bld.coord_bld.zero;
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.c b/src/gallium/auxiliary/gallivm/lp_bld_type.c
index 8270cd057f..c327ba045a 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_type.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_type.c
@@ -178,6 +178,25 @@ lp_build_int32_vec4_type(void)
}
+/**
+ * Create unsigned integer type variation of given type.
+ */
+struct lp_type
+lp_uint_type(struct lp_type type)
+{
+ struct lp_type res_type;
+
+ memset(&res_type, 0, sizeof res_type);
+ res_type.width = type.width;
+ res_type.length = type.length;
+
+ return res_type;
+}
+
+
+/**
+ * Create signed integer type variation of given type.
+ */
struct lp_type
lp_int_type(struct lp_type type)
{
@@ -186,6 +205,7 @@ lp_int_type(struct lp_type type)
memset(&res_type, 0, sizeof res_type);
res_type.width = type.width;
res_type.length = type.length;
+ res_type.sign = 1;
return res_type;
}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.h b/src/gallium/auxiliary/gallivm/lp_bld_type.h
index 62ee05be4d..16946cc28a 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_type.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_type.h
@@ -257,6 +257,10 @@ lp_build_int32_vec4_type(void);
struct lp_type
+lp_uint_type(struct lp_type type);
+
+
+struct lp_type
lp_int_type(struct lp_type type);