[Mesa-dev] [PATCH] gallivm: more integer texture format fetch fixes
sroland at vmware.com
sroland at vmware.com
Thu Jan 10 18:22:53 PST 2013
From: Roland Scheidegger <sroland at vmware.com>
Change the texel type to int/uint instead of float throughout the sampling
code which makes it easier to catch errors (as llvm will complain about wrong
types if we mistakenly treat these values as real floats somewhere).
This should also get things like e.g. sampler swizzles (for unused channels)
right.
This fixes piglit texture_integer_glsl130 test.
Border color not working (crashing) yet.
(These formats are not exposed yet in llvmpipe.)
v2: couple cleanups according to José's comments
Reviewed-by: José Fonseca <jfonseca at vmware.com>
---
src/gallium/drivers/llvmpipe/lp_bld_blend.h | 2 +-
src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c | 6 +++---
src/gallium/drivers/llvmpipe/lp_state_fs.c | 22 +++++++++++-----------
src/gallium/drivers/llvmpipe/lp_test_blend.c | 2 +-
4 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend.h b/src/gallium/drivers/llvmpipe/lp_bld_blend.h
index 0a1cea1..3a3be81 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_blend.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_blend.h
@@ -56,7 +56,7 @@ lp_build_blend(struct lp_build_context *bld,
LLVMValueRef
lp_build_blend_aos(struct gallivm_state *gallivm,
const struct pipe_blend_state *blend,
- const enum pipe_format *cbuf_format,
+ const enum pipe_format cbuf_format,
struct lp_type type,
unsigned rt,
LLVMValueRef src,
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
index 641c253..2dc2082 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
@@ -266,7 +266,7 @@ lp_build_blend_factor(struct lp_build_blend_aos_context *bld,
* @param blend the blend state of the shader variant
* @param cbuf_format format of the colour buffer
* @param type data type of the pixel vector
- * @param rt rt number
+ * @param rt blend state index number
* @param src blend src
* @param dst blend dst
* @param mask optional mask to apply to the blending result
@@ -278,7 +278,7 @@ lp_build_blend_factor(struct lp_build_blend_aos_context *bld,
LLVMValueRef
lp_build_blend_aos(struct gallivm_state *gallivm,
const struct pipe_blend_state *blend,
- const enum pipe_format *cbuf_format,
+ const enum pipe_format cbuf_format,
struct lp_type type,
unsigned rt,
LLVMValueRef src,
@@ -298,7 +298,7 @@ lp_build_blend_aos(struct gallivm_state *gallivm,
unsigned alpha_swizzle = UTIL_FORMAT_SWIZZLE_NONE;
unsigned i;
- desc = util_format_description(cbuf_format[rt]);
+ desc = util_format_description(cbuf_format);
/* Setup build context */
memset(&bld, 0, sizeof bld);
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 5a8351b..551fba6 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -1010,7 +1010,7 @@ lp_blend_type_from_format_desc(const struct util_format_description *format_desc
/**
- * Scale a normalised value from src_bits to dst_bits
+ * Scale a normalized value from src_bits to dst_bits
*/
static INLINE LLVMValueRef
scale_bits(struct gallivm_state *gallivm,
@@ -1578,6 +1578,7 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
unsigned pixels = block_size / src_count;
unsigned channels = pad_inline ? TGSI_NUM_CHANNELS : dst_channels;
unsigned alpha_span = 1;
+ LLVMValueRef shuffles[LP_MAX_VECTOR_LENGTH];
/* Check if we need 2 src_alphas for our shuffles */
if (pixels > alpha_type.length) {
@@ -1585,8 +1586,15 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
}
/* Broadcast alpha across all channels, e.g. a1a2 to a1a1a1a1a2a2a2a2 */
+ for (j = 0; j < row_type.length; ++j) {
+ if (j < pixels * channels) {
+ shuffles[j] = lp_build_const_int32(gallivm, j / channels);
+ } else {
+ shuffles[j] = LLVMGetUndef(LLVMInt32TypeInContext(gallivm->context));
+ }
+ }
+
for (i = 0; i < src_count; ++i) {
- LLVMValueRef shuffles[LP_MAX_VECTOR_LENGTH];
unsigned idx1 = i, idx2 = i;
if (alpha_span > 1){
@@ -1594,14 +1602,6 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
idx2 = idx1 + 1;
}
- for (j = 0; j < row_type.length; ++j) {
- if (j < pixels * channels) {
- shuffles[j] = lp_build_const_int32(gallivm, j / channels);
- } else {
- shuffles[j] = LLVMGetUndef(LLVMInt32TypeInContext(gallivm->context));
- }
- }
-
src_alpha[i] = LLVMBuildShuffleVector(builder,
src_alpha[idx1],
src_alpha[idx2],
@@ -1650,7 +1650,7 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
for (i = 0; i < src_count; ++i) {
dst[i] = lp_build_blend_aos(gallivm,
&variant->key.blend,
- variant->key.cbuf_format,
+ out_format,
row_type,
rt,
src[i],
diff --git a/src/gallium/drivers/llvmpipe/lp_test_blend.c b/src/gallium/drivers/llvmpipe/lp_test_blend.c
index 9c0a076..754434d 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_blend.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_blend.c
@@ -172,7 +172,7 @@ add_blend_test(struct gallivm_state *gallivm,
dst = LLVMBuildLoad(builder, dst_ptr, "dst");
con = LLVMBuildLoad(builder, const_ptr, "const");
- res = lp_build_blend_aos(gallivm, blend, &format, type, rt, src, NULL, dst, NULL, con, NULL, swizzle, 4);
+ res = lp_build_blend_aos(gallivm, blend, format, type, rt, src, NULL, dst, NULL, con, NULL, swizzle, 4);
lp_build_name(res, "res");
--
1.7.9.5
More information about the mesa-dev
mailing list