[Mesa-dev] [PATCH 06/30] mesa: Replace ctx->Shader.Current{Vertex, Fragment, Geometry}Program with an array.

Paul Berry stereotype441 at gmail.com
Thu Jan 9 18:19:07 PST 2014


These are replaced with
ctx->Shader.CurrentProgram[MESA_SHADER_{VERTEX,FRAGMENT,GEOMETRY}].
In patches to follow, this will allow us to replace a lot of ad-hoc
logic with a variable index into the array.

With the exception of the changes to mtypes.h, this patch was
generated entirely by the command:

    find src -type f '(' -iname '*.c' -o -iname '*.cpp' ')' \
    -print0 | xargs -0 sed -i \
    -e 's/\.CurrentVertexProgram/.CurrentProgram[MESA_SHADER_VERTEX]/g' \
    -e 's/\.CurrentGeometryProgram/.CurrentProgram[MESA_SHADER_GEOMETRY]/g' \
    -e 's/\.CurrentFragmentProgram/.CurrentProgram[MESA_SHADER_FRAGMENT]/g'
---
 src/mesa/drivers/common/meta.c                   |  6 ++---
 src/mesa/drivers/dri/i965/brw_gs.c               |  2 +-
 src/mesa/drivers/dri/i965/brw_gs_surface_state.c |  4 ++--
 src/mesa/drivers/dri/i965/brw_vec4_gs.c          |  2 +-
 src/mesa/drivers/dri/i965/brw_vs.c               |  4 ++--
 src/mesa/drivers/dri/i965/brw_vs_state.c         |  2 +-
 src/mesa/drivers/dri/i965/brw_vs_surface_state.c |  4 ++--
 src/mesa/drivers/dri/i965/brw_wm_state.c         |  2 +-
 src/mesa/drivers/dri/i965/gen6_sol.c             |  6 ++---
 src/mesa/drivers/dri/i965/gen6_vs_state.c        |  2 +-
 src/mesa/drivers/dri/i965/gen6_wm_state.c        |  2 +-
 src/mesa/drivers/dri/i965/gen7_sol_state.c       |  4 ++--
 src/mesa/drivers/dri/i965/gen7_vs_state.c        |  2 +-
 src/mesa/drivers/dri/i965/gen7_wm_state.c        |  2 +-
 src/mesa/main/api_validate.c                     | 10 ++++----
 src/mesa/main/context.c                          | 30 ++++++++++++------------
 src/mesa/main/ff_fragment_shader.cpp             |  8 +++----
 src/mesa/main/mtypes.h                           |  7 +++---
 src/mesa/main/shaderapi.c                        | 12 +++++-----
 src/mesa/main/state.c                            |  8 +++----
 src/mesa/main/texstate.c                         | 18 +++++++-------
 src/mesa/main/transformfeedback.c                |  8 +++----
 src/mesa/state_tracker/st_atom_clip.c            |  2 +-
 src/mesa/state_tracker/st_atom_constbuf.c        |  6 ++---
 src/mesa/state_tracker/st_cb_drawpixels.c        |  2 +-
 src/mesa/state_tracker/st_draw.c                 |  6 ++---
 src/mesa/state_tracker/st_program.c              |  6 ++---
 src/mesa/swrast/s_fragprog.c                     |  2 +-
 28 files changed, 84 insertions(+), 85 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 7b41876..5643e3c 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -618,11 +618,11 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
       }
 
       _mesa_reference_shader_program(ctx, &save->VertexShader,
-                                     ctx->Shader.CurrentVertexProgram);
+                                     ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]);
       _mesa_reference_shader_program(ctx, &save->GeometryShader,
-                                     ctx->Shader.CurrentGeometryProgram);
+                                     ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]);
       _mesa_reference_shader_program(ctx, &save->FragmentShader,
-                                     ctx->Shader.CurrentFragmentProgram);
+                                     ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT]);
       _mesa_reference_shader_program(ctx, &save->ActiveShader,
                                      ctx->Shader.ActiveProgram);
 
diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c
index faa8f94..1ba26de 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -187,7 +187,7 @@ static void populate_key(struct brw_context *brw,
       /* BRW_NEW_TRANSFORM_FEEDBACK */
       if (_mesa_is_xfb_active_and_unpaused(ctx)) {
          const struct gl_shader_program *shaderprog =
-            ctx->Shader.CurrentVertexProgram;
+            ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX];
          const struct gl_transform_feedback_info *linked_xfb_info =
             &shaderprog->LinkedTransformFeedback;
          int i;
diff --git a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c
index 5661941..1ccf2e2 100644
--- a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c
@@ -69,7 +69,7 @@ brw_upload_gs_ubo_surfaces(struct brw_context *brw)
    struct gl_context *ctx = &brw->ctx;
 
    /* _NEW_PROGRAM */
-   struct gl_shader_program *prog = ctx->Shader.CurrentGeometryProgram;
+   struct gl_shader_program *prog = ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY];
 
    if (!prog)
       return;
@@ -93,7 +93,7 @@ brw_upload_gs_abo_surfaces(struct brw_context *brw)
 {
    struct gl_context *ctx = &brw->ctx;
    /* _NEW_PROGRAM */
-   struct gl_shader_program *prog = ctx->Shader.CurrentGeometryProgram;
+   struct gl_shader_program *prog = ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY];
 
    if (prog) {
       /* CACHE_NEW_GS_PROG */
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs.c b/src/mesa/drivers/dri/i965/brw_vec4_gs.c
index 018b0b6..7a803cb 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_vec4_gs.c
@@ -290,7 +290,7 @@ brw_upload_gs_prog(struct brw_context *brw)
    if (!brw_search_cache(&brw->cache, BRW_GS_PROG,
                          &key, sizeof(key),
                          &stage_state->prog_offset, &brw->gs.prog_data)) {
-      bool success = do_gs_prog(brw, ctx->Shader.CurrentGeometryProgram,
+      bool success = do_gs_prog(brw, ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY],
                                 gp, &key);
       assert(success);
    }
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index 5d50c3c..351a83e 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -155,7 +155,7 @@ brw_compute_vue_map(struct brw_context *brw, struct brw_vue_map *vue_map,
  */
 gl_clip_plane *brw_select_clip_planes(struct gl_context *ctx)
 {
-   if (ctx->Shader.CurrentVertexProgram) {
+   if (ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]) {
       /* There is currently a GLSL vertex shader, so clip according to GLSL
        * rules, which means compare gl_ClipVertex (or gl_Position, if
        * gl_ClipVertex wasn't assigned) against the eye-coordinate clip planes
@@ -481,7 +481,7 @@ static void brw_upload_vs_prog(struct brw_context *brw)
    if (!brw_search_cache(&brw->cache, BRW_VS_PROG,
 			 &key, sizeof(key),
 			 &brw->vs.base.prog_offset, &brw->vs.prog_data)) {
-      bool success = do_vs_prog(brw, ctx->Shader.CurrentVertexProgram,
+      bool success = do_vs_prog(brw, ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX],
 				vp, &key);
       (void) success;
       assert(success);
diff --git a/src/mesa/drivers/dri/i965/brw_vs_state.c b/src/mesa/drivers/dri/i965/brw_vs_state.c
index 015abf1..5d86bf5 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_state.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_state.c
@@ -60,7 +60,7 @@ brw_upload_vs_unit(struct brw_context *brw)
    /* Use ALT floating point mode for ARB vertex programs, because they
     * require 0^0 == 1.
     */
-   if (brw->ctx.Shader.CurrentVertexProgram == NULL)
+   if (brw->ctx.Shader.CurrentProgram[MESA_SHADER_VERTEX] == NULL)
       vs->thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
    else
       vs->thread1.floating_point_mode = BRW_FLOATING_POINT_IEEE_754;
diff --git a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
index 9834c11..2fbcdf9 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
@@ -130,7 +130,7 @@ brw_upload_vs_ubo_surfaces(struct brw_context *brw)
 {
    struct gl_context *ctx = &brw->ctx;
    /* _NEW_PROGRAM */
-   struct gl_shader_program *prog = ctx->Shader.CurrentVertexProgram;
+   struct gl_shader_program *prog = ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX];
 
    if (!prog)
       return;
@@ -154,7 +154,7 @@ brw_upload_vs_abo_surfaces(struct brw_context *brw)
 {
    struct gl_context *ctx = &brw->ctx;
    /* _NEW_PROGRAM */
-   struct gl_shader_program *prog = ctx->Shader.CurrentVertexProgram;
+   struct gl_shader_program *prog = ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX];
 
    if (prog) {
       /* CACHE_NEW_VS_PROG */
diff --git a/src/mesa/drivers/dri/i965/brw_wm_state.c b/src/mesa/drivers/dri/i965/brw_wm_state.c
index d56ef20..303a2eb 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_state.c
@@ -115,7 +115,7 @@ brw_upload_wm_unit(struct brw_context *brw)
     * rendering, CurrentFragmentProgram is used for this check to
     * differentiate between the GLSL and non-GLSL cases.
     */
-   if (ctx->Shader.CurrentFragmentProgram == NULL)
+   if (ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT] == NULL)
       wm->thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
    else
       wm->thread1.floating_point_mode = BRW_FLOATING_POINT_IEEE_754;
diff --git a/src/mesa/drivers/dri/i965/gen6_sol.c b/src/mesa/drivers/dri/i965/gen6_sol.c
index eede109..0047c8a 100644
--- a/src/mesa/drivers/dri/i965/gen6_sol.c
+++ b/src/mesa/drivers/dri/i965/gen6_sol.c
@@ -43,7 +43,7 @@ gen6_update_sol_surfaces(struct brw_context *brw)
       ctx->TransformFeedback.CurrentObject;
    /* BRW_NEW_VERTEX_PROGRAM */
    const struct gl_shader_program *shaderprog =
-      ctx->Shader.CurrentVertexProgram;
+      ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX];
    const struct gl_transform_feedback_info *linked_xfb_info =
       &shaderprog->LinkedTransformFeedback;
    int i;
@@ -89,7 +89,7 @@ brw_gs_upload_binding_table(struct brw_context *brw)
    struct gl_context *ctx = &brw->ctx;
    /* BRW_NEW_VERTEX_PROGRAM */
    const struct gl_shader_program *shaderprog =
-      ctx->Shader.CurrentVertexProgram;
+      ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX];
    bool has_surfaces = false;
    uint32_t *bind;
 
@@ -175,7 +175,7 @@ brw_begin_transform_feedback(struct gl_context *ctx, GLenum mode,
 {
    struct brw_context *brw = brw_context(ctx);
    const struct gl_shader_program *vs_prog =
-      ctx->Shader.CurrentVertexProgram;
+      ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX];
    const struct gl_transform_feedback_info *linked_xfb_info =
       &vs_prog->LinkedTransformFeedback;
    struct gl_transform_feedback_object *xfb_obj =
diff --git a/src/mesa/drivers/dri/i965/gen6_vs_state.c b/src/mesa/drivers/dri/i965/gen6_vs_state.c
index 80129cd..e35f21b 100644
--- a/src/mesa/drivers/dri/i965/gen6_vs_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_vs_state.c
@@ -158,7 +158,7 @@ upload_vs_state(struct brw_context *brw)
    /* Use ALT floating point mode for ARB vertex programs, because they
     * require 0^0 == 1.
     */
-   if (ctx->Shader.CurrentVertexProgram == NULL)
+   if (ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX] == NULL)
       floating_point_mode = GEN6_VS_FLOATING_POINT_MODE_ALT;
 
    BEGIN_BATCH(6);
diff --git a/src/mesa/drivers/dri/i965/gen6_wm_state.c b/src/mesa/drivers/dri/i965/gen6_wm_state.c
index 83a1708..5188aa8 100644
--- a/src/mesa/drivers/dri/i965/gen6_wm_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_wm_state.c
@@ -140,7 +140,7 @@ upload_wm_state(struct brw_context *brw)
     * rendering, CurrentFragmentProgram is used for this check to
     * differentiate between the GLSL and non-GLSL cases.
     */
-   if (ctx->Shader.CurrentFragmentProgram == NULL)
+   if (ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT] == NULL)
       dw2 |= GEN6_WM_FLOATING_POINT_MODE_ALT;
 
    /* CACHE_NEW_SAMPLER */
diff --git a/src/mesa/drivers/dri/i965/gen7_sol_state.c b/src/mesa/drivers/dri/i965/gen7_sol_state.c
index 8ef8993..1ca2b74 100644
--- a/src/mesa/drivers/dri/i965/gen7_sol_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_sol_state.c
@@ -41,7 +41,7 @@ upload_3dstate_so_buffers(struct brw_context *brw)
    struct gl_context *ctx = &brw->ctx;
    /* BRW_NEW_VERTEX_PROGRAM */
    const struct gl_shader_program *vs_prog =
-      ctx->Shader.CurrentVertexProgram;
+      ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX];
    const struct gl_transform_feedback_info *linked_xfb_info =
       &vs_prog->LinkedTransformFeedback;
    /* BRW_NEW_TRANSFORM_FEEDBACK */
