<div dir="ltr"><div>Oops, forgot to add:<br><br></div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 17, 2017 at 9:27 AM, Jason Ekstrand <span dir="ltr"><<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Mon, Jul 17, 2017 at 6:34 AM, Topi Pohjolainen <span dir="ltr"><<a href="mailto:topi.pohjolainen@gmail.com" target="_blank">topi.pohjolainen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Once the driver moves to ISL both compressed and uncompressed have<br>
the same type. One needs to tell them apart by other means. This<br>
can be done by checking the existence of mcs_buf.<br>
<br>
There is a short period of time within intel_miptree_create()<br>
where mcs_buf doesn't exist yet (between calls to<br>
intel_miptree_create_layout() and intel_miptree_alloc_mcs()).<br>
First compute_msaa_layout() makes the decision if compression is<br>
to be used and sets the msaa_layout type. Then based on the type<br>
one sets aux_usage and finally decides if mcs_buf is needed.<br>
<br>
This patch duplicates the logic in compute_msaa_layout() and uses<br>
that to make the decision on aux_usage and mcs_buf allocation.<br>
Most of the original logic in compute_msaa_layout() will be gone<br>
in the following patch leaving only one version.<br></blockquote><div><br></div></span><div>Not true since you pulled this patch out for early merging. :-)<br><br></div><div>That said, I think it's ok to duplicate here.  I'm not sure what we're going to want all this to look like in the ISLified future anyway.  Probably something like Vulkan where we just call isl_surf_init_mcs and set aux_layout to NONE if it fails.  In any case, this doesn't seem to make anything worse.<br></div><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Elsewhere only brw_populate_sampler_prog_key_<wbr>data() needs to know<br>
if compression is used based on the msaa_type. This is now<br>
replaced with consideration for number of samples and existence<br>
of mcs_buf. All other occurrences consider CMS || UMS which can<br>
be represented using single the type of ISL_MSAA_LAYOUT_ARRAY<br>
without any tweaks.<br>
<br>
Signed-off-by: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com" target="_blank">topi.pohjolainen@intel.com</a>><br>
---<br>
 src/mesa/drivers/dri/i965/<wbr>brw_wm.c            |  8 +++--<br>
 src/mesa/drivers/dri/i965/int<wbr>el_mipmap_tree.c | 43 ++++++++++++++++++++++++++-<br>
 2 files changed, 47 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/br<wbr>w_wm.c b/src/mesa/drivers/dri/i965/br<wbr>w_wm.c<br>
index 3a5fcf5485..18056d51d0 100644<br>
--- a/src/mesa/drivers/dri/i965/br<wbr>w_wm.c<br>
+++ b/src/mesa/drivers/dri/i965/br<wbr>w_wm.c<br>
@@ -396,9 +396,11 @@ brw_populate_sampler_prog_key_<wbr>data(struct gl_context *ctx,<br>
          /* From gen9 onwards some single sampled buffers can also be<br>
           * compressed. These don't need ld2dms sampling along with mcs fetch.<br>
           */<br>
-         if (brw->gen >= 7 &&<br>
-             intel_tex->mt->msaa_layout == INTEL_MSAA_LAYOUT_CMS &&<br>
-             intel_tex->mt->num_samples > 1) {<br>
+         if (intel_tex->mt->aux_usage == ISL_AUX_USAGE_MCS) {<br>
+            assert(brw->gen >= 7);<br>
+            assert(intel_tex->mt->num_samp<wbr>les > 1);<br>
+            assert(intel_tex->mt->mcs_buf)<wbr>;<br>
+            assert(intel_tex->mt->msaa_lay<wbr>out == INTEL_MSAA_LAYOUT_CMS);<br>
             key->compressed_multisample_l<wbr>ayout_mask |= 1 << s;<br>
<br>
             if (intel_tex->mt->num_samples >= 16) {<br>
diff --git a/src/mesa/drivers/dri/i965/in<wbr>tel_mipmap_tree.c b/src/mesa/drivers/dri/i965/in<wbr>tel_mipmap_tree.c<br>
index 69a9328d6c..bef544c0ae 100644<br>
--- a/src/mesa/drivers/dri/i965/in<wbr>tel_mipmap_tree.c<br>
+++ b/src/mesa/drivers/dri/i965/in<wbr>tel_mipmap_tree.c<br>
@@ -62,6 +62,45 @@ static bool<br>
 intel_miptree_alloc_aux(<wbr>struct brw_context *brw,<br>
                         struct intel_mipmap_tree *mt);<br>
<br>
+static bool<br>
+is_mcs_supported(const struct brw_context *brw, mesa_format format,<br>
+                 uint32_t layout_flags)<br>
+{<br>
+   /* Prior to Gen7, all MSAA surfaces used IMS layout. */<br>
+   if (brw->gen < 7)<br>
+      return false;<br>
+<br>
+   /* In Gen7, IMS layout is only used for depth and stencil buffers. */<br>
+   switch (_mesa_get_format_base_format(<wbr>format)) {<br>
+   case GL_DEPTH_COMPONENT:<br>
+   case GL_STENCIL_INDEX:<br>
+   case GL_DEPTH_STENCIL:<br>
+      return false;<br>
+   default:<br>
+      /* From the Ivy Bridge PRM, Vol4 Part1 p77 ("MCS Enable"):<br>
+       *<br>
+       *   This field must be set to 0 for all SINT MSRTs when all RT channels<br>
+       *   are not written<br>
+       *<br>
+       * In practice this means that we have to disable MCS for all signed<br>
+       * integer MSAA buffers.  The alternative, to disable MCS only when one<br>
+       * of the render target channels is disabled, is impractical because it<br>
+       * would require converting between CMS and UMS MSAA layouts on the fly,<br>
+       * which is expensive.<br>
+       */<br>
+      if (brw->gen == 7 && _mesa_get_format_datatype(form<wbr>at) == GL_INT) {<br>
+         return false;<br>
+      } else if (layout_flags & MIPTREE_LAYOUT_DISABLE_AUX) {<br>
+         /* We can't use the CMS layout because it uses an aux buffer, the MCS<br>
+          * buffer. So fallback to UMS, which is identical to CMS without the<br>
+          * MCS. */<br>
+         return false;<br>
+      } else {<br>
+         return true;<br>
+      }<br>
+   }<br>
+}<br>
+<br>
 /**<br>
  * Determine which MSAA layout should be used by the MSAA surface being<br>
  * created, based on the chip generation and the surface type.<br>
@@ -566,7 +605,9 @@ intel_miptree_choose_aux_usage<wbr>(struct brw_context *brw,<br>
 {<br>
    assert(mt->aux_usage == ISL_AUX_USAGE_NONE);<br>
<br>
-   if (mt->msaa_layout == INTEL_MSAA_LAYOUT_CMS) {<br>
+   const unsigned no_flags = 0;<br>
+   if (mt->num_samples > 1 && is_mcs_supported(brw, mt->format, no_flags)) {<br>
+      assert(mt->msaa_layout == INTEL_MSAA_LAYOUT_CMS);<br>
       mt->aux_usage = ISL_AUX_USAGE_MCS;<br>
    } else if (intel_tiling_supports_ccs(brw<wbr>, mt->tiling) &&<br>
               intel_miptree_supports_ccs(br<wbr>w, mt)) {<br>
<span class="m_2131185973661049130HOEnZb"><font color="#888888">--<br>
2.11.0<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>