i965/mesa/st: eliminate gl_tess_ctrl_program
authorTimothy Arceri <timothy.arceri@collabora.com>
Wed, 19 Oct 2016 00:13:52 +0000 (11:13 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Wed, 26 Oct 2016 03:29:36 +0000 (14:29 +1100)
We now get all the tcs metadata from shader_info.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
21 files changed:
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_draw.c
src/mesa/drivers/dri/i965/brw_program.c
src/mesa/drivers/dri/i965/brw_tcs.c
src/mesa/drivers/dri/i965/brw_tcs_surface_state.c
src/mesa/drivers/dri/i965/brw_tes.c
src/mesa/drivers/dri/i965/gen7_hs_state.c
src/mesa/main/context.c
src/mesa/main/mtypes.h
src/mesa/main/state.c
src/mesa/program/prog_statevars.c
src/mesa/program/program.c
src/mesa/program/program.h
src/mesa/state_tracker/st_atom.c
src/mesa/state_tracker/st_atom_constbuf.c
src/mesa/state_tracker/st_atom_sampler.c
src/mesa/state_tracker/st_atom_shader.c
src/mesa/state_tracker/st_atom_texture.c
src/mesa/state_tracker/st_cb_program.c
src/mesa/state_tracker/st_program.c
src/mesa/state_tracker/st_program.h

index c92bb9f84312cd39b0b17ebbb19388594e8e2f08..9b7e184668030d1b26ee97fc2b62298d80ae790a 100644 (file)
@@ -337,7 +337,7 @@ struct brw_vertex_program {
 
 /** Subclass of Mesa tessellation control program */
 struct brw_tess_ctrl_program {
-   struct gl_tess_ctrl_program program;
+   struct gl_program program;
    unsigned id;  /**< serial no. to identify tess ctrl progs, never re-used */
 };
 
@@ -1008,7 +1008,7 @@ struct brw_context
     */
    const struct gl_vertex_program *vertex_program;
    const struct gl_geometry_program *geometry_program;
-   const struct gl_tess_ctrl_program *tess_ctrl_program;
+   const struct gl_program *tess_ctrl_program;
    const struct gl_tess_eval_program *tess_eval_program;
    const struct gl_fragment_program *fragment_program;
    const struct gl_compute_program *compute_program;
@@ -1730,7 +1730,7 @@ brw_vertex_program_const(const struct gl_vertex_program *p)
 }
 
 static inline struct brw_tess_ctrl_program *
-brw_tess_ctrl_program(struct gl_tess_ctrl_program *p)
+brw_tess_ctrl_program(struct gl_program *p)
 {
    return (struct brw_tess_ctrl_program *) p;
 }
index 5d176efb53c8de554721107334fb5af956254363..5485de3692aa63ef64fede3d6665b6e6590bc850 100644 (file)
@@ -458,7 +458,7 @@ brw_try_draw_prims(struct gl_context *ctx,
    brw->tes.base.sampler_count = ctx->TessEvalProgram._Current ?
       util_last_bit(ctx->TessEvalProgram._Current->Base.SamplersUsed) : 0;
    brw->tcs.base.sampler_count = ctx->TessCtrlProgram._Current ?
-      util_last_bit(ctx->TessCtrlProgram._Current->Base.SamplersUsed) : 0;
+      util_last_bit(ctx->TessCtrlProgram._Current->SamplersUsed) : 0;
    brw->vs.base.sampler_count =
       util_last_bit(ctx->VertexProgram._Current->Base.SamplersUsed);
 
index a41f36e766b89db83ea92f1616a9a119f6f0c340..4e0df5a77ffff01897eef000b783660b1dbcde70 100644 (file)
@@ -168,7 +168,7 @@ static struct gl_program *brwNewProgram( struct gl_context *ctx,
       if (prog) {
          prog->id = get_new_program_id(brw->screen);
 
-         return _mesa_init_gl_program(&prog->program.Base, target, id);
+         return _mesa_init_gl_program(&prog->program, target, id);
       } else {
          return NULL;
       }
index 20ea4f1d57cef45260d3ba7855fd2cbdc0c4365e..8a78a40f690d6ce62321d981dd55bc39aee403dd 100644 (file)
@@ -178,7 +178,7 @@ brw_codegen_tcs_prog(struct brw_context *brw,
    double start_time = 0;
 
    if (tcp) {
-      nir = tcp->program.Base.nir;
+      nir = tcp->program.nir;
    } else {
       /* Create a dummy nir_shader.  We won't actually use NIR code to
        * generate assembly (it's easier to generate assembly directly),
@@ -211,14 +211,14 @@ brw_codegen_tcs_prog(struct brw_context *brw,
 
    if (tcs) {
       brw_assign_common_binding_table_offsets(MESA_SHADER_TESS_CTRL, devinfo,
-                                              shader_prog, &tcp->program.Base,
+                                              shader_prog, &tcp->program,
                                               &prog_data.base.base, 0);
 
       prog_data.base.base.image_param =
          rzalloc_array(NULL, struct brw_image_param, tcs->NumImages);
       prog_data.base.base.nr_image_params = tcs->NumImages;
 
-      brw_nir_setup_glsl_uniforms(nir, shader_prog, &tcp->program.Base,
+      brw_nir_setup_glsl_uniforms(nir, shader_prog, &tcp->program,
                                   &prog_data.base.base,
                                   compiler->scalar_stage[MESA_SHADER_TESS_CTRL]);
    } else {
@@ -320,7 +320,6 @@ brw_tcs_populate_key(struct brw_context *brw,
       (struct brw_tess_ctrl_program *) brw->tess_ctrl_program;
    struct brw_tess_eval_program *tep =
       (struct brw_tess_eval_program *) brw->tess_eval_program;
-   struct gl_program *prog = &tcp->program.Base;
    struct gl_program *tes_prog = &tep->program.Base;
 
    uint64_t per_vertex_slots = tes_prog->info.inputs_read;
@@ -329,6 +328,7 @@ brw_tcs_populate_key(struct brw_context *brw,
    memset(key, 0, sizeof(*key));
 
    if (tcp) {
+      struct gl_program *prog = &tcp->program;
       per_vertex_slots |= prog->info.outputs_written;
       per_patch_slots |= prog->info.patch_outputs_written;
    }
@@ -350,7 +350,7 @@ brw_tcs_populate_key(struct brw_context *brw,
       key->program_string_id = tcp->id;
 
       /* _NEW_TEXTURE */
-      brw_populate_sampler_prog_key_data(&brw->ctx, prog, &key->tex);
+      brw_populate_sampler_prog_key_data(&brw->ctx, &tcp->program, &key->tex);
    } else {
       key->outputs_written = tes_prog->info.inputs_read;
    }
@@ -400,8 +400,7 @@ brw_tcs_precompile(struct gl_context *ctx,
    struct brw_stage_prog_data *old_prog_data = brw->tcs.base.prog_data;
    bool success;
 
-   struct gl_tess_ctrl_program *tcp = (struct gl_tess_ctrl_program *)prog;
-   struct brw_tess_ctrl_program *btcp = brw_tess_ctrl_program(tcp);
+   struct brw_tess_ctrl_program *btcp = brw_tess_ctrl_program(prog);
    const struct gl_linked_shader *tes =
       shader_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL];
 
index 5021e10e13402dd721337ca136bb9ba8331a9e3e..e91488fb492cedece9bf4a8c85884336951d2600 100644 (file)
@@ -52,7 +52,7 @@ brw_upload_tcs_pull_constants(struct brw_context *brw)
 
    _mesa_shader_write_subroutine_indices(&brw->ctx, MESA_SHADER_TESS_CTRL);
    /* _NEW_PROGRAM_CONSTANTS */
-   brw_upload_pull_constants(brw, BRW_NEW_TCS_CONSTBUF, &tcp->program.Base,
+   brw_upload_pull_constants(brw, BRW_NEW_TCS_CONSTBUF, &tcp->program,
                              stage_state, prog_data);
 }
 
index 3f01c07dffb9c74a5bf643f3899036c3db620965..fe03816b5484de6d4cf3998ced7ff98295db372c 100644 (file)
@@ -251,7 +251,7 @@ brw_tes_populate_key(struct brw_context *brw,
     * be stored in the Patch URB Entry as well.
     */
    if (tcp) {
-      struct gl_program *tcp_prog = &tcp->program.Base;
+      struct gl_program *tcp_prog = &tcp->program;
       per_vertex_slots |= tcp_prog->info.outputs_written;
       per_patch_slots |= tcp_prog->info.patch_outputs_written;
    }
index f16af287dce290f5e957b39812ac0b20e14c2cc5..290aea2392470a0fb84cf6c408daec4b0971b301 100644 (file)
@@ -41,8 +41,8 @@ gen7_upload_tcs_push_constants(struct brw_context *brw)
       const struct brw_stage_prog_data *prog_data = brw->tcs.base.prog_data;
 
       _mesa_shader_write_subroutine_indices(&brw->ctx, MESA_SHADER_TESS_CTRL);
-      gen6_upload_push_constants(brw, &tcp->program.Base, prog_data,
-                                      stage_state, AUB_TRACE_VS_CONSTANTS);
+      gen6_upload_push_constants(brw, &tcp->program, prog_data, stage_state,
+                                 AUB_TRACE_VS_CONSTANTS);
    }
 
    gen7_upload_constant_state(brw, stage_state, active, _3DSTATE_CONSTANT_HS);
index 47fd4a0919f6a6e0fc4e2784ba93c81394d37076..1e4f87d65361d48a3dd69f9cb2268221f395068a 100644 (file)
@@ -1297,7 +1297,7 @@ _mesa_free_context_data( struct gl_context *ctx )
    _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL);
    _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram, NULL);
 
-   _mesa_reference_tesscprog(ctx, &ctx->TessCtrlProgram._Current, NULL);
+   _mesa_reference_program(ctx, &ctx->TessCtrlProgram._Current, NULL);
    _mesa_reference_tesseprog(ctx, &ctx->TessEvalProgram._Current, NULL);
    _mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current, NULL);
 
index c9310ef3070ef533870c24626339794fba4b639b..9436f8e29094936e1844afe1497fd8e29b88b62c 100644 (file)
@@ -1998,16 +1998,6 @@ struct gl_vertex_program
 };
 
 
