+ if (multisampled_fbo) {
+ /* _NEW_MULTISAMPLE */
+ if (ctx->Multisample.Enabled)
+ dw6 |= GEN6_WM_MSRAST_ON_PATTERN;
+ else
+ dw6 |= GEN6_WM_MSRAST_OFF_PIXEL;
+
+ if (min_inv_per_frag > 1)
+ dw6 |= GEN6_WM_MSDISPMODE_PERSAMPLE;
+ else {
+ dw6 |= GEN6_WM_MSDISPMODE_PERPIXEL;
+
+ /* From the Sandy Bridge PRM, Vol 2 part 1, 7.7.1 ("Pixel Grouping
+ * (Dispatch Size) Control"), p.334:
+ *
+ * Note: in the table below, the Valid column indicates which
+ * products that combination is supported on. Combinations of
+ * dispatch enables not listed in the table are not available on
+ * any product.
+ *
+ * A: Valid on all products
+ *
+ * B: Not valid on [DevSNB] if 4x PERPIXEL mode with pixel shader
+ * computed depth.
+ *
+ * D: Valid on all products, except when in non-1x PERSAMPLE mode
+ * (applies to [DevSNB+] only). Not valid on [DevSNB] if 4x
+ * PERPIXEL mode with pixel shader computed depth.
+ *
+ * E: Not valid on [DevSNB] if 4x PERPIXEL mode with pixel shader
+ * computed depth.
+ *
+ * F: Valid on all products, except not valid on [DevSNB] if 4x
+ * PERPIXEL mode with pixel shader computed depth.
+ *
+ * In the table that follows, the only entry with "A" in the Valid
+ * column is the entry where only 8 pixel dispatch is enabled.
+ * Therefore, when we are in PERPIXEL mode with pixel shader computed
+ * depth, we need to disable SIMD16 dispatch.
+ */
+ if (dw5 & GEN6_WM_COMPUTED_DEPTH)
+ dw5 &= ~GEN6_WM_16_DISPATCH_ENABLE;
+ }
+ } else {
+ dw6 |= GEN6_WM_MSRAST_OFF_PIXEL;
+ dw6 |= GEN6_WM_MSDISPMODE_PERSAMPLE;
+ }
+
+ /* _NEW_BUFFERS, _NEW_MULTISAMPLE */
+ /* From the SNB PRM, volume 2 part 1, page 281:
+ * "If the PS kernel does not need the Position XY Offsets
+ * to compute a Position XY value, then this field should be
+ * programmed to POSOFFSET_NONE."
+ *
+ * "SW Recommendation: If the PS kernel needs the Position Offsets
+ * to compute a Position XY value, this field should match Position
+ * ZW Interpolation Mode to ensure a consistent position.xyzw
+ * computation."
+ * We only require XY sample offsets. So, this recommendation doesn't
+ * look useful at the moment. We might need this in future.
+ */
+ if (brw->wm.prog_data->uses_pos_offset)
+ dw6 |= GEN6_WM_POSOFFSET_SAMPLE;
+ else
+ dw6 |= GEN6_WM_POSOFFSET_NONE;