summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/llvmpipe')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_depth.c29
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_fs.c20
2 files changed, 21 insertions, 28 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.c b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
index 79891cf5d83..06556dcba7a 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_depth.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
@@ -349,8 +349,6 @@ get_z_shift_and_mask(const struct util_format_description *format_desc,
{
unsigned total_bits;
unsigned z_swizzle;
- unsigned chan;
- unsigned padding_left, padding_right;
assert(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS);
assert(format_desc->block.width == 1);
@@ -365,25 +363,14 @@ get_z_shift_and_mask(const struct util_format_description *format_desc,
return FALSE;
*width = format_desc->channel[z_swizzle].size;
+ *shift = format_desc->channel[z_swizzle].shift;
- padding_right = 0;
- for (chan = 0; chan < z_swizzle; ++chan)
- padding_right += format_desc->channel[chan].size;
-
- padding_left =
- total_bits - (padding_right + *width);
-
- if (padding_left || padding_right) {
- unsigned long long mask_left = (1ULL << (total_bits - padding_left)) - 1;
- unsigned long long mask_right = (1ULL << (padding_right)) - 1;
- *mask = mask_left ^ mask_right;
- }
- else {
+ if (*width == total_bits) {
*mask = 0xffffffff;
+ } else {
+ *mask = ((1 << *width) - 1) << *shift;
}
- *shift = padding_right;
-
return TRUE;
}
@@ -398,7 +385,7 @@ get_s_shift_and_mask(const struct util_format_description *format_desc,
unsigned *shift, unsigned *mask)
{
unsigned s_swizzle;
- unsigned chan, sz;
+ unsigned sz;
s_swizzle = format_desc->swizzle[1];
@@ -407,16 +394,14 @@ get_s_shift_and_mask(const struct util_format_description *format_desc,
/* just special case 64bit d/s format */
if (format_desc->block.bits > 32) {
+ /* XXX big-endian? */
assert(format_desc->format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT);
*shift = 0;
*mask = 0xff;
return TRUE;
}
- *shift = 0;
- for (chan = 0; chan < s_swizzle; chan++)
- *shift += format_desc->channel[chan].size;
-
+ *shift = format_desc->channel[s_swizzle].shift;
sz = format_desc->channel[s_swizzle].size;
*mask = (1U << sz) - 1U;
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index fc2ba5ed9dc..38e9fc7d736 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -1015,12 +1015,17 @@ convert_to_blend_type(struct gallivm_state *gallivm,
for (i = 0; i < num_srcs; ++i) {
LLVMValueRef chans[4];
LLVMValueRef res = NULL;
- unsigned sa = 0;
dst[i] = LLVMBuildZExt(builder, src[i], lp_build_vec_type(gallivm, src_type), "");
for (j = 0; j < src_fmt->nr_channels; ++j) {
unsigned mask = 0;
+ unsigned sa = src_fmt->channel[j].shift;
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+ unsigned from_lsb = j;
+#else
+ unsigned from_lsb = src_fmt->nr_channels - j - 1;
+#endif
for (k = 0; k < src_fmt->channel[j].size; ++k) {
mask |= 1 << k;
@@ -1046,11 +1051,9 @@ convert_to_blend_type(struct gallivm_state *gallivm,
/* Insert bits into correct position */
chans[j] = LLVMBuildShl(builder,
chans[j],
- lp_build_const_int_vec(gallivm, src_type, j * blend_type.width),
+ lp_build_const_int_vec(gallivm, src_type, from_lsb * blend_type.width),
"");
- sa += src_fmt->channel[j].size;
-
if (j == 0) {
res = chans[j];
} else {
@@ -1166,12 +1169,17 @@ convert_from_blend_type(struct gallivm_state *gallivm,
for (i = 0; i < num_srcs; ++i) {
LLVMValueRef chans[4];
LLVMValueRef res = NULL;
- unsigned sa = 0;
dst[i] = LLVMBuildBitCast(builder, src[i], lp_build_vec_type(gallivm, src_type), "");
for (j = 0; j < src_fmt->nr_channels; ++j) {
unsigned mask = 0;
+ unsigned sa = src_fmt->channel[j].shift;
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+ unsigned from_lsb = j;
+#else
+ unsigned from_lsb = src_fmt->nr_channels - j - 1;
+#endif
assert(blend_type.width > src_fmt->channel[j].size);
@@ -1182,7 +1190,7 @@ convert_from_blend_type(struct gallivm_state *gallivm,
/* Extract bits */
chans[j] = LLVMBuildLShr(builder,
dst[i],
- lp_build_const_int_vec(gallivm, src_type, j * blend_type.width),
+ lp_build_const_int_vec(gallivm, src_type, from_lsb * blend_type.width),
"");
chans[j] = LLVMBuildAnd(builder,