[Mesa-dev] [PATCH 7/8] i965: Set "Shader Channel Select" fields in Haswell's SURFACE_STATE.

Kenneth Graunke kenneth at whitecape.org
Mon Mar 19 14:10:44 PDT 2012


These can be used to implement EXT_texture_swizzle without baking
state-dependent swizzle instructions into the shader and forcing
recompiles.

For now, just set them to pass-through mode, so everything continues to
work as it did on Ivybridge.  We can optimize this later.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_defines.h           |    8 ++++++++
 src/mesa/drivers/dri/i965/brw_structs.h           |    9 ++++++++-
 src/mesa/drivers/dri/i965/gen7_wm_surface_state.c |   14 ++++++++++++++
 3 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h
index a093112..812052d 100644
--- a/src/mesa/drivers/dri/i965/brw_defines.h
+++ b/src/mesa/drivers/dri/i965/brw_defines.h
@@ -464,6 +464,14 @@
 #define BRW_SURFACE_Y_OFFSET_SHIFT		20
 #define BRW_SURFACE_Y_OFFSET_MASK		INTEL_MASK(23, 20)
 
+/* Surface state DW7 */
+#define HSW_SCS_ZERO                     0
+#define HSW_SCS_ONE                      1
+#define HSW_SCS_RED                      4
+#define HSW_SCS_GREEN                    5
+#define HSW_SCS_BLUE                     6
+#define HSW_SCS_ALPHA                    7
+
 #define BRW_TEXCOORDMODE_WRAP            0
 #define BRW_TEXCOORDMODE_MIRROR          1
 #define BRW_TEXCOORDMODE_CLAMP           2
diff --git a/src/mesa/drivers/dri/i965/brw_structs.h b/src/mesa/drivers/dri/i965/brw_structs.h
index 8283abf..41c88d0 100644
--- a/src/mesa/drivers/dri/i965/brw_structs.h
+++ b/src/mesa/drivers/dri/i965/brw_structs.h
@@ -860,7 +860,14 @@ struct gen7_surface_state
 
    struct {
       GLuint resource_min_lod:12;
-      GLuint pad0:16;
+
+      /* Only on Haswell */
+      GLuint pad0:4;
+      GLuint shader_chanel_select_a:3;
+      GLuint shader_chanel_select_b:3;
+      GLuint shader_chanel_select_g:3;
+      GLuint shader_chanel_select_r:3;
+
       GLuint alpha_clear_color:1;
       GLuint blue_clear_color:1;
       GLuint green_clear_color:1;
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 c52f6aa..91cc5d1 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
@@ -121,6 +121,13 @@ gen7_update_texture_surface(struct gl_context *ctx, GLuint unit)
     * - cache_control
     */
 
+   if (brw->intel.is_haswell) {
+      surf->ss7.shader_chanel_select_r = HSW_SCS_RED;
+      surf->ss7.shader_chanel_select_g = HSW_SCS_GREEN;
+      surf->ss7.shader_chanel_select_b = HSW_SCS_BLUE;
+      surf->ss7.shader_chanel_select_a = HSW_SCS_ALPHA;
+   }
+
    /* Emit relocation to surface contents */
    drm_intel_bo_emit_reloc(brw->intel.batch.bo,
 			   brw->wm.surf_offset[surf_index] +
@@ -249,6 +256,13 @@ gen7_update_renderbuffer_surface(struct brw_context *brw,
    gen7_set_surface_tiling(surf, region->tiling);
    surf->ss3.pitch = (region->pitch * region->cpp) - 1;
 
+   if (intel->is_haswell) {
+      surf->ss7.shader_chanel_select_r = HSW_SCS_RED;
+      surf->ss7.shader_chanel_select_g = HSW_SCS_GREEN;
+      surf->ss7.shader_chanel_select_b = HSW_SCS_BLUE;
+      surf->ss7.shader_chanel_select_a = HSW_SCS_ALPHA;
+   }
+
    drm_intel_bo_emit_reloc(brw->intel.batch.bo,
 			   brw->wm.surf_offset[unit] +
 			   offsetof(struct gen7_surface_state, ss1),
-- 
1.7.7.6



More information about the mesa-dev mailing list