[Mesa-dev] [PATCH] mesa: don't map depth+stencil buffer twice in glReadPixels()
Vadim Girlin
vadimgirlin at gmail.com
Wed Nov 16 08:54:37 PST 2011
On Wed, 2011-11-16 at 20:41 +0400, Vadim Girlin wrote:
> On Wed, 2011-11-16 at 07:53 -0700, Brian Paul wrote:
> > In slow_read_depth_stencil_pixels_separate() we might have separate
> > depth and stencil buffers or a combined buffer. In the later case,
> > don't map the buffer twice. This function is used when the depth
> > scale/bias pixel transfer values are not the defaults.
> >
> > Fixes http://bugs.freedesktop.org/show_bug.cgi?id=42963
> > ---
> > src/mesa/main/readpix.c | 14 +++++++++++---
> > 1 files changed, 11 insertions(+), 3 deletions(-)
> >
> > diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
> > index 8550618..0b41de6 100644
> > --- a/src/mesa/main/readpix.c
> > +++ b/src/mesa/main/readpix.c
> > @@ -402,10 +402,16 @@ slow_read_depth_stencil_pixels_separate(struct gl_context *ctx,
> > GLubyte *depthMap, *stencilMap;
> > int depthStride, stencilStride, j;
> >
> > + /* The depth and stencil buffers might be separate, or a single buffer.
> > + * If one buffer, only map it once.
> > + */
> > ctx->Driver.MapRenderbuffer(ctx, depthRb, x, y, width, height,
> > GL_MAP_READ_BIT, &depthMap, &depthStride);
> > - ctx->Driver.MapRenderbuffer(ctx, stencilRb, x, y, width, height,
> > - GL_MAP_READ_BIT, &stencilMap, &stencilStride);
> > + if (stencilRb != depthRb) {
> > + ctx->Driver.MapRenderbuffer(ctx, stencilRb, x, y, width, height,
> > + GL_MAP_READ_BIT, &stencilMap,
> > + &stencilStride);
> > + }
> >
>
> Probably we want the following here:
>
> else
> stencilMap = depthMap;
>
>
And I also forgot stencilStride.
Vadim
> Vadim
>
> > for (j = 0; j < height; j++) {
> > GLubyte stencilVals[MAX_WIDTH];
> > @@ -424,7 +430,9 @@ slow_read_depth_stencil_pixels_separate(struct gl_context *ctx,
> > }
> >
> > ctx->Driver.UnmapRenderbuffer(ctx, depthRb);
> > - ctx->Driver.UnmapRenderbuffer(ctx, stencilRb);
> > + if (stencilRb != depthRb) {
> > + ctx->Driver.UnmapRenderbuffer(ctx, stencilRb);
> > + }
> > }
> >
> >
>
>
>
More information about the mesa-dev
mailing list