[Mesa-dev] [PATCH 2/4] gallium: Plumb the swap INVALIDATE_ANCILLARY flag through more layers.

Jose Fonseca jfonseca at vmware.com
Mon Dec 29 06:57:41 PST 2014


IIUC, "ancillary" here means depth/stencil buffer associated with the 
framebuffer.

So basically PIPE_FLUSH_INVALIDATE_ANCILLARY you're proposing will 
invalidate the currently bound pipe_framebuffer_state::zsbuf.


I think we eventually will want a more general invalidate pipe_context 
method, as some APIs enable that too.  See for example

   http://msdn.microsoft.com/en-us/library/windows/desktop/hh404616.aspx

and

 
https://www.khronos.org/registry/gles/extensions/EXT/EXT_discard_framebuffer.txt

That is, we'll want to add to pipe_context something like

    void (*discard_surface)(pipe_context *, pipe_surface *);

    void (*discard_sampler_view)(pipe_context *, pipe_sampler_view *);


You already implemented PIPE_FLUSH_INVALIDATE_ANCILLARY but I think it 
would save everybody time to aim straight to a more future proof 
solution, and add discard_surface now.


I believe that for your needs, discard_surface would suffice.  It's fine 
to defer discard_sampler_view until it's actually needed.   Also, 
instead of adding a dummy discard_surface to every driver, I think it's 
fine to leave that method as NULL pointer on all drivers except the ones 
that actually implement it (and trace driver), and check the method 
pointer for NULL before calling it.


Jose


On 26/12/14 18:45, Eric Anholt wrote:
> ---
>   src/gallium/include/pipe/p_defines.h          | 3 ++-
>   src/gallium/include/state_tracker/st_api.h    | 1 +
>   src/gallium/state_trackers/dri/dri_drawable.c | 2 ++
>   src/mesa/state_tracker/st_manager.c           | 3 +++
>   4 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
> index 6c5703a..89f0065 100644
> --- a/src/gallium/include/pipe/p_defines.h
> +++ b/src/gallium/include/pipe/p_defines.h
> @@ -322,7 +322,8 @@ enum pipe_transfer_usage {
>    * Flags for the flush function.
>    */
>   enum pipe_flush_flags {
> -   PIPE_FLUSH_END_OF_FRAME = (1 << 0)
> +   PIPE_FLUSH_END_OF_FRAME = (1 << 0),
> +   PIPE_FLUSH_INVALIDATE_ANCILLARY = (1 << 1),
>   };
>
>   /**
> diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h
> index 86fdc69..2b42ac5 100644
> --- a/src/gallium/include/state_tracker/st_api.h
> +++ b/src/gallium/include/state_tracker/st_api.h
> @@ -159,6 +159,7 @@ enum st_context_resource_type {
>    */
>   #define ST_FLUSH_FRONT                    (1 << 0)
>   #define ST_FLUSH_END_OF_FRAME             (1 << 1)
> +#define ST_FLUSH_INVALIDATE_ANCILLARY     (1 << 2)
>
>   /**
>    * Value to st_manager->get_param function.
> diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c
> index b7df053..668cfb8 100644
> --- a/src/gallium/state_trackers/dri/dri_drawable.c
> +++ b/src/gallium/state_trackers/dri/dri_drawable.c
> @@ -491,6 +491,8 @@ dri_flush(__DRIcontext *cPriv,
>         flush_flags |= ST_FLUSH_FRONT;
>      if (reason == __DRI2_THROTTLE_SWAPBUFFER)
>         flush_flags |= ST_FLUSH_END_OF_FRAME;
> +   if (flags & __DRI2_FLUSH_INVALIDATE_ANCILLARY)
> +      flush_flags |= ST_FLUSH_INVALIDATE_ANCILLARY;
>
>      /* Flush the context and throttle if needed. */
>      if (dri_screen(ctx->sPriv)->throttling_enabled &&
> diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
> index 606d678..10839eb 100644
> --- a/src/mesa/state_tracker/st_manager.c
> +++ b/src/mesa/state_tracker/st_manager.c
> @@ -499,6 +499,9 @@ st_context_flush(struct st_context_iface *stctxi, unsigned flags,
>      if (flags & ST_FLUSH_END_OF_FRAME) {
>         pipe_flags |= PIPE_FLUSH_END_OF_FRAME;
>      }
> +   if (flags & ST_FLUSH_INVALIDATE_ANCILLARY) {
> +      pipe_flags |= PIPE_FLUSH_INVALIDATE_ANCILLARY;
> +   }
>
>      st_flush(st, fence, pipe_flags);
>      if (flags & ST_FLUSH_FRONT)
>



More information about the mesa-dev mailing list