[Mesa-dev] [PATCH 12/16] i965/blorp: Move sampler setup for the parameter type to handle

Topi Pohjolainen topi.pohjolainen at intel.com
Thu Apr 23 11:00:37 PDT 2015


Also move the gen >= 7 specific logic into gen6_blorp.ccp, this
will help to avoid more duplication when corresponding logic for
glsl-based programs is added.

Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 src/mesa/drivers/dri/i965/brw_blorp.h    |  9 +++---
 src/mesa/drivers/dri/i965/gen6_blorp.cpp | 47 ++++++++++++++++++++++----------
 src/mesa/drivers/dri/i965/gen7_blorp.cpp | 16 +----------
 3 files changed, 38 insertions(+), 34 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp.h b/src/mesa/drivers/dri/i965/brw_blorp.h
index 0149197..7ea82c0 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp.h
+++ b/src/mesa/drivers/dri/i965/brw_blorp.h
@@ -220,6 +220,8 @@ public:
    virtual void gen6_emit_wm_config(struct brw_context *brw) const;
    virtual void gen7_emit_wm_config(struct brw_context *brw) const;
 
+   virtual void gen6_emit_sampler_state(struct brw_context *brw) const;
+
    virtual void gen7_emit_ps_config(struct brw_context *brw) const;
 
    uint32_t x0;
@@ -360,6 +362,8 @@ public:
    virtual void gen6_emit_wm_config(struct brw_context *brw) const;
    virtual void gen7_emit_wm_config(struct brw_context *brw) const;
 
+   virtual void gen6_emit_sampler_state(struct brw_context *brw) const;
+
    virtual void gen7_emit_ps_config(struct brw_context *brw) const;
 
 private:
@@ -425,11 +429,6 @@ void
 gen6_blorp_emit_drawing_rectangle(struct brw_context *brw,
                                   const brw_blorp_params *params);
 
-uint32_t
-gen6_blorp_emit_sampler_state(struct brw_context *brw,
-                              unsigned tex_filter, unsigned max_lod,
-                              bool use_unorm_coords);
-
 /** \} */
 
 #endif /* __cplusplus */
diff --git a/src/mesa/drivers/dri/i965/gen6_blorp.cpp b/src/mesa/drivers/dri/i965/gen6_blorp.cpp
index d42b7f3..d5f89bb 100644
--- a/src/mesa/drivers/dri/i965/gen6_blorp.cpp
+++ b/src/mesa/drivers/dri/i965/gen6_blorp.cpp
@@ -451,22 +451,15 @@ gen6_blorp_emit_binding_table(struct brw_context *brw,
 /**
  * SAMPLER_STATE.  See brw_update_sampler_state().
  */
-uint32_t
+static uint32_t
 gen6_blorp_emit_sampler_state(struct brw_context *brw,
-                              unsigned tex_filter, unsigned max_lod,
-                              bool use_unorm_coords)
+                              unsigned address_rounding, unsigned tex_filter,
+                              unsigned max_lod, bool use_unorm_coords)
 {
    uint32_t sampler_offset;
    uint32_t *sampler_state = (uint32_t *)
       brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE, 16, 32, &sampler_offset);
 
