i965/mesa/st: eliminate gl_compute_program
authorTimothy Arceri <timothy.arceri@collabora.com>
Wed, 19 Oct 2016 01:11:06 +0000 (12:11 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Wed, 26 Oct 2016 03:29:36 +0000 (14:29 +1100)
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
16 files changed:
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_cs.c
src/mesa/drivers/dri/i965/brw_program.c
src/mesa/drivers/dri/i965/gen7_cs_state.c
src/mesa/main/mtypes.h
src/mesa/main/state.c
src/mesa/program/program.c
src/mesa/program/program.h
src/mesa/state_tracker/st_atom.c
src/mesa/state_tracker/st_atom_constbuf.c
src/mesa/state_tracker/st_atom_sampler.c
src/mesa/state_tracker/st_atom_shader.c
src/mesa/state_tracker/st_atom_texture.c
src/mesa/state_tracker/st_cb_program.c
src/mesa/state_tracker/st_program.c
src/mesa/state_tracker/st_program.h

index c1d6e08fea5cdae371b777a03465a16422c2bfca..e190d531c80d6e29e8b24c2ece0a6aa65fbcaa0f 100644 (file)
@@ -365,7 +365,7 @@ struct brw_fragment_program {
 
 /** Subclass of Mesa compute program */
 struct brw_compute_program {
-   struct gl_compute_program program;
+   struct gl_program program;
    unsigned id;  /**< serial no. to identify compute progs, never re-used */
 };
 
@@ -1011,7 +1011,7 @@ struct brw_context
    const struct gl_program *tess_ctrl_program;
    const struct gl_program *tess_eval_program;
    const struct gl_fragment_program *fragment_program;
-   const struct gl_compute_program *compute_program;
+   const struct gl_program *compute_program;
 
    /**
     * Number of samples in ctx->DrawBuffer, updated by BRW_NEW_NUM_SAMPLES so
@@ -1760,7 +1760,7 @@ brw_fragment_program_const(const struct gl_fragment_program *p)
 }
 
 static inline struct brw_compute_program *
-brw_compute_program(struct gl_compute_program *p)
+brw_compute_program(struct gl_program *p)
 {
    return (struct brw_compute_program *) p;
 }
index e7dcf477b766df22b4410e81356891355ac1dc74..799a9b433aedb908527ee6920002cb5b9da56f98 100644 (file)
@@ -85,14 +85,13 @@ brw_codegen_cs_prog(struct brw_context *brw,
       prog_data.base.total_shared = prog->Comp.SharedSize;
    }
 
-   assign_cs_binding_table_offsets(devinfo, prog,
-                                   &cp->program.Base, &prog_data);
+   assign_cs_binding_table_offsets(devinfo, prog, &cp->program, &prog_data);
 
    /* Allocate the references to the uniforms that will end up in the
     * prog_data associated with the compiled program, and which will be freed
     * by the state cache.
     */
-   int param_count = cp->program.Base.nir->num_uniforms / 4;
+   int param_count = cp->program.nir->num_uniforms / 4;
 
    /* The backend also sometimes add a param for the thread local id. */
    prog_data.thread_local_id_index = param_count++;
@@ -108,7 +107,7 @@ brw_codegen_cs_prog(struct brw_context *brw,
    prog_data.base.nr_params = param_count;
    prog_data.base.nr_image_params = cs->base.NumImages;
 
-   brw_nir_setup_glsl_uniforms(cp->program.Base.nir, prog, &cp->program.Base,
+   brw_nir_setup_glsl_uniforms(cp->program.nir, prog, &cp->program,
                                &prog_data.base, true);
 
    if (unlikely(brw->perf_debug)) {
@@ -118,16 +117,16 @@ brw_codegen_cs_prog(struct brw_context *brw,
    }
 
    if (unlikely(INTEL_DEBUG & DEBUG_CS))
-      brw_dump_ir("compute", prog, &cs->base, &cp->program.Base);
+      brw_dump_ir("compute", prog, &cs->base, &cp->program);
 
    int st_index = -1;
    if (INTEL_DEBUG & DEBUG_SHADER_TIME)
-      st_index = brw_get_shader_time_index(brw, prog, &cp->program.Base, ST_CS);
+      st_index = brw_get_shader_time_index(brw, prog, &cp->program, ST_CS);
 
    char *error_str;
-   program = brw_compile_cs(brw->screen->compiler, brw, mem_ctx,
-                            key, &prog_data, cp->program.Base.nir,
-                            st_index, &program_size, &error_str);
+   program = brw_compile_cs(brw->screen->compiler, brw, mem_ctx, key,
+                            &prog_data, cp->program.nir, st_index,
+                            &program_size, &error_str);
    if (program == NULL) {
       prog->LinkStatus = false;
       ralloc_strcat(&prog->InfoLog, error_str);
@@ -221,7 +220,7 @@ brw_upload_cs_prog(struct brw_context *brw)
       return;
 
    brw->cs.base.sampler_count =
-      util_last_bit(ctx->ComputeProgram._Current->Base.SamplersUsed);
+      util_last_bit(ctx->ComputeProgram._Current->SamplersUsed);
 
    brw_cs_populate_key(brw, &key);
 
@@ -247,8 +246,7 @@ brw_cs_precompile(struct gl_context *ctx,
    struct brw_context *brw = brw_context(ctx);
    struct brw_cs_prog_key key;
 
-   struct gl_compute_program *cp = (struct gl_compute_program *) prog;
-   struct brw_compute_program *bcp = brw_compute_program(cp);
+   struct brw_compute_program *bcp = brw_compute_program(prog);
 
    memset(&key, 0, sizeof(key));
    key.program_string_id = bcp->id;
index 6804f3122da85087cba11047d45bcd82f78ebdec..7516baf1e1f830485956115c658f43edc05b1d9e 100644 (file)
@@ -190,7 +190,7 @@ static struct gl_program *brwNewProgram( struct gl_context *ctx,
       if (prog) {
          prog->id = get_new_program_id(brw->screen);
 
-         return _mesa_init_gl_program(&prog->program.Base, target, id);
+         return _mesa_init_gl_program(&prog->program, target, id);
       } else {
          return NULL;
       }
index f0743fc5d38dc0140cb75bda8538a04c9552c33c..3533ac9cb3b9ac379046985f5e036b7e81a440dc 100644 (file)
@@ -289,7 +289,7 @@ gen7_upload_cs_push_constants(struct brw_context *brw)
          brw_cs_prog_data(brw->cs.base.prog_data);
 
       _mesa_shader_write_subroutine_indices(&brw->ctx, MESA_SHADER_COMPUTE);
-      brw_upload_cs_push_constants(brw, &cp->program.Base, cs_prog_data,
+      brw_upload_cs_push_constants(brw, &cp->program, cs_prog_data,
                                    stage_state, AUB_TRACE_WM_CONSTANTS);
    }
 }
@@ -324,7 +324,7 @@ brw_upload_cs_pull_constants(struct brw_context *brw)
 
    _mesa_shader_write_subroutine_indices(&brw->ctx, MESA_SHADER_COMPUTE);
    /* _NEW_PROGRAM_CONSTANTS */
-   brw_upload_pull_constants(brw, BRW_NEW_SURFACES, &cp->program.Base,
+   brw_upload_pull_constants(brw, BRW_NEW_SURFACES, &cp->program,
                              stage_state, prog_data);
 }
 
index 451ede8043fe0d2ef3c03e067d4a6b0354c26d7d..200a7afb1e02b6b8fdfb2a25442ec21844835126 100644 (file)
@@ -2025,23 +2025,6 @@ struct gl_fragment_program
 };
 
 
-/** Compute program object */
-struct gl_compute_program
-{
-   struct gl_program Base;   /**< base class */
-
-   /**
-    * Size specified using local_size_{x,y,z}.
-    */
-   unsigned LocalSize[3];
-
-   /**
-    * Size of shared variables accessed by the compute shader.
-    */
-   unsigned SharedSize;
-};
-
-
 /**
  * State common to vertex and fragment programs.
  */
@@ -2154,7 +2137,7 @@ struct gl_compute_program_state
    /** Currently enabled and valid program (including internal programs
     * and compiled shader programs).
     */
-   struct gl_compute_program *_Current;
+   struct gl_program *_Current;
 };
 
 
@@ -2782,7 +2765,7 @@ struct gl_shader_program
    } Vert;
 
    /**
-    * Compute shader state - copied into gl_compute_program by
+    * Compute shader state - copied into gl_program by
     * _mesa_copy_linked_program_data().
     */
    struct {
index b09b3fefec8ee3a35aaee159274cabe87e07911f..2f810b497b8c1e30d1319a9554d4e5e260f93449 100644 (file)
@@ -112,7 +112,7 @@ update_program(struct gl_context *ctx)
    const struct gl_program *prevGP = ctx->GeometryProgram._Current;
    const struct gl_program *prevTCP = ctx->TessCtrlProgram._Current;
    const struct gl_program *prevTEP = ctx->TessEvalProgram._Current;
-   const struct gl_compute_program *prevCP = ctx->ComputeProgram._Current;
+   const struct gl_program *prevCP = ctx->ComputeProgram._Current;
    GLbitfield new_state = 0x0;
 
    /*
@@ -245,11 +245,11 @@ update_program(struct gl_context *ctx)
    if (csProg && csProg->LinkStatus
        && csProg->_LinkedShaders[MESA_SHADER_COMPUTE]) {
       /* Use GLSL compute shader */
-      _mesa_reference_compprog(ctx, &ctx->ComputeProgram._Current,
-                               gl_compute_program(csProg->_LinkedShaders[MESA_SHADER_COMPUTE]->Program));
+      _mesa_reference_program(ctx, &ctx->ComputeProgram._Current,
+                              csProg->_LinkedShaders[MESA_SHADER_COMPUTE]->Program);
    } else {
       /* no compute program */
-      _mesa_reference_compprog(ctx, &ctx->ComputeProgram._Current, NULL);
+      _mesa_reference_program(ctx, &ctx->ComputeProgram._Current, NULL);
    }
 
    /* Let the driver know what's happening:
@@ -298,7 +298,7 @@ update_program(struct gl_context *ctx)
       new_state |= _NEW_PROGRAM;
       if (ctx->Driver.BindProgram) {
          ctx->Driver.BindProgram(ctx, GL_COMPUTE_PROGRAM_NV,
-                                 (struct gl_program *) ctx->ComputeProgram._Current);
+                                 ctx->ComputeProgram._Current);
       }
    }
 
index a72e6a11dbdabc0e3fbed443d6665925e1ffe93a..61cc6fe9e96514369e9e527ca24778160eea5874 100644 (file)
@@ -222,14 +222,11 @@ _mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id)
    case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */
    case GL_GEOMETRY_PROGRAM_NV:
    case GL_TESS_CONTROL_PROGRAM_NV:
-   case GL_TESS_EVALUATION_PROGRAM_NV: {
+   case GL_TESS_EVALUATION_PROGRAM_NV:
+   case GL_COMPUTE_PROGRAM_NV: {
       struct gl_program *prog = CALLOC_STRUCT(gl_program);
       return _mesa_init_gl_program(prog, target, id);
    }
-   case GL_COMPUTE_PROGRAM_NV: {
-      struct gl_compute_program *prog = CALLOC_STRUCT(gl_compute_program);
-      return _mesa_init_gl_program(&prog->Base, target, id);
-   }
    default:
       _mesa_problem(ctx, "bad target in _mesa_new_program");
       return NULL;
index 5f322da85a692f6ff71e6f3e8e28fe7fbed550a7..defeb2f2a0f246fe745f4d33bc6485a025a4479e 100644 (file)
@@ -98,15 +98,6 @@ _mesa_reference_fragprog(struct gl_context *ctx,
                            (struct gl_program *) prog);
 }
 
-static inline void
-_mesa_reference_compprog(struct gl_context *ctx,
-                         struct gl_compute_program **ptr,
-                         struct gl_compute_program *prog)
-{
-   _mesa_reference_program(ctx, (struct gl_program **) ptr,
-                           (struct gl_program *) prog);
-}
-
 extern  GLboolean
 _mesa_insert_instructions(struct gl_program *prog, GLuint start, GLuint count);
 
@@ -187,18 +178,6 @@ gl_fragment_program_const(const struct gl_program *prog)
    return (const struct gl_fragment_program *) prog;
 }
 
-static inline struct gl_compute_program *
-gl_compute_program(struct gl_program *prog)
-{
-   return (struct gl_compute_program *) prog;
-}
-
-static inline const struct gl_compute_program *
-gl_compute_program_const(const struct gl_program *prog)
-{
-   return (const struct gl_compute_program *) prog;
-}
-
 #ifdef __cplusplus
 } /* extern "C" */
 #endif
index 573615e2ea01797d3c66293b3187e282d1492602..a86cffc4c65e3409037d6a11f4c0d560969d4ee4 100644 (file)
@@ -178,7 +178,7 @@ void st_validate_state( struct st_context *st, enum st_pipeline pipeline )
 
    case ST_PIPELINE_COMPUTE: {
       struct st_compute_program *old_cp = st->cp;
-      struct gl_compute_program *new_cp = ctx->ComputeProgram._Current;
+      struct gl_program *new_cp = ctx->ComputeProgram._Current;
 
       if (new_cp != &old_cp->Base) {
          if (old_cp)
index bc9a1568ed37cee3bca19fb78c08366829d5a222..31d1ef49ab4921a416d2848b82b39ad10ff5478c 100644 (file)
@@ -229,7 +229,7 @@ static void update_cs_constants(struct st_context *st )
    struct gl_program_parameter_list *params;
 
    if (cp) {
-      params = cp->Base.Base.Parameters;
+      params = cp->Base.Parameters;
       st_upload_constants( st, params, MESA_SHADER_COMPUTE );
    }
 }
index 91baa59df2556f1239d6d9b725ee4d474d7bd13b..a7174f882b6baefe05afa7b207e2db83b4472603 100644 (file)
@@ -360,7 +360,7 @@ update_samplers(struct st_context *st)
    if (ctx->ComputeProgram._Current) {
       update_shader_samplers(st,
                              PIPE_SHADER_COMPUTE,
-                             &ctx->ComputeProgram._Current->Base,
+                             ctx->ComputeProgram._Current,
                              ctx->Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits,
                              st->state.samplers[PIPE_SHADER_COMPUTE],
                              &st->state.num_samplers[PIPE_SHADER_COMPUTE]);
index 554e342e8050143ea61553b76f6c465c7f28b5cb..1c3be08de7a8cf0a8b396198b3275987936d2e50 100644 (file)
@@ -312,7 +312,7 @@ update_cp( struct st_context *st )
    }
 
    stcp = st_compute_program(st->ctx->ComputeProgram._Current);
-   assert(stcp->Base.Base.Target == GL_COMPUTE_PROGRAM_NV);
+   assert(stcp->Base.Target == GL_COMPUTE_PROGRAM_NV);
 
    st->cp_variant = st_get_cp_variant(st, &stcp->tgsi, &stcp->variants);
 
index e4257dd2271553c49f83557cffa34bc7268278a5..ea263ab43d89f1f82ae90f5de287c699ddff4561 100644 (file)
@@ -285,7 +285,7 @@ update_compute_textures(struct st_context *st)
    if (ctx->ComputeProgram._Current) {
       update_textures(st,
                       MESA_SHADER_COMPUTE,
-                      &ctx->ComputeProgram._Current->Base,
+                      ctx->ComputeProgram._Current,
                       ctx->Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits,
                       st->state.sampler_views[PIPE_SHADER_COMPUTE],
                       &st->state.num_sampler_views[PIPE_SHADER_COMPUTE]);
index fb0bdd2ded345738bfaf9e5b67a29ba90fa5fc6d..d0478ca2ea9bdf0495ecd44513079223787698ad 100644 (file)
@@ -79,7 +79,7 @@ st_new_program(struct gl_context *ctx, GLenum target, GLuint id)
    }
    case GL_COMPUTE_PROGRAM_NV: {
       struct st_compute_program *prog = ST_CALLOC_STRUCT(st_compute_program);
-      return _mesa_init_gl_program(&prog->Base.Base, target, id);
+      return _mesa_init_gl_program(&prog->Base, target, id);
    }
    default:
       assert(0);
index 2e58f07d5c124805ab475cf9f21a213a8a9bc01a..55cf57289ec1be2585c3971f772e56702b57199e 100644 (file)
@@ -211,7 +211,7 @@ st_release_cp_variants(struct st_context *st, struct st_compute_program *stcp)
 
    for (v = *variants; v; ) {
       struct st_basic_variant *next = v->next;
-      delete_basic_variant(st, v, stcp->Base.Base.Target);
+      delete_basic_variant(st, v, stcp->Base.Target);
       v = next;
    }
 
@@ -1681,12 +1681,12 @@ st_translate_compute_program(struct st_context *st,
    if (ureg == NULL)
       return false;
 
-   st_translate_program_common(st, &stcp->Base.Base, stcp->glsl_to_tgsi, ureg,
+   st_translate_program_common(st, &stcp->Base, stcp->glsl_to_tgsi, ureg,
                                PIPE_SHADER_COMPUTE, &prog);
 
    stcp->tgsi.ir_type = PIPE_SHADER_IR_TGSI;
    stcp->tgsi.prog = prog.tokens;
-   stcp->tgsi.req_local_mem = stcp->Base.Base.info.cs.shared_size;
+   stcp->tgsi.req_local_mem = stcp->Base.info.cs.shared_size;
    stcp->tgsi.req_private_mem = 0;
    stcp->tgsi.req_input_mem = 0;
 
index 0263c8eb39e8a1140b0e8236b748ead2ba5e72d3..deb7009bfaccf310db62c64e5821bc482609df7b 100644 (file)
@@ -288,11 +288,11 @@ struct st_tesseval_program
 
 
 /**
- * Derived from Mesa gl_compute_program:
+ * Derived from Mesa gl_program:
  */
 struct st_compute_program
 {
-   struct gl_compute_program Base;  /**< The Mesa 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 */
@@ -333,7 +333,7 @@ st_tesseval_program( struct gl_program *tep )
 }
 
 static inline struct st_compute_program *
-st_compute_program( struct gl_compute_program *cp )
+st_compute_program( struct gl_program *cp )
 {
    return (struct st_compute_program *)cp;
 }