<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 4, 2014 at 8:40 AM, Chris Forbes <span dir="ltr"><<a href="mailto:chrisf@ijw.co.nz" target="_blank">chrisf@ijw.co.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Two things were broken here:<br>
- The depth/stencil surface dimensions were broken for MSAA.<br>
- Sample count was programmed incorrectly.<br>
<br>
Result was the depth resolve didn't work correctly on MSAA surfaces, and<br>
so sampling the surface later produced garbage.<br>
<br>
Fixes the new piglit test arb_texture_multisample-sample-depth, and<br>
various artifacts in 'tesseract' with msaa=4 glineardepth=0.<br>
<br>
Not observed any piglit regressions on Haswell.<br>
<br>
Signed-off-by: Chris Forbes <<a href="mailto:chrisf@ijw.co.nz">chrisf@ijw.co.nz</a>><br>
---<br>
 src/mesa/drivers/dri/i965/brw_blorp.h    |  4 ++++<br>
 src/mesa/drivers/dri/i965/gen7_blorp.cpp | 24 +++++++++++++++++-------<br>
 2 files changed, 21 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_blorp.h b/src/mesa/drivers/dri/i965/brw_blorp.h<br>
index ff68000..c4ff0f7 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_blorp.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_blorp.h<br>
@@ -236,6 +236,10 @@ public:<br>
    bool use_wm_prog;<br>
    brw_blorp_wm_push_constants wm_push_consts;<br>
    bool color_write_disable[4];<br>
+<br>
+   unsigned num_samples() const {<br>
+      return <a href="http://dst.mt" target="_blank">dst.mt</a> ? dst.num_samples : depth.mt->num_samples;<br>
+   }<br>
 };<br>
<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/gen7_blorp.cpp b/src/mesa/drivers/dri/i965/gen7_blorp.cpp<br>
index 206a6ff..cc57ffe 100644<br>
--- a/src/mesa/drivers/dri/i965/gen7_blorp.cpp<br>
+++ b/src/mesa/drivers/dri/i965/gen7_blorp.cpp<br>
@@ -415,7 +415,7 @@ gen7_blorp_emit_sf_config(struct brw_context *brw,<br>
       OUT_BATCH(_3DSTATE_SF << 16 | (7 - 2));<br>
       OUT_BATCH(params->depth_format <<<br>
                 GEN7_SF_DEPTH_BUFFER_SURFACE_FORMAT_SHIFT);<br>
-      OUT_BATCH(params->dst.num_samples > 1 ? GEN6_SF_MSRAST_ON_PATTERN : 0);<br>
+      OUT_BATCH(params->num_samples() > 1 ? GEN6_SF_MSRAST_ON_PATTERN : 0);<br>
       OUT_BATCH(0);<br>
       OUT_BATCH(0);<br>
       OUT_BATCH(0);<br>
@@ -470,7 +470,7 @@ gen7_blorp_emit_wm_config(struct brw_context *brw,<br>
       dw1 |= GEN7_WM_DISPATCH_ENABLE; /* We are rendering */<br>
    }<br>
<br>
-      if (params->dst.num_samples > 1) {<br>
+      if (params->num_samples() > 1) {<br>
          dw1 |= GEN7_WM_MSRAST_ON_PATTERN;<br>
          if (prog_data && prog_data->persample_msaa_dispatch)<br>
             dw2 |= GEN7_WM_MSDISPMODE_PERSAMPLE;<br>
@@ -661,8 +661,17 @@ gen7_blorp_emit_depth_stencil_config(struct brw_context *brw,<br>
        * larger to allow the fast depth clear to fit the hardware<br>
        * alignment requirements. (8x4)<br>
        */<br>
-      surfwidth = params->depth.width;<br>
-      surfheight = params->depth.height;<br>
+<br>
+      if (params->num_samples() > 1) {<br>
+         /* If this is an MSAA + HIZ op, we need to program the<br>
+          * aligned logical size of the depth surface.<br>
+          */<br>
+         surfwidth = ALIGN(params->depth.mt->logical_width0, 8);<br>
+         surfheight = ALIGN(params->depth.mt->logical_height0, 4);<br>
+      } else {<br>
+         surfwidth = params->depth.width;<br>
+         surfheight = params->depth.height;<br>
+      }<br>
    } else {<br>
       surfwidth = params->depth.mt->logical_width0;<br>
       surfheight = params->depth.mt->logical_height0;<br>
@@ -805,10 +814,11 @@ gen7_blorp_exec(struct brw_context *brw,<br>
    uint32_t sampler_offset = 0;<br>
<br>
    uint32_t prog_offset = params->get_wm_prog(brw, &prog_data);<br>
-   gen6_emit_3dstate_multisample(brw, params->dst.num_samples);<br>
+   unsigned num_samples = params->num_samples();<br>
+   gen6_emit_3dstate_multisample(brw, num_samples);<br>
    gen6_emit_3dstate_sample_mask(brw,<br>
-                                 params->dst.num_samples > 1 ?<br>
-                                 (1 << params->dst.num_samples) - 1 : 1);<br>
+                                 num_samples > 1 ?<br>
+                                 (1 << num_samples) - 1 : 1);<br>
    gen6_blorp_emit_state_base_address(brw, params);<br>
    gen6_blorp_emit_vertices(brw, params);<br>
    gen7_blorp_emit_urb_config(brw, params);<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.1.2<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div><div class="gmail_extra">Looks good to me. Verified the requirement in IVB PRM.</div><div class="gmail_extra">Reviewed-by: Anuj Phogat <<a href="mailto:anuj.phogat@gmail.com">anuj.phogat@gmail.com</a>></div></div>