i965: Remove the brw_vue_prog_key base class.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 28 Aug 2015 01:24:39 +0000 (18:24 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Fri, 4 Sep 2015 05:31:04 +0000 (22:31 -0700)
The legacy userclip fields are only used for the vertex shader, and at
that point there's only program_string_id and the tex struct, which are
common to all keys.  So there's no need for a "VUE" key base class.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
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.h
src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp
src/mesa/drivers/dri/i965/brw_vs.c

index 7100646750e241df10a5a6dda0ef3d694552bb0e..5cb794b5fd17587aaa54ac83af3d148010442cb8 100644 (file)
@@ -783,8 +783,8 @@ fs_visitor::emit_fb_writes()
 void
 fs_visitor::setup_uniform_clipplane_values(gl_clip_plane *clip_planes)
 {
-   const struct brw_vue_prog_key *key =
-      (const struct brw_vue_prog_key *) this->key;
+   const struct brw_vs_prog_key *key =
+      (const struct brw_vs_prog_key *) this->key;
 
    for (int i = 0; i < key->nr_userclip_plane_consts; i++) {
       this->userplane[i] = fs_reg(UNIFORM, uniforms);
@@ -806,8 +806,8 @@ void fs_visitor::compute_clip_distance(gl_clip_plane *clip_planes)
 {
    struct brw_vue_prog_data *vue_prog_data =
       (struct brw_vue_prog_data *) prog_data;
-   const struct brw_vue_prog_key *key =
-      (const struct brw_vue_prog_key *) this->key;
+   const struct brw_vs_prog_key *key =
+      (const struct brw_vs_prog_key *) this->key;
 
    /* Bail unless some sort of legacy clipping is enabled */
    if (key->nr_userclip_plane_consts == 0)
@@ -1076,8 +1076,10 @@ fs_visitor::fs_visitor(const struct brw_compiler *compiler, void *log_data,
       key_tex = &((const brw_wm_prog_key *) key)->tex;
       break;
    case MESA_SHADER_VERTEX:
+      key_tex = &((const brw_vs_prog_key *) key)->tex;
+      break;
    case MESA_SHADER_GEOMETRY:
-      key_tex = &((const brw_vue_prog_key *) key)->tex;
+      key_tex = &((const brw_gs_prog_key *) key)->tex;
       break;
    case MESA_SHADER_COMPUTE:
       key_tex = &((const brw_cs_prog_key*) key)->tex;
index f1da63543c4bbf94b59af86212f5925617ce654a..1c1a0953bbe3d4fff9ed7328b62e1ef09758e7fd 100644 (file)
@@ -300,11 +300,11 @@ brw_gs_populate_key(struct brw_context *brw,
 
    memset(key, 0, sizeof(*key));
 
-   key->base.program_string_id = gp->id;
+   key->program_string_id = gp->id;
 
    /* _NEW_TEXTURE */
    brw_populate_sampler_prog_key_data(ctx, prog, stage_state->sampler_count,
-                                      &key->base.tex);
+                                      &key->tex);
 
    /* BRW_NEW_VUE_MAP_VS */
    key->input_varyings = brw->vue_map_vs.slots_valid;
@@ -381,7 +381,8 @@ brw_gs_precompile(struct gl_context *ctx,
 
    memset(&key, 0, sizeof(key));
 
-   brw_vue_setup_prog_key_for_precompile(ctx, &key.base, bgp->id, &gp->Base);
+   brw_setup_tex_for_precompile(brw, &key.tex, prog);
+   key.program_string_id = bgp->id;
 
    /* Assume that the set of varyings coming in from the vertex shader exactly
     * matches what the geometry shader requires.
index 5ebf9226cdd48bdd2f30d23cf5103b0919fe00b5..00e8f3f370eb871025ef965f5ff17029608e21c3 100644 (file)
@@ -78,24 +78,9 @@ struct brw_sampler_prog_key_data {
 };
 
 
-struct brw_vue_prog_key {
-   unsigned program_string_id;
-
-   /**
-    * How many user clipping planes are being uploaded to the vertex shader as
-    * push constants.
-    *
-    * These are used for lowering legacy gl_ClipVertex/gl_Position clipping to
-    * clip distances.
-    */
-   unsigned nr_userclip_plane_consts:4;
-
-   struct brw_sampler_prog_key_data tex;
-};
-
 /** The program key for Vertex Shaders. */
 struct brw_vs_prog_key {
-   struct brw_vue_prog_key base;
+   unsigned program_string_id;
 
    /*
     * Per-attribute workaround flags
@@ -106,6 +91,15 @@ struct brw_vs_prog_key {
 
    bool clamp_vertex_color:1;
 
+   /**
+    * How many user clipping planes are being uploaded to the vertex shader as
+    * push constants.
+    *
+    * These are used for lowering legacy gl_ClipVertex/gl_Position clipping to
+    * clip distances.
+    */
+   unsigned nr_userclip_plane_consts:4;
+
    /**
     * For pre-Gen6 hardware, a bitfield indicating which texture coordinates
     * are going to be replaced with point coordinates (as a consequence of a
@@ -115,14 +109,18 @@ struct brw_vs_prog_key {
     * the VUE, even if they aren't written by the vertex shader.
     */
    uint8_t point_coord_replace;
+
+   struct brw_sampler_prog_key_data tex;
 };
 
 /** The program key for Geometry Shaders. */
 struct brw_gs_prog_key
 {
-   struct brw_vue_prog_key base;
+   unsigned program_string_id;
 
    uint64_t input_varyings;
+
+   struct brw_sampler_prog_key_data tex;
 };
 
 /** The program key for Fragment/Pixel Shaders. */
index 073e90beb6062e270d50416778b3fab31ba71ecb..24b2be916a6c3b3d1c341113884d8e38a4570547 100644 (file)
@@ -2011,16 +2011,4 @@ brw_vs_emit(struct brw_context *brw,
    return assembly;
 }
 
-
-void
-brw_vue_setup_prog_key_for_precompile(struct gl_context *ctx,
-                                      struct brw_vue_prog_key *key,
-                                      GLuint id, struct gl_program *prog)
-{
-   struct brw_context *brw = brw_context(ctx);
-   key->program_string_id = id;
-
-   brw_setup_tex_for_precompile(brw, &key->tex, prog);
-}
-
 } /* extern "C" */
index 7df87b5d8417369be38e9a3037a9ac5bc0ff62c6..01c6e8492c7b7fcd3368ae3097b7d238f6a87b3a 100644 (file)
@@ -52,11 +52,6 @@ extern "C" {
 extern "C" {
 #endif
 
-void
-brw_vue_setup_prog_key_for_precompile(struct gl_context *ctx,
-                                      struct brw_vue_prog_key *key,
-                                      GLuint id, struct gl_program *prog);
-
 #ifdef __cplusplus
 } /* extern "C" */
 
@@ -76,7 +71,7 @@ public:
    vec4_visitor(const struct brw_compiler *compiler,
                 void *log_data,
                 struct gl_program *prog,
-                const struct brw_vue_prog_key *key,
+                const struct brw_sampler_prog_key_data *key,
                 struct brw_vue_prog_data *prog_data,
                struct gl_shader_program *shader_prog,
                 gl_shader_stage stage,
@@ -100,7 +95,6 @@ public:
       return dst_reg(retype(brw_null_reg(), BRW_REGISTER_TYPE_UD));
    }
 
-   const struct brw_vue_prog_key * const key;
    const struct brw_sampler_prog_key_data * const key_tex;
    struct brw_vue_prog_data * const prog_data;
    unsigned int sanity_param_count;
index 4fd626f52c94db15aca62d7c1255629117d99859..b9694f67787225ab26d5951b0a04a4dd49d3b56f 100644 (file)
@@ -42,7 +42,7 @@ vec4_gs_visitor::vec4_gs_visitor(const struct brw_compiler *compiler,
                                  bool no_spills,
                                  int shader_time_index)
    : vec4_visitor(compiler, log_data,
-                  &c->gp->program.Base, &c->key.base,
+                  &c->gp->program.Base, &c->key.tex,
                   &c->prog_data.base, prog, MESA_SHADER_GEOMETRY, mem_ctx,
                   no_spills, shader_time_index),
      c(c)
index 034286fbf2ec5b71979a1573152a71390ba01c37..0ff298ed0e9098e34392fbb3b281e3a58fbe494d 100644 (file)
@@ -3692,7 +3692,7 @@ vec4_visitor::resolve_bool_comparison(ir_rvalue *rvalue, src_reg *reg)
 vec4_visitor::vec4_visitor(const struct brw_compiler *compiler,
                            void *log_data,
                            struct gl_program *prog,
-                           const struct brw_vue_prog_key *key,
+                           const struct brw_sampler_prog_key_data *key_tex,
                            struct brw_vue_prog_data *prog_data,
                           struct gl_shader_program *shader_prog,
                            gl_shader_stage stage,
@@ -3701,8 +3701,7 @@ vec4_visitor::vec4_visitor(const struct brw_compiler *compiler,
                            int shader_time_index)
    : backend_shader(compiler, log_data, mem_ctx,
                     shader_prog, prog, &prog_data->base, stage),
-     key(key),
-     key_tex(&key->tex),
+     key_tex(key_tex),
      prog_data(prog_data),
      sanity_param_count(0),
      fail_msg(NULL),
index 442cefd6c43d387376a157762c9c87a48bafe895..f4b50ba9d9fd74a4ddce6252752658a14937263f 100644 (file)
@@ -247,7 +247,7 @@ vec4_vs_visitor::emit_clip_distances(dst_reg reg, int offset)
       clip_vertex = VARYING_SLOT_POS;
    }
 
-   for (int i = 0; i + offset < key->base.nr_userclip_plane_consts && i < 4;
+   for (int i = 0; i + offset < key->nr_userclip_plane_consts && i < 4;
         ++i) {
       reg.writemask = 1 << i;
       emit(DP4(reg,
@@ -260,7 +260,7 @@ vec4_vs_visitor::emit_clip_distances(dst_reg reg, int offset)
 void
 vec4_vs_visitor::setup_uniform_clipplane_values()
 {
-   for (int i = 0; i < key->base.nr_userclip_plane_consts; ++i) {
+   for (int i = 0; i < key->nr_userclip_plane_consts; ++i) {
       assert(this->uniforms < uniform_array_size);
       this->uniform_vector_size[this->uniforms] = 4;
       this->userplane[i] = dst_reg(UNIFORM, this->uniforms);
@@ -280,7 +280,7 @@ vec4_vs_visitor::emit_thread_end()
    setup_uniform_clipplane_values();
 
    /* Lower legacy ff and ClipVertex clipping to clip distances */
-   if (key->base.nr_userclip_plane_consts > 0) {
+   if (key->nr_userclip_plane_consts > 0) {
       current_annotation = "user clip distances";
 
       output_reg[VARYING_SLOT_CLIP_DIST0] = dst_reg(this, glsl_type::vec4_type);
@@ -309,7 +309,7 @@ vec4_vs_visitor::vec4_vs_visitor(const struct brw_compiler *compiler,
                                  int shader_time_index,
                                  bool use_legacy_snorm_formula)
    : vec4_visitor(compiler, log_data,
-                  &vp->Base, &key->base, &vs_prog_data->base, prog,
+                  &vp->Base, &key->tex, &vs_prog_data->base, prog,
                   MESA_SHADER_VERTEX,
                   mem_ctx, false /* no_spills */,
                   shader_time_index),
index 365396825dcfa904a6a11e1a2496f6069d007e11..df7e5314d6e7f1c89d7a0225c4d495bb4ff9488f 100644 (file)
@@ -130,7 +130,7 @@ brw_codegen_vs_prog(struct brw_context *brw,
    /* vec4_visitor::setup_uniform_clipplane_values() also uploads user clip
     * planes as uniforms.
     */
-   param_count += key->base.nr_userclip_plane_consts * 4;
+   param_count += key->nr_userclip_plane_consts * 4;
 
    stage_prog_data->param =
       rzalloc_array(NULL, const gl_constant_value *, param_count);
@@ -172,7 +172,7 @@ brw_codegen_vs_prog(struct brw_context *brw,
     * distance varying slots whenever clipping is enabled, even if the vertex
     * shader doesn't write to gl_ClipDistance.
     */
-   if (key->base.nr_userclip_plane_consts > 0) {
+   if (key->nr_userclip_plane_consts > 0) {
       outputs_written |= BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST0);
       outputs_written |= BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST1);
    }
@@ -237,7 +237,7 @@ brw_vs_debug_recompile(struct brw_context *brw,
          if (c->cache_id == BRW_CACHE_VS_PROG) {
             old_key = c->key;
 
-            if (old_key->base.program_string_id == key->base.program_string_id)
+            if (old_key->program_string_id == key->program_string_id)
                break;
          }
       }
@@ -258,8 +258,8 @@ brw_vs_debug_recompile(struct brw_context *brw,
    }
 
    found |= key_debug(brw, "legacy user clipping",
-                      old_key->base.nr_userclip_plane_consts,
-                      key->base.nr_userclip_plane_consts);
+                      old_key->nr_userclip_plane_consts,
+                      key->nr_userclip_plane_consts);
 
    found |= key_debug(brw, "copy edgeflag",
                       old_key->copy_edgeflag, key->copy_edgeflag);
@@ -268,8 +268,7 @@ brw_vs_debug_recompile(struct brw_context *brw,
    found |= key_debug(brw, "vertex color clamping",
                       old_key->clamp_vertex_color, key->clamp_vertex_color);
 
-   found |= brw_debug_recompile_sampler_key(brw, &old_key->base.tex,
-                                            &key->base.tex);
+   found |= brw_debug_recompile_sampler_key(brw, &old_key->tex, &key->tex);
 
    if (!found) {
       perf_debug("  Something else\n");
@@ -306,11 +305,11 @@ brw_vs_populate_key(struct brw_context *brw,
    /* Just upload the program verbatim for now.  Always send it all
     * the inputs it asks for, whether they are varying or not.
     */
-   key->base.program_string_id = vp->id;
+   key->program_string_id = vp->id;
 
    if (ctx->Transform.ClipPlanesEnabled != 0 &&
        !vp->program.Base.UsesClipDistanceOut) {
-      key->base.nr_userclip_plane_consts =
+      key->nr_userclip_plane_consts =
          _mesa_logbase2(ctx->Transform.ClipPlanesEnabled) + 1;
    }
 
@@ -336,7 +335,7 @@ brw_vs_populate_key(struct brw_context *brw,
 
    /* _NEW_TEXTURE */
    brw_populate_sampler_prog_key_data(ctx, prog, brw->vs.base.sampler_count,
-                                      &key->base.tex);
+                                      &key->tex);
 
    /* BRW_NEW_VS_ATTRIB_WORKAROUNDS */
    memcpy(key->gl_attrib_wa_flags, brw->vb.attrib_wa_flags,
@@ -398,7 +397,8 @@ brw_vs_precompile(struct gl_context *ctx,
 
    memset(&key, 0, sizeof(key));
 
-   brw_vue_setup_prog_key_for_precompile(ctx, &key.base, bvp->id, &vp->Base);
+   brw_setup_tex_for_precompile(brw, &key.tex, prog);
+   key.program_string_id = bvp->id;
    key.clamp_vertex_color =
       (prog->OutputsWritten & (VARYING_BIT_COL0 | VARYING_BIT_COL1 |
                                VARYING_BIT_BFC0 | VARYING_BIT_BFC1));