@@ -104,7 +104,7 @@ gen7_upload_3dstate_so_decl_list(struct brw_context *brw,
    struct gl_context *ctx = &brw->ctx;
    /* BRW_NEW_VERTEX_PROGRAM */
    const struct gl_shader_program *vs_prog =
-      ctx->Shader.CurrentVertexProgram;
+      ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX];
    /* BRW_NEW_TRANSFORM_FEEDBACK */
    const struct gl_transform_feedback_info *linked_xfb_info =
       &vs_prog->LinkedTransformFeedback;
diff --git a/src/mesa/drivers/dri/i965/gen7_vs_state.c b/src/mesa/drivers/dri/i965/gen7_vs_state.c
index 1e76eb1..8381e1f 100644
--- a/src/mesa/drivers/dri/i965/gen7_vs_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_vs_state.c
@@ -92,7 +92,7 @@ upload_vs_state(struct brw_context *brw)
    /* Use ALT floating point mode for ARB vertex programs, because they
     * require 0^0 == 1.
     */
-   if (ctx->Shader.CurrentVertexProgram == NULL)
+   if (ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX] == NULL)
       floating_point_mode = GEN6_VS_FLOATING_POINT_MODE_ALT;
 
    BEGIN_BATCH(6);
diff --git a/src/mesa/drivers/dri/i965/gen7_wm_state.c b/src/mesa/drivers/dri/i965/gen7_wm_state.c
index b6561bb..7f2a50c 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_state.c
@@ -174,7 +174,7 @@ upload_ps_state(struct brw_context *brw)
     * differentiate between the GLSL and non-GLSL cases.
     */
    /* BRW_NEW_FRAGMENT_PROGRAM */
