<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, May 31, 2017 at 2:08 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5">On Fri, May 26, 2017 at 04:30:20PM -0700, Jason Ekstrand wrote:<br>
> ---<br>
>  src/mesa/drivers/dri/i965/brw_<wbr>context.c        |  2 +-<br>
>  src/mesa/drivers/dri/i965/<wbr>intel_blit.c         | 14 ++++----------<br>
>  src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c  | 12 +++++-------<br>
>  src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h  | 18 ++++++++++++++++++<br>
>  src/mesa/drivers/dri/i965/<wbr>intel_pixel_bitmap.c |  2 +-<br>
>  src/mesa/drivers/dri/i965/<wbr>intel_pixel_read.c   |  2 +-<br>
>  src/mesa/drivers/dri/i965/<wbr>intel_tex_image.c    |  7 ++++---<br>
>  src/mesa/drivers/dri/i965/<wbr>intel_tex_subimage.c |  7 ++++---<br>
>  8 files changed, 38 insertions(+), 26 deletions(-)<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_context.c b/src/mesa/drivers/dri/i965/<wbr>brw_context.c<br>
> index 7840217..593b325 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>brw_context.c<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>brw_context.c<br>
> @@ -1390,7 +1390,7 @@ intel_resolve_for_dri2_flush(<wbr>struct brw_context *brw,<br>
>        if (rb->mt->num_samples <= 1) {<br>
>           assert(rb->mt_layer == 0 && rb->mt_level == 0 &&<br>
>                  rb->layer_count == 1);<br>
> -         intel_miptree_resolve_color(<wbr>brw, rb->mt, 0, 1, 0, 1, 0);<br>
> +         intel_miptree_prepare_access(<wbr>brw, rb->mt, 0, 1, 0, 1, false, false);<br>
>        } else {<br>
>           intel_renderbuffer_downsample(<wbr>brw, rb);<br>
>        }<br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_blit.c b/src/mesa/drivers/dri/i965/<wbr>intel_blit.c<br>
> index 4d68fcf..5fa43b7 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>intel_blit.c<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>intel_blit.c<br>
> @@ -325,11 +325,8 @@ intel_miptree_blit(struct brw_context *brw,<br>
>     /* The blitter has no idea about HiZ or fast color clears, so we need to<br>
>      * resolve the miptrees before we do anything.<br>
>      */<br>
> -   intel_miptree_slice_resolve_<wbr>depth(brw, src_mt, src_level, src_slice);<br>
> -   intel_miptree_slice_resolve_<wbr>depth(brw, dst_mt, dst_level, dst_slice);<br>
> -   intel_miptree_resolve_color(<wbr>brw, src_mt, src_level, 1, src_slice, 1, 0);<br>
> -   intel_miptree_resolve_color(<wbr>brw, dst_mt, dst_level, 1, dst_slice, 1, 0);<br>
> -   intel_miptree_slice_set_needs_<wbr>hiz_resolve(dst_mt, dst_level, dst_slice);<br>
> +   intel_miptree_access_raw(brw, src_mt, src_level, src_slice, false);<br>
> +   intel_miptree_access_raw(brw, dst_mt, dst_level, dst_slice, true);<br>
><br>
>     if (src_flip)<br>
>        src_y = minify(src_mt->physical_<wbr>height0, src_level - src_mt->first_level) - src_y - height;<br>
> @@ -384,11 +381,8 @@ intel_miptree_copy(struct brw_context *brw,<br>
>     /* The blitter has no idea about HiZ or fast color clears, so we need to<br>
>      * resolve the miptrees before we do anything.<br>
>      */<br>
> -   intel_miptree_slice_resolve_<wbr>depth(brw, src_mt, src_level, src_slice);<br>
> -   intel_miptree_slice_resolve_<wbr>depth(brw, dst_mt, dst_level, dst_slice);<br>
> -   intel_miptree_resolve_color(<wbr>brw, src_mt, src_level, 1, src_slice, 1, 0);<br>
> -   intel_miptree_resolve_color(<wbr>brw, dst_mt, dst_level, 1, dst_slice, 1, 0);<br>
> -   intel_miptree_slice_set_needs_<wbr>hiz_resolve(dst_mt, dst_level, dst_slice);<br>
> +   intel_miptree_access_raw(brw, src_mt, src_level, src_slice, false);<br>
> +   intel_miptree_access_raw(brw, dst_mt, dst_level, dst_slice, true);<br>
><br>
>     uint32_t src_image_x, src_image_y;<br>
>     intel_miptree_get_image_<wbr>offset(src_mt, src_level, src_slice,<br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
> index 0659e75..195d5e6 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
> @@ -2390,8 +2390,10 @@ intel_miptree_make_shareable(<wbr>struct brw_context *brw,<br>
>      */<br>
>     assert(mt->msaa_layout == INTEL_MSAA_LAYOUT_NONE || mt->num_samples <= 1);<br>
><br>
> +   intel_miptree_prepare_access(<wbr>brw, mt, 0, INTEL_REMAINING_LEVELS,<br>
> +                                0, INTEL_REMAINING_LAYERS, false, false);<br>
> +<br>
>     if (mt->mcs_buf) {<br>
> -      intel_miptree_all_slices_<wbr>resolve_color(brw, mt, 0);<br>
>        mt->aux_disable |= (INTEL_AUX_DISABLE_CCS | INTEL_AUX_DISABLE_MCS);<br>
>        brw_bo_unreference(mt->mcs_<wbr>buf->bo);<br>
>        free(mt->mcs_buf);<br>
> @@ -2406,7 +2408,6 @@ intel_miptree_make_shareable(<wbr>struct brw_context *brw,<br>
><br>
>     if (mt->hiz_buf) {<br>
>        mt->aux_disable |= INTEL_AUX_DISABLE_HIZ;<br>
> -      intel_miptree_all_slices_<wbr>resolve_depth(brw, mt);<br>
>        intel_miptree_hiz_buffer_free(<wbr>mt->hiz_buf);<br>
>        mt->hiz_buf = NULL;<br>
><br>
> @@ -3179,11 +3180,8 @@ intel_miptree_map(struct brw_context *brw,<br>
>        return;<br>
>     }<br>
><br>
> -   intel_miptree_resolve_color(<wbr>brw, mt, level, 1, slice, 1, 0);<br>
> -   intel_miptree_slice_resolve_<wbr>depth(brw, mt, level, slice);<br>
> -   if (map->mode & GL_MAP_WRITE_BIT) {<br>
> -      intel_miptree_slice_set_needs_<wbr>hiz_resolve(mt, level, slice);<br>
> -   }<br>
> +   intel_miptree_access_raw(brw, mt, level, slice,<br>
> +                            map->mode & GL_MAP_WRITE_BIT);<br>
<br>
</div></div>This is the only case where the given boolean is clear what it means without<br>
knowing the function signature by heart. I was about to comment in the<br>
previous patch that using "uint32_t flags" and properly named enum values<br>
instead of booleans document the call sites better.<br><div><div class="gmail-h5"></div></div></blockquote><div><br></div><div>Yeah...  I'm also not sure how I feel about the proliferation of enums...<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="gmail-h5">
><br>
>     if (mt->format == MESA_FORMAT_S_UINT8) {<br>
>        intel_miptree_map_s8(brw, mt, map, level, slice);<br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h<br>
> index e74fca6..aadb8f5 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h<br>
> @@ -992,6 +992,24 @@ intel_miptree_set_aux_state(<wbr>struct brw_context *brw,<br>
>                              uint32_t start_layer, uint32_t num_layers,<br>
>                              enum isl_aux_state aux_state);<br>
><br>
> +/**<br>
> + * Prepare a miptree for raw access<br>
> + *<br>
> + * This helper prepares the miptree for access that knows nothing about any<br>
> + * sort of compression whatsoever.  This is useful when mapping the surface or<br>
> + * using it with the blitter.<br>
> + */<br>
> +static inline void<br>
> +intel_miptree_access_raw(<wbr>struct brw_context *brw,<br>
> +                         struct intel_mipmap_tree *mt,<br>
> +                         uint32_t level, uint32_t layer,<br>
> +                         bool write)<br>
> +{<br>
> +   intel_miptree_prepare_access(<wbr>brw, mt, level, 1, layer, 1, false, false);<br>
> +   if (write)<br>
> +      intel_miptree_finish_write(<wbr>brw, mt, level, layer, 1, false);<br>
> +}<br>
> +<br>
>  void<br>
>  intel_miptree_make_shareable(<wbr>struct brw_context *brw,<br>
>                               struct intel_mipmap_tree *mt);<br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_pixel_bitmap.c b/src/mesa/drivers/dri/i965/<wbr>intel_pixel_bitmap.c<br>
> index 4522d28..af94a1c 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>intel_pixel_bitmap.c<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>intel_pixel_bitmap.c<br>
> @@ -256,7 +256,7 @@ do_blit_bitmap( struct gl_context *ctx,<br>
>     /* The blitter has no idea about fast color clears, so we need to resolve<br>
>      * the miptree before we do anything.<br>
>      */<br>
> -   intel_miptree_all_slices_<wbr>resolve_color(brw, irb->mt, 0);<br>
> +   intel_miptree_access_raw(brw, irb->mt, irb->mt_level, irb->mt_layer, true);<br>
<br>
</div></div>It would be nice to have a word or two in the commit message about now<br>
resolving only the needed slice instead of all (here and the in the cases<br>
further down).<br><div><div class="gmail-h5"></div></div></blockquote><div><br></div><div>I've done one better.  I split all those changes out into their own patch:<br><br><a href="https://cgit.freedesktop.org/~jekstrand/mesa/commit/?h=wip/i965-resolve-rework-v3&id=eeee565a0c8d02816d55669e405b16334e11567b">https://cgit.freedesktop.org/~jekstrand/mesa/commit/?h=wip/i965-resolve-rework-v3&id=eeee565a0c8d02816d55669e405b16334e11567b</a><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="gmail-h5">
><br>
>     /* Chop it all into chunks that can be digested by hardware: */<br>
>     for (py = 0; py < height; py += DY) {<br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_pixel_read.c b/src/mesa/drivers/dri/i965/<wbr>intel_pixel_read.c<br>
> index 8793c3e..e583f1d 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>intel_pixel_read.c<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>intel_pixel_read.c<br>
> @@ -138,7 +138,7 @@ intel_readpixels_tiled_memcpy(<wbr>struct gl_context * ctx,<br>
>     /* Since we are going to read raw data to the miptree, we need to resolve<br>
>      * any pending fast color clears before we start.<br>
>      */<br>
> -   intel_miptree_all_slices_<wbr>resolve_color(brw, irb->mt, 0);<br>
> +   intel_miptree_access_raw(brw, irb->mt, irb->mt_level, irb->mt_layer, false);<br>
><br>
>     bo = irb->mt->bo;<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_tex_image.c b/src/mesa/drivers/dri/i965/<wbr>intel_tex_image.c<br>
> index 7208d8e..2c3b6f2 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>intel_tex_image.c<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>intel_tex_image.c<br>
> @@ -520,10 +520,13 @@ intel_gettexsubimage_tiled_<wbr>memcpy(struct gl_context *ctx,<br>
>        return false;<br>
>     }<br>
><br>
> +   int level = texImage->Level + texImage->TexObject->MinLevel;<br>
> +<br>
>     /* Since we are going to write raw data to the miptree, we need to resolve<br>
>      * any pending fast color clears before we start.<br>
>      */<br>
> -   intel_miptree_all_slices_<wbr>resolve_color(brw, image->mt, 0);<br>
> +   assert(image->mt->logical_<wbr>depth0 == 1);<br>
> +   intel_miptree_access_raw(brw, image->mt, level, 0, true);<br>
><br>
>     bo = image->mt->bo;<br>
><br>
> @@ -548,8 +551,6 @@ intel_gettexsubimage_tiled_<wbr>memcpy(struct gl_context *ctx,<br>
>         packing->Alignment, packing->RowLength, packing->SkipPixels,<br>
>         packing->SkipRows);<br>
><br>
> -   int level = texImage->Level + texImage->TexObject->MinLevel;<br>
> -<br>
>     /* Adjust x and y offset based on miplevel */<br>
>     xoffset += image->mt->level[level].level_<wbr>x;<br>
>     yoffset += image->mt->level[level].level_<wbr>y;<br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_tex_subimage.c b/src/mesa/drivers/dri/i965/<wbr>intel_tex_subimage.c<br>
> index 9126222..29d8a3f 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>intel_tex_subimage.c<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>intel_tex_subimage.c<br>
> @@ -136,10 +136,13 @@ intel_texsubimage_tiled_<wbr>memcpy(struct gl_context * ctx,<br>
>        return false;<br>
>     }<br>
><br>
> +   int level = texImage->Level + texImage->TexObject->MinLevel;<br>
> +<br>
>     /* Since we are going to write raw data to the miptree, we need to resolve<br>
>      * any pending fast color clears before we start.<br>
>      */<br>
> -   intel_miptree_all_slices_<wbr>resolve_color(brw, image->mt, 0);<br>
> +   assert(image->mt->logical_<wbr>depth0 == 1);<br>
> +   intel_miptree_access_raw(brw, image->mt, level, 0, true);<br>
><br>
>     bo = image->mt->bo;<br>
><br>
> @@ -168,8 +171,6 @@ intel_texsubimage_tiled_<wbr>memcpy(struct gl_context * ctx,<br>
>         packing->Alignment, packing->RowLength, packing->SkipPixels,<br>
>         packing->SkipRows, for_glTexImage);<br>
><br>
> -   int level = texImage->Level + texImage->TexObject->MinLevel;<br>
> -<br>
>     /* Adjust x and y offset based on miplevel */<br>
>     xoffset += image->mt->level[level].level_<wbr>x;<br>
>     yoffset += image->mt->level[level].level_<wbr>y;<br>
> --<br>
> 2.5.0.400.gff86faf<br>
><br>
</div></div>> ______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>