[Mesa-dev] [PATCH 72/88] i965: add upload cache functions for tcs and tes

Timothy Arceri timothy.arceri at collabora.com
Sat Sep 24 05:25:53 UTC 2016


---
 src/mesa/drivers/dri/i965/brw_shader_cache.c | 80 ++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index 44ff969..f95dc57 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -372,6 +372,78 @@ upload_cached_gs(struct brw_context *brw, struct blob_reader *binary,
 }
 
 static void
+upload_cached_tcs(struct brw_context *brw, struct blob_reader *binary,
+                  struct gl_shader_program *prog,
+                  struct brw_tcs_prog_key *tcs_key)
+{
+   struct brw_tcs_prog_data *tcs_prog_data;
+   struct brw_stage_prog_data *prog_data;
+   const struct gen_device_info *devinfo = &brw->screen->devinfo;
+
+   /* Read TCS program from blob. */
+   size_t tcs_program_size = blob_read_uint32(binary);
+   uint8_t *tcs_program = blob_read_bytes(binary, tcs_program_size);
+
+   /* Read TCS program_data from blob and fixup params pointers. */
+   size_t tcs_prog_data_size = blob_read_uint32(binary);
+   assert(tcs_prog_data_size == sizeof *tcs_prog_data);
+
+   tcs_prog_data = blob_read_bytes(binary, tcs_prog_data_size);
+   prog_data = &tcs_prog_data->base.base;
+   load_program_data(prog, binary, prog_data, MESA_SHADER_TESS_CTRL,
+                     &brw->ctx, NULL);
+
+   struct brw_tess_ctrl_program *tcp =
+      (struct brw_tess_ctrl_program *)brw->tess_ctrl_program;
+   tcs_key->program_string_id = tcp->id;
+
+   brw_alloc_stage_scratch(brw, &brw->tcs.base, prog_data->total_scratch,
+                           devinfo->max_hs_threads);
+
+   brw_upload_cache(&brw->cache, BRW_CACHE_TCS_PROG,
+                    tcs_key, sizeof(struct brw_tcs_prog_key),
+                    tcs_program, tcs_program_size,
+                    tcs_prog_data, tcs_prog_data_size,
+                    &brw->tcs.base.prog_offset, &brw->tcs.prog_data, tcp);
+}
+
+static void
+upload_cached_tes(struct brw_context *brw, struct blob_reader *binary,
+                  struct gl_shader_program *prog,
+                  struct brw_tes_prog_key *tes_key)
+{
+   struct brw_tes_prog_data *tes_prog_data;
+   struct brw_stage_prog_data *prog_data;
+   const struct gen_device_info *devinfo = &brw->screen->devinfo;
+
+   /* Read TES program from blob. */
+   size_t tes_program_size = blob_read_uint32(binary);
+   uint8_t *tes_program = blob_read_bytes(binary, tes_program_size);
+
+   /* Read TES program_data from blob and fixup params pointers. */
+   size_t tes_prog_data_size = blob_read_uint32(binary);
+   assert(tes_prog_data_size == sizeof *tes_prog_data);
+
+   tes_prog_data = blob_read_bytes(binary, tes_prog_data_size);
+   prog_data = &tes_prog_data->base.base;
+   load_program_data(prog, binary, prog_data, MESA_SHADER_TESS_EVAL,
+                     &brw->ctx, NULL);
+
+   struct brw_tess_eval_program *tep =
+      (struct brw_tess_eval_program *)brw->tess_eval_program;
+   tes_key->program_string_id = tep->id;
+
+   brw_alloc_stage_scratch(brw, &brw->tes.base, prog_data->total_scratch,
+                           devinfo->max_ds_threads);
+
+   brw_upload_cache(&brw->cache, BRW_CACHE_TES_PROG,
+                    tes_key, sizeof(struct brw_tes_prog_key),
+                    tes_program, tes_program_size,
+                    tes_prog_data, tes_prog_data_size,
+                    &brw->tes.base.prog_offset, &brw->tes.prog_data, tep);
+}
+
+static void
 upload_cached_wm(struct brw_context *brw, struct blob_reader *binary,
                  struct gl_shader_program *prog,
                  struct brw_wm_prog_key *wm_key)
@@ -419,6 +491,8 @@ upload_cached_program(struct brw_context *brw, gl_shader_stage stage)
    struct gl_shader_program *prog;
    struct brw_wm_prog_key wm_key;
    struct brw_vs_prog_key vs_key;
+   struct brw_tcs_prog_key tcs_key;
+   struct brw_tes_prog_key tes_key;
    struct brw_gs_prog_key gs_key;
 
    struct program_cache *cache = brw->ctx.Cache;
@@ -477,6 +551,12 @@ upload_cached_program(struct brw_context *brw, gl_shader_stage stage)
    case MESA_SHADER_VERTEX:
       upload_cached_vs(brw, &binary, prog, &vs_key);
       break;
+   case MESA_SHADER_TESS_CTRL:
+      upload_cached_tcs(brw, &binary, prog, &tcs_key);
+      break;
+   case MESA_SHADER_TESS_EVAL:
+      upload_cached_tes(brw, &binary, prog, &tes_key);
+      break;
    case MESA_SHADER_GEOMETRY:
       upload_cached_gs(brw, &binary, prog, &gs_key);
       break;
-- 
2.7.4



More information about the mesa-dev mailing list