-   if (ctx->Shader.CurrentFragmentProgram == NULL)
+   if (ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT] == NULL)
       dw2 |= GEN7_PS_FLOATING_POINT_MODE_ALT;
 
    /* Haswell requires the sample mask to be set in this packet as well as
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 96b1789..6945584 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -128,7 +128,7 @@ check_valid_to_render(struct gl_context *ctx, const char *function)
    case API_OPENGL_CORE:
       {
          const struct gl_shader_program *vsProg =
-            ctx->Shader.CurrentVertexProgram;
+            ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX];
          GLboolean haveVertexShader = (vsProg && vsProg->LinkStatus);
          GLboolean haveVertexProgram = ctx->VertexProgram._Enabled;
          if (haveVertexShader || haveVertexProgram) {
@@ -269,9 +269,9 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
     *   TRIANGLES_ADJACENCY_ARB or TRIANGLE_STRIP_ADJACENCY_ARB.
     *
    */
-   if (ctx->Shader.CurrentGeometryProgram) {
+   if (ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]) {
       const GLenum geom_mode =
-         ctx->Shader.CurrentGeometryProgram->Geom.InputType;
+         ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]->Geom.InputType;
       switch (mode) {
       case GL_POINTS:
          valid_enum = (geom_mode == GL_POINTS);
@@ -330,8 +330,8 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
    if (_mesa_is_xfb_active_and_unpaused(ctx)) {
       GLboolean pass = GL_TRUE;
 
-      if(ctx->Shader.CurrentGeometryProgram) {
-         switch (ctx->Shader.CurrentGeometryProgram->Geom.OutputType) {
+      if(ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]) {
+         switch (ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]->Geom.OutputType) {
          case GL_POINTS:
             pass = ctx->TransformFeedback.Mode == GL_POINTS;
             break;
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 0b8fb94..8e978eb 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1744,10 +1744,10 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
    if (ctx->NewState)
       _mesa_update_state(ctx);
 
-   if (ctx->Shader.CurrentVertexProgram) {
+   if (ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]) {
       vert_from_glsl_shader = true;
 
-      if (!ctx->Shader.CurrentVertexProgram->LinkStatus) {
+      if (!ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->LinkStatus) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "%s(shader not linked)", where);
          return GL_FALSE;
@@ -1756,19 +1756,19 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
       {
          char errMsg[100];
          if (!_mesa_validate_shader_program(ctx,
-					    ctx->Shader.CurrentVertexProgram,
+					    ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX],
                                             errMsg)) {
             _mesa_warning(ctx, "Shader program %u is invalid: %s",
-                          ctx->Shader.CurrentVertexProgram->Name, errMsg);
+                          ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->Name, errMsg);
          }
       }
 #endif
    }
 
-   if (ctx->Shader.CurrentGeometryProgram) {
+   if (ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]) {
       geom_from_glsl_shader = true;
 
-      if (!ctx->Shader.CurrentGeometryProgram->LinkStatus) {
+      if (!ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]->LinkStatus) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "%s(shader not linked)", where);
          return GL_FALSE;
@@ -1777,19 +1777,19 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
       {
          char errMsg[100];
          if (!_mesa_validate_shader_program(ctx,
-					    ctx->Shader.CurrentGeometryProgram,
+					    ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY],
                                             errMsg)) {
             _mesa_warning(ctx, "Shader program %u is invalid: %s",
-                          ctx->Shader.CurrentGeometryProgram->Name, errMsg);
+                          ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]->Name, errMsg);
          }
       }
 #endif
    }
 
