summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_alpha.c13
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_alpha.h6
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_logic.c12
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_logic.h9
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_tgsi.h3
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c23
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_fs.c11
7 files changed, 43 insertions, 34 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_alpha.c b/src/gallium/drivers/llvmpipe/lp_bld_alpha.c
index a3faa22b997..58f6f6cd8ff 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_alpha.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_alpha.c
@@ -41,12 +41,12 @@
#include "lp_bld_alpha.h"
-LLVMValueRef
+void
lp_build_alpha_test(LLVMBuilderRef builder,
const struct pipe_alpha_state *state,
union lp_type type,
- LLVMValueRef alpha,
- LLVMValueRef mask)
+ LLVMValueRef *mask,
+ LLVMValueRef alpha)
{
struct lp_build_context bld;
@@ -58,11 +58,6 @@ lp_build_alpha_test(LLVMBuilderRef builder,
lp_build_name(test, "alpha_mask");
- if(mask)
- mask = LLVMBuildAnd(builder, mask, test, "");
- else
- mask = test;
+ lp_build_mask_and(builder, mask, test);
}
-
- return mask;
}
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_alpha.h b/src/gallium/drivers/llvmpipe/lp_bld_alpha.h
index f3fa8b60534..f372210a7a0 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_alpha.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_alpha.h
@@ -41,12 +41,12 @@ struct pipe_alpha_state;
union lp_type;
-LLVMValueRef
+void
lp_build_alpha_test(LLVMBuilderRef builder,
const struct pipe_alpha_state *state,
union lp_type type,
- LLVMValueRef alpha,
- LLVMValueRef mask);
+ LLVMValueRef *mask,
+ LLVMValueRef alpha);
#endif /* !LP_BLD_ALPHA_H */
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_logic.c b/src/gallium/drivers/llvmpipe/lp_bld_logic.c
index 5b8efb05778..1ce9a9109e8 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_logic.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_logic.c
@@ -33,6 +33,18 @@
#include "lp_bld_logic.h"
+void
+lp_build_mask_and(LLVMBuilderRef builder,
+ LLVMValueRef *mask,
+ LLVMValueRef value)
+{
+ if(*mask)
+ *mask = LLVMBuildAnd(builder, *mask, value, "");
+ else
+ *mask = value;
+}
+
+
LLVMValueRef
lp_build_cmp(struct lp_build_context *bld,
unsigned func,
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_logic.h b/src/gallium/drivers/llvmpipe/lp_bld_logic.h
index 0989f9f2078..8ba73b94eda 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_logic.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_logic.h
@@ -45,6 +45,15 @@ struct lp_build_context;
/**
+ * Bitwise AND the mask with the given value, if a previous mask was set.
+ */
+void
+lp_build_mask_and(LLVMBuilderRef builder,
+ LLVMValueRef *mask,
+ LLVMValueRef value);
+
+
+/**
* @param func is one of PIPE_FUNC_xxx
*/
LLVMValueRef
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_tgsi.h b/src/gallium/drivers/llvmpipe/lp_bld_tgsi.h
index b61b2dc5bfd..7ad711e396d 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_tgsi.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_tgsi.h
@@ -40,10 +40,11 @@ lp_build_tgsi_fetch_texel_soa( struct tgsi_sampler **samplers,
uint32_t unit,
float *store );
-LLVMValueRef
+void
lp_build_tgsi_soa(LLVMBuilderRef builder,
const struct tgsi_token *tokens,
union lp_type type,
+ LLVMValueRef *mask,
LLVMValueRef *pos,
LLVMValueRef a0_ptr,
LLVMValueRef dadx_ptr,
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c b/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c
index 01328c1c48a..e392a50005f 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c
@@ -88,7 +88,7 @@ struct lp_build_tgsi_soa_context
LLVMValueRef immediates[LP_MAX_IMMEDIATES][NUM_CHANNELS];
LLVMValueRef temps[LP_MAX_TEMPS][NUM_CHANNELS];
- LLVMValueRef mask;
+ LLVMValueRef *mask;
/** Coords/texels store */
LLVMValueRef store_ptr;
@@ -395,10 +395,7 @@ emit_kil(
mask = lp_build_cmp(&bld->base, PIPE_FUNC_GEQUAL, terms[chan_index], bld->base.zero);
- if(bld->mask)
- bld->mask = LLVMBuildAnd(bld->base.builder, bld->mask, mask, "");
- else
- bld->mask = mask;
+ lp_build_mask_and(bld->base.builder, bld->mask, mask);
}
}
}
@@ -1409,19 +1406,12 @@ emit_declaration(
}
}
-/**
- * Translate a TGSI vertex/fragment shader to SSE2 code.
- * Slightly different things are done for vertex vs. fragment shaders.
- *
- * \param tokens the TGSI input shader
- * \param bld the output SSE code/function
- * \param immediates buffer to place immediates, later passed to SSE bld
- * \param return 1 for success, 0 if translation failed
- */
-LLVMValueRef
+
+void
lp_build_tgsi_soa(LLVMBuilderRef builder,
const struct tgsi_token *tokens,
union lp_type type,
+ LLVMValueRef *mask,
LLVMValueRef *pos,
LLVMValueRef a0_ptr,
LLVMValueRef dadx_ptr,
@@ -1438,6 +1428,7 @@ lp_build_tgsi_soa(LLVMBuilderRef builder,
/* Setup build context */
memset(&bld, 0, sizeof bld);
lp_build_context_init(&bld.base, builder, type);
+ bld.mask = mask;
bld.x = pos[0];
bld.y = pos[1];
bld.w = pos[3];
@@ -1490,7 +1481,5 @@ lp_build_tgsi_soa(LLVMBuilderRef builder,
}
tgsi_parse_free( &parse );
-
- return bld.mask;
}
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 702be429164..22274676df6 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -210,11 +210,13 @@ shader_generate(struct llvmpipe_screen *screen,
setup_pos_vector(builder, x, y, a0_ptr, dadx_ptr, dady_ptr, pos);
+ mask = LLVMBuildLoad(builder, mask_ptr, "");
+
memset(outputs, 0, sizeof outputs);
- mask = lp_build_tgsi_soa(builder, tokens, type,
- pos, a0_ptr, dadx_ptr, dady_ptr,
- consts_ptr, outputs, samplers_ptr);
+ lp_build_tgsi_soa(builder, tokens, type, &mask,
+ pos, a0_ptr, dadx_ptr, dady_ptr,
+ consts_ptr, outputs, samplers_ptr);
for (attrib = 0; attrib < shader->info.num_outputs; ++attrib) {
for(chan = 0; chan < NUM_CHANNELS; ++chan) {
@@ -233,7 +235,8 @@ shader_generate(struct llvmpipe_screen *screen,
/* Alpha test */
/* XXX: should the alpha reference value be passed separately? */
if(cbuf == 0 && chan == 3)
- mask = lp_build_alpha_test(builder, alpha, type, outputs[attrib][chan], mask);
+ lp_build_alpha_test(builder, &key->alpha, type, &mask,
+ outputs[attrib][chan]);
break;
}