Mesa (master): i965/vs: Set brw_vs_prog_key:: clamp_vertex_color to 0 when irrelevant.
Kenneth Graunke
kwg at kemper.freedesktop.org
Wed Dec 3 01:01:12 UTC 2014
Module: Mesa
Branch: master
Commit: 51f7f613f920148d5e9d1f5380da64fd55c66334
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=51f7f613f920148d5e9d1f5380da64fd55c66334
Author: Kenneth Graunke <kenneth at whitecape.org>
Date: Mon Dec 1 01:09:35 2014 -0800
i965/vs: Set brw_vs_prog_key::clamp_vertex_color to 0 when irrelevant.
Vertex color clamping is only relevant if the shader writes to
the built-in gl_[Secondary]{Front,Back}Color varyings. Otherwise,
brw_vs_prog_key::clamp_vertex_color is never used, so we can simply
leave it set to 0.
This enables us to correctly predict the clamp_vertex_color key value
in the precompile for shaders which don't use those varyings.
Eliminates virtually all VS recompiles in Serious Sam 3's intro.
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Reviewed-by: Chris Forbes <chrisf at ijw.co.nz>
---
src/mesa/drivers/dri/i965/brw_vs.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index e5de3c2..2f628e5 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -431,8 +431,11 @@ static void brw_upload_vs_prog(struct brw_context *brw)
ctx->Polygon.BackMode != GL_FILL);
}
- /* _NEW_LIGHT | _NEW_BUFFERS */
- key.clamp_vertex_color = ctx->Light._ClampVertexColor;
+ if (prog->OutputsWritten & (VARYING_BIT_COL0 | VARYING_BIT_COL1 |
+ VARYING_BIT_BFC0 | VARYING_BIT_BFC1)) {
+ /* _NEW_LIGHT | _NEW_BUFFERS */
+ key.clamp_vertex_color = ctx->Light._ClampVertexColor;
+ }
/* _NEW_POINT */
if (brw->gen < 6 && ctx->Point.PointSprite) {
@@ -541,7 +544,9 @@ brw_vs_precompile(struct gl_context *ctx,
memset(&key, 0, sizeof(key));
brw_vec4_setup_prog_key_for_precompile(ctx, &key.base, bvp->id, &vp->Base);
- key.clamp_vertex_color = ctx->API == API_OPENGL_COMPAT;
+ key.clamp_vertex_color =
+ (prog->OutputsWritten & (VARYING_BIT_COL0 | VARYING_BIT_COL1 |
+ VARYING_BIT_BFC0 | VARYING_BIT_BFC1));
success = do_vs_prog(brw, shader_prog, bvp, &key);
More information about the mesa-commit
mailing list