[Mesa-dev] [v2 08/12] i965: Refactor effective depth calculation

Topi Pohjolainen topi.pohjolainen at intel.com
Wed May 6 04:25:14 PDT 2015


Reviewed-by: Matt Turner <mattst88 at gmail.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 src/mesa/drivers/dri/i965/brw_context.h           |  1 +
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c  | 12 ++++++++++--
 src/mesa/drivers/dri/i965/gen7_wm_surface_state.c |  7 +------
 src/mesa/drivers/dri/i965/gen8_surface_state.c    |  8 +-------
 4 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 7e1f5db..81878d9 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -986,6 +986,7 @@ struct brw_context
       void (*update_texture_surface)(struct brw_context *brw,
                                      const struct intel_mipmap_tree *mt,
                                      struct gl_texture_object *tObj,
+                                     uint32_t effective_depth,
                                      uint32_t tex_format, int swizzle,
                                      uint32_t *surf_offset,
                                      bool for_gather);
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 4538d02..0bb5621 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -311,6 +311,7 @@ static void
 brw_update_texture_surface(struct brw_context *brw,
                            const struct intel_mipmap_tree *mt,
                            struct gl_texture_object *tObj,
+                           uint32_t effective_depth /* unused */,
                            uint32_t tex_format, int swizzle /* unused */,
                            uint32_t *surf_offset,
                            bool for_gather)
@@ -824,8 +825,15 @@ update_texture_surface(struct gl_context *ctx,
    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);
+   /* if this is a view with restricted NumLayers, then
+    * our effective depth is not just the miptree depth.
+    */
+   uint32_t effective_depth = (tObj->Immutable && tObj->Target != GL_TEXTURE_3D)
+                              ? tObj->NumLayers : mt->logical_depth0;
+
+   brw->vtbl.update_texture_surface(brw, mt, tObj,
+                                    effective_depth, 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 bd63786..b5cb976 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
@@ -267,6 +267,7 @@ static void
 gen7_update_texture_surface(struct brw_context *brw,
                             const struct intel_mipmap_tree *mt,
                             struct gl_texture_object *tObj,
+                            uint32_t effective_depth,
                             uint32_t tex_format, int swizzle,
                             uint32_t *surf_offset,
                             bool for_gather)
@@ -297,12 +298,6 @@ gen7_update_texture_surface(struct brw_context *brw,
        tObj->Target == GL_TEXTURE_CUBE_MAP)
       surf[0] |= GEN7_SURFACE_IS_ARRAY;
 
-   /* if this is a view with restricted NumLayers, then
-    * our effective depth is not just the miptree depth.
-    */
-   uint32_t effective_depth = (tObj->Immutable && tObj->Target != GL_TEXTURE_3D)
-                              ? tObj->NumLayers : mt->logical_depth0;
-
    if (mt->array_layout == ALL_SLICES_AT_EACH_LOD)
       surf[0] |= GEN7_SURFACE_ARYSPC_LOD0;
 
diff --git a/src/mesa/drivers/dri/i965/gen8_surface_state.c b/src/mesa/drivers/dri/i965/gen8_surface_state.c
index af891ff..e4c06b6 100644
--- a/src/mesa/drivers/dri/i965/gen8_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen8_surface_state.c
@@ -153,6 +153,7 @@ static void
 gen8_update_texture_surface(struct brw_context *brw,
                             const struct intel_mipmap_tree *mt,
                             struct gl_texture_object *tObj,
+                            uint32_t effective_depth,
                             uint32_t tex_format, int swizzle,
                             uint32_t *surf_offset,
                             bool for_gather)
@@ -176,13 +177,6 @@ gen8_update_texture_surface(struct brw_context *brw,
       aux_mode = GEN8_SURFACE_AUX_MODE_MCS;
    }
 
-   /* If this is a view with restricted NumLayers, then our effective depth
-    * is not just the miptree depth.
-    */
-   uint32_t effective_depth =
-      (tObj->Immutable && tObj->Target != GL_TEXTURE_3D) ? tObj->NumLayers
-                                                         : mt->logical_depth0;
-
    uint32_t *surf = allocate_surface_state(brw, surf_offset);
 
    surf[0] = translate_tex_target(tObj->Target) << BRW_SURFACE_TYPE_SHIFT |
-- 
1.9.3



More information about the mesa-dev mailing list