-   unsigned address_rounding = BRW_ADDRESS_ROUNDING_ENABLE_U_MIN |
-                               BRW_ADDRESS_ROUNDING_ENABLE_V_MIN |
-                               BRW_ADDRESS_ROUNDING_ENABLE_R_MIN |
-                               BRW_ADDRESS_ROUNDING_ENABLE_U_MAG |
-                               BRW_ADDRESS_ROUNDING_ENABLE_V_MAG |
-                               BRW_ADDRESS_ROUNDING_ENABLE_R_MAG;
-
    /* XXX: I don't think that using firstLevel, lastLevel works,
     * because we always setup the surface state as if firstLevel ==
     * level zero.  Probably have to subtract firstLevel from each of
@@ -502,6 +495,14 @@ static void
 gen6_blorp_emit_sampler_state_pointers(struct brw_context *brw,
                                        uint32_t sampler_offset)
 {
+   if (brw->gen >= 7) {
+      BEGIN_BATCH(2);
+      OUT_BATCH(_3DSTATE_SAMPLER_STATE_POINTERS_PS << 16 | (2 - 2));
+      OUT_BATCH(sampler_offset);
+      ADVANCE_BATCH();
+      return;
+   }
+
    BEGIN_BATCH(4);
    OUT_BATCH(_3DSTATE_SAMPLER_STATE_POINTERS << 16 |
              VS_SAMPLER_STATE_CHANGE |
@@ -1011,6 +1012,11 @@ brw_blorp_params::gen6_emit_wm_config(struct brw_context *brw) const
 }
 
 void
+brw_blorp_params::gen6_emit_sampler_state(struct brw_context *brw) const
+{
+}
+
+void
 brw_blorp_blit_params::gen6_emit_wm_constants(struct brw_context *brw)
 {
    wm_push_const_offset = gen6_blorp_emit_wm_constants(brw, this);
@@ -1023,6 +1029,22 @@ brw_blorp_blit_params::gen6_emit_wm_config(struct brw_context *brw) const
    gen6_blorp_emit_wm_config(brw, this, prog_offset, prog_data);
 }
 
+void
+brw_blorp_blit_params::gen6_emit_sampler_state(struct brw_context *brw) const
+{
+   const unsigned address_rounding = BRW_ADDRESS_ROUNDING_ENABLE_U_MIN |
+                                     BRW_ADDRESS_ROUNDING_ENABLE_V_MIN |
+                                     BRW_ADDRESS_ROUNDING_ENABLE_R_MIN |
+                                     BRW_ADDRESS_ROUNDING_ENABLE_U_MAG |
+                                     BRW_ADDRESS_ROUNDING_ENABLE_V_MAG |
+                                     BRW_ADDRESS_ROUNDING_ENABLE_R_MAG;
+   const unsigned max_lod = 0;
+   const uint32_t sampler_offset =
+      gen6_blorp_emit_sampler_state(brw, address_rounding,
+                                    BRW_MAPFILTER_LINEAR, max_lod, true);
+   gen6_blorp_emit_sampler_state_pointers(brw, sampler_offset);
+}
+
 /**
  * \brief Execute a blit or render pass operation.
  *
@@ -1062,7 +1084,6 @@ gen6_blorp_exec(struct brw_context *brw,
    if (params->use_wm_prog) {
       uint32_t wm_surf_offset_renderbuffer;
       uint32_t wm_surf_offset_texture = 0;
-      uint32_t sampler_offset;
       intel_miptree_used_for_rendering(params->dst.mt);
       wm_surf_offset_renderbuffer =
          gen6_blorp_emit_surface_state(brw, params, &params->dst,
@@ -1077,10 +1098,8 @@ gen6_blorp_exec(struct brw_context *brw,
          gen6_blorp_emit_binding_table(brw,
                                        wm_surf_offset_renderbuffer,
                                        wm_surf_offset_texture);
-      sampler_offset =
-         gen6_blorp_emit_sampler_state(brw, BRW_MAPFILTER_LINEAR, 0, true);
-      gen6_blorp_emit_sampler_state_pointers(brw, sampler_offset);
    }
+   params->gen6_emit_sampler_state(brw);
    gen6_blorp_emit_vs_disable(brw, params);
    gen6_blorp_emit_gs_disable(brw, params);
    gen6_blorp_emit_clip_disable(brw);
diff --git a/src/mesa/drivers/dri/i965/gen7_blorp.cpp b/src/mesa/drivers/dri/i965/gen7_blorp.cpp
index f849a0b..ce4e46d 100644
--- a/src/mesa/drivers/dri/i965/gen7_blorp.cpp
+++ b/src/mesa/drivers/dri/i965/gen7_blorp.cpp
@@ -544,17 +544,6 @@ gen7_blorp_emit_binding_table_pointers_ps(struct brw_context *brw,
 
 
 static void
-gen7_blorp_emit_sampler_state_pointers_ps(struct brw_context *brw,
-                                          uint32_t sampler_offset)
-{
-   BEGIN_BATCH(2);
-   OUT_BATCH(_3DSTATE_SAMPLER_STATE_POINTERS_PS << 16 | (2 - 2));
-   OUT_BATCH(sampler_offset);
-   ADVANCE_BATCH();
-}
-
-
-static void
 gen7_blorp_emit_constant_ps(struct brw_context *brw,
                             uint32_t wm_push_const_offset)
 {
@@ -799,7 +788,6 @@ gen7_blorp_exec(struct brw_context *brw,
    uint32_t cc_state_offset = 0;
    uint32_t depthstencil_offset;
    uint32_t wm_bind_bo_offset = 0;
-   uint32_t sampler_offset = 0;
 
    gen6_emit_3dstate_multisample(brw, params->dst.num_samples);
    gen6_emit_3dstate_sample_mask(brw,
@@ -836,9 +824,8 @@ gen7_blorp_exec(struct brw_context *brw,
          gen6_blorp_emit_binding_table(brw,
                                        wm_surf_offset_renderbuffer,
                                        wm_surf_offset_texture);
-      sampler_offset =
-         gen6_blorp_emit_sampler_state(brw, BRW_MAPFILTER_LINEAR, 0, true);
    }
+   params->gen6_emit_sampler_state(brw);
    gen7_blorp_emit_vs_disable(brw);
    gen7_blorp_emit_hs_disable(brw);
    gen7_blorp_emit_te_disable(brw);
@@ -850,7 +837,6 @@ gen7_blorp_exec(struct brw_context *brw,
    params->gen7_emit_wm_config(brw);
    if (params->use_wm_prog) {
       gen7_blorp_emit_binding_table_pointers_ps(brw, wm_bind_bo_offset);
-      gen7_blorp_emit_sampler_state_pointers_ps(brw, sampler_offset);
    }
    params->gen7_emit_ps_config(brw);
    gen7_blorp_emit_cc_viewport(brw);
-- 
1.9.3



More information about the mesa-dev mailing list