[Mesa-dev] [PATCH] stash

Jason Ekstrand jason at jlekstrand.net
Thu Mar 30 00:44:55 UTC 2017


---
 src/intel/blorp/blorp_gen4_exec_priv.h | 81 ++++++++++++++++++++++++++++++++++
 src/intel/blorp/blorp_priv.h           |  1 +
 2 files changed, 82 insertions(+)

diff --git a/src/intel/blorp/blorp_gen4_exec_priv.h b/src/intel/blorp/blorp_gen4_exec_priv.h
index 90f9613..b0e4cba 100644
--- a/src/intel/blorp/blorp_gen4_exec_priv.h
+++ b/src/intel/blorp/blorp_gen4_exec_priv.h
@@ -40,13 +40,94 @@ blorp_emit_vs_state(struct blorp_batch *batch,
    return blorp_general_state_address(batch, offset);
 }
 
+struct blorp_sf_key {
+   enum blorp_shader_type shader_type; /* Must be BLORP_SHADER_TYPE_GEN4_SF */
+
+   struct brw_sf_prog_key key;
+};
+
+static bool
+blorp_get_gen4_sf_program(struct blorp_context *blorp,
+                          const struct brw_wm_prog_data *wm_prog_data,
+                          uint32_t *kernel,
+                          struct brw_sf_prog_data **prog_data)
+{
+   struct blorp_sf_key key = {
+      .shader_type = BLORP_SHADER_TYPE_GEN4_SF,
+   };
+
+   assert(wm_prog_data);
+
+   /* Everything gets compacted in vertex setup, so we just need a
+    * pass-through for the correct number of input varyings.
+    */
+   const uint64_t slots_valid = VARYING_BIT_POS |
+      ((1 << wm_prog_data->num_varying_inputs) - 1) << VARYING_SLOT_VAR0;
+
+   key.key.contains_flat_varying = wm_prog_data->contains_flat_varying;
+   key.key.attrs = slots_valid;
+
+   STATIC_ASSERT(sizeof(key.key.interp_mode) ==
+                 sizeof(wm_prog_data->interp_mode));
+   memcpy(key.key.interp_mode, wm_prog_data->interp_mode,
+          sizeof(key.key.interp_mode));
+
+   if (blorp->lookup_shader(blorp, &key, sizeof(key), kernel, prog_data))
+      return true;
+
+   void *mem_ctx = ralloc_context(NULL);
+
+   const unsigned *program;
+   unsigned program_size;
+
+   struct brw_vue_map vue_map;
+   brw_compute_vue_map(blorp->compiler->devinfo, &vue_map, slots_valid, false);
+
+   struct brw_sf_prog_data prog_data_tmp;
+   program = brw_compile_sf(blorp->compiler, mem_ctx, &key.key,
+                            &prog_data_tmp, &vue_map, &program_size);
+
+   bool result =
+      blorp->upload_shader(blorp, &key, sizeof(key), program, program_size,
+                           (void *)&prog_data_tmp, sizeof(prog_data_tmp),
+                           kernel, prog_data);
+
+   ralloc_free(mem_ctx);
+
+   return result;
+}
+
 static struct blorp_address
 blorp_emit_sf_state(struct blorp_batch *batch,
                     const struct blorp_params *params)
 {
+   uint32_t kernel;
+   struct brw_sf_prog_data *prog_data;
+   blorp_get_gen4_sf_program(batch->blorp, params->wm_prog_data,
+                             &kernel, &prog_data);
+   /* TODO: Handle error? */
+
    uint32_t offset;
    blorp_emit_dynamic(batch, GENX(SF_STATE), sf,
                       AUB_TRACE_SF_STATE, 64, &offset) {
+      sf.KernelStartPointer = kernel;
+      sf.GRFRegisterCount = DIV_ROUND_UP(prog_data->total_grf, 16);
+      sf.VertexURBEntryReadLength = prog_data->urb_read_length;
+      sf.VertexURBEntryReadOffset = BRW_SF_URB_ENTRY_READ_OFFSET;
+      sf.DispatchGRFStartRegisterforURBData = 3;
+
+#if GEN_GEN == 5
+      sf.MaximumNumberofThreads = 48;
+#else
+      sf.MaximumNumberofThreads = 24;
+#endif
+
+      sf.URBEntryAllocationSize = prog_data->urb_entry_size;
+      sf.NumberofURBEntries;
+
+      sf.ViewportTransformEnable = false;
+
+      sf.CullMode = CULLMODE_NONE;
    }
 
    return blorp_general_state_address(batch, offset);
diff --git a/src/intel/blorp/blorp_priv.h b/src/intel/blorp/blorp_priv.h
index c61ab08..e7b3508 100644
--- a/src/intel/blorp/blorp_priv.h
+++ b/src/intel/blorp/blorp_priv.h
@@ -201,6 +201,7 @@ enum blorp_shader_type {
    BLORP_SHADER_TYPE_BLIT,
    BLORP_SHADER_TYPE_CLEAR,
    BLORP_SHADER_TYPE_LAYER_OFFSET_VS,
+   BLORP_SHADER_TYPE_GEN4_SF,
 };
 
 struct brw_blorp_blit_prog_key
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list