<p dir="ltr"><br>
On Jul 5, 2016 6:44 AM, "Pohjolainen, Topi" <<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>> wrote:<br>
><br>
> On Wed, Jun 29, 2016 at 04:22:22PM -0700, Jason Ekstrand wrote:<br>
> > v2: Switch on the usage when filling out formats<br>
> ><br>
> > Reviewed-by: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>><br>
> > ---<br>
> > src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 119 ++++++++++++++++++++++++++<br>
> > src/mesa/drivers/dri/i965/intel_mipmap_tree.h | 5 ++<br>
> > 2 files changed, 124 insertions(+)<br>
> ><br>
> > diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c<br>
> > index 8a746ec..6febb9a 100644<br>
> > --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c<br>
> > +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c<br>
> > @@ -3167,6 +3167,125 @@ intel_miptree_get_isl_surf(struct brw_context *brw,<br>
> > surf->usage = 0; /* TODO */<br>
> > }<br>
> ><br>
> > +/* WARNING: THE SURFACE CREATED BY THIS FUNCTION IS NOT COMPLETE AND CANNOT BE<br>
> > + * USED FOR ANY REAL CALCULATIONS. THE ONLY VALID USE OF SUCH A SURFACE IS TO<br>
> > + * PASS IT INTO isl_surf_fill_state.<br>
> > + */<br>
> > +void<br>
> > +intel_miptree_get_aux_isl_surf(struct brw_context *brw,<br>
> > + const struct intel_mipmap_tree *mt,<br>
> > + struct isl_surf *surf,<br>
> > + enum isl_aux_usage *usage)<br>
> > +{<br>
> > + /* Much is the same as the regular surface */<br>
> > + intel_miptree_get_isl_surf(brw, mt->mcs_mt, surf);<br>
> > +<br>
> > + /* Figure out the layout */<br>
> > + if (_mesa_get_format_base_format(mt->format) == GL_DEPTH_COMPONENT) {<br>
> > + *usage = ISL_AUX_USAGE_HIZ;<br>
> > + } else if (mt->num_samples > 1) {<br>
> > + if (mt->msaa_layout == INTEL_MSAA_LAYOUT_CMS)<br>
> > + *usage = ISL_AUX_USAGE_MCS;<br>
> > + else<br>
> > + *usage = ISL_AUX_USAGE_NONE;<br>
> > + } else if (intel_miptree_is_lossless_compressed(brw, mt)) {<br>
> > + assert(brw->gen >= 9);<br>
> > + *usage = ISL_AUX_USAGE_CCS_E;<br>
> > + } else if (mt->fast_clear_state != INTEL_FAST_CLEAR_STATE_NO_MCS) {<br>
> > + *usage = ISL_AUX_USAGE_CCS_D;<br>
> > + } else {<br>
> > + /* Can we even get here? */<br>
> > + *usage = ISL_AUX_USAGE_NONE;<br>
> > + }<br>
> > +<br>
> > + /* Figure out the format of the auxiliary surface */<br>
> > + switch (*usage) {<br>
> > + case ISL_AUX_USAGE_NONE:<br>
> > + /* Can we even get here? */<br>
> > + break;<br>
> > +<br>
> > + case ISL_AUX_USAGE_HIZ:<br>
> > + if (brw->gen >= 9) {<br>
> > + /* gen9+ uses the same size HiZ buffer regardless of multisampling */<br>
> > + surf->format = ISL_FORMAT_GEN9_HIZ;<br>
> > + } else {<br>
> > + switch (mt->num_samples) {<br>
> > + case 0:<br>
> > + case 1: surf->format = ISL_FORMAT_GEN6_HIZ_1X; break;<br>
> > + case 2: surf->format = ISL_FORMAT_GEN6_HIZ_2X; break;<br>
> > + case 4: surf->format = ISL_FORMAT_GEN6_HIZ_4X; break;<br>
> > + case 8: surf->format = ISL_FORMAT_GEN6_HIZ_8X; break;<br>
> > + default:<br>
> > + unreachable("Invalid number of samples");<br>
> > + }<br>
> > + }<br>
> > + break;<br>
> > +<br>
> > + case ISL_AUX_USAGE_MCS:<br>
> > + /*<br>
> > + * From the SKL PRM:<br>
> > + * "When Auxiliary Surface Mode is set to AUX_CCS_D or AUX_CCS_E,<br>
> > + * HALIGN 16 must be used."<br>
> > + */<br>
> > + if (brw->gen >= 9)<br>
> > + assert(mt->halign == 16);<br>
> > +<br>
> > + switch (mt->num_samples) {<br>
> > + case 2: surf->format = ISL_FORMAT_MCS_2X; break;<br>
> > + case 4: surf->format = ISL_FORMAT_MCS_4X; break;<br>
> > + case 8: surf->format = ISL_FORMAT_MCS_8X; break;<br>
> > + case 16: surf->format = ISL_FORMAT_MCS_16X; break;<br>
> > + default:<br>
> > + unreachable("Invalid number of samples");<br>
> > + }<br>
> > + break;<br>
> > +<br>
> > + case ISL_AUX_USAGE_CCS_D:<br>
> > + case ISL_AUX_USAGE_CCS_E:<br>
> > + /*<br>
> > + * From the BDW PRM, Volume 2d, page 260 (RENDER_SURFACE_STATE):<br>
> > + *<br>
> > + * "When MCS is enabled for non-MSRT, HALIGN_16 must be used"<br>
> > + *<br>
> > + * From the hardware spec for GEN9:<br>
> > + *<br>
> > + * "When Auxiliary Surface Mode is set to AUX_CCS_D or AUX_CCS_E,<br>
> > + * HALIGN 16 must be used."<br>
> > + */<br>
> > + if (brw->gen >= 9 || mt->num_samples == 1)<br>
> > + assert(mt->halign == 16);<br>
> > +<br>
> > + if (brw->gen >= 9) {<br>
> > + assert(mt->tiling == I915_TILING_Y);<br>
> > + switch (_mesa_get_format_bytes(mt->format)) {<br>
> > + case 4: surf->format = ISL_FORMAT_GEN9_CCS_32BPP; break;<br>
> > + case 8: surf->format = ISL_FORMAT_GEN9_CCS_64BPP; break;<br>
> > + case 16: surf->format = ISL_FORMAT_GEN9_CCS_128BPP; break;<br>
> > + default:<br>
> > + unreachable("Invalid format size for color compression");<br>
> > + }<br>
> > + } else if (mt->tiling == I915_TILING_Y) {<br>
> > + switch (_mesa_get_format_bytes(mt->format)) {<br>
> > + case 4: surf->format = ISL_FORMAT_GEN7_CCS_32BPP_Y; break;<br>
> > + case 8: surf->format = ISL_FORMAT_GEN7_CCS_64BPP_Y; break;<br>
> > + case 16: surf->format = ISL_FORMAT_GEN7_CCS_128BPP_X; break;<br>
><br>
> Shouldn't this be ISL_FORMAT_GEN7_CCS_128BPP_Y instead?</p>
<p dir="ltr">Yes it should.</p>
<p dir="ltr">> > + default:<br>
> > + unreachable("Invalid format size for color compression");<br>
> > + }<br>
> > + } else {<br>
> > + assert(mt->tiling == I915_TILING_X);<br>
> > + switch (_mesa_get_format_bytes(mt->format)) {<br>
> > + case 4: surf->format = ISL_FORMAT_GEN7_CCS_32BPP_X; break;<br>
> > + case 8: surf->format = ISL_FORMAT_GEN7_CCS_64BPP_X; break;<br>
> > + case 16: surf->format = ISL_FORMAT_GEN7_CCS_128BPP_X; break;<br>
> > + default:<br>
> > + unreachable("Invalid format size for color compression");<br>
> > + }<br>
> > + }<br>
> > + break;<br>
> > + }<br>
> > +}<br>
> > +<br>
> > union isl_color_value<br>
> > intel_miptree_get_isl_clear_color(struct brw_context *brw,<br>
> > const struct intel_mipmap_tree *mt)<br>
> > diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h<br>
> > index a50f181..4388741 100644<br>
> > --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h<br>
> > +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h<br>
> > @@ -801,6 +801,11 @@ void<br>
> > intel_miptree_get_isl_surf(struct brw_context *brw,<br>
> > const struct intel_mipmap_tree *mt,<br>
> > struct isl_surf *surf);<br>
> > +void<br>
> > +intel_miptree_get_aux_isl_surf(struct brw_context *brw,<br>
> > + const struct intel_mipmap_tree *mt,<br>
> > + struct isl_surf *surf,<br>
> > + enum isl_aux_usage *usage);<br>
> ><br>
> > union isl_color_value<br>
> > intel_miptree_get_isl_clear_color(struct brw_context *brw,<br>
> > --<br>
> > 2.5.0.400.gff86faf<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="https://lists.freedesktop.org/mailman/listinfo/mesa-dev">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</p>