i965: Make vertex color clamp handling code VS specific.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 1 Dec 2014 09:01:02 +0000 (01:01 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 3 Dec 2014 01:00:26 +0000 (17:00 -0800)
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@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
src/mesa/drivers/dri/i965/brw_gs.c
src/mesa/drivers/dri/i965/brw_program.h
src/mesa/drivers/dri/i965/brw_vec4.cpp
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
src/mesa/drivers/dri/i965/brw_vs.c

index b2ecf8fd0c560136f197f6e8d5f4263a2e74393f..a9649516bf7d50da71dcf42da97cacc7bc35fc55 100644 (file)
@@ -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,
index 57de2728265ff3c10d6d400db6f3d74dd2aaabdf..808fe80f4067a5b6bc865b3e7c819dd78f0a12ec 100644 (file)
@@ -93,8 +93,6 @@ struct brw_vec4_prog_key {
     */
    unsigned nr_userclip_plane_consts:4;
 
-   bool clamp_vertex_color:1;
-
    struct brw_sampler_prog_key_data tex;
 };
 
@@ -109,6 +107,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
index 4d893e15dca7077398bf96cf0f6a6e12b5fe47fb..18a336922a19c1dac0abcc900114d99d4a46b66a 100644 (file)
@@ -1813,7 +1813,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++) {
index 96816b6fbd06b7e2debd1df3b3f00ad3c83fc36a..61af3258cec46f33ca4c3330a0f247b0fc977fc0 100644 (file)
@@ -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;
    }
index 798d975b1e7269a1fc0a4e7a9ca773fa9196112e..e5de3c20d2fdfee749c20503b917a25bf02c9401 100644 (file)
@@ -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);