-/** Tessellation control program object */
-struct gl_tess_ctrl_program
-{
-   struct gl_program Base;   /**< base class */
-
-   /* output layout */
-   GLint VerticesOut;
-};
-
-
 /** Tessellation evaluation program object */
 struct gl_tess_eval_program
 {
@@ -2133,7 +2123,7 @@ struct gl_vertex_program_state
 struct gl_tess_ctrl_program_state
 {
    /** Currently bound and valid shader. */
-   struct gl_tess_ctrl_program *_Current;
+   struct gl_program *_Current;
 
    GLint patch_vertices;
    GLfloat patch_default_outer_level[4];
index bf6035e014226f229950bfdc645d9444637fa890..b5207613e32918c506a0cc346b5768aeacd1d508 100644 (file)
@@ -110,7 +110,7 @@ update_program(struct gl_context *ctx)
    const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current;
    const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current;
    const struct gl_geometry_program *prevGP = ctx->GeometryProgram._Current;
-   const struct gl_tess_ctrl_program *prevTCP = ctx->TessCtrlProgram._Current;
+   const struct gl_program *prevTCP = ctx->TessCtrlProgram._Current;
    const struct gl_tess_eval_program *prevTEP = ctx->TessEvalProgram._Current;
    const struct gl_compute_program *prevCP = ctx->ComputeProgram._Current;
    GLbitfield new_state = 0x0;
@@ -208,13 +208,12 @@ update_program(struct gl_context *ctx)
    if (tcsProg && tcsProg->LinkStatus
        && tcsProg->_LinkedShaders[MESA_SHADER_TESS_CTRL]) {
       /* Use GLSL tessellation control shader */
-      _mesa_reference_tesscprog(ctx, &ctx->TessCtrlProgram._Current,
-         gl_tess_ctrl_program(
-            tcsProg->_LinkedShaders[MESA_SHADER_TESS_CTRL]->Program));
+      _mesa_reference_program(ctx, &ctx->TessCtrlProgram._Current,
+          tcsProg->_LinkedShaders[MESA_SHADER_TESS_CTRL]->Program);
    }
    else {
       /* No tessellation control program */
-      _mesa_reference_tesscprog(ctx, &ctx->TessCtrlProgram._Current, NULL);
+      _mesa_reference_program(ctx, &ctx->TessCtrlProgram._Current, NULL);
    }
 
    /* Examine vertex program after fragment program as
@@ -284,7 +283,7 @@ update_program(struct gl_context *ctx)
       new_state |= _NEW_PROGRAM;
       if (ctx->Driver.BindProgram) {
          ctx->Driver.BindProgram(ctx, GL_TESS_CONTROL_PROGRAM_NV,
-                            (struct gl_program *) ctx->TessCtrlProgram._Current);
+                                 ctx->TessCtrlProgram._Current);
       }
    }
 
index 86bbd0ac663ac4cf5869ffb6d3b9ca0bc8e023be..2ac7b561b692056d2c918ab115d9b0630f92ea68 100644 (file)
@@ -604,7 +604,7 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
 
       case STATE_TES_PATCH_VERTICES_IN:
          if (ctx->TessCtrlProgram._Current)
-            val[0].i = ctx->TessCtrlProgram._Current->Base.info.tcs.vertices_out;
+            val[0].i = ctx->TessCtrlProgram._Current->info.tcs.vertices_out;
          else
             val[0].i = ctx->TessCtrlProgram.patch_vertices;
          return;
index 67672164f594fbea18ef105b2624d013262a4a19..f89a833d20221b457f0b9023d6a45aa45af0ba34 100644 (file)
@@ -228,8 +228,8 @@ _mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id)
       return _mesa_init_gl_program(&prog->Base, target, id);
    }
    case GL_TESS_CONTROL_PROGRAM_NV: {
-      struct gl_tess_ctrl_program *prog = CALLOC_STRUCT(gl_tess_ctrl_program);
-      return _mesa_init_gl_program(&prog->Base, target, id);
+      struct gl_program *prog = CALLOC_STRUCT(gl_program);
+      return _mesa_init_gl_program(prog, target, id);
    }
    case GL_TESS_EVALUATION_PROGRAM_NV: {
       struct gl_tess_eval_program *prog = CALLOC_STRUCT(gl_tess_eval_program);
index 09e69280d461bb96b531a434eae6d7e59aef0ab3..d937f826697c62945004ac19a71b667fd1a44086 100644 (file)
@@ -125,16 +125,6 @@ _mesa_reference_compprog(struct gl_context *ctx,
                            (struct gl_program *) prog);
 }
 
-
-static inline void
-_mesa_reference_tesscprog(struct gl_context *ctx,
-                         struct gl_tess_ctrl_program **ptr,
-                         struct gl_tess_ctrl_program *prog)
-{
-   _mesa_reference_program(ctx, (struct gl_program **) ptr,
-                           (struct gl_program *) prog);
-}
-
 static inline void
 _mesa_reference_tesseprog(struct gl_context *ctx,
                          struct gl_tess_eval_program **ptr,
@@ -267,19 +257,6 @@ gl_compute_program_const(const struct gl_program *prog)
    return (const struct gl_compute_program *) prog;
 }
 
-static inline struct gl_tess_ctrl_program *
-gl_tess_ctrl_program(struct gl_program *prog)
-{
-   return (struct gl_tess_ctrl_program *) prog;
-}
-
-static inline const struct gl_tess_ctrl_program *
-gl_tess_ctrl_program_const(const struct gl_program *prog)
-{
-   return (const struct gl_tess_ctrl_program *) prog;
-}
-
-
 static inline struct gl_tess_eval_program *
 gl_tess_eval_program(struct gl_program *prog)
 {
index 94e012a97c7cd0a3f555b7ce354415fb0f02d417..497ba82aab9758dbe2e19d886f7d5d188b553524 100644 (file)
@@ -70,7 +70,7 @@ static void check_program_state( struct st_context *st )
    struct st_fragment_program *old_fp = st->fp;
 
    struct gl_vertex_program *new_vp = ctx->VertexProgram._Current;
-   struct gl_tess_ctrl_program *new_tcp = ctx->TessCtrlProgram._Current;
+   struct gl_program *new_tcp = ctx->TessCtrlProgram._Current;
    struct gl_tess_eval_program *new_tep = ctx->TessEvalProgram._Current;
    struct gl_geometry_program *new_gp = ctx->GeometryProgram._Current;
    struct gl_fragment_program *new_fp = ctx->FragmentProgram._Current;
index 8882582c6012a98757fa0a2b5f3f227fc0d67610..90d4ffbe98b975d2e51e69b7a84ee0327ec7d223 100644 (file)
@@ -195,7 +195,7 @@ static void update_tcs_constants(struct st_context *st )
    struct gl_program_parameter_list *params;
 
    if (tcp) {
-      params = tcp->Base.Base.Parameters;
+      params = tcp->Base.Parameters;
       st_upload_constants( st, params, MESA_SHADER_TESS_CTRL );
    }
 }
index 065df6dd0067d3d64a338c372ec135f71fa9e0d7..76b355cec9536a489a228237288255a5e08e8dcf 100644 (file)
@@ -344,7 +344,7 @@ update_samplers(struct st_context *st)
    if (ctx->TessCtrlProgram._Current) {
       update_shader_samplers(st,
                              PIPE_SHADER_TESS_CTRL,
-                             &ctx->TessCtrlProgram._Current->Base,
+                             ctx->TessCtrlProgram._Current,
                              ctx->Const.Program[MESA_SHADER_TESS_CTRL].MaxTextureImageUnits,
                              st->state.samplers[PIPE_SHADER_TESS_CTRL],
                              &st->state.num_samplers[PIPE_SHADER_TESS_CTRL]);
index 2f700a2fc55e8862a6ad90831f10c08e52314acc..0df0770bb1e565ac9f0dbb20c866d0ad3e529ade 100644 (file)
@@ -254,7 +254,7 @@ update_tcp( struct st_context *st )
    }
 
    sttcp = st_tessctrl_program(st->ctx->TessCtrlProgram._Current);
-   assert(sttcp->Base.Base.Target == GL_TESS_CONTROL_PROGRAM_NV);
+   assert(sttcp->Base.Target == GL_TESS_CONTROL_PROGRAM_NV);
 
    st->tcp_variant = st_get_basic_variant(st, PIPE_SHADER_TESS_CTRL,
                                           &sttcp->tgsi, &sttcp->variants);
index c8ae62c2a7bfc1d1a5098548593f0cd55fab34dd..fbd73d69f225cae81537f146d43bf1d507bafffb 100644 (file)
@@ -253,7 +253,7 @@ update_tessctrl_textures(struct st_context *st)
    if (ctx->TessCtrlProgram._Current) {
       update_textures(st,
                       MESA_SHADER_TESS_CTRL,
-                      &ctx->TessCtrlProgram._Current->Base,
+                      ctx->TessCtrlProgram._Current,
                       ctx->Const.Program[MESA_SHADER_TESS_CTRL].MaxTextureImageUnits,
                       st->state.sampler_views[PIPE_SHADER_TESS_CTRL],
                       &st->state.num_sampler_views[PIPE_SHADER_TESS_CTRL]);
index 1fd50191d75e1fce1fef847747442555b5b29f93..c85f0ef83ff846755d75cc635573760e6349e928 100644 (file)
@@ -71,7 +71,7 @@ st_new_program(struct gl_context *ctx, GLenum target, GLuint id)
    }
    case GL_TESS_CONTROL_PROGRAM_NV: {
       struct st_tessctrl_program *prog = ST_CALLOC_STRUCT(st_tessctrl_program);
-      return _mesa_init_gl_program(&prog->Base.Base, target, id);
+      return _mesa_init_gl_program(&prog->Base, target, id);
    }
    case GL_TESS_EVALUATION_PROGRAM_NV: {
       struct st_tesseval_program *prog = ST_CALLOC_STRUCT(st_tesseval_program);
@@ -134,8 +134,8 @@ st_delete_program(struct gl_context *ctx, struct gl_program *prog)
          struct st_tessctrl_program *sttcp =
             (struct st_tessctrl_program *) prog;
 
-         st_release_basic_variants(st, sttcp->Base.Base.Target,
-                                   &sttcp->variants, &sttcp->tgsi);
+         st_release_basic_variants(st, sttcp->Base.Target, &sttcp->variants,
+                                   &sttcp->tgsi);
 
          if (sttcp->glsl_to_tgsi)
             free_glsl_to_tgsi_visitor(sttcp->glsl_to_tgsi);
@@ -221,8 +221,8 @@ st_program_string_notify( struct gl_context *ctx,
       struct st_tessctrl_program *sttcp =
          (struct st_tessctrl_program *) prog;
 
-      st_release_basic_variants(st, sttcp->Base.Base.Target,
-                                &sttcp->variants, &sttcp->tgsi);
+      st_release_basic_variants(st, sttcp->Base.Target, &sttcp->variants,
+                                &sttcp->tgsi);
       if (!st_translate_tessctrl_program(st, sttcp))
          return false;
 
index 65f903703c2a342b78cf4335321271089ed49a09..cb402115c23f915420d3096b0bc8bac8f455b196 100644 (file)
@@ -1605,10 +1605,10 @@ st_translate_tessctrl_program(struct st_context *st,
       return false;
 
    ureg_property(ureg, TGSI_PROPERTY_TCS_VERTICES_OUT,
-                 sttcp->Base.Base.info.tcs.vertices_out);
+                 sttcp->Base.info.tcs.vertices_out);
 
-   st_translate_program_common(st, &sttcp->Base.Base, sttcp->glsl_to_tgsi,
-                               ureg, PIPE_SHADER_TESS_CTRL, &sttcp->tgsi);
+   st_translate_program_common(st, &sttcp->Base, sttcp->glsl_to_tgsi, ureg,
+                               PIPE_SHADER_TESS_CTRL, &sttcp->tgsi);
 
    free_glsl_to_tgsi_visitor(sttcp->glsl_to_tgsi);
    sttcp->glsl_to_tgsi = NULL;
index ea55d476ff00d84ca62066f453171fa363d9588a..b801891832d92798c9f5942e24a98c25d3c2d9eb 100644 (file)
@@ -260,11 +260,11 @@ struct st_geometry_program
 
 
 /**
- * Derived from Mesa gl_tess_ctrl_program:
+ * Derived from Mesa gl_program:
  */
 struct st_tessctrl_program
 {
-   struct gl_tess_ctrl_program Base;  /**< The Mesa tess ctrl program */
+   struct gl_program Base;  /**< The Mesa tess ctrl program */
    struct pipe_shader_state tgsi;
    struct glsl_to_tgsi_visitor* glsl_to_tgsi;
    uint64_t affected_states; /**< ST_NEW_* flags to mark dirty when binding */
@@ -321,7 +321,7 @@ st_geometry_program( struct gl_geometry_program *gp )
 }
 
 static inline struct st_tessctrl_program *
-st_tessctrl_program( struct gl_tess_ctrl_program *tcp )
+st_tessctrl_program( struct gl_program *tcp )
 {
    return (struct st_tessctrl_program *)tcp;
 }