Module: Mesa Branch: floating Commit: cd451a98dce54e28d9b6b87d2f3033f0a9dec8a9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cd451a98dce54e28d9b6b87d2f3033f0a9dec8a9
Author: Luca Barbieri <[email protected]> Date: Thu Aug 26 18:27:38 2010 +0200 draw_llvm: respect vertex color clamp --- src/gallium/auxiliary/draw/draw_llvm.c | 35 +++++++++++++++++++++++++++++-- src/gallium/auxiliary/draw/draw_llvm.h | 5 ++- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 8759c38..e86534c 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -323,7 +323,8 @@ generate_vs(struct draw_llvm *llvm, LLVMValueRef (*outputs)[NUM_CHANNELS], const LLVMValueRef (*inputs)[NUM_CHANNELS], 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; @@ -358,6 +359,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, builder, 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 @@ -786,7 +811,8 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant) outputs, ptr_aos, context_ptr, - sampler); + sampler, + variant->key.clamp_vertex_color); convert_to_aos(builder, io, outputs, draw->vs.vertex_shader->info.num_outputs, @@ -960,7 +986,8 @@ draw_llvm_generate_elts(struct draw_llvm *llvm, struct draw_llvm_variant *varian outputs, ptr_aos, context_ptr, - sampler); + sampler, + variant->key.clamp_vertex_color); convert_to_aos(builder, io, outputs, draw->vs.vertex_shader->info.num_outputs, @@ -1015,6 +1042,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. */ diff --git a/src/gallium/auxiliary/draw/draw_llvm.h b/src/gallium/auxiliary/draw/draw_llvm.h index 6196b2f..a463f54 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.h +++ b/src/gallium/auxiliary/draw/draw_llvm.h @@ -151,8 +151,9 @@ typedef void struct draw_llvm_variant_key { - unsigned nr_vertex_elements:16; - unsigned nr_samplers:16; + unsigned nr_vertex_elements:8; + unsigned nr_samplers:8; + unsigned clamp_vertex_color:8; /* Variable number of vertex elements: */ _______________________________________________ mesa-commit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-commit
