<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jun 14, 2017 at 12:13 AM, Pohjolainen, Topi <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"><div class="m_-7983647689082039336HOEnZb"><div class="m_-7983647689082039336h5">On Tue, Jun 13, 2017 at 04:28:53PM -0700, Jason Ekstrand wrote:<br>
> On Tue, Jun 13, 2017 at 7:53 AM, Topi Pohjolainen <<br>
> <a href="mailto:topi.pohjolainen@gmail.com" target="_blank">topi.pohjolainen@gmail.com</a>> wrote:<br>
><br>
> > Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>><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/brw_<wbr>blorp.c | 2 +<br>
> > src/mesa/drivers/dri/i965/brw_<wbr>wm_surface_state.c | 8 +-<br>
> > src/mesa/drivers/dri/i965/inte<wbr>l_mipmap_tree.c | 103<br>
> > ++++-------------------<br>
> > 3 files changed, 25 insertions(+), 88 deletions(-)<br>
> ><br>
> > diff --git a/src/mesa/drivers/dri/i965/br<wbr>w_blorp.c<br>
> > b/src/mesa/drivers/dri/i965/br<wbr>w_blorp.c<br>
> > index b722454703..3d8f24b304 100644<br>
> > --- a/src/mesa/drivers/dri/i965/br<wbr>w_blorp.c<br>
> > +++ b/src/mesa/drivers/dri/i965/br<wbr>w_blorp.c<br>
> > @@ -168,6 +168,8 @@ blorp_surf_for_miptree(struct brw_context *brw,<br>
> > struct isl_surf *aux_surf;<br>
> > if (brw->gen == 6 && mt->hiz_buf) {<br>
> > aux_surf = &mt->hiz_buf->aux_base.surf;<br>
> > + } else if (mt->mcs_buf) {<br>
> > + aux_surf = &mt->mcs_buf->surf;<br>
> > } else {<br>
> > aux_surf = &tmp_surfs[1];<br>
> > intel_miptree_get_aux_isl_surf<wbr>(brw, mt, surf->aux_usage, aux_surf);<br>
> > diff --git a/src/mesa/drivers/dri/i965/br<wbr>w_wm_surface_state.c<br>
> > b/src/mesa/drivers/dri/i965/br<wbr>w_wm_surface_state.c<br>
> > index 5aa0c7c809..d13302d03e 100644<br>
> > --- a/src/mesa/drivers/dri/i965/br<wbr>w_wm_surface_state.c<br>
> > +++ b/src/mesa/drivers/dri/i965/br<wbr>w_wm_surface_state.c<br>
> > @@ -143,13 +143,17 @@ brw_emit_surface_state(struct brw_context *brw,<br>
> > if ((mt->mcs_buf || intel_miptree_sample_with_hiz(<wbr>brw, mt)) &&<br>
> > !(flags & INTEL_AUX_BUFFER_DISABLED)) {<br>
> > aux_usage = intel_miptree_get_aux_isl_usag<wbr>e(brw, mt);<br>
> > - intel_miptree_get_aux_isl_surf<wbr>(brw, mt, aux_usage, &aux_surf_s);<br>
> > - aux_surf = &aux_surf_s;<br>
> ><br>
> > if (mt->mcs_buf) {<br>
> > + aux_surf = &mt->mcs_buf->surf;<br>
> ><br>
><br>
> This doesn't work unless we're going to convert MCS and CCS at the same<br>
> time. Again, I think just making miptree_get_aux_isl_surf do the right<br>
> thing would help.<br>
<br>
</div></div>Yeah, after reading your question in the summary, I realized had "do not<br>
re-calculate for ccs either" hidden in this patch. I'm happy to add something<br>
to the commit message or split into another patch. I'd like to keep<br>
miptree_get_aux_isl_surf() as it is as I'm going to drop that altogether once<br>
hiz is converted.<br><div><div class="m_-7983647689082039336h5"></div></div></blockquote><div><br></div><div>Right. It's very confusing. That said, I think I've convinced myself that it's ok though I would like something added to the commit message of this patch. Assuming all of the other trivial little comments get addressed, the series is<br><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_-7983647689082039336h5">
><br>
><br>
> > +<br>
> > + assert(mt->mcs_buf->offset == 0);<br>
> > aux_bo = mt->mcs_buf->bo;<br>
> > aux_offset = mt->mcs_buf->bo->offset64 + mt->mcs_buf->offset;<br>
> > } else {<br>
> > + intel_miptree_get_aux_isl_sur<wbr>f(brw, mt, aux_usage, &aux_surf_s);<br>
> > + aux_surf = &aux_surf_s;<br>
> > +<br>
> > aux_bo = mt->hiz_buf-><a href="http://aux_base.bo" rel="noreferrer" target="_blank">aux_base.bo</a>;<br>
> > aux_offset = mt->hiz_buf->aux_base.bo->offs<wbr>et64;<br>
> > }<br>
> > diff --git 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>
> > index 0a86d3401d..f51bbd9cda 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>
> > @@ -1599,56 +1599,6 @@ intel_miptree_init_mcs(struct brw_context *brw,<br>
> > }<br>
> ><br>
> > static struct intel_miptree_aux_buffer *<br>
> > -intel_mcs_miptree_buf_create(<wbr>struct brw_context *brw,<br>
> > - struct intel_mipmap_tree *mt,<br>
> > - mesa_format format,<br>
> > - unsigned mcs_width,<br>
> > - unsigned mcs_height,<br>
> > - uint32_t layout_flags)<br>
> > -{<br>
> > - struct intel_miptree_aux_buffer *buf = calloc(sizeof(*buf), 1);<br>
> > - struct intel_mipmap_tree *temp_mt;<br>
> > -<br>
> > - if (!buf)<br>
> > - return NULL;<br>
> > -<br>
> > - /* From the Ivy Bridge PRM, Vol4 Part1 p76, "MCS Base Address":<br>
> > - *<br>
> > - * "The MCS surface must be stored as Tile Y."<br>
> > - */<br>
> > - layout_flags |= MIPTREE_LAYOUT_TILING_Y;<br>
> > - temp_mt = miptree_create(brw,<br>
> > - mt->target,<br>
> > - format,<br>
> > - mt->first_level,<br>
> > - mt->last_level,<br>
> > - mcs_width,<br>
> > - mcs_height,<br>
> > - mt->logical_depth0,<br>
> > - 0 /* num_samples */,<br>
> > - layout_flags);<br>
> > - if (!temp_mt) {<br>
> > - free(buf);<br>
> > - return NULL;<br>
> > - }<br>
> > -<br>
> > - buf->bo = temp_mt->bo;<br>
> > - buf->offset = temp_mt->offset;<br>
> > - buf->size = temp_mt->total_height * temp_mt->pitch;<br>
> > - buf->pitch = temp_mt->pitch;<br>
> > - buf->qpitch = temp_mt->qpitch;<br>
> > -<br>
> > - /* Just hang on to the BO which backs the AUX buffer; the rest of the<br>
> > miptree<br>
> > - * structure should go away. We use miptree create simply as a means<br>
> > to make<br>
> > - * sure all the constraints for the buffer are satisfied.<br>
> > - */<br>
> > - brw_bo_reference(temp_mt->bo)<wbr>;<br>
> > - intel_miptree_release(&temp_m<wbr>t);<br>
> > -<br>
> > - return buf;<br>
> > -}<br>
> > -<br>
> > -static struct intel_miptree_aux_buffer *<br>
> > intel_alloc_aux_buffer(struct brw_context *brw,<br>
> > const char *name,<br>
> > const struct isl_surf *main_surf,<br>
> > @@ -1679,6 +1629,7 @@ intel_alloc_aux_buffer(struct brw_context *brw,<br>
> > }<br>
> ><br>
> > assert(pitch == buf->pitch);<br>
> > + buf->surf = *aux_surf;<br></div></div></blockquote><div><br></div><div>Does this hunk belong in the patch which adds intel_alloc_aux_buffer? I think it does.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_-7983647689082039336h5">
> ><br>
> > return buf;<br>
> > }<br>
> > @@ -1692,36 +1643,6 @@ intel_miptree_alloc_mcs(struct brw_context *brw,<br>
> > assert(mt->mcs_buf == NULL);<br>
> > assert((mt->aux_disable & INTEL_AUX_DISABLE_MCS) == 0);<br>
> ><br>
> > - /* Choose the correct format for the MCS buffer. All that really<br>
> > matters<br>
> > - * is that we allocate the right buffer size, since we'll always be<br>
> > - * accessing this miptree using MCS-specific hardware mechanisms, which<br>
> > - * infer the correct format based on num_samples.<br>
> > - */<br>
> > - mesa_format format;<br>
> > - switch (num_samples) {<br>
> > - case 2:<br>
> > - case 4:<br>
> > - /* 8 bits/pixel are required for MCS data when using 4x MSAA (2<br>
> > bits for<br>
> > - * each sample).<br>
> > - */<br>
> > - format = MESA_FORMAT_R_UNORM8;<br>
> > - break;<br>
> > - case 8:<br>
> > - /* 32 bits/pixel are required for MCS data when using 8x MSAA (3<br>
> > bits<br>
> > - * for each sample, plus 8 padding bits).<br>
> > - */<br>
> > - format = MESA_FORMAT_R_UINT32;<br>
> > - break;<br>
> > - case 16:<br>
> > - /* 64 bits/pixel are required for MCS data when using 16x MSAA (4<br>
> > bits<br>
> > - * for each sample).<br>
> > - */<br>
> > - format = MESA_FORMAT_RG_UINT32;<br>
> > - break;<br>
> > - default:<br>
> > - unreachable("Unrecognized sample count in intel_miptree_alloc_mcs");<br>
> > - };<br>
> > -<br>
> > /* Multisampled miptrees are only supported for single level. */<br>
> > assert(mt->first_level == 0);<br>
> > enum isl_aux_state **aux_state =<br>
> > @@ -1729,12 +1650,22 @@ intel_miptree_alloc_mcs(struct brw_context *brw,<br>
> > if (!aux_state)<br>
> > return false;<br>
> ><br>
> > - mt->mcs_buf =<br>
> > - intel_mcs_miptree_buf_create(b<wbr>rw, mt,<br>
> > - format,<br>
> > - mt->logical_width0,<br>
> > - mt->logical_height0,<br>
> > - MIPTREE_LAYOUT_ACCELERATED_UP<wbr>LOAD);<br>
> > + struct isl_surf temp_main_surf;<br>
> > + struct isl_surf temp_mcs_surf;<br>
> > +<br>
> > + /* Create first an ISL presentation for the main color surface and let<br>
> > ISL<br>
> > + * calculate equivalent MCS surface against it.<br>
> > + */<br>
> > + intel_miptree_get_isl_surf(br<wbr>w, mt, &temp_main_surf);<br>
> > + isl_surf_get_mcs_surf(&brw->i<wbr>sl_dev, &temp_main_surf, &temp_mcs_surf);<br>
> > +<br>
> > + assert(temp_mcs_surf.size &&<br>
> > + (temp_mcs_surf.size % temp_mcs_surf.row_pitch == 0));<br>
> ><br>
><br>
> The better thing to do here would be to assert that isl_surf_get_mcs_surf<br>
> returns true.<br>
<br>
</div></div>Agreed.<br>
<div class="m_-7983647689082039336HOEnZb"><div class="m_-7983647689082039336h5"><br>
><br>
><br>
> > +<br>
> > + const uint32_t alloc_flags = BO_ALLOC_FOR_RENDER;<br>
> > + mt->mcs_buf = intel_alloc_aux_buffer(brw, "mcs-miptree",<br>
> > + &temp_main_surf, &temp_mcs_surf,<br>
> > + alloc_flags, mt);<br>
> ><br>
><br>
> I like this new helper. :-)<br>
><br>
><br>
> > if (!mt->mcs_buf) {<br>
> > free(aux_state);<br>
> > return false;<br>
> > --<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>
> ><br>
</div></div></blockquote></div><br></div></div>