[Mesa-dev] [PATCH 4/5] i965: Make vertex color clamp handling code VS specific.

Kenneth Graunke kenneth at whitecape.org
Mon Dec 1 02:00:38 PST 2014


Vertex color clamping only applies to gl_[Secondary]{Front,Back}Color,
which are compatibility-only built-in varyings.  We only support GS in
core profile, so they can't exist in geometry shaders.

We can drop several dirty bits from the GS program key - they're
unnecessary for a core profile implementation.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_gs.c             | 7 +------
 src/mesa/drivers/dri/i965/brw_program.h        | 4 ++--
 src/mesa/drivers/dri/i965/brw_vec4.cpp         | 1 -
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 7 ++++++-
 src/mesa/drivers/dri/i965/brw_vs.c             | 5 +++--
 5 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c
index b2ecf8f..a964951 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -333,9 +333,6 @@ brw_upload_gs_prog(struct brw_context *brw)
    brw_setup_vec4_key_clip_info(brw, &key.base,
                                 gp->program.Base.UsesClipDistanceOut);
 
-   /* _NEW_LIGHT | _NEW_BUFFERS */
-   key.base.clamp_vertex_color = ctx->Light._ClampVertexColor;
-
    /* _NEW_TEXTURE */
    brw_populate_sampler_prog_key_data(ctx, prog, stage_state->sampler_count,
                                       &key.base.tex);
@@ -364,9 +361,7 @@ brw_upload_gs_prog(struct brw_context *brw)
 
 const struct brw_tracked_state brw_gs_prog = {
    .dirty = {
-      .mesa  = _NEW_BUFFERS |
-               _NEW_LIGHT |
-               _NEW_TEXTURE,
+      .mesa  = _NEW_TEXTURE,
       .brw   = BRW_NEW_GEOMETRY_PROGRAM |
                BRW_NEW_TRANSFORM_FEEDBACK |
                BRW_NEW_VUE_MAP_VS,
diff --git a/src/mesa/drivers/dri/i965/brw_program.h b/src/mesa/drivers/dri/i965/brw_program.h
index bb926f3..f2688f5 100644
--- a/src/mesa/drivers/dri/i965/brw_program.h
+++ b/src/mesa/drivers/dri/i965/brw_program.h
@@ -87,8 +87,6 @@ struct brw_vec4_prog_key {
     */
    unsigned nr_userclip_plane_consts:4;
 
-   bool clamp_vertex_color:1;
-
    struct brw_sampler_prog_key_data tex;
 };
 
@@ -103,6 +101,8 @@ struct brw_vs_prog_key {
 
    bool copy_edgeflag:1;
 
+   bool clamp_vertex_color:1;
+
    /**
     * For pre-Gen6 hardware, a bitfield indicating which texture coordinates
     * are going to be replaced with point coordinates (as a consequence of a
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 534b4b0..bf22ec5 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -1968,7 +1968,6 @@ brw_vec4_setup_prog_key_for_precompile(struct gl_context *ctx,
                                        GLuint id, struct gl_program *prog)
 {
    key->program_string_id = id;
-   key->clamp_vertex_color = ctx->API == API_OPENGL_COMPAT;
 
    unsigned sampler_count = _mesa_fls(prog->SamplersUsed);
    for (unsigned i = 0; i < sampler_count; i++) {
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 66d68c0..4633824 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -3104,8 +3104,13 @@ vec4_visitor::emit_urb_slot(dst_reg reg, int varying)
    case VARYING_SLOT_COL1:
    case VARYING_SLOT_BFC0:
    case VARYING_SLOT_BFC1: {
+      /* These built-in varyings are only supported in compatibility mode,
+       * and we only support GS in core profile.  So, this must be a vertex
+       * shader.
+       */
+      assert(stage == MESA_SHADER_VERTEX);
       vec4_instruction *inst = emit_generic_urb_slot(reg, varying);
-      if (key->clamp_vertex_color)
+      if (((struct brw_vs_prog_key *) key)->clamp_vertex_color)
          inst->saturate = true;
       break;
    }
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index 798d975..e5de3c2 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -380,7 +380,7 @@ brw_vs_debug_recompile(struct brw_context *brw,
    found |= key_debug(brw, "PointCoord replace",
                       old_key->point_coord_replace, key->point_coord_replace);
    found |= key_debug(brw, "vertex color clamping",
-                      old_key->base.clamp_vertex_color, key->base.clamp_vertex_color);
+                      old_key->clamp_vertex_color, key->clamp_vertex_color);
 
    found |= brw_debug_recompile_sampler_key(brw, &old_key->base.tex,
                                             &key->base.tex);
@@ -432,7 +432,7 @@ static void brw_upload_vs_prog(struct brw_context *brw)
    }
 
    /* _NEW_LIGHT | _NEW_BUFFERS */
-   key.base.clamp_vertex_color = ctx->Light._ClampVertexColor;
+   key.clamp_vertex_color = ctx->Light._ClampVertexColor;
 
    /* _NEW_POINT */
    if (brw->gen < 6 && ctx->Point.PointSprite) {
@@ -541,6 +541,7 @@ 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;
 
    success = do_vs_prog(brw, shader_prog, bvp, &key);
 
-- 
2.1.3



More information about the mesa-dev mailing list