-   if (ctx->Shader.CurrentFragmentProgram) {
+   if (ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT]) {
       frag_from_glsl_shader = true;
 
-      if (!ctx->Shader.CurrentFragmentProgram->LinkStatus) {
+      if (!ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT]->LinkStatus) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "%s(shader not linked)", where);
          return GL_FALSE;
@@ -1798,10 +1798,10 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
       {
          char errMsg[100];
          if (!_mesa_validate_shader_program(ctx,
-					    ctx->Shader.CurrentFragmentProgram,
+					    ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT],
                                             errMsg)) {
             _mesa_warning(ctx, "Shader program %u is invalid: %s",
-                          ctx->Shader.CurrentFragmentProgram->Name, errMsg);
+                          ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT]->Name, errMsg);
          }
       }
 #endif
@@ -1854,9 +1854,9 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
       struct gl_shader_program *shProg[MESA_SHADER_STAGES];
       gl_shader_stage i;
 
-      shProg[MESA_SHADER_VERTEX] = ctx->Shader.CurrentVertexProgram;
-      shProg[MESA_SHADER_GEOMETRY] = ctx->Shader.CurrentGeometryProgram;
-      shProg[MESA_SHADER_FRAGMENT] = ctx->Shader.CurrentFragmentProgram;
+      shProg[MESA_SHADER_VERTEX] = ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX];
+      shProg[MESA_SHADER_GEOMETRY] = ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY];
+      shProg[MESA_SHADER_FRAGMENT] = ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT];
 
       for (i = 0; i < MESA_SHADER_STAGES; i++) {
 	 if (shProg[i] == NULL || shProg[i]->_Used
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index 00ca025..81d1414 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -317,9 +317,9 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx )
 {
    /* _NEW_PROGRAM */
    const GLboolean vertexShader =
-      (ctx->Shader.CurrentVertexProgram &&
-       ctx->Shader.CurrentVertexProgram->LinkStatus &&
-       ctx->Shader.CurrentVertexProgram->_LinkedShaders[MESA_SHADER_VERTEX]);
+      (ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX] &&
+       ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->LinkStatus &&
+       ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->_LinkedShaders[MESA_SHADER_VERTEX]);
    const GLboolean vertexProgram = ctx->VertexProgram._Enabled;
    GLbitfield fp_inputs = 0x0;
 
@@ -383,7 +383,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx )
        * validation (see additional comments in state.c).
        */
       if (vertexShader)
