[Mesa-dev] [PATCH 06/17] st/mesa: unify TCS, TES, GS st_*_program structures

Marek Olšák maraeo at gmail.com
Mon May 1 12:52:55 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

---
 src/mesa/state_tracker/st_atom.c           | 12 ++---
 src/mesa/state_tracker/st_atom_constbuf.c  |  6 +--
 src/mesa/state_tracker/st_atom_shader.c    | 24 ++++-----
 src/mesa/state_tracker/st_cb_program.c     | 34 ++++++------
 src/mesa/state_tracker/st_context.c        | 18 +++----
 src/mesa/state_tracker/st_context.h        |  6 +--
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 12 ++---
 src/mesa/state_tracker/st_program.c        | 24 ++++-----
 src/mesa/state_tracker/st_program.h        | 86 ++++--------------------------
 src/mesa/state_tracker/st_shader_cache.c   | 30 +++++------
 10 files changed, 93 insertions(+), 159 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c
index b40ce1e..cbac762 100644
--- a/src/mesa/state_tracker/st_atom.c
+++ b/src/mesa/state_tracker/st_atom.c
@@ -58,23 +58,23 @@ void st_destroy_atoms( struct st_context *st )
    /* no-op */
 }
 
 
 /* Too complex to figure out, just check every time:
  */
 static void check_program_state( struct st_context *st )
 {
    struct gl_context *ctx = st->ctx;
    struct st_vertex_program *old_vp = st->vp;
-   struct st_tessctrl_program *old_tcp = st->tcp;
-   struct st_tesseval_program *old_tep = st->tep;
-   struct st_geometry_program *old_gp = st->gp;
+   struct st_common_program *old_tcp = st->tcp;
+   struct st_common_program *old_tep = st->tep;
+   struct st_common_program *old_gp = st->gp;
    struct st_fragment_program *old_fp = st->fp;
 
    struct gl_program *new_vp = ctx->VertexProgram._Current;
    struct gl_program *new_tcp = ctx->TessCtrlProgram._Current;
    struct gl_program *new_tep = ctx->TessEvalProgram._Current;
    struct gl_program *new_gp = ctx->GeometryProgram._Current;
    struct gl_program *new_fp = ctx->FragmentProgram._Current;
    uint64_t dirty = 0;
 
    /* Flag states used by both new and old shaders to unbind shader resources
@@ -84,35 +84,35 @@ static void check_program_state( struct st_context *st )
       if (old_vp)
          dirty |= old_vp->affected_states;
       if (new_vp)
          dirty |= ST_NEW_VERTEX_PROGRAM(st, st_vertex_program(new_vp));
    }
 
    if (unlikely(new_tcp != &old_tcp->Base)) {
       if (old_tcp)
          dirty |= old_tcp->affected_states;
       if (new_tcp)
-         dirty |= st_tessctrl_program(new_tcp)->affected_states;
+         dirty |= st_common_program(new_tcp)->affected_states;
    }
 
    if (unlikely(new_tep != &old_tep->Base)) {
       if (old_tep)
          dirty |= old_tep->affected_states;
       if (new_tep)
-         dirty |= st_tesseval_program(new_tep)->affected_states;
+         dirty |= st_common_program(new_tep)->affected_states;
    }
 
    if (unlikely(new_gp != &old_gp->Base)) {
       if (old_gp)
          dirty |= old_gp->affected_states;
       if (new_gp)
-         dirty |= st_geometry_program(new_gp)->affected_states;
+         dirty |= st_common_program(new_gp)->affected_states;
    }
 
    if (unlikely(new_fp != &old_fp->Base)) {
       if (old_fp)
          dirty |= old_fp->affected_states;
       if (new_fp)
          dirty |= st_fragment_program(new_fp)->affected_states;
    }
 
    st->dirty |= dirty;
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
index 9c04580..6cbfba7 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -156,47 +156,47 @@ void st_update_fs_constants(struct st_context *st )
    struct gl_program_parameter_list *params = fp->Base.Parameters;
 
    st_upload_constants( st, params, MESA_SHADER_FRAGMENT );
 }
 
 
 /* Geometry shader:
  */
 void st_update_gs_constants(struct st_context *st )
 {
-   struct st_geometry_program *gp = st->gp;
+   struct st_common_program *gp = st->gp;
    struct gl_program_parameter_list *params;
 
    if (gp) {
       params = gp->Base.Parameters;
       st_upload_constants( st, params, MESA_SHADER_GEOMETRY );
    }
 }
 
 /* Tessellation control shader:
  */
 void st_update_tcs_constants(struct st_context *st )
 {
-   struct st_tessctrl_program *tcp = st->tcp;
+   struct st_common_program *tcp = st->tcp;
    struct gl_program_parameter_list *params;
 
    if (tcp) {
       params = tcp->Base.Parameters;
       st_upload_constants( st, params, MESA_SHADER_TESS_CTRL );
    }
 }
 
 /* Tessellation evaluation shader:
  */
 void st_update_tes_constants(struct st_context *st )
 {
-   struct st_tesseval_program *tep = st->tep;
+   struct st_common_program *tep = st->tep;
    struct gl_program_parameter_list *params;
 
    if (tep) {
       params = tep->Base.Parameters;
       st_upload_constants( st, params, MESA_SHADER_TESS_EVAL );
    }
 }
 
 /* Compute shader:
  */
diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c
index 091cbe0..875279d 100644
--- a/src/mesa/state_tracker/st_atom_shader.c
+++ b/src/mesa/state_tracker/st_atom_shader.c
@@ -178,83 +178,83 @@ st_update_vp( struct st_context *st )
    st_reference_vertprog(st, &st->vp, stvp);
 
    cso_set_vertex_shader_handle(st->cso_context, 
                                 st->vp_variant->driver_shader);
 }
 
 
 void
 st_update_gp( struct st_context *st )
 {
-   struct st_geometry_program *stgp;
+   struct st_common_program *stgp;
 
    if (!st->ctx->GeometryProgram._Current) {
       cso_set_geometry_shader_handle(st->cso_context, NULL);
-      st_reference_geomprog(st, &st->gp, NULL);
+      st_reference_prog(st, &st->gp, NULL);
       return;
    }
 
-   stgp = st_geometry_program(st->ctx->GeometryProgram._Current);
+   stgp = st_common_program(st->ctx->GeometryProgram._Current);
    assert(stgp->Base.Target == GL_GEOMETRY_PROGRAM_NV);
 
    st->gp_variant = st_get_basic_variant(st, PIPE_SHADER_GEOMETRY,
                                          &stgp->tgsi, &stgp->variants);
 
-   st_reference_geomprog(st, &st->gp, stgp);
+   st_reference_prog(st, &st->gp, stgp);
 
    cso_set_geometry_shader_handle(st->cso_context,
                                   st->gp_variant->driver_shader);
 }
 
 
 void
 st_update_tcp( struct st_context *st )
 {
-   struct st_tessctrl_program *sttcp;
+   struct st_common_program *sttcp;
 
    if (!st->ctx->TessCtrlProgram._Current) {
       cso_set_tessctrl_shader_handle(st->cso_context, NULL);
-      st_reference_tesscprog(st, &st->tcp, NULL);
+      st_reference_prog(st, &st->tcp, NULL);
       return;
    }
 
-   sttcp = st_tessctrl_program(st->ctx->TessCtrlProgram._Current);
+   sttcp = st_common_program(st->ctx->TessCtrlProgram._Current);
    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);
 
