i965: Make BLORP use brw_emit_sampler_state().
authorKenneth Graunke <kenneth@whitecape.org>
Sun, 27 Jul 2014 03:49:32 +0000 (20:49 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Sat, 2 Aug 2014 12:16:41 +0000 (05:16 -0700)
This simplifies the code, removes use of the old structures, and also
allows us to combine the Gen6 and Gen7+ code.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/brw_blorp.h
src/mesa/drivers/dri/i965/gen6_blorp.cpp
src/mesa/drivers/dri/i965/gen7_blorp.cpp

index 683f09e681f897fe544601cbf2c140da01d7ab51..419744f07301fda0c15f06b50ab75b4079cec700 100644 (file)
@@ -420,6 +420,10 @@ gen6_blorp_emit_clip_disable(struct brw_context *brw,
 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,
+                              const brw_blorp_params *params);
 /** \} */
 
 #endif /* __cplusplus */
index d4198860c467e22904b0cfa1143fa405b57048d7..1cab8b71ff02841ca19a029f5defd4d79c96407f 100644 (file)
@@ -445,53 +445,44 @@ gen6_blorp_emit_binding_table(struct brw_context *brw,
 /**
  * SAMPLER_STATE.  See brw_update_sampler_state().
  */
-static uint32_t
+uint32_t
 gen6_blorp_emit_sampler_state(struct brw_context *brw,
                               const brw_blorp_params *params)
 {
    uint32_t sampler_offset;
+   uint32_t *sampler_state = (uint32_t *)
+      brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE, 16, 32, &sampler_offset);
 
-   struct brw_sampler_state *sampler = (struct brw_sampler_state *)
-      brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE,
-                      sizeof(struct brw_sampler_state),
-                      32, &sampler_offset);
-   memset(sampler, 0, sizeof(*sampler));
-
-   sampler->ss0.min_filter = BRW_MAPFILTER_LINEAR;
-   sampler->ss0.mip_filter = BRW_MIPFILTER_NONE;
-   sampler->ss0.mag_filter = BRW_MAPFILTER_LINEAR;
-
-   sampler->ss1.r_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
-   sampler->ss1.s_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
-   sampler->ss1.t_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
-
-   /* Set LOD bias:
-    */
-   sampler->ss0.lod_bias = 0;
+   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;
 
-   sampler->ss0.lod_preclamp = 1; /* OpenGL mode */
-   sampler->ss0.default_color_mode = 0; /* OpenGL/DX10 mode */
-
-   /* Set BaseMipLevel, MaxLOD, MinLOD:
-    *
-    * XXX: I don't think that using firstLevel, lastLevel works,
+   /* 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
     * these:
     */
-   sampler->ss0.base_level = U_FIXED(0, 1);
-
-   sampler->ss1.max_lod = U_FIXED(0, 6);
-   sampler->ss1.min_lod = U_FIXED(0, 6);
-
-   sampler->ss3.non_normalized_coord = 1;
-
-   sampler->ss3.address_round |= BRW_ADDRESS_ROUNDING_ENABLE_U_MIN |
-      BRW_ADDRESS_ROUNDING_ENABLE_V_MIN |
-      BRW_ADDRESS_ROUNDING_ENABLE_R_MIN;
-   sampler->ss3.address_round |= BRW_ADDRESS_ROUNDING_ENABLE_U_MAG |
-      BRW_ADDRESS_ROUNDING_ENABLE_V_MAG |
-      BRW_ADDRESS_ROUNDING_ENABLE_R_MAG;
+   brw_emit_sampler_state(brw,
+                          sampler_state,
+                          sampler_offset,
+                          BRW_MAPFILTER_LINEAR, /* min filter */
+                          BRW_MAPFILTER_LINEAR, /* mag filter */
+                          BRW_MIPFILTER_NONE,
+                          BRW_ANISORATIO_2,
+                          address_rounding,
+                          BRW_TEXCOORDMODE_CLAMP,
+                          BRW_TEXCOORDMODE_CLAMP,
+                          BRW_TEXCOORDMODE_CLAMP,
+                          0, /* min LOD */
+                          0, /* max LOD */
+                          0, /* LOD bias */
+                          0, /* base miplevel */
+                          0, /* shadow function */
+                          true, /* non-normalized coordinates */
+                          0); /* border color offset - unused */
 
    return sampler_offset;
 }
index 0ad570b44f44fb3581b5e39e8f376470f0bbe990..1cf55fd4cf586504d063d6b9d1d4bf6e809c1298 100644 (file)
@@ -223,63 +223,6 @@ gen7_blorp_emit_surface_state(struct brw_context *brw,
 }
 
 
-/**
- * SAMPLER_STATE.  See gen7_update_sampler_state().
- */
-static uint32_t
-gen7_blorp_emit_sampler_state(struct brw_context *brw,
-                              const brw_blorp_params *params)
-{
-   uint32_t sampler_offset;
-
-   struct gen7_sampler_state *sampler = (struct gen7_sampler_state *)
-      brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE,
-                      sizeof(struct gen7_sampler_state),
-                      32, &sampler_offset);
-   memset(sampler, 0, sizeof(*sampler));
-
-   sampler->ss0.min_filter = BRW_MAPFILTER_LINEAR;
-   sampler->ss0.mip_filter = BRW_MIPFILTER_NONE;
-   sampler->ss0.mag_filter = BRW_MAPFILTER_LINEAR;
-
-   sampler->ss3.r_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
-   sampler->ss3.s_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
-   sampler->ss3.t_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
-
-   //   sampler->ss0.min_mag_neq = 1;
-
-   /* Set LOD bias:
-    */
-   sampler->ss0.lod_bias = 0;
-
-   sampler->ss0.lod_preclamp = 1; /* OpenGL mode */
-   sampler->ss0.default_color_mode = 0; /* OpenGL/DX10 mode */
-
-   /* Set BaseMipLevel, MaxLOD, MinLOD:
-    *
-    * 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
-    * these:
-    */
-   sampler->ss0.base_level = U_FIXED(0, 1);
-
-   sampler->ss1.max_lod = U_FIXED(0, 8);
-   sampler->ss1.min_lod = U_FIXED(0, 8);
-
-   sampler->ss3.non_normalized_coord = 1;
-
-   sampler->ss3.address_round |= BRW_ADDRESS_ROUNDING_ENABLE_U_MIN |
-      BRW_ADDRESS_ROUNDING_ENABLE_V_MIN |
-      BRW_ADDRESS_ROUNDING_ENABLE_R_MIN;
-   sampler->ss3.address_round |= BRW_ADDRESS_ROUNDING_ENABLE_U_MAG |
-      BRW_ADDRESS_ROUNDING_ENABLE_V_MAG |
-      BRW_ADDRESS_ROUNDING_ENABLE_R_MAG;
-
-   return sampler_offset;
-}
-
-
 /* 3DSTATE_VS
  *
  * Disable vertex shader.
@@ -898,7 +841,7 @@ gen7_blorp_exec(struct brw_context *brw,
          gen6_blorp_emit_binding_table(brw, params,
                                        wm_surf_offset_renderbuffer,
                                        wm_surf_offset_texture);
-      sampler_offset = gen7_blorp_emit_sampler_state(brw, params);
+      sampler_offset = gen6_blorp_emit_sampler_state(brw, params);
    }
    gen7_blorp_emit_vs_disable(brw, params);
    gen7_blorp_emit_hs_disable(brw, params);