i965: Pass gl_program pointers into precompile functions.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 24 Nov 2014 07:26:00 +0000 (23:26 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 24 Nov 2014 23:30:09 +0000 (15:30 -0800)
We'd like to do precompiling for ARB vertex and fragment programs,
which only have gl_program structures - gl_shader_program is NULL.

This patch makes the various precompile functions take a gl_program
parameter directly, rather than accessing it via gl_shader_program.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_gs.c
src/mesa/drivers/dri/i965/brw_gs.h
src/mesa/drivers/dri/i965/brw_shader.cpp
src/mesa/drivers/dri/i965/brw_vs.c
src/mesa/drivers/dri/i965/brw_vs.h

index 054ff2c7944b86a5890b40578f07231f39d4b80d..f3f69c46c2cbaa7dcac18bd2c6a963c9656fa57f 100644 (file)
@@ -3749,16 +3749,14 @@ brw_wm_fs_emit(struct brw_context *brw,
 }
 
 bool
-brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
+brw_fs_precompile(struct gl_context *ctx,
+                  struct gl_shader_program *shader_prog,
+                  struct gl_program *prog)
 {
    struct brw_context *brw = brw_context(ctx);
    struct brw_wm_prog_key key;
 
-   if (!prog->_LinkedShaders[MESA_SHADER_FRAGMENT])
-      return true;
-
-   struct gl_fragment_program *fp = (struct gl_fragment_program *)
-      prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
+   struct gl_fragment_program *fp = (struct gl_fragment_program *) prog;
    struct brw_fragment_program *bfp = brw_fragment_program(fp);
    bool program_uses_dfdy = fp->UsesDFdy;
 
@@ -3816,7 +3814,7 @@ brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
    uint32_t old_prog_offset = brw->wm.base.prog_offset;
    struct brw_wm_prog_data *old_prog_data = brw->wm.prog_data;
 
-   bool success = do_wm_prog(brw, prog, bfp, &key);
+   bool success = do_wm_prog(brw, shader_prog, bfp, &key);
 
    brw->wm.base.prog_offset = old_prog_offset;
    brw->wm.prog_data = old_prog_data;
index d4f663d2bebfd0f02b13b91599be41b9354dd332..f558662064b0d57e8e0cbe4f9510774cecb46cbd 100644 (file)
@@ -797,6 +797,8 @@ private:
 
 bool brw_do_channel_expressions(struct exec_list *instructions);
 bool brw_do_vector_splitting(struct exec_list *instructions);
-bool brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog);
+bool brw_fs_precompile(struct gl_context *ctx,
+                       struct gl_shader_program *shader_prog,
+                       struct gl_program *prog);
 
 struct brw_reg brw_reg_from_fs_reg(fs_reg *reg);
index f44ac26d580f52e38c14e44130eded18f34a1353..d51500effba7d3ad8fd12e092dbe244937e44d95 100644 (file)
@@ -374,7 +374,9 @@ const struct brw_tracked_state brw_gs_prog = {
 
 
 bool
-brw_gs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
+brw_gs_precompile(struct gl_context *ctx,
+                  struct gl_shader_program *shader_prog,
+                  struct gl_program *prog)
 {
    struct brw_context *brw = brw_context(ctx);
    struct brw_gs_prog_key key;
@@ -382,11 +384,7 @@ brw_gs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
    struct brw_gs_prog_data *old_prog_data = brw->gs.prog_data;
    bool success;
 
-   if (!prog->_LinkedShaders[MESA_SHADER_GEOMETRY])
-      return true;
-
-   struct gl_geometry_program *gp = (struct gl_geometry_program *)
-      prog->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program;
+   struct gl_geometry_program *gp = (struct gl_geometry_program *) prog;
    struct brw_geometry_program *bgp = brw_geometry_program(gp);
 
    memset(&key, 0, sizeof(key));
@@ -398,7 +396,7 @@ brw_gs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
     */
    key.input_varyings = gp->Base.InputsRead;
 
-   success = do_gs_prog(brw, prog, bgp, &key);
+   success = do_gs_prog(brw, shader_prog, bgp, &key);
 
    brw->gs.base.prog_offset = old_prog_offset;
    brw->gs.prog_data = old_prog_data;
index 5d4244edf8588b34be59076c937b481ceed3fed9..85228eb5e7871fd6a3af249ec647af2e5ce22ab9 100644 (file)
@@ -32,8 +32,11 @@ extern "C" {
 
 struct gl_context;
 struct gl_shader_program;
+struct gl_program;
 
-bool brw_gs_precompile(struct gl_context *ctx, struct gl_shader_program *prog);
+bool brw_gs_precompile(struct gl_context *ctx,
+                       struct gl_shader_program *shader_prog,
+                       struct gl_program *prog);
 bool brw_gs_prog_data_compare(const void *a, const void *b);
 
 #ifdef __cplusplus
index 78db48420b44e2d5232cab72d5a45aa959af72ff..6a14932629aa6db658725d064e1475fb9c2b0226 100644 (file)
@@ -55,17 +55,20 @@ brw_new_shader(struct gl_context *ctx, GLuint name, GLuint type)
  * the eventual NOS used, and thus allows us to produce link failures.
  */
 static bool
-brw_shader_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
+brw_shader_precompile(struct gl_context *ctx,
+                      struct gl_shader_program *sh_prog)
 {
-   struct brw_context *brw = brw_context(ctx);
+   struct gl_shader *vs = sh_prog->_LinkedShaders[MESA_SHADER_VERTEX];
+   struct gl_shader *gs = sh_prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
+   struct gl_shader *fs = sh_prog->_LinkedShaders[MESA_SHADER_FRAGMENT];
 
-   if (!brw_fs_precompile(ctx, prog))
+   if (fs && !brw_fs_precompile(ctx, sh_prog, fs->Program))
       return false;
 
-   if (!brw_gs_precompile(ctx, prog))
+   if (gs && !brw_gs_precompile(ctx, sh_prog, gs->Program))
       return false;
 
-   if (!brw_vs_precompile(ctx, prog))
+   if (vs && !brw_vs_precompile(ctx, sh_prog, vs->Program))
       return false;
 
    return true;
index edaa82cb4c3fb03ed0fa556315e6c982d9458eb7..bab72cb8888e5e7687fd2df25ece66a2593863e0 100644 (file)
@@ -523,7 +523,9 @@ const struct brw_tracked_state brw_vs_prog = {
 };
 
 bool
-brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
+brw_vs_precompile(struct gl_context *ctx,
+                  struct gl_shader_program *shader_prog,
+                  struct gl_program *prog)
 {
    struct brw_context *brw = brw_context(ctx);
    struct brw_vs_prog_key key;
@@ -531,18 +533,14 @@ brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
    struct brw_vs_prog_data *old_prog_data = brw->vs.prog_data;
    bool success;
 
-   if (!prog->_LinkedShaders[MESA_SHADER_VERTEX])
-      return true;
-
-   struct gl_vertex_program *vp = (struct gl_vertex_program *)
-      prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
+   struct gl_vertex_program *vp = (struct gl_vertex_program *) prog;
    struct brw_vertex_program *bvp = brw_vertex_program(vp);
 
    memset(&key, 0, sizeof(key));
 
    brw_vec4_setup_prog_key_for_precompile(ctx, &key.base, bvp->id, &vp->Base);
 
-   success = do_vs_prog(brw, prog, bvp, &key);
+   success = do_vs_prog(brw, shader_prog, bvp, &key);
 
    brw->vs.base.prog_offset = old_prog_offset;
    brw->vs.prog_data = old_prog_data;
index 97308a78a3ca61f91fbccdf21bd2990f15f62665..77792d99b47fd0efe3710cb758d572eb6958af70 100644 (file)
@@ -89,7 +89,9 @@ const unsigned *brw_vs_emit(struct brw_context *brw,
                             struct brw_vs_prog_data *prog_data,
                             void *mem_ctx,
                             unsigned *program_size);
-bool brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog);
+bool brw_vs_precompile(struct gl_context *ctx,
+                       struct gl_shader_program *shader_prog,
+                       struct gl_program *prog);
 void brw_vs_debug_recompile(struct brw_context *brw,
                             struct gl_shader_program *prog,
                             const struct brw_vs_prog_key *key);