[Mesa-dev] [PATCH 09/18] i965: Move texture swizzle resolving into dispatcher

Topi Pohjolainen topi.pohjolainen at intel.com
Wed Apr 22 13:47:29 PDT 2015


Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 src/mesa/drivers/dri/i965/brw_context.h           |  4 ++--
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c  | 20 +++++++++++++++-----
 src/mesa/drivers/dri/i965/gen7_wm_surface_state.c | 17 ++---------------
 src/mesa/drivers/dri/i965/gen8_surface_state.c    | 16 ++--------------
 4 files changed, 21 insertions(+), 36 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 096bc4d..6bb46e3 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -962,10 +962,10 @@ struct brw_context
 
    struct
    {
-      void (*update_texture_surface)(struct gl_context *ctx,
+      void (*update_texture_surface)(struct brw_context *brw,
                                      const struct intel_mipmap_tree *mt,
                                      struct gl_texture_object *tObj,
-                                     uint32_t tex_format,
+                                     uint32_t tex_format, int swizzle,
                                      uint32_t *surf_offset,
                                      bool for_gather);
       uint32_t (*update_renderbuffer_surface)(struct brw_context *brw,
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index d8faf82..0d81576 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -308,14 +308,13 @@ update_buffer_texture_surface(struct gl_context *ctx,
 }
 
 static void
-brw_update_texture_surface(struct gl_context *ctx,
+brw_update_texture_surface(struct brw_context *brw,
                            const struct intel_mipmap_tree *mt,
                            struct gl_texture_object *tObj,
-                           uint32_t tex_format,
+                           uint32_t tex_format, int swizzle /* unused */,
                            uint32_t *surf_offset,
                            bool for_gather)
 {
-   struct brw_context *brw = brw_context(ctx);
    struct intel_texture_object *intelObj = intel_texture_object(tObj);
    uint32_t *surf;
 
@@ -814,8 +813,19 @@ update_texture_surface(struct gl_context *ctx,
    const uint32_t tex_format = translate_tex_format(brw, format,
                                                     sampler->sRGBDecode);
 
-   brw->vtbl.update_texture_surface(ctx, mt, tObj, tex_format, surf_offset,
-                                    for_gather);
+   /* Handling GL_ALPHA as a surface format override breaks 1.30+ style
+    * texturing functions that return a float, as our code generation always
+    * selects the .x channel (which would always be 0).
+    */
+   const bool alpha_depth = tObj->DepthMode == GL_ALPHA &&
+      (firstImage->_BaseFormat == GL_DEPTH_COMPONENT ||
+       firstImage->_BaseFormat == GL_DEPTH_STENCIL);
+
+   const int swizzle = unlikely(alpha_depth)
+      ? SWIZZLE_XYZW : brw_get_texture_swizzle(ctx, tObj);
+
+   brw->vtbl.update_texture_surface(brw, mt, tObj, tex_format, swizzle,
+                                    surf_offset, for_gather);
 }
 
 static void
diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
index 9a1af98..bb2b889 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
@@ -264,16 +264,14 @@ gen7_emit_buffer_surface_state(struct brw_context *brw,
 }
 
 static void
-gen7_update_texture_surface(struct gl_context *ctx,
+gen7_update_texture_surface(struct brw_context *brw,
                             const struct intel_mipmap_tree *mt,
                             struct gl_texture_object *tObj,
-                            uint32_t tex_format,
+                            uint32_t tex_format, int swizzle,
                             uint32_t *surf_offset,
                             bool for_gather)
 {
-   struct brw_context *brw = brw_context(ctx);
    struct intel_texture_object *intelObj = intel_texture_object(tObj);
-   struct gl_texture_image *firstImage = tObj->Image[0][tObj->BaseLevel];
 
    uint32_t *surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,
                                     8 * 4, 32, surf_offset);
@@ -332,17 +330,6 @@ gen7_update_texture_surface(struct gl_context *ctx,
    surf[7] = mt->fast_clear_color_value;
 
    if (brw->is_haswell) {
-      /* Handling GL_ALPHA as a surface format override breaks 1.30+ style
-       * texturing functions that return a float, as our code generation always
-       * selects the .x channel (which would always be 0).
-       */
-      const bool alpha_depth = tObj->DepthMode == GL_ALPHA &&
-         (firstImage->_BaseFormat == GL_DEPTH_COMPONENT ||
-          firstImage->_BaseFormat == GL_DEPTH_STENCIL);
-
-      const int swizzle = unlikely(alpha_depth)
-         ? SWIZZLE_XYZW : brw_get_texture_swizzle(ctx, tObj);
-
       const bool need_scs_green_to_blue = for_gather && tex_format == BRW_SURFACEFORMAT_R32G32_FLOAT_LD;
 
       surf[7] |=
diff --git a/src/mesa/drivers/dri/i965/gen8_surface_state.c b/src/mesa/drivers/dri/i965/gen8_surface_state.c
index 4c4319c..af891ff 100644
--- a/src/mesa/drivers/dri/i965/gen8_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen8_surface_state.c
@@ -150,16 +150,14 @@ gen8_emit_buffer_surface_state(struct brw_context *brw,
 }
 
 static void
-gen8_update_texture_surface(struct gl_context *ctx,
+gen8_update_texture_surface(struct brw_context *brw,
                             const struct intel_mipmap_tree *mt,
                             struct gl_texture_object *tObj,
-                            uint32_t tex_format,
+                            uint32_t tex_format, int swizzle,
                             uint32_t *surf_offset,
                             bool for_gather)
 {
-   struct brw_context *brw = brw_context(ctx);
    struct intel_texture_object *intelObj = intel_texture_object(tObj);
-   struct gl_texture_image *firstImage = tObj->Image[0][tObj->BaseLevel];
    struct intel_mipmap_tree *aux_mt = NULL;
    uint32_t aux_mode = 0;
    uint32_t mocs_wb = brw->gen >= 9 ? SKL_MOCS_WB : BDW_MOCS_WB;
@@ -226,18 +224,8 @@ gen8_update_texture_surface(struct gl_context *ctx,
       surf[6] = 0;
    }
 
-   /* Handling GL_ALPHA as a surface format override breaks 1.30+ style
-    * texturing functions that return a float, as our code generation always
-    * selects the .x channel (which would always be 0).
-    */
-   const bool alpha_depth = tObj->DepthMode == GL_ALPHA &&
-      (firstImage->_BaseFormat == GL_DEPTH_COMPONENT ||
-       firstImage->_BaseFormat == GL_DEPTH_STENCIL);
-
    surf[7] = mt->fast_clear_color_value;
 
-   const int swizzle =
-      unlikely(alpha_depth) ? SWIZZLE_XYZW : brw_get_texture_swizzle(ctx, tObj);
    surf[7] |=
       SET_FIELD(swizzle_to_scs(GET_SWZ(swizzle, 0)), GEN7_SURFACE_SCS_R) |
       SET_FIELD(swizzle_to_scs(GET_SWZ(swizzle, 1)), GEN7_SURFACE_SCS_G) |
-- 
1.9.3



More information about the mesa-dev mailing list