[Mesa-dev] [PATCH] i965: Move surface resolves back to draw/dispatch time

Kenneth Graunke kenneth at whitecape.org
Mon Jun 26 18:37:23 UTC 2017


On Saturday, June 24, 2017 3:54:59 PM PDT Jason Ekstrand wrote:
> This is effectively a revert of 388f02729bbf88ba104f4f8ee1fdf005a240969c
> though much code has been added since.  Kristian initially moved it to
> try and avoid locking problems with meta-based resolves.  Now that meta
> is gone from the resolve path (for good this time, we hope), we can move
> it back.  The problem with having it in intel_update_state was that the
> UpdateState hook gets called by core mesa directly and all sorts of
> things will cause a UpdateState to get called which may trigger resolves
> at inopportune times.  In particular, it gets called by _mesa_Clear and,
> if we have a HiZ buffer in the INVALID_AUX state, causes a HiZ resolve
> right before the clear which is pointless.  By moving it back to
> try_draw_prims time, we know it will only get called right before a draw
> which is where we want it.
> ---
>  src/mesa/drivers/dri/i965/brw_compute.c |   2 +
>  src/mesa/drivers/dri/i965/brw_context.c | 121 ---------------------------
>  src/mesa/drivers/dri/i965/brw_context.h |   2 +
>  src/mesa/drivers/dri/i965/brw_draw.c    | 139 ++++++++++++++++++++++++++++++++
>  4 files changed, 143 insertions(+), 121 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_compute.c b/src/mesa/drivers/dri/i965/brw_compute.c
> index 8046153..2867a14 100644
> --- a/src/mesa/drivers/dri/i965/brw_compute.c
> +++ b/src/mesa/drivers/dri/i965/brw_compute.c
> @@ -188,6 +188,8 @@ brw_dispatch_compute_common(struct gl_context *ctx)
>  
>     brw_validate_textures(brw);
>  
> +   brw_predraw_resolve_inputs(brw);
> +
>     const int sampler_state_size = 16; /* 16 bytes */
>     estimated_buffer_space_needed = 512; /* batchbuffer commands */
>     estimated_buffer_space_needed += (BRW_MAX_TEX_UNIT *
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
> index e921a41..0b3fdc6 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -170,39 +170,17 @@ intel_update_framebuffer(struct gl_context *ctx,
>                                   fb->DefaultGeometry.NumSamples);
>  }
>  
> -static bool
> -intel_disable_rb_aux_buffer(struct brw_context *brw, const struct brw_bo *bo)
> -{
> -   const struct gl_framebuffer *fb = brw->ctx.DrawBuffer;
> -   bool found = false;
> -
> -   for (unsigned i = 0; i < fb->_NumColorDrawBuffers; i++) {
> -      const struct intel_renderbuffer *irb =
> -         intel_renderbuffer(fb->_ColorDrawBuffers[i]);
> -
> -      if (irb && irb->mt->bo == bo) {
> -         found = brw->draw_aux_buffer_disabled[i] = true;
> -      }
> -   }
> -
> -   return found;
> -}
> -
>  static void
>  intel_update_state(struct gl_context * ctx)
>  {
>     GLuint new_state = ctx->NewState;
>     struct brw_context *brw = brw_context(ctx);
> -   struct intel_texture_object *tex_obj;
> -   struct intel_renderbuffer *depth_irb;
>  
>     if (ctx->swrast_context)
>        _swrast_InvalidateState(ctx, new_state);
>  
>     brw->NewGLState |= new_state;
>  
> -   _mesa_unlock_context_textures(ctx);
> -
>     if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
>        _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
>  
> @@ -218,105 +196,6 @@ intel_update_state(struct gl_context * ctx)
>  
>     intel_prepare_render(brw);
>  
> -   /* Resolve the depth buffer's HiZ buffer. */
> -   depth_irb = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_DEPTH);
> -   if (depth_irb && depth_irb->mt) {
> -      intel_miptree_prepare_depth(brw, depth_irb->mt,
> -                                  depth_irb->mt_level,
> -                                  depth_irb->mt_layer,
> -                                  depth_irb->layer_count);
> -   }
> -
> -   memset(brw->draw_aux_buffer_disabled, 0,
> -          sizeof(brw->draw_aux_buffer_disabled));
> -
> -   /* Resolve depth buffer and render cache of each enabled texture. */
> -   int maxEnabledUnit = ctx->Texture._MaxEnabledTexImageUnit;
> -   for (int i = 0; i <= maxEnabledUnit; i++) {
> -      if (!ctx->Texture.Unit[i]._Current)
> -	 continue;
> -      tex_obj = intel_texture_object(ctx->Texture.Unit[i]._Current);
> -      if (!tex_obj || !tex_obj->mt)
> -	 continue;
> -
> -      /* We need inte_texture_object::_Format to be valid */
> -      intel_finalize_mipmap_tree(brw, i);

This one line doesn't get moved over...and that's okay, because we already
call brw_validate_textures(brw) which finalizes miptrees.  Both
brw_try_draw_prims and brw_dispatch_compute_common handle this.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170626/b3aaddbd/attachment.sig>


More information about the mesa-dev mailing list