-         vprog = ctx->Shader.CurrentVertexProgram->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
+         vprog = ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
       else
          vprog = &ctx->VertexProgram.Current->Base;
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 908ec30..bdd2804 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1806,7 +1806,8 @@ struct gl_transform_feedback_object
 
    /**
     * The shader program active when BeginTransformFeedback() was called.
-    * When active and unpaused, this equals ctx->Shader.CurrentVertexProgram.
+    * When active and unpaused, this equals
+    * ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX].
     */
    struct gl_shader_program *shader_program;
 
@@ -2679,9 +2680,7 @@ struct gl_shader_state
     * GL_EXT_separate_shader_objects is not supported, each of these must point
     * to \c NULL or to the same program.
     */
-   struct gl_shader_program *CurrentVertexProgram;
-   struct gl_shader_program *CurrentGeometryProgram;
-   struct gl_shader_program *CurrentFragmentProgram;
+   struct gl_shader_program *CurrentProgram[MESA_SHADER_STAGES];
 
    struct gl_shader_program *_CurrentFragmentProgram;
 
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 2ab0a0c..d57748c 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -130,10 +130,10 @@ _mesa_init_shader_state(struct gl_context *ctx)
 void
 _mesa_free_shader_state(struct gl_context *ctx)
 {
-   _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentVertexProgram, NULL);
-   _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentGeometryProgram,
+   _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX], NULL);
+   _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY],
 				  NULL);
-   _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentFragmentProgram,
+   _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT],
 				  NULL);
    _mesa_reference_shader_program(ctx, &ctx->Shader._CurrentFragmentProgram,
 				  NULL);
@@ -949,21 +949,21 @@ use_shader_program(struct gl_context *ctx, GLenum type,
 
    switch (type) {
    case GL_VERTEX_SHADER:
-      target = &ctx->Shader.CurrentVertexProgram;
+      target = &ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX];
       if ((shProg == NULL)
 	  || (shProg->_LinkedShaders[MESA_SHADER_VERTEX] == NULL)) {
 	 shProg = NULL;
       }
       break;
    case GL_GEOMETRY_SHADER_ARB:
-      target = &ctx->Shader.CurrentGeometryProgram;
+      target = &ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY];
       if ((shProg == NULL)
 	  || (shProg->_LinkedShaders[MESA_SHADER_GEOMETRY] == NULL)) {
 	 shProg = NULL;
       }
       break;
    case GL_FRAGMENT_SHADER:
