[Mesa-dev] [PATCH] st-api: Rework how drawables are invalidated v2

Chia-I Wu olv at lunarg.com
Wed Jun 29 03:18:01 PDT 2011


On Wed, Jun 29, 2011 at 4:12 PM, Thomas Hellstrom <thellstrom at vmware.com> wrote:
[snipped]
> diff --git a/src/gallium/state_trackers/vega/vg_manager.c b/src/gallium/state_trackers/vega/vg_manager.c
> index eeea686..dec1581 100644
> --- a/src/gallium/state_trackers/vega/vg_manager.c
> +++ b/src/gallium/state_trackers/vega/vg_manager.c
> @@ -106,35 +106,38 @@ vg_manager_validate_framebuffer(struct vg_context *ctx)
>  {
>    struct st_framebuffer *stfb = ctx->draw_buffer;
>    struct pipe_resource *pt;
> +   int32_t new_stamp;
>
>    /* no binding surface */
>    if (!stfb)
>       return;
>
> -   if (!p_atomic_read(&ctx->draw_buffer_invalid))
> -      return;
> +   new_stamp = p_atomic_read(&stfb->iface->stamp);
> +   if (stfb->iface_stamp != new_stamp) {
> +      do {
> +        /* validate the fb */
> +        if (!stfb->iface->validate(stfb->iface, &stfb->strb_att,
> +                                   1, &pt) || !pt)
> +           return;
>
> -   /* validate the fb */
> -   if (!stfb->iface->validate(stfb->iface, &stfb->strb_att, 1, &pt) || !pt)
> -      return;
> +        stfb->iface_stamp = new_stamp;
> +        new_stamp = p_atomic_read(&stfb->iface->stamp);
>
> -   p_atomic_set(&ctx->draw_buffer_invalid, FALSE);
> +      } while (stfb->iface_stamp != new_stamp);
If we change the st_framebuffer_iface::validate to also return the
stamp of the returned resources, we can validate the framebuffer with
a simpler loop

   // pseudo-code; error should be checked
   while (stfb->iface_stamp != p_atomic_read(&stfb->iface->stamp))
      stfb->iface->validate(stfb->iface, &stfb->iface_stamp, ...);

That said, this patch looks good to me.  We can do that with follow-on commits.

-- 
olv at LunarG.com


More information about the mesa-dev mailing list