i965/ps: Use SET_FIELD() for sampler count
authorTopi Pohjolainen <topi.pohjolainen@intel.com>
Wed, 29 Apr 2015 17:35:45 +0000 (20:35 +0300)
committerTopi Pohjolainen <topi.pohjolainen@intel.com>
Wed, 29 Apr 2015 21:28:33 +0000 (00:28 +0300)
The value is actually clamped to 0-16 as sample state pointer
can be used to support more than 16 samplers.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/brw_defines.h
src/mesa/drivers/dri/i965/gen7_wm_state.c
src/mesa/drivers/dri/i965/gen8_ps_state.c

index bd3218a1d3ed923131cccc1fdbe0e9c94bb2d4c1..7d55d85bfaec3db3c449f160aacb10a75e3c856e 100644 (file)
@@ -2259,6 +2259,7 @@ enum brw_wm_barycentric_interp_mode {
 # define GEN7_PS_SPF_MODE                              (1 << 31)
 # define GEN7_PS_VECTOR_MASK_ENABLE                    (1 << 30)
 # define GEN7_PS_SAMPLER_COUNT_SHIFT                   27
+# define GEN7_PS_SAMPLER_COUNT_MASK                     INTEL_MASK(29, 27)
 # define GEN7_PS_BINDING_TABLE_ENTRY_COUNT_SHIFT       18
 # define GEN7_PS_FLOATING_POINT_MODE_IEEE_754          (0 << 16)
 # define GEN7_PS_FLOATING_POINT_MODE_ALT               (1 << 16)
index 923414edfb8d99c16a43b885733b745ed6407405..55a1acd563db98b1d1761f0c86119a630154024c 100644 (file)
@@ -135,8 +135,9 @@ upload_ps_state(struct brw_context *brw)
 
    dw2 = dw4 = dw5 = ksp2 = 0;
 
-   dw2 |=
-      (ALIGN(brw->wm.base.sampler_count, 4) / 4) << GEN7_PS_SAMPLER_COUNT_SHIFT;
+   const unsigned sampler_count =
+      DIV_ROUND_UP(CLAMP(brw->wm.base.sampler_count, 0, 16), 4);
+   dw2 |= SET_FIELD(sampler_count, GEN7_PS_SAMPLER_COUNT);
 
    dw2 |= ((prog_data->base.binding_table.size_bytes / 4) <<
            GEN7_PS_BINDING_TABLE_ENTRY_COUNT_SHIFT);
index 5f39e12b89c53cb073084d9b5443e3f79f204724..84811533bba3ff7ce31bd6beacc3b98f95806e42 100644 (file)
@@ -133,8 +133,9 @@ upload_ps_state(struct brw_context *brw)
     */
    dw3 |= GEN7_PS_VECTOR_MASK_ENABLE;
 
-   dw3 |=
-      (ALIGN(brw->wm.base.sampler_count, 4) / 4) << GEN7_PS_SAMPLER_COUNT_SHIFT;
+   const unsigned sampler_count =
+      DIV_ROUND_UP(CLAMP(brw->wm.base.sampler_count, 0, 16), 4);
+   dw3 |= SET_FIELD(sampler_count, GEN7_PS_SAMPLER_COUNT); 
 
    /* BRW_NEW_FS_PROG_DATA */
    dw3 |=