[Mesa-dev] [PATCH 10/25] intel/blorp: Add a shader type to make keys more unique

Jason Ekstrand jason at jlekstrand.net
Sat Oct 22 17:50:41 UTC 2016


Depending on how the driver using blorp implements its shader caching,
there is a small chance of shader collisions due to identical keys between
blit and clear programs.  Adding a small shader type at the top of the key
alleviates this problem.
---
 src/intel/blorp/blorp_blit.c  | 10 ++++++----
 src/intel/blorp/blorp_clear.c |  8 +++++---
 src/intel/blorp/blorp_priv.h  |  7 +++++++
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c
index 37b6dd7..20a5eac 100644
--- a/src/intel/blorp/blorp_blit.c
+++ b/src/intel/blorp/blorp_blit.c
@@ -1664,8 +1664,9 @@ blorp_blit(struct blorp_batch *batch,
    params.src.view.swizzle = src_swizzle;
    params.dst.view.swizzle = dst_swizzle;
 
-   struct brw_blorp_blit_prog_key wm_prog_key;
-   memset(&wm_prog_key, 0, sizeof(wm_prog_key));
+   struct brw_blorp_blit_prog_key wm_prog_key = {
+      .shader_type = BLORP_SHADER_TYPE_BLIT
+   };
 
    /* Scaled blitting or not. */
    wm_prog_key.blit_scaled =
@@ -1850,8 +1851,9 @@ blorp_copy(struct blorp_batch *batch,
    brw_blorp_surface_info_init(batch->blorp, &params.dst, dst_surf, dst_level,
                                dst_layer, ISL_FORMAT_UNSUPPORTED, true);
 
-   struct brw_blorp_blit_prog_key wm_prog_key;
-   memset(&wm_prog_key, 0, sizeof(wm_prog_key));
+   struct brw_blorp_blit_prog_key wm_prog_key = {
+      .shader_type = BLORP_SHADER_TYPE_BLIT
+   };
 
    const struct isl_format_layout *src_fmtl =
       isl_format_get_layout(params.src.surf.format);
diff --git a/src/intel/blorp/blorp_clear.c b/src/intel/blorp/blorp_clear.c
index 0920049..c69a99a 100644
--- a/src/intel/blorp/blorp_clear.c
+++ b/src/intel/blorp/blorp_clear.c
@@ -35,6 +35,7 @@
 
 struct brw_blorp_const_color_prog_key
 {
+   enum blorp_shader_type shader_type; /* Must be BLORP_SHADER_TYPE_CLEAR */
    bool use_simd16_replicated_data;
    bool pad[3];
 };
@@ -44,9 +45,10 @@ blorp_params_get_clear_kernel(struct blorp_context *blorp,
                               struct blorp_params *params,
                               bool use_replicated_data)
 {
-   struct brw_blorp_const_color_prog_key blorp_key;
-   memset(&blorp_key, 0, sizeof(blorp_key));
-   blorp_key.use_simd16_replicated_data = use_replicated_data;
+   const struct brw_blorp_const_color_prog_key blorp_key = {
+      .shader_type = BLORP_SHADER_TYPE_CLEAR,
+      .use_simd16_replicated_data = use_replicated_data,
+   };
 
    if (blorp->lookup_shader(blorp, &blorp_key, sizeof(blorp_key),
                             &params->wm_prog_kernel, &params->wm_prog_data))
diff --git a/src/intel/blorp/blorp_priv.h b/src/intel/blorp/blorp_priv.h
index 4266f13..4fe5b5a 100644
--- a/src/intel/blorp/blorp_priv.h
+++ b/src/intel/blorp/blorp_priv.h
@@ -203,8 +203,15 @@ struct blorp_params
 
 void blorp_params_init(struct blorp_params *params);
 
+enum blorp_shader_type {
+   BLORP_SHADER_TYPE_BLIT,
+   BLORP_SHADER_TYPE_CLEAR,
+};
+
 struct brw_blorp_blit_prog_key
 {
+   enum blorp_shader_type shader_type; /* Must be BLORP_SHADER_TYPE_BLIT */
+
    /* Number of samples per pixel that have been configured in the surface
     * state for texturing from.
     */
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list