-   st_reference_tesscprog(st, &st->tcp, sttcp);
+   st_reference_prog(st, &st->tcp, sttcp);
 
    cso_set_tessctrl_shader_handle(st->cso_context,
                                   st->tcp_variant->driver_shader);
 }
 
 
 void
 st_update_tep( struct st_context *st )
 {
-   struct st_tesseval_program *sttep;
+   struct st_common_program *sttep;
 
    if (!st->ctx->TessEvalProgram._Current) {
       cso_set_tesseval_shader_handle(st->cso_context, NULL);
-      st_reference_tesseprog(st, &st->tep, NULL);
+      st_reference_prog(st, &st->tep, NULL);
       return;
    }
 
-   sttep = st_tesseval_program(st->ctx->TessEvalProgram._Current);
+   sttep = st_common_program(st->ctx->TessEvalProgram._Current);
    assert(sttep->Base.Target == GL_TESS_EVALUATION_PROGRAM_NV);
 
    st->tep_variant = st_get_basic_variant(st, PIPE_SHADER_TESS_EVAL,
                                           &sttep->tgsi, &sttep->variants);
 
-   st_reference_tesseprog(st, &st->tep, sttep);
+   st_reference_prog(st, &st->tep, sttep);
 
    cso_set_tesseval_shader_handle(st->cso_context,
                                   st->tep_variant->driver_shader);
 }
 
 
 void
 st_update_cp( struct st_context *st )
 {
    struct st_compute_program *stcp;
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index b104649..531d20d 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -62,32 +62,32 @@ st_new_program(struct gl_context *ctx, GLenum target, GLuint id,
       struct st_vertex_program *prog = rzalloc(NULL,
                                                struct st_vertex_program);
       return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
    }
    case GL_FRAGMENT_PROGRAM_ARB: {
       struct st_fragment_program *prog = rzalloc(NULL,
                                                  struct st_fragment_program);
       return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
    }
    case GL_GEOMETRY_PROGRAM_NV: {
-      struct st_geometry_program *prog = rzalloc(NULL,
-                                                 struct st_geometry_program);
+      struct st_common_program *prog = rzalloc(NULL,
+                                                 struct st_common_program);
       return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
    }
    case GL_TESS_CONTROL_PROGRAM_NV: {
-      struct st_tessctrl_program *prog = rzalloc(NULL,
-                                                 struct st_tessctrl_program);
+      struct st_common_program *prog = rzalloc(NULL,
+                                                 struct st_common_program);
       return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
    }
    case GL_TESS_EVALUATION_PROGRAM_NV: {
-      struct st_tesseval_program *prog = rzalloc(NULL,
-                                                 struct st_tesseval_program);
+      struct st_common_program *prog = rzalloc(NULL,
+                                                 struct st_common_program);
       return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
    }
    case GL_COMPUTE_PROGRAM_NV: {
       struct st_compute_program *prog = rzalloc(NULL,
                                                 struct st_compute_program);
       return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
    }
    default:
       assert(0);
       return NULL;
@@ -108,22 +108,22 @@ st_delete_program(struct gl_context *ctx, struct gl_program *prog)
       {
          struct st_vertex_program *stvp = (struct st_vertex_program *) prog;
          st_release_vp_variants( st, stvp );
          
          if (stvp->glsl_to_tgsi)
             free_glsl_to_tgsi_visitor(stvp->glsl_to_tgsi);
       }
       break;
    case GL_GEOMETRY_PROGRAM_NV:
       {
-         struct st_geometry_program *stgp =
-            (struct st_geometry_program *) prog;
+         struct st_common_program *stgp =
+            (struct st_common_program *) prog;
 
          st_release_basic_variants(st, stgp->Base.Target, &stgp->variants,
                                    &stgp->tgsi);
          
          if (stgp->glsl_to_tgsi)
             free_glsl_to_tgsi_visitor(stgp->glsl_to_tgsi);
       }
       break;
    case GL_FRAGMENT_PROGRAM_ARB:
       {
@@ -131,34 +131,34 @@ st_delete_program(struct gl_context *ctx, struct gl_program *prog)
             (struct st_fragment_program *) prog;
 
          st_release_fp_variants(st, stfp);
          
          if (stfp->glsl_to_tgsi)
             free_glsl_to_tgsi_visitor(stfp->glsl_to_tgsi);
       }
       break;
    case GL_TESS_CONTROL_PROGRAM_NV:
       {
-         struct st_tessctrl_program *sttcp =
-            (struct st_tessctrl_program *) prog;
+         struct st_common_program *sttcp =
+            (struct st_common_program *) prog;
 
          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);
       }
       break;
    case GL_TESS_EVALUATION_PROGRAM_NV:
       {
-         struct st_tesseval_program *sttep =
-            (struct st_tesseval_program *) prog;
+         struct st_common_program *sttep =
+            (struct st_common_program *) prog;
 
          st_release_basic_variants(st, sttep->Base.Target,
                                    &sttep->variants, &sttep->tgsi);
 
          if (sttep->glsl_to_tgsi)
             free_glsl_to_tgsi_visitor(sttep->glsl_to_tgsi);
       }
       break;
    case GL_COMPUTE_PROGRAM_NV:
       {
@@ -197,55 +197,55 @@ st_program_string_notify( struct gl_context *ctx,
       struct st_fragment_program *stfp = (struct st_fragment_program *) prog;
 
       st_release_fp_variants(st, stfp);
       if (!st_translate_fragment_program(st, stfp))
          return false;
 
       if (st->fp == stfp)
 	 st->dirty |= stfp->affected_states;
    }
    else if (target == GL_GEOMETRY_PROGRAM_NV) {
-      struct st_geometry_program *stgp = (struct st_geometry_program *) prog;
+      struct st_common_program *stgp = (struct st_common_program *) prog;
 
       st_release_basic_variants(st, stgp->Base.Target, &stgp->variants,
                                 &stgp->tgsi);
       if (!st_translate_geometry_program(st, stgp))
          return false;
 
       if (st->gp == stgp)
 	 st->dirty |= stgp->affected_states;
    }
    else if (target == GL_VERTEX_PROGRAM_ARB) {
       struct st_vertex_program *stvp = (struct st_vertex_program *) prog;
 
       st_release_vp_variants(st, stvp);
       if (!st_translate_vertex_program(st, stvp))
          return false;
 
       if (st->vp == stvp)
 	 st->dirty |= ST_NEW_VERTEX_PROGRAM(st, stvp);
    }
    else if (target == GL_TESS_CONTROL_PROGRAM_NV) {
-      struct st_tessctrl_program *sttcp =
-         (struct st_tessctrl_program *) prog;
+      struct st_common_program *sttcp =
+         (struct st_common_program *) prog;
 
       st_release_basic_variants(st, sttcp->Base.Target, &sttcp->variants,
                                 &sttcp->tgsi);
       if (!st_translate_tessctrl_program(st, sttcp))
          return false;
 
       if (st->tcp == sttcp)
          st->dirty |= sttcp->affected_states;
    }
    else if (target == GL_TESS_EVALUATION_PROGRAM_NV) {
-      struct st_tesseval_program *sttep =
-         (struct st_tesseval_program *) prog;
+      struct st_common_program *sttep =
+         (struct st_common_program *) prog;
 
       st_release_basic_variants(st, sttep->Base.Target, &sttep->variants,
                                 &sttep->tgsi);
       if (!st_translate_tesseval_program(st, sttep))
          return false;
 
       if (st->tep == sttep)
          st->dirty |= sttep->affected_states;
    }
    else if (target == GL_COMPUTE_PROGRAM_NV) {
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 8013226..d997911 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -124,26 +124,26 @@ st_query_memory_info(struct gl_context *ctx, struct gl_memory_info *out)
    out->device_memory_evicted = info.device_memory_evicted;
    out->nr_device_memory_evictions = info.nr_device_memory_evictions;
 }
 
 
 uint64_t
 st_get_active_states(struct gl_context *ctx)
 {
    struct st_vertex_program *vp =
       st_vertex_program(ctx->VertexProgram._Current);
-   struct st_tessctrl_program *tcp =
-      st_tessctrl_program(ctx->TessCtrlProgram._Current);
-   struct st_tesseval_program *tep =
-      st_tesseval_program(ctx->TessEvalProgram._Current);
-   struct st_geometry_program *gp =
-      st_geometry_program(ctx->GeometryProgram._Current);
+   struct st_common_program *tcp =
+      st_common_program(ctx->TessCtrlProgram._Current);
+   struct st_common_program *tep =
+      st_common_program(ctx->TessEvalProgram._Current);
+   struct st_common_program *gp =
+      st_common_program(ctx->GeometryProgram._Current);
    struct st_fragment_program *fp =
       st_fragment_program(ctx->FragmentProgram._Current);
    struct st_compute_program *cp =
       st_compute_program(ctx->ComputeProgram._Current);
    uint64_t active_shader_states = 0;
 
    if (vp)
       active_shader_states |= vp->affected_states;
    if (tcp)
       active_shader_states |= tcp->affected_states;
@@ -576,24 +576,24 @@ void st_destroy_context( struct st_context *st )
 {
    struct gl_context *ctx = st->ctx;
    GLuint i;
 
    /* This must be called first so that glthread has a chance to finish */
    _mesa_glthread_destroy(ctx);
 
    _mesa_HashWalk(ctx->Shared->TexObjects, destroy_tex_sampler_cb, st);
 
    st_reference_fragprog(st, &st->fp, NULL);
-   st_reference_geomprog(st, &st->gp, NULL);
+   st_reference_prog(st, &st->gp, NULL);
    st_reference_vertprog(st, &st->vp, NULL);
-   st_reference_tesscprog(st, &st->tcp, NULL);
-   st_reference_tesseprog(st, &st->tep, NULL);
+   st_reference_prog(st, &st->tcp, NULL);
+   st_reference_prog(st, &st->tep, NULL);
    st_reference_compprog(st, &st->cp, NULL);
 
    /* release framebuffer surfaces */
    for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
       pipe_surface_reference(&st->state.framebuffer.cbufs[i], NULL);
    }
    pipe_surface_reference(&st->state.framebuffer.zsbuf, NULL);
    pipe_sampler_view_reference(&st->pixel_xfer.pixelmap_sampler_view, NULL);
    pipe_resource_reference(&st->pixel_xfer.pixelmap_texture, NULL);
 
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index f1b38fc..eb1a163 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -165,23 +165,23 @@ struct st_context
     * has changed. Used mainly for shaders.
     */
    bool gfx_shaders_may_be_dirty;
    bool compute_shader_may_be_dirty;
 
    GLboolean vertdata_edgeflags;
    GLboolean edgeflag_culls_prims;
 
    struct st_vertex_program *vp;    /**< Currently bound vertex program */
    struct st_fragment_program *fp;  /**< Currently bound fragment program */
-   struct st_geometry_program *gp;  /**< Currently bound geometry program */
-   struct st_tessctrl_program *tcp; /**< Currently bound tess control program */
-   struct st_tesseval_program *tep; /**< Currently bound tess eval program */
+   struct st_common_program *gp;  /**< Currently bound geometry program */
+   struct st_common_program *tcp; /**< Currently bound tess control program */
+   struct st_common_program *tep; /**< Currently bound tess eval program */
    struct st_compute_program *cp;   /**< Currently bound compute program */
 
    struct st_vp_variant *vp_variant;
    struct st_fp_variant *fp_variant;
    struct st_basic_variant *gp_variant;
    struct st_basic_variant *tcp_variant;
    struct st_basic_variant *tep_variant;
    struct st_basic_variant *cp_variant;
 
    struct {
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index e7f09e4..de1d6f9 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6789,44 +6789,44 @@ get_mesa_program_tgsi(struct gl_context *ctx,
    _mesa_associate_uniform_storage(ctx, shader_program, prog->Parameters,
                                    true);
    if (!shader_program->data->LinkStatus) {
       free_glsl_to_tgsi_visitor(v);
       _mesa_reference_program(ctx, &shader->Program, NULL);
       return NULL;
    }
 
    struct st_vertex_program *stvp;
    struct st_fragment_program *stfp;
-   struct st_geometry_program *stgp;
-   struct st_tessctrl_program *sttcp;
-   struct st_tesseval_program *sttep;
+   struct st_common_program *stgp;
+   struct st_common_program *sttcp;
+   struct st_common_program *sttep;
    struct st_compute_program *stcp;
 
    switch (shader->Stage) {
    case MESA_SHADER_VERTEX:
       stvp = (struct st_vertex_program *)prog;
       stvp->glsl_to_tgsi = v;
       break;
    case MESA_SHADER_FRAGMENT:
       stfp = (struct st_fragment_program *)prog;
       stfp->glsl_to_tgsi = v;
       break;
    case MESA_SHADER_GEOMETRY:
-      stgp = (struct st_geometry_program *)prog;
+      stgp = (struct st_common_program *)prog;
       stgp->glsl_to_tgsi = v;
       break;
    case MESA_SHADER_TESS_CTRL:
-      sttcp = (struct st_tessctrl_program *)prog;
+      sttcp = (struct st_common_program *)prog;
       sttcp->glsl_to_tgsi = v;
       break;
    case MESA_SHADER_TESS_EVAL:
-      sttep = (struct st_tesseval_program *)prog;
+      sttep = (struct st_common_program *)prog;
       sttep->glsl_to_tgsi = v;
       break;
    case MESA_SHADER_COMPUTE:
       stcp = (struct st_compute_program *)prog;
       stcp->glsl_to_tgsi = v;
       break;
    default:
       assert(!"should not be reached");
       return NULL;
    }
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 747f9a9..943b7d1 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -113,52 +113,52 @@ st_set_prog_affected_state_flags(struct gl_program *prog)
                                ST_NEW_VS_CONSTANTS,
                                ST_NEW_VS_SAMPLER_VIEWS,
                                ST_NEW_VS_SAMPLERS,
                                ST_NEW_VS_IMAGES,
                                ST_NEW_VS_UBOS,
                                ST_NEW_VS_SSBOS,
                                ST_NEW_VS_ATOMICS);
       break;
 
    case MESA_SHADER_TESS_CTRL:
-      states = &((struct st_tessctrl_program*)prog)->affected_states;
+      states = &((struct st_common_program*)prog)->affected_states;
 
       *states = ST_NEW_TCS_STATE;
 
       set_affected_state_flags(states, prog,
                                ST_NEW_TCS_CONSTANTS,
                                ST_NEW_TCS_SAMPLER_VIEWS,
                                ST_NEW_TCS_SAMPLERS,
                                ST_NEW_TCS_IMAGES,
                                ST_NEW_TCS_UBOS,
                                ST_NEW_TCS_SSBOS,
                                ST_NEW_TCS_ATOMICS);
       break;
 
    case MESA_SHADER_TESS_EVAL:
-      states = &((struct st_tesseval_program*)prog)->affected_states;
+      states = &((struct st_common_program*)prog)->affected_states;
 
       *states = ST_NEW_TES_STATE |
                 ST_NEW_RASTERIZER;
 
       set_affected_state_flags(states, prog,
                                ST_NEW_TES_CONSTANTS,
                                ST_NEW_TES_SAMPLER_VIEWS,
                                ST_NEW_TES_SAMPLERS,
                                ST_NEW_TES_IMAGES,
                                ST_NEW_TES_UBOS,
                                ST_NEW_TES_SSBOS,
                                ST_NEW_TES_ATOMICS);
       break;
 
    case MESA_SHADER_GEOMETRY:
-      states = &((struct st_geometry_program*)prog)->affected_states;
+      states = &((struct st_common_program*)prog)->affected_states;
 
       *states = ST_NEW_GS_STATE |
                 ST_NEW_RASTERIZER;
 
       set_affected_state_flags(states, prog,
                                ST_NEW_GS_CONSTANTS,
                                ST_NEW_GS_SAMPLER_VIEWS,
                                ST_NEW_GS_SAMPLERS,
                                ST_NEW_GS_IMAGES,
                                ST_NEW_GS_UBOS,
@@ -1623,21 +1623,21 @@ st_translate_program_common(struct st_context *st,
       debug_printf("\n");
    }
 }
 
 
 /**
  * Translate a geometry program to create a new variant.
  */
 bool
 st_translate_geometry_program(struct st_context *st,
-                              struct st_geometry_program *stgp)
+                              struct st_common_program *stgp)
 {
    struct ureg_program *ureg;
 
    ureg = ureg_create_with_screen(PIPE_SHADER_GEOMETRY, st->pipe->screen);
    if (ureg == NULL)
       return false;
 
    ureg_property(ureg, TGSI_PROPERTY_GS_INPUT_PRIM,
                  stgp->Base.info.gs.input_primitive);
    ureg_property(ureg, TGSI_PROPERTY_GS_OUTPUT_PRIM,
@@ -1710,21 +1710,21 @@ st_get_basic_variant(struct st_context *st,
 
    return v;
 }
 
 
 /**
  * Translate a tessellation control program to create a new variant.
  */
 bool
 st_translate_tessctrl_program(struct st_context *st,
-                              struct st_tessctrl_program *sttcp)
+                              struct st_common_program *sttcp)
 {
    struct ureg_program *ureg;
 
    ureg = ureg_create_with_screen(PIPE_SHADER_TESS_CTRL, st->pipe->screen);
    if (ureg == NULL)
       return false;
 
    ureg_property(ureg, TGSI_PROPERTY_TCS_VERTICES_OUT,
                  sttcp->Base.info.tess.tcs_vertices_out);
 
@@ -1735,21 +1735,21 @@ st_translate_tessctrl_program(struct st_context *st,
    sttcp->glsl_to_tgsi = NULL;
    return true;
 }
 
 
 /**
  * Translate a tessellation evaluation program to create a new variant.
  */
 bool
 st_translate_tesseval_program(struct st_context *st,
-                              struct st_tesseval_program *sttep)
+                              struct st_common_program *sttep)
 {
    struct ureg_program *ureg;
 
    ureg = ureg_create_with_screen(PIPE_SHADER_TESS_EVAL, st->pipe->screen);
    if (ureg == NULL)
       return false;
 
    if (sttep->Base.info.tess.primitive_mode == GL_ISOLINES)
       ureg_property(ureg, TGSI_PROPERTY_TES_PRIM_MODE, GL_LINES);
    else
@@ -1898,23 +1898,23 @@ destroy_program_variants(struct st_context *st, struct gl_program *target)
             }
             fpv = next;
          }
       }
       break;
    case GL_GEOMETRY_PROGRAM_NV:
    case GL_TESS_CONTROL_PROGRAM_NV:
    case GL_TESS_EVALUATION_PROGRAM_NV:
    case GL_COMPUTE_PROGRAM_NV:
       {
-         struct st_geometry_program *gp = (struct st_geometry_program*)target;
-         struct st_tessctrl_program *tcp = (struct st_tessctrl_program*)target;
-         struct st_tesseval_program *tep = (struct st_tesseval_program*)target;
+         struct st_common_program *gp = (struct st_common_program*)target;
+         struct st_common_program *tcp = (struct st_common_program*)target;
+         struct st_common_program *tep = (struct st_common_program*)target;
          struct st_compute_program *cp = (struct st_compute_program*)target;
          struct st_basic_variant **variants =
             target->Target == GL_GEOMETRY_PROGRAM_NV ? &gp->variants :
             target->Target == GL_TESS_CONTROL_PROGRAM_NV ? &tcp->variants :
             target->Target == GL_TESS_EVALUATION_PROGRAM_NV ? &tep->variants :
             target->Target == GL_COMPUTE_PROGRAM_NV ? &cp->variants :
             NULL;
          struct st_basic_variant *v, **prevPtr = variants;
 
          for (v = *variants; v; ) {
@@ -2046,33 +2046,33 @@ st_precompile_shader_variant(struct st_context *st,
       struct st_vertex_program *p = (struct st_vertex_program *)prog;
       struct st_vp_variant_key key;
 
       memset(&key, 0, sizeof(key));
       key.st = st->has_shareable_shaders ? NULL : st;
       st_get_vp_variant(st, p, &key);
       break;
    }
 
    case GL_TESS_CONTROL_PROGRAM_NV: {
-      struct st_tessctrl_program *p = (struct st_tessctrl_program *)prog;
+      struct st_common_program *p = (struct st_common_program *)prog;
       st_get_basic_variant(st, PIPE_SHADER_TESS_CTRL, &p->tgsi, &p->variants);
       break;
    }
 
    case GL_TESS_EVALUATION_PROGRAM_NV: {
-      struct st_tesseval_program *p = (struct st_tesseval_program *)prog;
+      struct st_common_program *p = (struct st_common_program *)prog;
       st_get_basic_variant(st, PIPE_SHADER_TESS_EVAL, &p->tgsi, &p->variants);
       break;
    }
 
    case GL_GEOMETRY_PROGRAM_NV: {
-      struct st_geometry_program *p = (struct st_geometry_program *)prog;
+      struct st_common_program *p = (struct st_common_program *)prog;
       st_get_basic_variant(st, PIPE_SHADER_GEOMETRY, &p->tgsi, &p->variants);
       break;
    }
 
    case GL_FRAGMENT_PROGRAM_ARB: {
       struct st_fragment_program *p = (struct st_fragment_program *)prog;
       struct st_fp_variant_key key;
 
       memset(&key, 0, sizeof(key));
       key.st = st->has_shareable_shaders ? NULL : st;
diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h
index cdc68a7..42274a4 100644
--- a/src/mesa/state_tracker/st_program.h
+++ b/src/mesa/state_tracker/st_program.h
@@ -247,71 +247,37 @@ struct st_basic_variant
 
    void *driver_shader;
 
    struct st_basic_variant *next;
 };
 
 
 /**
  * Derived from Mesa gl_program:
  */
-struct st_geometry_program
+struct st_common_program
 {
    struct gl_program Base;  /**< The Mesa geometry 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 */
 
    struct st_basic_variant *variants;
 
    /** SHA1 hash of linked tgsi shader program, used for on-disk cache */
    unsigned char sha1[20];
 };
 
 
 /**
  * Derived from Mesa gl_program:
  */
-struct st_tessctrl_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 */
-
-   struct st_basic_variant *variants;
-
-   /** SHA1 hash of linked tgsi shader program, used for on-disk cache */
-   unsigned char sha1[20];
-};
-
-
-/**
- * Derived from Mesa gl_program:
- */
-struct st_tesseval_program
-{
-   struct gl_program Base;  /**< The Mesa tess eval 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 */
-
-   struct st_basic_variant *variants;
-
-   /** SHA1 hash of linked tgsi shader program, used for on-disk cache */
-   unsigned char sha1[20];
-};
-
-
-/**
- * Derived from Mesa gl_program:
- */
 struct st_compute_program
 {
    struct gl_program Base;  /**< The Mesa compute program */
    struct pipe_compute_state tgsi;
    struct glsl_to_tgsi_visitor* glsl_to_tgsi;
    uint64_t affected_states; /**< ST_NEW_* flags to mark dirty when binding */
 
    struct st_basic_variant *variants;
 
    /** SHA1 hash of linked tgsi shader program, used for on-disk cache */
@@ -325,88 +291,56 @@ st_fragment_program( struct gl_program *fp )
    return (struct st_fragment_program *)fp;
 }
 
 
 static inline struct st_vertex_program *
 st_vertex_program( struct gl_program *vp )
 {
    return (struct st_vertex_program *)vp;
 }
 
-static inline struct st_geometry_program *
-st_geometry_program( struct gl_program *gp )
+static inline struct st_common_program *
+st_common_program( struct gl_program *gp )
 {
-   return (struct st_geometry_program *)gp;
-}
-
-static inline struct st_tessctrl_program *
-st_tessctrl_program( struct gl_program *tcp )
-{
-   return (struct st_tessctrl_program *)tcp;
-}
-
-static inline struct st_tesseval_program *
-st_tesseval_program( struct gl_program *tep )
-{
-   return (struct st_tesseval_program *)tep;
+   return (struct st_common_program *)gp;
 }
 
 static inline struct st_compute_program *
 st_compute_program( struct gl_program *cp )
 {
    return (struct st_compute_program *)cp;
 }
 
 static inline void
 st_reference_vertprog(struct st_context *st,
                       struct st_vertex_program **ptr,
                       struct st_vertex_program *prog)
 {
    _mesa_reference_program(st->ctx,
                            (struct gl_program **) ptr,
                            (struct gl_program *) prog);
 }
 
 static inline void
-st_reference_geomprog(struct st_context *st,
-                      struct st_geometry_program **ptr,
-                      struct st_geometry_program *prog)
-{
-   _mesa_reference_program(st->ctx,
-                           (struct gl_program **) ptr,
-                           (struct gl_program *) prog);
-}
-
-static inline void
 st_reference_fragprog(struct st_context *st,
                       struct st_fragment_program **ptr,
                       struct st_fragment_program *prog)
 {
    _mesa_reference_program(st->ctx,
                            (struct gl_program **) ptr,
                            (struct gl_program *) prog);
 }
 
 static inline void
-st_reference_tesscprog(struct st_context *st,
-                       struct st_tessctrl_program **ptr,
-                       struct st_tessctrl_program *prog)
-{
-   _mesa_reference_program(st->ctx,
-                           (struct gl_program **) ptr,
-                           (struct gl_program *) prog);
-}
-
-static inline void
-st_reference_tesseprog(struct st_context *st,
-                       struct st_tesseval_program **ptr,
-                       struct st_tesseval_program *prog)
+st_reference_prog(struct st_context *st,
+                  struct st_common_program **ptr,
+                  struct st_common_program *prog)
 {
    _mesa_reference_program(st->ctx,
                            (struct gl_program **) ptr,
                            (struct gl_program *) prog);
 }
 
 static inline void
 st_reference_compprog(struct st_context *st,
                       struct st_compute_program **ptr,
                       struct st_compute_program *prog)
@@ -489,29 +423,29 @@ st_destroy_program_variants(struct st_context *st);
 extern bool
 st_translate_vertex_program(struct st_context *st,
                             struct st_vertex_program *stvp);
 
 extern bool
 st_translate_fragment_program(struct st_context *st,
                               struct st_fragment_program *stfp);
 
 extern bool
 st_translate_geometry_program(struct st_context *st,
-                              struct st_geometry_program *stgp);
+                              struct st_common_program *stgp);
 
 extern bool
 st_translate_tessctrl_program(struct st_context *st,
-                              struct st_tessctrl_program *sttcp);
+                              struct st_common_program *sttcp);
 
 extern bool
 st_translate_tesseval_program(struct st_context *st,
-                              struct st_tesseval_program *sttep);
+                              struct st_common_program *sttep);
 
 extern bool
 st_translate_compute_program(struct st_context *st,
                              struct st_compute_program *stcp);
 
 extern void
 st_print_current_vertex_program(void);
 
 extern void
 st_precompile_shader_variant(struct st_context *st,
diff --git a/src/mesa/state_tracker/st_shader_cache.c b/src/mesa/state_tracker/st_shader_cache.c
index 1a11f113..0771ca6 100644
--- a/src/mesa/state_tracker/st_shader_cache.c
+++ b/src/mesa/state_tracker/st_shader_cache.c
@@ -80,37 +80,37 @@ st_store_tgsi_in_disk_cache(struct st_context *st, struct gl_program *prog,
       blob_write_bytes(blob, stvp->index_to_input,
                        sizeof(stvp->index_to_input));
       blob_write_bytes(blob, stvp->result_to_output,
                        sizeof(stvp->result_to_output));
 
       write_stream_out_to_cache(blob, &stvp->tgsi);
       write_tgsi_to_cache(blob, &stvp->tgsi, st, sha1, num_tokens);
       break;
    }
    case MESA_SHADER_TESS_CTRL: {
-      struct st_tessctrl_program *stcp = (struct st_tessctrl_program *) prog;
+      struct st_common_program *stcp = (struct st_common_program *) prog;
       sha1 = stcp->sha1;
 
       write_stream_out_to_cache(blob, out_state);
       write_tgsi_to_cache(blob, out_state, st, sha1, num_tokens);
       break;
    }
    case MESA_SHADER_TESS_EVAL: {
-      struct st_tesseval_program *step = (struct st_tesseval_program *) prog;
+      struct st_common_program *step = (struct st_common_program *) prog;
       sha1 = step->sha1;
 
       write_stream_out_to_cache(blob, out_state);
       write_tgsi_to_cache(blob, out_state, st, sha1, num_tokens);
       break;
    }
    case MESA_SHADER_GEOMETRY: {
-      struct st_geometry_program *stgp = (struct st_geometry_program *) prog;
+      struct st_common_program *stgp = (struct st_common_program *) prog;
       sha1 = stgp->sha1;
 
       write_stream_out_to_cache(blob, out_state);
       write_tgsi_to_cache(blob, out_state, st, sha1, num_tokens);
       break;
    }
    case MESA_SHADER_FRAGMENT: {
       struct st_fragment_program *stfp = (struct st_fragment_program *) prog;
       sha1 = stfp->sha1;
 
@@ -181,38 +181,38 @@ st_load_tgsi_from_disk_cache(struct gl_context *ctx,
       struct gl_program *glprog = prog->_LinkedShaders[i]->Program;
       switch (glprog->info.stage) {
       case MESA_SHADER_VERTEX: {
          struct st_vertex_program *stvp = (struct st_vertex_program *) glprog;
          stage_sha1[i] = stvp->sha1;
          ralloc_strcat(&buf, " vs");
          disk_cache_compute_key(ctx->Cache, buf, strlen(buf), stage_sha1[i]);
          break;
       }
       case MESA_SHADER_TESS_CTRL: {
-         struct st_tessctrl_program *stcp =
-            (struct st_tessctrl_program *) glprog;
+         struct st_common_program *stcp =
+            (struct st_common_program *) glprog;
          stage_sha1[i] = stcp->sha1;
          ralloc_strcat(&buf, " tcs");
          disk_cache_compute_key(ctx->Cache, buf, strlen(buf), stage_sha1[i]);
          break;
       }
       case MESA_SHADER_TESS_EVAL: {
-         struct st_tesseval_program *step =
-            (struct st_tesseval_program *) glprog;
+         struct st_common_program *step =
+            (struct st_common_program *) glprog;
          stage_sha1[i] = step->sha1;
          ralloc_strcat(&buf, " tes");
          disk_cache_compute_key(ctx->Cache, buf, strlen(buf), stage_sha1[i]);
          break;
       }
       case MESA_SHADER_GEOMETRY: {
-         struct st_geometry_program *stgp =
-            (struct st_geometry_program *) glprog;
+         struct st_common_program *stgp =
+            (struct st_common_program *) glprog;
          stage_sha1[i] = stgp->sha1;
          ralloc_strcat(&buf, " gs");
          disk_cache_compute_key(ctx->Cache, buf, strlen(buf), stage_sha1[i]);
          break;
       }
       case MESA_SHADER_FRAGMENT: {
          struct st_fragment_program *stfp =
             (struct st_fragment_program *) glprog;
          stage_sha1[i] = stfp->sha1;
          ralloc_strcat(&buf, " fs");
@@ -271,52 +271,52 @@ st_load_tgsi_from_disk_cache(struct gl_context *ctx,
 
             read_stream_out_from_cache(&blob_reader, &stvp->tgsi);
             read_tgsi_from_cache(&blob_reader, &stvp->tgsi.tokens);
 
             if (st->vp == stvp)
                st->dirty |= ST_NEW_VERTEX_PROGRAM(st, stvp);
 
             break;
          }
          case MESA_SHADER_TESS_CTRL: {
-            struct st_tessctrl_program *sttcp =
-               (struct st_tessctrl_program *) glprog;
+            struct st_common_program *sttcp =
+               (struct st_common_program *) glprog;
 
             st_release_basic_variants(st, sttcp->Base.Target,
                                       &sttcp->variants, &sttcp->tgsi);
 
             read_stream_out_from_cache(&blob_reader, &sttcp->tgsi);
             read_tgsi_from_cache(&blob_reader, &sttcp->tgsi.tokens);
 
             if (st->tcp == sttcp)
                st->dirty |= sttcp->affected_states;
 
             break;
          }
          case MESA_SHADER_TESS_EVAL: {
-            struct st_tesseval_program *sttep =
-               (struct st_tesseval_program *) glprog;
+            struct st_common_program *sttep =
+               (struct st_common_program *) glprog;
 
             st_release_basic_variants(st, sttep->Base.Target,
                                       &sttep->variants, &sttep->tgsi);
 
             read_stream_out_from_cache(&blob_reader, &sttep->tgsi);
             read_tgsi_from_cache(&blob_reader, &sttep->tgsi.tokens);
 
             if (st->tep == sttep)
                st->dirty |= sttep->affected_states;
 
             break;
          }
          case MESA_SHADER_GEOMETRY: {
-            struct st_geometry_program *stgp =
-               (struct st_geometry_program *) glprog;
+            struct st_common_program *stgp =
+               (struct st_common_program *) glprog;
 
             st_release_basic_variants(st, stgp->Base.Target, &stgp->variants,
                                       &stgp->tgsi);
 
             read_stream_out_from_cache(&blob_reader, &stgp->tgsi);
             read_tgsi_from_cache(&blob_reader, &stgp->tgsi.tokens);
 
             if (st->gp == stgp)
                st->dirty |= stgp->affected_states;
 
-- 
2.7.4



More information about the mesa-dev mailing list