i965/cs: Support CS program precompile
authorJordan Justen <jordan.l.justen@intel.com>
Sat, 14 Mar 2015 19:55:54 +0000 (12:55 -0700)
committerJordan Justen <jordan.l.justen@intel.com>
Sat, 2 May 2015 07:49:59 +0000 (00:49 -0700)
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_cs.cpp
src/mesa/drivers/dri/i965/brw_shader.cpp
src/mesa/drivers/dri/i965/brw_shader.h

index 10e954362a8fb6f2f9c1e13cbc1d8b5ef754e4bf..106b237506bc47f019e6ce9b56d7a5c7e2cfbde5 100644 (file)
@@ -1866,6 +1866,12 @@ brw_fragment_program_const(const struct gl_fragment_program *p)
    return (const struct brw_fragment_program *) p;
 }
 
+static inline struct brw_compute_program *
+brw_compute_program(struct gl_compute_program *p)
+{
+   return (struct brw_compute_program *) p;
+}
+
 /**
  * Pre-gen6, the register file of the EUs was shared between threads,
  * and each thread used some subset allocated on a 16-register block
index 1b88fd40f3af82341800fa5efd3ba6343481c7b9..e18685a2683e925c870256e9527a4c7565a43952 100644 (file)
@@ -254,3 +254,31 @@ brw_upload_cs_prog(struct brw_context *brw)
    }
    brw->cs.base.prog_data = &brw->cs.prog_data->base;
 }
+
+
+extern "C" bool
+brw_cs_precompile(struct gl_context *ctx,
+                  struct gl_shader_program *shader_prog,
+                  struct gl_program *prog)
+{
+   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);
+
+   memset(&key, 0, sizeof(key));
+   key.program_string_id = bcp->id;
+
+   brw_setup_tex_for_precompile(brw, &key.tex, prog);
+
+   uint32_t old_prog_offset = brw->cs.base.prog_offset;
+   struct brw_cs_prog_data *old_prog_data = brw->cs.prog_data;
+
+   bool success = brw_codegen_cs_prog(brw, shader_prog, bcp, &key);
+
+   brw->cs.base.prog_offset = old_prog_offset;
+   brw->cs.prog_data = old_prog_data;
+
+   return success;
+}
index 157bb32f64c84e4b9bfde2036611c66874f3b999..4fbd8d063e327fb5cda6a97ddf506b9e142264ab 100644 (file)
@@ -73,6 +73,7 @@ brw_shader_precompile(struct gl_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];
+   struct gl_shader *cs = sh_prog->_LinkedShaders[MESA_SHADER_COMPUTE];
 
    if (fs && !brw_fs_precompile(ctx, sh_prog, fs->Program))
       return false;
@@ -83,6 +84,9 @@ brw_shader_precompile(struct gl_context *ctx,
    if (vs && !brw_vs_precompile(ctx, sh_prog, vs->Program))
       return false;
 
+   if (cs && !brw_cs_precompile(ctx, sh_prog, cs->Program))
+      return false;
+
    return true;
 }
 
index ac4e62a9a27618bb9512290f79b0dcc403114a51..ebce51dfe2cf6e17b33cbac8c4fc1dc806fb74e6 100644 (file)
@@ -287,6 +287,9 @@ bool brw_gs_precompile(struct gl_context *ctx,
 bool brw_fs_precompile(struct gl_context *ctx,
                        struct gl_shader_program *shader_prog,
                        struct gl_program *prog);
+bool brw_cs_precompile(struct gl_context *ctx,
+                       struct gl_shader_program *shader_prog,
+                       struct gl_program *prog);
 
 #ifdef __cplusplus
 }