[Mesa-dev] [PATCH] i965/miptree_map_blit: Don't do the initial copy if INVALIDATE_RANGE is set

Jason Ekstrand jason at jlekstrand.net
Tue Jan 13 22:37:40 PST 2015


On Tue, Jan 13, 2015 at 6:35 PM, Kenneth Graunke <kenneth at whitecape.org>
wrote:
>
> On Tuesday, January 13, 2015 10:39:22 AM Jason Ekstrand wrote:
> > Before we were always coping from the buffer being mapped into the
> > temporary buffer.  However, if INVALIDATE_RANGE is set, then we know
that
> > the data is going to be junk after we unmap so there's no point in doing
> > the blit.  This is important because doing the blit will cause a stall 3
> > lines later when we map the buffer.
> >
> > Signed-off-by: Jason Ekstrand <jason.ekstrand at intel.com>
> > ---
> >  src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 23
+++++++++++++++--------
> >  1 file changed, 15 insertions(+), 8 deletions(-)
> >
> > diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> > index f815fbe..d44df18 100644
> > --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> > +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> > @@ -1807,14 +1807,21 @@ intel_miptree_map_blit(struct brw_context *brw,
> >     }
> >     map->stride = map->mt->pitch;
> >
> > -   if (!intel_miptree_blit(brw,
> > -                           mt, level, slice,
> > -                           map->x, map->y, false,
> > -                           map->mt, 0, 0,
> > -                           0, 0, false,
> > -                           map->w, map->h, GL_COPY)) {
> > -      fprintf(stderr, "Failed to blit\n");
> > -      goto fail;
> > +   /* One of either READ_BIT or WRITE_BIT or both is set.  READ_BIT
implies no
> > +    * INVALIDATE_RANGE_BIT.  WRITE_BIT needs the original values read
in unless
> > +    * invalidate is set, since we'll be writing the whole rectangle
from our
> > +    * temporary buffer back out.
> > +    */
> > +   if (!(map->mode & GL_MAP_INVALIDATE_RANGE_BIT)) {
> > +      if (!intel_miptree_blit(brw,
> > +                              mt, level, slice,
> > +                              map->x, map->y, false,
> > +                              map->mt, 0, 0,
> > +                              0, 0, false,
> > +                              map->w, map->h, GL_COPY)) {
> > +         fprintf(stderr, "Failed to blit\n");
> > +         goto fail;
> > +      }
> >     }
> >
> >     map->ptr = intel_miptree_map_raw(brw, map->mt);
>
> Just for the hell of it, how about
>
> if (!(map->mode & (GL_MAP_INVALIDATE_RANGE_BIT |
GL_MAP_INVALIDATE_BUFFER_BIT)))
>
> I don't think we pass INVALIDATE_BUFFER_BIT today, but we could someday,
> and the same logic applies.


Sure, it would be valid.  However, it would also be confusing as that's the
only place in the entire file where INVALIDATE_BUFFER_BIT would occur.
Let's leave it for now.  We can add INVALIDATE_BUFFER_BIT support later and
actually be clever about it then.

> Either way,
> Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

Thanks,
--Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150113/c28042df/attachment.html>


More information about the mesa-dev mailing list