-      target = &ctx->Shader.CurrentFragmentProgram;
+      target = &ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT];
       if ((shProg == NULL)
 	  || (shProg->_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL)) {
 	 shProg = NULL;
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 33070b7..d8fb3b0 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -94,9 +94,9 @@ update_program_enables(struct gl_context *ctx)
 static GLbitfield
 update_program(struct gl_context *ctx)
 {
-   const struct gl_shader_program *vsProg = ctx->Shader.CurrentVertexProgram;
-   const struct gl_shader_program *gsProg = ctx->Shader.CurrentGeometryProgram;
-   struct gl_shader_program *fsProg = ctx->Shader.CurrentFragmentProgram;
+   const struct gl_shader_program *vsProg = ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX];
+   const struct gl_shader_program *gsProg = ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY];
+   struct gl_shader_program *fsProg = ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT];
    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;
@@ -304,7 +304,7 @@ update_multisample(struct gl_context *ctx)
 static void
 update_twoside(struct gl_context *ctx)
 {
-   if (ctx->Shader.CurrentVertexProgram ||
+   if (ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX] ||
        ctx->VertexProgram._Enabled) {
       ctx->VertexProgram._TwoSideEnabled = ctx->VertexProgram.TwoSideEnabled;
    } else {
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index ad80dcf..b9c76da 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -531,19 +531,19 @@ update_texture_state( struct gl_context *ctx )
    struct gl_program *gprog = NULL;
    GLbitfield enabledFragUnits = 0x0;
 
-   if (ctx->Shader.CurrentVertexProgram &&
-       ctx->Shader.CurrentVertexProgram->LinkStatus) {
-      vprog = ctx->Shader.CurrentVertexProgram->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
+   if (ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX] &&
+       ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->LinkStatus) {
+      vprog = ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
    }
 
-   if (ctx->Shader.CurrentGeometryProgram &&
-       ctx->Shader.CurrentGeometryProgram->LinkStatus) {
-      gprog = ctx->Shader.CurrentGeometryProgram->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program;
+   if (ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY] &&
+       ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]->LinkStatus) {
+      gprog = ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program;
    }
 
-   if (ctx->Shader.CurrentFragmentProgram &&
-       ctx->Shader.CurrentFragmentProgram->LinkStatus) {
-      fprog = ctx->Shader.CurrentFragmentProgram->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
+   if (ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT] &&
+       ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT]->LinkStatus) {
+      fprog = ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT]->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
    }
    else if (ctx->FragmentProgram._Enabled) {
       fprog = &ctx->FragmentProgram.Current->Base;
diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c
index 76d213b..9eaa698 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -387,13 +387,13 @@ _mesa_BeginTransformFeedback(GLenum mode)
 
    obj = ctx->TransformFeedback.CurrentObject;
 
-   if (ctx->Shader.CurrentVertexProgram == NULL) {
+   if (ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX] == NULL) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
                   "glBeginTransformFeedback(no program active)");
       return;
    }
 
-   info = &ctx->Shader.CurrentVertexProgram->LinkedTransformFeedback;
+   info = &ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->LinkedTransformFeedback;
 
    if (info->NumOutputs == 0) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
@@ -451,7 +451,7 @@ _mesa_BeginTransformFeedback(GLenum mode)
       obj->GlesRemainingPrims = max_vertices / vertices_per_prim;
    }
 
-   obj->shader_program = ctx->Shader.CurrentVertexProgram;
+   obj->shader_program = ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX];
 
    assert(ctx->Driver.BeginTransformFeedback);
    ctx->Driver.BeginTransformFeedback(ctx, mode, obj);
@@ -993,7 +993,7 @@ _mesa_ResumeTransformFeedback(void)
     *  the program object being used by the current transform feedback object
     *  is not active."
     */
