summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/draw/draw_llvm.c
diff options
context:
space:
mode:
authorLuca Barbieri <[email protected]>2011-02-16 00:25:54 +0100
committerMarek Olšák <[email protected]>2011-03-31 03:35:31 +0200
commit5f996e2b1d09dad64c088ccabb1a4a53ebfb8102 (patch)
treeb6024af538017958475cd1a913f2677667a90993 /src/gallium/auxiliary/draw/draw_llvm.c
parentebe304fa540f98d047382297f448fec692a67b8b (diff)
draw: implement vertex color clamping, and disable SSE and PPC paths
(some little changes by Marek Olšák) Squashed commit of the following: commit 737c0c6b7d591ac0fc969a7590e1691eeef0ce5e Author: Luca Barbieri <[email protected]> Date: Fri Aug 27 02:13:57 2010 +0200 draw: disable SSE and PPC paths (use LLVM instead) These paths don't support vertex clamping, and are anyway obsoleted by LLVM. If you want to re-enable them, add vertex clamping and test that it works with the ARB_color_buffer_float piglit tests. commit fed3486a7ca0683b403913604a26ee49a3ef48c7 Author: Luca Barbieri <[email protected]> Date: Thu Aug 26 18:27:38 2010 +0200 draw_llvm: respect vertex color clamp commit ef0efe9f3d1d0f9b40ebab78940491d2154277a9 Author: Luca Barbieri <[email protected]> Date: Thu Aug 26 18:26:43 2010 +0200 draw: respect vertex clamping in interpreter path
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_llvm.c')
-rw-r--r--src/gallium/auxiliary/draw/draw_llvm.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index a5217c1d4ec..27c5f3bff5a 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -438,7 +438,8 @@ generate_vs(struct draw_llvm *llvm,
const LLVMValueRef (*inputs)[NUM_CHANNELS],
LLVMValueRef system_values_array,
LLVMValueRef context_ptr,
- struct lp_build_sampler_soa *draw_sampler)
+ struct lp_build_sampler_soa *draw_sampler,
+ boolean clamp_vertex_color)
{
const struct tgsi_token *tokens = llvm->draw->vs.vertex_shader->state.tokens;
struct lp_type vs_type;
@@ -474,6 +475,30 @@ generate_vs(struct draw_llvm *llvm,
outputs,
sampler,
&llvm->draw->vs.vertex_shader->info);
+
+ if(clamp_vertex_color)
+ {
+ LLVMValueRef out;
+ unsigned chan, attrib;
+ struct lp_build_context bld;
+ struct tgsi_shader_info* info = &llvm->draw->vs.vertex_shader->info;
+ lp_build_context_init(&bld, llvm->gallivm, vs_type);
+
+ for (attrib = 0; attrib < info->num_outputs; ++attrib) {
+ for(chan = 0; chan < NUM_CHANNELS; ++chan) {
+ if(outputs[attrib][chan]) {
+ switch (info->output_semantic_name[attrib]) {
+ case TGSI_SEMANTIC_COLOR:
+ case TGSI_SEMANTIC_BCOLOR:
+ out = LLVMBuildLoad(builder, outputs[attrib][chan], "");
+ out = lp_build_clamp(&bld, out, bld.zero, bld.one);
+ LLVMBuildStore(builder, out, outputs[attrib][chan]);
+ break;
+ }
+ }
+ }
+ }
+ }
}
#if DEBUG_STORE
@@ -1235,7 +1260,8 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
ptr_aos,
system_values_array,
context_ptr,
- sampler);
+ sampler,
+ variant->key.clamp_vertex_color);
/* store original positions in clip before further manipulation */
store_clip(gallivm, io, outputs);
@@ -1446,7 +1472,8 @@ draw_llvm_generate_elts(struct draw_llvm *llvm, struct draw_llvm_variant *varian
ptr_aos,
system_values_array,
context_ptr,
- sampler);
+ sampler,
+ variant->key.clamp_vertex_color);
/* store original positions in clip before further manipulation */
store_clip(gallivm, io, outputs);
@@ -1524,6 +1551,8 @@ draw_llvm_make_variant_key(struct draw_llvm *llvm, char *store)
key = (struct draw_llvm_variant_key *)store;
+ key->clamp_vertex_color = llvm->draw->rasterizer->clamp_vertex_color; /**/
+
/* Presumably all variants of the shader should have the same
* number of vertex elements - ie the number of shader inputs.
*/