i965: Convert brw->*_program into a brw->programs[i] array.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 25 Sep 2017 02:59:41 +0000 (19:59 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 26 Sep 2017 22:29:16 +0000 (15:29 -0700)
This makes it easier to loop over programs.

Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
22 files changed:
src/mesa/drivers/dri/i965/brw_binding_tables.c
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_cs.c
src/mesa/drivers/dri/i965/brw_curbe.c
src/mesa/drivers/dri/i965/brw_gs.c
src/mesa/drivers/dri/i965/brw_gs_surface_state.c
src/mesa/drivers/dri/i965/brw_program.c
src/mesa/drivers/dri/i965/brw_sf.c
src/mesa/drivers/dri/i965/brw_state_upload.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/brw_tes_surface_state.c
src/mesa/drivers/dri/i965/brw_vs.c
src/mesa/drivers/dri/i965/brw_vs_surface_state.c
src/mesa/drivers/dri/i965/brw_wm.c
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
src/mesa/drivers/dri/i965/gen6_sol.c
src/mesa/drivers/dri/i965/gen6_urb.c
src/mesa/drivers/dri/i965/gen7_cs_state.c
src/mesa/drivers/dri/i965/gen7_urb.c
src/mesa/drivers/dri/i965/genX_state_upload.c

index 4bbaa5d05940090485bb17e7d69883a10c11de08..73f5e56010b41f2f6a1a1b8e6c7949b0b8837e84 100644 (file)
@@ -153,7 +153,7 @@ static void
 brw_tcs_upload_binding_table(struct brw_context *brw)
 {
    /* Skip if the tessellation stages are disabled. */
-   if (brw->tess_eval_program == NULL)
+   if (brw->programs[MESA_SHADER_TESS_EVAL] == NULL)
       return;
 
    /* BRW_NEW_TCS_PROG_DATA */
@@ -182,7 +182,7 @@ static void
 brw_tes_upload_binding_table(struct brw_context *brw)
 {
    /* If there's no TES, skip changing anything. */
-   if (brw->tess_eval_program == NULL)
+   if (brw->programs[MESA_SHADER_TESS_EVAL] == NULL)
       return;
 
    /* BRW_NEW_TES_PROG_DATA */
@@ -210,7 +210,7 @@ static void
 brw_gs_upload_binding_table(struct brw_context *brw)
 {
    /* If there's no GS, skip changing anything. */
-   if (brw->geometry_program == NULL)
+   if (brw->programs[MESA_SHADER_GEOMETRY] == NULL)
       return;
 
    /* BRW_NEW_GS_PROG_DATA */
index 6de5c2d0974894876da7f647a1a2f3f32b4d0a24..bc3d3e398be6ed29c9044fdc663eb33d2902296d 100644 (file)
@@ -875,12 +875,7 @@ struct brw_context
 
    /* Active vertex program:
     */
-   const struct gl_program *vertex_program;
-   const struct gl_program *geometry_program;
-   const struct gl_program *tess_ctrl_program;
-   const struct gl_program *tess_eval_program;
-   const struct gl_program *fragment_program;
-   const struct gl_program *compute_program;
+   struct gl_program *programs[MESA_SHADER_STAGES];
 
    /**
     * Number of samples in ctx->DrawBuffer, updated by BRW_NEW_NUM_SAMPLES so
index cf72889b411a0f336061465419d90b4be9b71cf4..bc09abd912c7d56770f0772116cf02abb3e73d3f 100644 (file)
@@ -177,7 +177,8 @@ brw_cs_populate_key(struct brw_context *brw, struct brw_cs_prog_key *key)
 {
    struct gl_context *ctx = &brw->ctx;
    /* BRW_NEW_COMPUTE_PROGRAM */
-   const struct brw_program *cp = (struct brw_program *) brw->compute_program;
+   const struct brw_program *cp =
+      (struct brw_program *) brw->programs[MESA_SHADER_COMPUTE];
    const struct gl_program *prog = (struct gl_program *) cp;
 
    memset(key, 0, sizeof(*key));
@@ -195,7 +196,8 @@ brw_upload_cs_prog(struct brw_context *brw)
 {
    struct gl_context *ctx = &brw->ctx;
    struct brw_cs_prog_key key;
-   struct brw_program *cp = (struct brw_program *) brw->compute_program;
+   struct brw_program *cp =
+      (struct brw_program *) brw->programs[MESA_SHADER_COMPUTE];
 
    if (!cp)
       return;
index 7adf911dea03be4c80b41c5f2d2a4aef6236acc2..07e3c42b152ab4462431fa755a2f38e12ce12fb9 100644 (file)
@@ -204,6 +204,12 @@ brw_upload_constant_buffer(struct brw_context *brw)
    GLuint i;
    gl_clip_plane *clip_planes;
 
+   /* BRW_NEW_FRAGMENT_PROGRAM */
+   struct gl_program *fp = brw->programs[MESA_SHADER_FRAGMENT];
+
+   /* BRW_NEW_VERTEX_PROGRAM */
+   struct gl_program *vp = brw->programs[MESA_SHADER_VERTEX];
+
    if (sz == 0) {
       goto emit;
    }
@@ -215,7 +221,7 @@ brw_upload_constant_buffer(struct brw_context *brw)
 
    /* fragment shader constants */
    if (brw->curbe.wm_size) {
-      _mesa_load_state_parameters(ctx, brw->fragment_program->Parameters);
+      _mesa_load_state_parameters(ctx, fp->Parameters);
 
       /* BRW_NEW_PUSH_CONSTANT_ALLOCATION */
       GLuint offset = brw->curbe.wm_start * 16;
@@ -257,7 +263,7 @@ brw_upload_constant_buffer(struct brw_context *brw)
 
    /* vertex shader constants */
    if (brw->curbe.vs_size) {
-      _mesa_load_state_parameters(ctx, brw->vertex_program->Parameters);
+      _mesa_load_state_parameters(ctx, vp->Parameters);
 
       GLuint offset = brw->curbe.vs_start * 16;
 
@@ -325,7 +331,7 @@ emit:
     * BRW_NEW_FRAGMENT_PROGRAM
     */
    if (devinfo->gen == 4 && !devinfo->is_g4x &&
-       (brw->fragment_program->info.inputs_read & (1 << VARYING_SLOT_POS))) {
+       (fp->info.inputs_read & (1 << VARYING_SLOT_POS))) {
       BEGIN_BATCH(2);
       OUT_BATCH(_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP << 16 | (2 - 2));
       OUT_BATCH(0);
index 01e85daca55a09c979e9825027a3407ab3471df3..e7062ee78998444a7c4166db10866f55e094b82c 100644 (file)
@@ -185,7 +185,8 @@ brw_gs_populate_key(struct brw_context *brw,
                     struct brw_gs_prog_key *key)
 {
    struct gl_context *ctx = &brw->ctx;
-   struct brw_program *gp = (struct brw_program *) brw->geometry_program;
+   struct brw_program *gp =
+      (struct brw_program *) brw->programs[MESA_SHADER_GEOMETRY];
 
    memset(key, 0, sizeof(*key));
 
@@ -201,7 +202,8 @@ brw_upload_gs_prog(struct brw_context *brw)
    struct brw_stage_state *stage_state = &brw->gs.base;
    struct brw_gs_prog_key key;
    /* BRW_NEW_GEOMETRY_PROGRAM */
-   struct brw_program *gp = (struct brw_program *) brw->geometry_program;
+   struct brw_program *gp =
+      (struct brw_program *) brw->programs[MESA_SHADER_GEOMETRY];
 
    if (!brw_gs_state_dirty(brw))
       return;
index f79ce53d9a55d8e59300afdda0ca416af66a125a..570f3fb4dd22ce094930d440eb1180ca441afa09 100644 (file)
@@ -41,7 +41,8 @@ brw_upload_gs_pull_constants(struct brw_context *brw)
    struct brw_stage_state *stage_state = &brw->gs.base;
 
    /* BRW_NEW_GEOMETRY_PROGRAM */
-   struct brw_program *gp = (struct brw_program *) brw->geometry_program;
+   struct brw_program *gp =
+      (struct brw_program *) brw->programs[MESA_SHADER_GEOMETRY];
 
    if (!gp)
       return;
@@ -94,7 +95,7 @@ static void
 brw_upload_gs_abo_surfaces(struct brw_context *brw)
 {
    /* _NEW_PROGRAM */
-   const struct gl_program *gp = brw->geometry_program;
+   const struct gl_program *gp = brw->programs[MESA_SHADER_GEOMETRY];
 
    if (gp) {
       /* BRW_NEW_GS_PROG_DATA */
@@ -116,7 +117,7 @@ static void
 brw_upload_gs_image_surfaces(struct brw_context *brw)
 {
    /* BRW_NEW_GEOMETRY_PROGRAM */
-   const struct gl_program *gp = brw->geometry_program;
+   const struct gl_program *gp = brw->programs[MESA_SHADER_GEOMETRY];
 
    if (gp) {
       /* BRW_NEW_GS_PROG_DATA, BRW_NEW_IMAGE_UNITS, _NEW_TEXTURE */
index 094bba43db1686506f7b1ba3feb836eb97972486..9ec2917c90e8d7a5a601da458a6adb49bda440ce 100644 (file)
@@ -151,15 +151,15 @@ static void brwDeleteProgram( struct gl_context *ctx,
 
    /* Beware!  prog's refcount has reached zero, and it's about to be freed.
     *
-    * In brw_upload_pipeline_state(), we compare brw->foo_program to
+    * In brw_upload_pipeline_state(), we compare brw->programs[i] to
     * ctx->FooProgram._Current, and flag BRW_NEW_FOO_PROGRAM if the
     * pointer has changed.
     *
-    * We cannot leave brw->foo_program as a dangling pointer to the dead
+    * We cannot leave brw->programs[i] as a dangling pointer to the dead
     * program.  malloc() may allocate the same memory for a new gl_program,
     * causing us to see matching pointers...but totally different programs.
     *
-    * We cannot set brw->foo_program to NULL, either.  If we've deleted the
+    * We cannot set brw->programs[i] to NULL, either.  If we've deleted the
     * active program, Mesa may set ctx->FooProgram._Current to NULL.  That
     * would cause us to see matching pointers (NULL == NULL), and fail to
     * detect that a program has changed since our last draw.
@@ -172,23 +172,10 @@ static void brwDeleteProgram( struct gl_context *ctx,
     */
    static const struct gl_program deleted_program;
 
-   if (brw->vertex_program == prog)
-      brw->vertex_program = &deleted_program;
-
-   if (brw->tess_ctrl_program == prog)
-      brw->tess_ctrl_program = &deleted_program;
-
-   if (brw->tess_eval_program == prog)
-      brw->tess_eval_program = &deleted_program;
-
-   if (brw->geometry_program == prog)
-      brw->geometry_program = &deleted_program;
-
-   if (brw->fragment_program == prog)
-      brw->fragment_program = &deleted_program;
-
-   if (brw->compute_program == prog)
-      brw->compute_program = &deleted_program;
+   for (int i = 0; i < MESA_SHADER_STAGES; i++) {
+      if (brw->programs[i] == prog)
+         brw->programs[i] = (struct gl_program *) &deleted_program;
+   }
 
    _mesa_delete_program( ctx, prog );
 }
@@ -208,7 +195,7 @@ brwProgramStringNotify(struct gl_context *ctx,
    case GL_FRAGMENT_PROGRAM_ARB: {
       struct brw_program *newFP = brw_program(prog);
       const struct brw_program *curFP =
-         brw_program_const(brw->fragment_program);
+         brw_program_const(brw->programs[MESA_SHADER_FRAGMENT]);
 
       if (newFP == curFP)
         brw->ctx.NewDriverState |= BRW_NEW_FRAGMENT_PROGRAM;
@@ -224,7 +211,7 @@ brwProgramStringNotify(struct gl_context *ctx,
    case GL_VERTEX_PROGRAM_ARB: {
       struct brw_program *newVP = brw_program(prog);
       const struct brw_program *curVP =
-         brw_program_const(brw->vertex_program);
+         brw_program_const(brw->programs[MESA_SHADER_VERTEX]);
 
       if (newVP == curVP)
         brw->ctx.NewDriverState |= BRW_NEW_VERTEX_PROGRAM;
index 1d5023258a772497c8b3d6240d71cde62bd145ed..37ce999dc0725ea62531b63c6a96d73bdfd8dd69 100644 (file)
@@ -128,7 +128,7 @@ brw_upload_sf_prog(struct brw_context *brw)
    if (key.do_point_sprite) {
       key.point_sprite_coord_replace = ctx->Point.CoordReplace & 0xff;
    }
-   if (brw->fragment_program->info.inputs_read &
+   if (brw->programs[MESA_SHADER_FRAGMENT]->info.inputs_read &
        BITFIELD64_BIT(VARYING_SLOT_PNTC)) {
       key.do_point_coord = 1;
    }
index 28a314828210234c905abc83e74c90be76cf7a7a..16f44d03bbeacf0ef4353901454f55d6557fc7a2 100644 (file)
@@ -380,7 +380,7 @@ brw_print_dirty_count(struct dirty_bit_map *bit_map)
 static inline void
 brw_upload_tess_programs(struct brw_context *brw)
 {
-   if (brw->tess_eval_program) {
+   if (brw->programs[MESA_SHADER_TESS_EVAL]) {
       brw_upload_tcs_prog(brw);
       brw_upload_tes_prog(brw);
    } else {
@@ -400,7 +400,7 @@ brw_upload_programs(struct brw_context *brw,
       brw_upload_vs_prog(brw);
       brw_upload_tess_programs(brw);
 
-      if (brw->geometry_program) {
+      if (brw->programs[MESA_SHADER_GEOMETRY]) {
          brw_upload_gs_prog(brw);
       } else {
          brw->gs.base.prog_data = NULL;
@@ -414,9 +414,9 @@ brw_upload_programs(struct brw_context *brw,
       GLbitfield64 old_slots = brw->vue_map_geom_out.slots_valid;
       bool old_separate = brw->vue_map_geom_out.separate;
       struct brw_vue_prog_data *vue_prog_data;
-      if (brw->geometry_program)
+      if (brw->programs[MESA_SHADER_GEOMETRY])
          vue_prog_data = brw_vue_prog_data(brw->gs.base.prog_data);
-      else if (brw->tess_eval_program)
+      else if (brw->programs[MESA_SHADER_TESS_EVAL])
          vue_prog_data = brw_vue_prog_data(brw->tes.base.prog_data);
       else
          vue_prog_data = brw_vue_prog_data(brw->vs.base.prog_data);
@@ -487,34 +487,38 @@ brw_upload_pipeline_state(struct brw_context *brw,
    }
 
    if (pipeline == BRW_RENDER_PIPELINE) {
-      if (brw->fragment_program != ctx->FragmentProgram._Current) {
-         brw->fragment_program = ctx->FragmentProgram._Current;
+      if (brw->programs[MESA_SHADER_FRAGMENT] !=
+          ctx->FragmentProgram._Current) {
+         brw->programs[MESA_SHADER_FRAGMENT] = ctx->FragmentProgram._Current;
          brw->ctx.NewDriverState |= BRW_NEW_FRAGMENT_PROGRAM;
       }
 
-      if (brw->tess_eval_program != ctx->TessEvalProgram._Current) {
-         brw->tess_eval_program = ctx->TessEvalProgram._Current;
+      if (brw->programs[MESA_SHADER_TESS_EVAL] !=
+          ctx->TessEvalProgram._Current) {
+         brw->programs[MESA_SHADER_TESS_EVAL] = ctx->TessEvalProgram._Current;
          brw->ctx.NewDriverState |= BRW_NEW_TESS_PROGRAMS;
       }
 
-      if (brw->tess_ctrl_program != ctx->TessCtrlProgram._Current) {
-         brw->tess_ctrl_program = ctx->TessCtrlProgram._Current;
+      if (brw->programs[MESA_SHADER_TESS_CTRL] !=
+          ctx->TessCtrlProgram._Current) {
+         brw->programs[MESA_SHADER_TESS_CTRL] = ctx->TessCtrlProgram._Current;
          brw->ctx.NewDriverState |= BRW_NEW_TESS_PROGRAMS;
       }
 
-      if (brw->geometry_program != ctx->GeometryProgram._Current) {
-         brw->geometry_program = ctx->GeometryProgram._Current;
+      if (brw->programs[MESA_SHADER_GEOMETRY] !=
+          ctx->GeometryProgram._Current) {
+         brw->programs[MESA_SHADER_GEOMETRY] = ctx->GeometryProgram._Current;
          brw->ctx.NewDriverState |= BRW_NEW_GEOMETRY_PROGRAM;
       }
 
-      if (brw->vertex_program != ctx->VertexProgram._Current) {
-         brw->vertex_program = ctx->VertexProgram._Current;
+      if (brw->programs[MESA_SHADER_VERTEX] != ctx->VertexProgram._Current) {
+         brw->programs[MESA_SHADER_VERTEX] = ctx->VertexProgram._Current;
          brw->ctx.NewDriverState |= BRW_NEW_VERTEX_PROGRAM;
       }
    }
 
-   if (brw->compute_program != ctx->ComputeProgram._Current) {
-      brw->compute_program = ctx->ComputeProgram._Current;
+   if (brw->programs[MESA_SHADER_COMPUTE] != ctx->ComputeProgram._Current) {
+      brw->programs[MESA_SHADER_COMPUTE] = ctx->ComputeProgram._Current;
       brw->ctx.NewDriverState |= BRW_NEW_COMPUTE_PROGRAM;
    }
 
index 109e3fdbf55557addbb05a67967f7eb8cacc5cc5..474787b0ea671be401e4d569391854db221bd0d6 100644 (file)
@@ -295,8 +295,10 @@ brw_tcs_populate_key(struct brw_context *brw,
                      struct brw_tcs_prog_key *key)
 {
    const struct gen_device_info *devinfo = &brw->screen->devinfo;
-   struct brw_program *tcp = (struct brw_program *) brw->tess_ctrl_program;
-   struct brw_program *tep = (struct brw_program *) brw->tess_eval_program;
+   struct brw_program *tcp =
+      (struct brw_program *) brw->programs[MESA_SHADER_TESS_CTRL];
+   struct brw_program *tep =
+      (struct brw_program *) brw->programs[MESA_SHADER_TESS_EVAL];
    struct gl_program *tes_prog = &tep->program;
 
    uint64_t per_vertex_slots = tes_prog->info.inputs_read;
@@ -337,9 +339,10 @@ brw_upload_tcs_prog(struct brw_context *brw)
    struct brw_stage_state *stage_state = &brw->tcs.base;
    struct brw_tcs_prog_key key;
    /* BRW_NEW_TESS_PROGRAMS */
-   struct brw_program *tcp = (struct brw_program *) brw->tess_ctrl_program;
+   struct brw_program *tcp =
+      (struct brw_program *) brw->programs[MESA_SHADER_TESS_CTRL];
    MAYBE_UNUSED struct brw_program *tep =
-      (struct brw_program *) brw->tess_eval_program;
+      (struct brw_program *) brw->programs[MESA_SHADER_TESS_EVAL];
    assert(tep);
 
    if (!brw_state_dirty(brw,
index df618e0a2aaa46ef1376d6401c15b4866a671192..f4f9abc06204aa3a1c670beb060c017ad54fcc4c 100644 (file)
@@ -41,7 +41,8 @@ brw_upload_tcs_pull_constants(struct brw_context *brw)
    struct brw_stage_state *stage_state = &brw->tcs.base;
 
    /* BRW_NEW_TESS_PROGRAMS */
-   struct brw_program *tcp = (struct brw_program *) brw->tess_ctrl_program;
+   struct brw_program *tcp =
+      (struct brw_program *) brw->programs[MESA_SHADER_TESS_CTRL];
 
    if (!tcp)
       return;
@@ -94,7 +95,7 @@ static void
 brw_upload_tcs_abo_surfaces(struct brw_context *brw)
 {
    /* _NEW_PROGRAM */
-   const struct gl_program *tcp = brw->tess_ctrl_program;
+   const struct gl_program *tcp = brw->programs[MESA_SHADER_TESS_CTRL];
 
    if (tcp) {
       /* BRW_NEW_TCS_PROG_DATA */
@@ -117,7 +118,7 @@ static void
 brw_upload_tcs_image_surfaces(struct brw_context *brw)
 {
    /* BRW_NEW_TESS_PROGRAMS */
-   const struct gl_program *tcp = brw->tess_ctrl_program;
+   const struct gl_program *tcp = brw->programs[MESA_SHADER_TESS_CTRL];
 
    if (tcp) {
       /* BRW_NEW_TCS_PROG_DATA, BRW_NEW_IMAGE_UNITS */
index 20ce1f4c15bc13f4803f0abee841ec0315804927..6564fefc06e5083083542cfa4376fb8b6cef9269 100644 (file)
@@ -165,8 +165,10 @@ void
 brw_tes_populate_key(struct brw_context *brw,
                      struct brw_tes_prog_key *key)
 {
-   struct brw_program *tcp = (struct brw_program *) brw->tess_ctrl_program;
-   struct brw_program *tep = (struct brw_program *) brw->tess_eval_program;
+   struct brw_program *tcp =
+      (struct brw_program *) brw->programs[MESA_SHADER_TESS_CTRL];
+   struct brw_program *tep =
+      (struct brw_program *) brw->programs[MESA_SHADER_TESS_EVAL];
    struct gl_program *prog = &tep->program;
 
    uint64_t per_vertex_slots = prog->info.inputs_read;
@@ -200,7 +202,8 @@ brw_upload_tes_prog(struct brw_context *brw)
    struct brw_stage_state *stage_state = &brw->tes.base;
    struct brw_tes_prog_key key;
    /* BRW_NEW_TESS_PROGRAMS */
-   struct brw_program *tep = (struct brw_program *) brw->tess_eval_program;
+   struct brw_program *tep =
+      (struct brw_program *) brw->programs[MESA_SHADER_TESS_EVAL];
 
    if (!brw_state_dirty(brw,
                         _NEW_TEXTURE,
index a6204ced28b255299d9b705f4736a080e03c5e4d..85b285d86884237b82f67b642b3dc3ac9482acc4 100644 (file)
@@ -41,7 +41,8 @@ brw_upload_tes_pull_constants(struct brw_context *brw)
    struct brw_stage_state *stage_state = &brw->tes.base;
 
    /* BRW_NEW_TESS_PROGRAMS */
-   struct brw_program *dp = (struct brw_program *) brw->tess_eval_program;
+   struct brw_program *dp =
+      (struct brw_program *) brw->programs[MESA_SHADER_TESS_EVAL];
 
    if (!dp)
       return;
@@ -94,7 +95,7 @@ static void
 brw_upload_tes_abo_surfaces(struct brw_context *brw)
 {
    /* _NEW_PROGRAM */
-   const struct gl_program *tep = brw->tess_eval_program;
+   const struct gl_program *tep = brw->programs[MESA_SHADER_TESS_EVAL];
 
    if (tep) {
       /* BRW_NEW_TES_PROG_DATA */
@@ -117,7 +118,7 @@ static void
 brw_upload_tes_image_surfaces(struct brw_context *brw)
 {
    /* BRW_NEW_TESS_PROGRAMS */
-   const struct gl_program *tep = brw->tess_eval_program;
+   const struct gl_program *tep = brw->programs[MESA_SHADER_TESS_EVAL];
 
    if (tep) {
       /* BRW_NEW_TES_PROG_DATA, BRW_NEW_IMAGE_UNITS */
index 1add877c85e92692fc921c298e8fc879b227c163..756e13db31f51022b033324010ea390cf8239653 100644 (file)
@@ -305,8 +305,8 @@ brw_vs_populate_key(struct brw_context *brw,
 {
    struct gl_context *ctx = &brw->ctx;
    /* BRW_NEW_VERTEX_PROGRAM */
-   struct brw_program *vp = (struct brw_program *)brw->vertex_program;
-   struct gl_program *prog = (struct gl_program *) brw->vertex_program;
+   struct gl_program *prog = brw->programs[MESA_SHADER_VERTEX];
+   struct brw_program *vp = (struct brw_program *) prog;
    const struct gen_device_info *devinfo = &brw->screen->devinfo;
 
    memset(key, 0, sizeof(*key));
@@ -356,7 +356,8 @@ brw_upload_vs_prog(struct brw_context *brw)
 {
    struct brw_vs_prog_key key;
    /* BRW_NEW_VERTEX_PROGRAM */
-   struct brw_program *vp = (struct brw_program *)brw->vertex_program;
+   struct brw_program *vp =
+      (struct brw_program *) brw->programs[MESA_SHADER_VERTEX];
 
    if (!brw_vs_state_dirty(brw))
       return;
index 00b5077894ce7cb368021213324219bca8b95b55..23f841ecc3105fe8b1f10f55fe42411b7a8e3149 100644 (file)
@@ -113,7 +113,8 @@ brw_upload_vs_pull_constants(struct brw_context *brw)
    struct brw_stage_state *stage_state = &brw->vs.base;
 
    /* BRW_NEW_VERTEX_PROGRAM */
-   struct brw_program *vp = (struct brw_program *) brw->vertex_program;
+   struct brw_program *vp =
+      (struct brw_program *) brw->programs[MESA_SHADER_VERTEX];
 
    /* BRW_NEW_VS_PROG_DATA */
    const struct brw_stage_prog_data *prog_data = brw->vs.base.prog_data;
@@ -159,7 +160,7 @@ static void
 brw_upload_vs_abo_surfaces(struct brw_context *brw)
 {
    /* _NEW_PROGRAM */
-   const struct gl_program *vp = brw->vertex_program;
+   const struct gl_program *vp = brw->programs[MESA_SHADER_VERTEX];
 
    if (vp) {
       /* BRW_NEW_VS_PROG_DATA */
@@ -181,7 +182,7 @@ static void
 brw_upload_vs_image_surfaces(struct brw_context *brw)
 {
    /* BRW_NEW_VERTEX_PROGRAM */
-   const struct gl_program *vp = brw->vertex_program;
+   const struct gl_program *vp = brw->programs[MESA_SHADER_VERTEX];
 
    if (vp) {
       /* BRW_NEW_VS_PROG_DATA, BRW_NEW_IMAGE_UNITS, _NEW_TEXTURE */
index 92354e464ca672189387e201dcac44f72ce774d7..3ab8e3930aedf4eedb5c86709f428e73b7ed9c2a 100644 (file)
@@ -460,8 +460,8 @@ brw_wm_populate_key(struct brw_context *brw, struct brw_wm_prog_key *key)
    const struct gen_device_info *devinfo = &brw->screen->devinfo;
    struct gl_context *ctx = &brw->ctx;
    /* BRW_NEW_FRAGMENT_PROGRAM */
-   const struct brw_program *fp = brw_program_const(brw->fragment_program);
-   const struct gl_program *prog = (struct gl_program *) brw->fragment_program;
+   const struct gl_program *prog = brw->programs[MESA_SHADER_FRAGMENT];
+   const struct brw_program *fp = brw_program_const(prog);
    GLuint lookup = 0;
    GLuint line_aa;
 
@@ -595,7 +595,8 @@ void
 brw_upload_wm_prog(struct brw_context *brw)
 {
    struct brw_wm_prog_key key;
-   struct brw_program *fp = (struct brw_program *) brw->fragment_program;
+   struct brw_program *fp =
+      (struct brw_program *) brw->programs[MESA_SHADER_FRAGMENT];
 
    if (!brw_wm_state_dirty(brw))
       return;
index 7ff6245832becded890a2289e4971c5830fabe3c..ae74ff1845ef75bd04dda6233e38960f5b4989c9 100644 (file)
@@ -798,7 +798,9 @@ brw_upload_wm_pull_constants(struct brw_context *brw)
 {
    struct brw_stage_state *stage_state = &brw->wm.base;
    /* BRW_NEW_FRAGMENT_PROGRAM */
-   struct brw_program *fp = (struct brw_program *) brw->fragment_program;
+   struct brw_program *fp =
+      (struct brw_program *) brw->programs[MESA_SHADER_FRAGMENT];
+
    /* BRW_NEW_FS_PROG_DATA */
    struct brw_stage_prog_data *prog_data = brw->wm.base.prog_data;
 
@@ -1169,17 +1171,17 @@ brw_update_texture_surfaces(struct brw_context *brw)
    const struct gen_device_info *devinfo = &brw->screen->devinfo;
 
    /* BRW_NEW_VERTEX_PROGRAM */
-   struct gl_program *vs = (struct gl_program *) brw->vertex_program;
+   struct gl_program *vs = brw->programs[MESA_SHADER_VERTEX];
 
    /* BRW_NEW_TESS_PROGRAMS */
-   struct gl_program *tcs = (struct gl_program *) brw->tess_ctrl_program;
-   struct gl_program *tes = (struct gl_program *) brw->tess_eval_program;
+   struct gl_program *tcs = brw->programs[MESA_SHADER_TESS_CTRL];
+   struct gl_program *tes = brw->programs[MESA_SHADER_TESS_EVAL];
 
    /* BRW_NEW_GEOMETRY_PROGRAM */
-   struct gl_program *gs = (struct gl_program *) brw->geometry_program;
+   struct gl_program *gs = brw->programs[MESA_SHADER_GEOMETRY];
 
    /* BRW_NEW_FRAGMENT_PROGRAM */
-   struct gl_program *fs = (struct gl_program *) brw->fragment_program;
+   struct gl_program *fs = brw->programs[MESA_SHADER_FRAGMENT];
 
    /* _NEW_TEXTURE */
    update_stage_texture_surfaces(brw, vs, &brw->vs.base, false, 0);
@@ -1237,7 +1239,7 @@ brw_update_cs_texture_surfaces(struct brw_context *brw)
    const struct gen_device_info *devinfo = &brw->screen->devinfo;
 
    /* BRW_NEW_COMPUTE_PROGRAM */
-   struct gl_program *cs = (struct gl_program *) brw->compute_program;
+   struct gl_program *cs = brw->programs[MESA_SHADER_COMPUTE];
 
    /* _NEW_TEXTURE */
    update_stage_texture_surfaces(brw, cs, &brw->cs.base, false, 0);
@@ -1409,7 +1411,7 @@ static void
 brw_upload_wm_abo_surfaces(struct brw_context *brw)
 {
    /* _NEW_PROGRAM */
-   const struct gl_program *wm = brw->fragment_program;
+   const struct gl_program *wm = brw->programs[MESA_SHADER_FRAGMENT];
 
    if (wm) {
       /* BRW_NEW_FS_PROG_DATA */
@@ -1431,7 +1433,7 @@ static void
 brw_upload_cs_abo_surfaces(struct brw_context *brw)
 {
    /* _NEW_PROGRAM */
-   const struct gl_program *cp = brw->compute_program;
+   const struct gl_program *cp = brw->programs[MESA_SHADER_COMPUTE];
 
    if (cp) {
       /* BRW_NEW_CS_PROG_DATA */
@@ -1453,7 +1455,7 @@ static void
 brw_upload_cs_image_surfaces(struct brw_context *brw)
 {
    /* _NEW_PROGRAM */
-   const struct gl_program *cp = brw->compute_program;
+   const struct gl_program *cp = brw->programs[MESA_SHADER_COMPUTE];
 
    if (cp) {
       /* BRW_NEW_CS_PROG_DATA, BRW_NEW_IMAGE_UNITS, _NEW_TEXTURE */
@@ -1640,7 +1642,7 @@ static void
 brw_upload_wm_image_surfaces(struct brw_context *brw)
 {
    /* BRW_NEW_FRAGMENT_PROGRAM */
-   const struct gl_program *wm = brw->fragment_program;
+   const struct gl_program *wm = brw->programs[MESA_SHADER_FRAGMENT];
 
    if (wm) {
       /* BRW_NEW_FS_PROG_DATA, BRW_NEW_IMAGE_UNITS, _NEW_TEXTURE */
index d350e77dc995661ef47a75236b666ef556149cb0..53e4fd1c144de3bb2bbeac55fe9355a8dd86700e 100644 (file)
@@ -55,7 +55,7 @@ gen6_update_sol_surfaces(struct brw_context *brw)
          unsigned buffer_offset =
             xfb_obj->Offset[buffer] / 4 +
             linked_xfb_info->Outputs[i].DstOffset;
-         if (brw->geometry_program) {
+         if (brw->programs[MESA_SHADER_GEOMETRY]) {
             brw_update_sol_surface(
                brw, xfb_obj->Buffers[buffer],
                &brw->gs.base.surf_offset[surf_index],
@@ -69,7 +69,7 @@ gen6_update_sol_surfaces(struct brw_context *brw)
                linked_xfb_info->Buffers[buffer].Stride, buffer_offset);
          }
       } else {
-         if (!brw->geometry_program)
+         if (!brw->programs[MESA_SHADER_GEOMETRY])
             brw->ff_gs.surf_offset[surf_index] = 0;
          else
             brw->gs.base.surf_offset[surf_index] = 0;
@@ -103,14 +103,15 @@ brw_gs_upload_binding_table(struct brw_context *brw)
 
    /* We have two scenarios here:
     * 1) We are using a geometry shader only to implement transform feedback
-    *    for a vertex shader (brw->geometry_program == NULL). In this case, we
-    *    only need surfaces for transform feedback in the GS stage.
+    *    for a vertex shader (brw->programs[MESA_SHADER_GEOMETRY] == NULL).
+    *    In this case, we only need surfaces for transform feedback in the
+    *    GS stage.
     * 2) We have a user-provided geometry shader. In this case we may need
     *    surfaces for transform feedback and/or other stuff, like textures,
     *    in the GS stage.
     */
 
-   if (!brw->geometry_program) {
+   if (!brw->programs[MESA_SHADER_GEOMETRY]) {
       /* BRW_NEW_VERTEX_PROGRAM */
       prog = ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
       if (prog) {
index e69a1dfada13060d59ac0d933732248602a455ad..a04cf8b8fbff0aa5f5c5f763364af110bdf483ed 100644 (file)
@@ -115,7 +115,8 @@ upload_urb(struct brw_context *brw)
    const unsigned vs_size = MAX2(vs_vue_prog_data->urb_entry_size, 1);
 
    /* BRW_NEW_GEOMETRY_PROGRAM, BRW_NEW_GS_PROG_DATA */
-   const bool gs_present = brw->ff_gs.prog_active || brw->geometry_program;
+   const bool gs_present =
+      brw->ff_gs.prog_active || brw->programs[MESA_SHADER_GEOMETRY];
 
    /* Whe using GS to do transform feedback only we use the same VUE layout for
     * VS outputs and GS outputs (as it's what the SF and Clipper expect), so we
@@ -128,7 +129,7 @@ upload_urb(struct brw_context *brw)
     * outputs can be different from the VS outputs.
     */
    unsigned gs_size = vs_size;
-   if (brw->geometry_program) {
+   if (brw->programs[MESA_SHADER_GEOMETRY]) {
       const struct brw_vue_prog_data *gs_vue_prog_data =
          brw_vue_prog_data(brw->gs.base.prog_data);
       gs_size = gs_vue_prog_data->urb_entry_size;
index 26e4264018fe46ee7d76bfee5adac20d6afde8f2..cdd6ad852cdbb2ca282498deda23ae7ff9978bea 100644 (file)
@@ -114,7 +114,8 @@ gen7_upload_cs_push_constants(struct brw_context *brw)
    struct brw_stage_state *stage_state = &brw->cs.base;
 
    /* BRW_NEW_COMPUTE_PROGRAM */
-   const struct brw_program *cp = (struct brw_program *) brw->compute_program;
+   const struct brw_program *cp =
+      (struct brw_program *) brw->programs[MESA_SHADER_COMPUTE];
 
    if (cp) {
       /* BRW_NEW_CS_PROG_DATA */
@@ -148,7 +149,8 @@ brw_upload_cs_pull_constants(struct brw_context *brw)
    struct brw_stage_state *stage_state = &brw->cs.base;
 
    /* BRW_NEW_COMPUTE_PROGRAM */
-   struct brw_program *cp = (struct brw_program *) brw->compute_program;
+   struct brw_program *cp =
+      (struct brw_program *) brw->programs[MESA_SHADER_COMPUTE];
 
    /* BRW_NEW_CS_PROG_DATA */
    const struct brw_stage_prog_data *prog_data = brw->cs.base.prog_data;
index 44ce2c6a58e4584a0cd4b8d0c5fcd0c62d99832f..2e5f8e60ba94295e50b6b01bd13ccefc70e8eb21 100644 (file)
@@ -65,10 +65,10 @@ gen7_allocate_push_constants(struct brw_context *brw)
    const struct gen_device_info *devinfo = &brw->screen->devinfo;
 
    /* BRW_NEW_GEOMETRY_PROGRAM */
-   bool gs_present = brw->geometry_program;
+   bool gs_present = brw->programs[MESA_SHADER_GEOMETRY];
 
    /* BRW_NEW_TESS_PROGRAMS */
-   bool tess_present = brw->tess_eval_program;
+   bool tess_present = brw->programs[MESA_SHADER_TESS_EVAL];
 
    unsigned avail_size = 16;
    unsigned multiplier =
index 612761601a289502c9f1b1f8709582e4f8580c92..2a99376e3c2c291a144dc364fc3569ed1642cca0 100644 (file)
@@ -1019,6 +1019,9 @@ genX(calculate_attr_overrides)(const struct brw_context *brw,
    /* _NEW_POINT */
    const struct gl_point_attrib *point = &ctx->Point;
 
+   /* BRW_NEW_FRAGMENT_PROGRAM */
+   const struct gl_program *fp = brw->programs[MESA_SHADER_FRAGMENT];
+
    /* BRW_NEW_FS_PROG_DATA */
    const struct brw_wm_prog_data *wm_prog_data =
       brw_wm_prog_data(brw->wm.base.prog_data);
@@ -1026,16 +1029,14 @@ genX(calculate_attr_overrides)(const struct brw_context *brw,
 
    *point_sprite_enables = 0;
 
-   /* BRW_NEW_FRAGMENT_PROGRAM
-    *
-    * If the fragment shader reads VARYING_SLOT_LAYER, then we need to pass in
+   /* If the fragment shader reads VARYING_SLOT_LAYER, then we need to pass in
     * the full vertex header.  Otherwise, we can program the SF to start
     * reading at an offset of 1 (2 varying slots) to skip unnecessary data:
     * - VARYING_SLOT_PSIZ and BRW_VARYING_SLOT_NDC on gen4-5
     * - VARYING_SLOT_{PSIZ,LAYER} and VARYING_SLOT_POS on gen6+
     */
 
-   bool fs_needs_vue_header = brw->fragment_program->info.inputs_read &
+   bool fs_needs_vue_header = fp->info.inputs_read &
       (VARYING_BIT_LAYER | VARYING_BIT_VIEWPORT);
 
    *urb_entry_read_offset = fs_needs_vue_header ? 0 : 1;
@@ -1713,7 +1714,7 @@ brw_color_buffer_write_enabled(struct brw_context *brw)
 {
    struct gl_context *ctx = &brw->ctx;
    /* BRW_NEW_FRAGMENT_PROGRAM */
-   const struct gl_program *fp = brw->fragment_program;
+   const struct gl_program *fp = brw->programs[MESA_SHADER_FRAGMENT];
    unsigned i;
 
    /* _NEW_BUFFERS */
@@ -2524,8 +2525,9 @@ genX(upload_gs_state)(struct brw_context *brw)
    UNUSED struct gl_context *ctx = &brw->ctx;
    UNUSED const struct gen_device_info *devinfo = &brw->screen->devinfo;
    const struct brw_stage_state *stage_state = &brw->gs.base;
+   const struct gl_program *gs_prog = brw->programs[MESA_SHADER_GEOMETRY];
    /* BRW_NEW_GEOMETRY_PROGRAM */
-   bool active = GEN_GEN >= 6 && brw->geometry_program;
+   bool active = GEN_GEN >= 6 && gs_prog;
 
    /* BRW_NEW_GS_PROG_DATA */
    struct brw_stage_prog_data *stage_prog_data = stage_state->prog_data;
@@ -2621,7 +2623,7 @@ genX(upload_gs_state)(struct brw_context *brw)
 
 #if GEN_GEN < 7
          gs.SOStatisticsEnable = true;
-         if (brw->geometry_program->info.has_transform_feedback_varyings)
+         if (gs_prog->info.has_transform_feedback_varyings)
             gs.SVBIPayloadEnable = true;
 
          /* GEN6_GS_SPF_MODE and GEN6_GS_VECTOR_MASK_ENABLE are enabled as it
@@ -3139,8 +3141,9 @@ genX(upload_vs_push_constants)(struct brw_context *brw)
 {
    struct brw_stage_state *stage_state = &brw->vs.base;
 
-   /* _BRW_NEW_VERTEX_PROGRAM */
-   const struct brw_program *vp = brw_program_const(brw->vertex_program);
+   /* BRW_NEW_VERTEX_PROGRAM */
+   const struct brw_program *vp =
+      brw_program_const(brw->programs[MESA_SHADER_VERTEX]);
    /* BRW_NEW_VS_PROG_DATA */
    const struct brw_stage_prog_data *prog_data = brw->vs.base.prog_data;
 
@@ -3166,7 +3169,8 @@ genX(upload_gs_push_constants)(struct brw_context *brw)
    struct brw_stage_state *stage_state = &brw->gs.base;
 
    /* BRW_NEW_GEOMETRY_PROGRAM */
-   const struct brw_program *gp = brw_program_const(brw->geometry_program);
+   const struct brw_program *gp =
+      brw_program_const(brw->programs[MESA_SHADER_GEOMETRY]);
 
    if (gp) {
       /* BRW_NEW_GS_PROG_DATA */
@@ -3194,7 +3198,8 @@ genX(upload_wm_push_constants)(struct brw_context *brw)
 {
    struct brw_stage_state *stage_state = &brw->wm.base;
    /* BRW_NEW_FRAGMENT_PROGRAM */
-   const struct brw_program *fp = brw_program_const(brw->fragment_program);
+   const struct brw_program *fp =
+      brw_program_const(brw->programs[MESA_SHADER_FRAGMENT]);
    /* BRW_NEW_FS_PROG_DATA */
    const struct brw_stage_prog_data *prog_data = brw->wm.base.prog_data;
 
@@ -3389,6 +3394,8 @@ static void
 genX(upload_sbe)(struct brw_context *brw)
 {
    struct gl_context *ctx = &brw->ctx;
+   /* BRW_NEW_FRAGMENT_PROGRAM */
+   UNUSED const struct gl_program *fp = brw->programs[MESA_SHADER_FRAGMENT];
    /* BRW_NEW_FS_PROG_DATA */
    const struct brw_wm_prog_data *wm_prog_data =
       brw_wm_prog_data(brw->wm.base.prog_data);
@@ -3451,10 +3458,8 @@ genX(upload_sbe)(struct brw_context *brw)
       /* prepare the active component dwords */
       int input_index = 0;
       for (int attr = 0; attr < VARYING_SLOT_MAX; attr++) {
-         if (!(brw->fragment_program->info.inputs_read &
-               BITFIELD64_BIT(attr))) {
+         if (!(fp->info.inputs_read & BITFIELD64_BIT(attr)))
             continue;
-         }
 
          assert(input_index < 32);
 
@@ -4000,7 +4005,7 @@ static void
 upload_te_state(struct brw_context *brw)
 {
    /* BRW_NEW_TESS_PROGRAMS */
-   bool active = brw->tess_eval_program;
+   bool active = brw->programs[MESA_SHADER_TESS_EVAL];
 
    /* BRW_NEW_TES_PROG_DATA */
    const struct brw_tes_prog_data *tes_prog_data =
@@ -4038,7 +4043,8 @@ genX(upload_tes_push_constants)(struct brw_context *brw)
 {
    struct brw_stage_state *stage_state = &brw->tes.base;
    /* BRW_NEW_TESS_PROGRAMS */
-   const struct brw_program *tep = brw_program_const(brw->tess_eval_program);
+   const struct brw_program *tep =
+      brw_program_const(brw->programs[MESA_SHADER_TESS_EVAL]);
 
    if (tep) {
       /* BRW_NEW_TES_PROG_DATA */
@@ -4064,8 +4070,9 @@ genX(upload_tcs_push_constants)(struct brw_context *brw)
 {
    struct brw_stage_state *stage_state = &brw->tcs.base;
    /* BRW_NEW_TESS_PROGRAMS */
-   const struct brw_program *tcp = brw_program_const(brw->tess_ctrl_program);
-   bool active = brw->tess_eval_program;
+   const struct brw_program *tcp =
+      brw_program_const(brw->programs[MESA_SHADER_TESS_CTRL]);
+   bool active = brw->programs[MESA_SHADER_TESS_EVAL];
 
    if (active) {
       /* BRW_NEW_TCS_PROG_DATA */
@@ -5113,7 +5120,7 @@ static void
 genX(upload_fs_samplers)(struct brw_context *brw)
 {
    /* BRW_NEW_FRAGMENT_PROGRAM */
-   struct gl_program *fs = (struct gl_program *) brw->fragment_program;
+   struct gl_program *fs = brw->programs[MESA_SHADER_FRAGMENT];
    genX(upload_sampler_state_table)(brw, fs, &brw->wm.base);
 }
 
@@ -5131,7 +5138,7 @@ static void
 genX(upload_vs_samplers)(struct brw_context *brw)
 {
    /* BRW_NEW_VERTEX_PROGRAM */
-   struct gl_program *vs = (struct gl_program *) brw->vertex_program;
+   struct gl_program *vs = brw->programs[MESA_SHADER_VERTEX];
    genX(upload_sampler_state_table)(brw, vs, &brw->vs.base);
 }
 
@@ -5150,7 +5157,7 @@ static void
 genX(upload_gs_samplers)(struct brw_context *brw)
 {
    /* BRW_NEW_GEOMETRY_PROGRAM */
-   struct gl_program *gs = (struct gl_program *) brw->geometry_program;
+   struct gl_program *gs = brw->programs[MESA_SHADER_GEOMETRY];
    if (!gs)
       return;
 
@@ -5174,7 +5181,7 @@ static void
 genX(upload_tcs_samplers)(struct brw_context *brw)
 {
    /* BRW_NEW_TESS_PROGRAMS */
-   struct gl_program *tcs = (struct gl_program *) brw->tess_ctrl_program;
+   struct gl_program *tcs = brw->programs[MESA_SHADER_TESS_CTRL];
    if (!tcs)
       return;
 
@@ -5197,7 +5204,7 @@ static void
 genX(upload_tes_samplers)(struct brw_context *brw)
 {
    /* BRW_NEW_TESS_PROGRAMS */
-   struct gl_program *tes = (struct gl_program *) brw->tess_eval_program;
+   struct gl_program *tes = brw->programs[MESA_SHADER_TESS_EVAL];
    if (!tes)
       return;
 
@@ -5220,7 +5227,7 @@ static void
 genX(upload_cs_samplers)(struct brw_context *brw)
 {
    /* BRW_NEW_COMPUTE_PROGRAM */
-   struct gl_program *cs = (struct gl_program *) brw->compute_program;
+   struct gl_program *cs = brw->programs[MESA_SHADER_COMPUTE];
    if (!cs)
       return;