-   if (obj->shader_program != ctx->Shader.CurrentVertexProgram) {
+   if (obj->shader_program != ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
                   "glResumeTransformFeedback(wrong vertex program bound)");
       return;
diff --git a/src/mesa/state_tracker/st_atom_clip.c b/src/mesa/state_tracker/st_atom_clip.c
index 8558d76..10f2b97 100644
--- a/src/mesa/state_tracker/st_atom_clip.c
+++ b/src/mesa/state_tracker/st_atom_clip.c
@@ -52,7 +52,7 @@ static void update_clip( struct st_context *st )
    /* if we have a vertex shader that writes clip vertex we need to pass
       the pre-projection transformed coordinates into the driver. */
    if (st->vp) {
-      if (ctx->Shader.CurrentVertexProgram)
+      if (ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX])
          use_eye = TRUE;
    }
 
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
index f3c4576..23b919b 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -218,7 +218,7 @@ static void st_bind_ubos(struct st_context *st,
 
 static void bind_vs_ubos(struct st_context *st)
 {
-   struct gl_shader_program *prog = st->ctx->Shader.CurrentVertexProgram;
+   struct gl_shader_program *prog = st->ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX];
 
    if (!prog)
       return;
@@ -237,7 +237,7 @@ const struct st_tracked_state st_bind_vs_ubos = {
 
 static void bind_fs_ubos(struct st_context *st)
 {
-   struct gl_shader_program *prog = st->ctx->Shader.CurrentFragmentProgram;
+   struct gl_shader_program *prog = st->ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT];
 
    if (!prog)
       return;
@@ -256,7 +256,7 @@ const struct st_tracked_state st_bind_fs_ubos = {
 
 static void bind_gs_ubos(struct st_context *st)
 {
-   struct gl_shader_program *prog = st->ctx->Shader.CurrentGeometryProgram;
+   struct gl_shader_program *prog = st->ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY];
 
    if (!prog)
       return;
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 3058dfb..37ec069 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -1364,7 +1364,7 @@ blit_copy_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
        !ctx->Stencil.Enabled &&
        !ctx->FragmentProgram.Enabled &&
        !ctx->VertexProgram.Enabled &&
-       !ctx->Shader.CurrentFragmentProgram &&
+       !ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT] &&
        ctx->DrawBuffer->_NumColorDrawBuffers == 1 &&
        !ctx->Query.CondRenderQuery &&
        !ctx->Query.CurrentOcclusionObject) {
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index ef0a607..75a71f1 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -132,9 +132,9 @@ static void
 check_uniforms(struct gl_context *ctx)
 {
    struct gl_shader_program *shProg[3] = {
-      ctx->Shader.CurrentVertexProgram,
-      ctx->Shader.CurrentGeometryProgram,
-      ctx->Shader.CurrentFragmentProgram,
+      ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX],
+      ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY],
+      ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT],
    };
    unsigned j;
 
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index f72122b..fe3dafe 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -1196,9 +1196,9 @@ void
 st_print_shaders(struct gl_context *ctx)
 {
    struct gl_shader_program *shProg[3] = {
-      ctx->Shader.CurrentVertexProgram,
-      ctx->Shader.CurrentGeometryProgram,
-      ctx->Shader.CurrentFragmentProgram,
+      ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX],
+      ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY],
+      ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT],
    };
    unsigned j;
 
diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c
index 4e9ac39..fa45fa9 100644
--- a/src/mesa/swrast/s_fragprog.c
+++ b/src/mesa/swrast/s_fragprog.c
@@ -182,7 +182,7 @@ init_machine(struct gl_context *ctx, struct gl_program_machine *machine,
    machine->Samplers = program->Base.SamplerUnits;
 
    /* if running a GLSL program (not ARB_fragment_program) */
-   if (ctx->Shader.CurrentFragmentProgram) {
+   if (ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT]) {
       /* Store front/back facing value */
       machine->Attribs[VARYING_SLOT_FACE][col][0] = 1.0F - span->facing;
    }
-- 
1.8.5.2



More information about the mesa-dev mailing list