summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Whitwell <keithw@vmware.com>2010-01-11 12:06:51 +0000
committerKeith Whitwell <keithw@vmware.com>2010-01-11 12:12:59 +0000
commit86f450060debebd66dd5fb72f83800d7634efeaa (patch)
tree9042a96f8a3257bfa3a624ba157bcf7279ba8028
parentad74ea286951634d49d500f2e5ce740072794fe2 (diff)
llvmpipe: force constant interpolation of flatshade colors
Nice speedup for gears.
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_interp.c11
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_interp.h1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state.h6
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_derived.c1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_fs.c7
5 files changed, 21 insertions, 5 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_interp.c b/src/gallium/drivers/llvmpipe/lp_bld_interp.c
index daedf40d55..a6acaead88 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_interp.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_interp.c
@@ -316,6 +316,7 @@ pos_update(struct lp_build_interp_soa_context *bld, int quad_index)
void
lp_build_interp_soa_init(struct lp_build_interp_soa_context *bld,
const struct tgsi_token *tokens,
+ boolean flatshade,
LLVMBuilderRef builder,
struct lp_type type,
LLVMValueRef a0_ptr,
@@ -358,7 +359,15 @@ lp_build_interp_soa_init(struct lp_build_interp_soa_context *bld,
for( attrib = first; attrib <= last; ++attrib ) {
bld->mask[1 + attrib] = mask;
- bld->mode[1 + attrib] = decl->Declaration.Interpolate;
+
+ /* XXX: have mesa set INTERP_CONSTANT in the fragment
+ * shader.
+ */
+ if (decl->Semantic.Name == TGSI_SEMANTIC_COLOR &&
+ flatshade)
+ bld->mode[1 + attrib] = TGSI_INTERPOLATE_CONSTANT;
+ else
+ bld->mode[1 + attrib] = decl->Declaration.Interpolate;
}
bld->num_attribs = MAX2(bld->num_attribs, 1 + last + 1);
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_interp.h b/src/gallium/drivers/llvmpipe/lp_bld_interp.h
index e2b3bc1bf0..ca958cdf34 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_interp.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_interp.h
@@ -79,6 +79,7 @@ struct lp_build_interp_soa_context
void
lp_build_interp_soa_init(struct lp_build_interp_soa_context *bld,
const struct tgsi_token *tokens,
+ boolean flatshade,
LLVMBuilderRef builder,
struct lp_type type,
LLVMValueRef a0_ptr,
diff --git a/src/gallium/drivers/llvmpipe/lp_state.h b/src/gallium/drivers/llvmpipe/lp_state.h
index cb240cb6e5..4c6747bb2b 100644
--- a/src/gallium/drivers/llvmpipe/lp_state.h
+++ b/src/gallium/drivers/llvmpipe/lp_state.h
@@ -66,12 +66,12 @@ struct lp_fragment_shader;
struct lp_fragment_shader_variant_key
{
- enum pipe_format zsbuf_format;
- unsigned nr_cbufs;
-
struct pipe_depth_state depth;
struct pipe_alpha_state alpha;
struct pipe_blend_state blend;
+ enum pipe_format zsbuf_format;
+ unsigned nr_cbufs:8;
+ unsigned flatshade:1;
struct {
ubyte colormask;
diff --git a/src/gallium/drivers/llvmpipe/lp_state_derived.c b/src/gallium/drivers/llvmpipe/lp_state_derived.c
index af02fcfec9..632cafa2e6 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_derived.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_derived.c
@@ -159,6 +159,7 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe )
if (llvmpipe->dirty & (LP_NEW_FS |
LP_NEW_BLEND |
LP_NEW_DEPTH_STENCIL_ALPHA |
+ LP_NEW_RASTERIZER |
LP_NEW_SAMPLER |
LP_NEW_TEXTURE))
llvmpipe_update_fs( llvmpipe );
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 01912d6ea2..7ce7202777 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -718,7 +718,10 @@ generate_fragment(struct llvmpipe_context *lp,
generate_pos0(builder, x, y, &x0, &y0);
- lp_build_interp_soa_init(&interp, shader->base.tokens, builder, fs_type,
+ lp_build_interp_soa_init(&interp,
+ shader->base.tokens,
+ key->flatshade,
+ builder, fs_type,
a0_ptr, dadx_ptr, dady_ptr,
x0, y0);
@@ -958,6 +961,8 @@ make_variant_key(struct llvmpipe_context *lp,
key->alpha.func = lp->depth_stencil->alpha.func;
/* alpha.ref_value is passed in jit_context */
+ key->flatshade = lp->rasterizer->flatshade;
+
if (lp->framebuffer.nr_cbufs) {
memcpy(&key->blend, lp->blend, sizeof key->blend);
}