[Mesa-dev] [PATCH 02/12] i965/rbc: Set aux surface unconditionally for sampling engine
Pohjolainen, Topi
topi.pohjolainen at gmail.com
Thu Sep 1 04:51:12 UTC 2016
On Wed, Aug 31, 2016 at 05:39:07PM -0700, Jason Ekstrand wrote:
> On Wed, Aug 31, 2016 at 8:17 AM, Topi Pohjolainen
> <[1]topi.pohjolainen at intel.com> wrote:
>
> Once mcs buffer gets allocated without delay for lossless
> compression (same as we do for msaa), one gets regression in:
> GL45-CTS.texture_barrier_ARB.same-texel-rw
> Setting the auxiliary surface for both sampling engine and data
> port seems to fix this. I haven't found any hardware documentation
> backing this though.
> Signed-off-by: Topi Pohjolainen <[2]topi.pohjolainen at intel.com>
> ---
> Ã src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 46
> ++++++++++++++++++++++--
> Ã 1 file changed, 43 insertions(+), 3 deletions(-)
> diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> index bfd973b..5cd27ef 100644
> --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> @@ -72,6 +72,48 @@ static const struct surface_state_info
> surface_state_infos[] = {
> Ã Ã [9] = {16, 64, 8,Ã 10, SKL_MOCS_WB,Ã SKL_MOCS_PTE},
> Ã };
> +static bool
> +brw_needs_aux_surface(const struct brw_context *brw,
> +Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã const struct intel_mipmap_tree
> *mt,
> +Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã const struct isl_view *view)
> +{
> +Ã Ã if (!mt->mcs_mt)
> +Ã Ã Ã return false;
> +
> +Ã Ã if (view->usage & ISL_SURF_USAGE_RENDER_TARGET_BIT)
> +Ã Ã Ã return true;
> +
> +Ã Ã const bool is_lossless_compressed =
> +Ã Ã Ã intel_miptree_is_lossless_compressed(brw, mt);
> +Ã Ã const bool view_format_lossless_compressed =
> +Ã Ã Ã Ã isl_format_supports_lossless_
> compression(brw->intelScreen->devinfo,
> +Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã
> Ã Ã view->format);
> +
> +Ã Ã /* If the underlying surface is compressed but it is sampled
> using a
> +Ã Ã * format that the sampling engine doesn't support as
> compressed, there
> +Ã Ã * is no alternative but to treat the surface as
> non-compressed.
> +Ã Ã */
>
> Does this even work?Ã I mean, can you render to a texture with one
> format and texture from it with another and still use color
> compression?
There is logic specifically for this in
brw_context::intel_texture_view_requires_resolve(). A compressed surface is
explicitly resolved if it is going to be sampled using a non-compatible
format.
Note also that this is an existing problem - we just don't hit it with
current test cases. They clear with slow path meaning the delayed mcs creation
don't trigger and hence compression stays turned off. Later patch in the
series will change to immediate allocation of mcs and the problem being
addressed here becomes visible.
> Ã
>
> +Ã Ã if (is_lossless_compressed && !view_format_lossless_
> compressed) {
>
> This is more of a change in behavior than the commit message says.Ã We
> should probably make the commit message a bit better.
Sure.
> Ã
>
> +Ã Ã Ã /* Logic elsewhere needs to take care to resolve the color
> buffer prior
> +Ã Ã Ã Ã * to sampling it as non-compressed.
> +Ã Ã Ã Ã */
> +Ã Ã Ã assert(mt->fast_clear_state == INTEL_FAST_CLEAR_STATE_
> RESOLVED);
> +Ã Ã Ã return false;
> +Ã Ã }
> +
> +Ã Ã /* In practise it looks that setting the same lossless
> compressed surface
> +Ã Ã * to be sampled without auxiliary surface and to be written
> with auxiliary
> +Ã Ã * surface confuses the hardware.
> +Ã Ã * Currently there is no direct way of knowing if render pass
> will use the
> +Ã Ã * sane surface as render target and therefore simply use the
> auxiliary
> +Ã Ã * surface unconditionally here.
> +Ã Ã */
> +Ã Ã if (is_lossless_compressed)
> +Ã Ã Ã return true;
>
> This makes a lot of sense.Ã If we're sampling from and rendering to
> the same surface, we'd better have the compression buffer for both.Ã
> That said, if we ever bind a compressed buffer as a render target with
> a texture-viewed version as a source (as per above), we're going to
> have a problem...
And like said above we already do, we just don't have a texture view test case
that would do either fast clear or normal render prior to sampling.
I can't really think of anything else than adding logic that turns off
compressed rendering if the same surface is going to be sampled using a view
having incompatible format.
> Ã
>
> +
> +Ã Ã return mt->fast_clear_state != INTEL_FAST_CLEAR_STATE_
> RESOLVED;
> +}
> +
> Ã static void
> Ã brw_emit_surface_state(struct brw_context *brw,
> Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã Ã struct intel_mipmap_tree *mt,
> @@ -135,9 +177,7 @@ brw_emit_surface_state(struct brw_context *brw,
> Ã Ã struct isl_surf *aux_surf = NULL, aux_surf_s;
> Ã Ã uint64_t aux_offset = 0;
> Ã Ã enum isl_aux_usage aux_usage = ISL_AUX_USAGE_NONE;
> -Ã Ã if (mt->mcs_mt &&
> -Ã Ã Ã Ã ((view.usage & ISL_SURF_USAGE_RENDER_TARGET_BIT) ||
> -Ã Ã Ã Ã mt->fast_clear_state != INTEL_FAST_CLEAR_STATE_
> RESOLVED)) {
> +Ã Ã if (brw_needs_aux_surface(brw, mt, &view)) {
> Ã Ã Ã Ã intel_miptree_get_aux_isl_surf(brw, mt, &aux_surf_s,
> &aux_usage);
> Ã Ã Ã Ã aux_surf = &aux_surf_s;
> Ã Ã Ã Ã assert(mt->mcs_mt->offset == 0);
> --
> 2.5.5
> _______________________________________________
> mesa-dev mailing list
> [3]mesa-dev at lists.freedesktop.org
> [4]https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
> References
>
> 1. mailto:topi.pohjolainen at intel.com
> 2. mailto:topi.pohjolainen at intel.com
> 3. mailto:mesa-dev at lists.freedesktop.org
> 4. https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list