[virglrenderer-devel] [PATCH v2] vrend: use the row-stride when directly reading back to an IOV

Gert Wollny gert.wollny at collabora.com
Thu Jul 26 16:49:44 UTC 2018


Am Donnerstag, den 26.07.2018, 16:02 +0200 schrieb Nathan Gauër:
> Hi,
> 
> On 07/18/2018 10:36 AM, Gert Wollny wrote:
> > When guest mesa does a glReadPixel call, it expects the data to be
> > placed
> > with correct row strides into the readback buffer. While for calls
> > that
> > invert or require more then one IOV this is done in
> > write_transfer_data,
> > for a read that only uses a small area and offset making it fit
> > into the
> > first IOV this was not done. Consequently, in this case configure
> > the
> > PACK_ROW_LENGTH accordingly.
> > 
> > v2: fix whitespace issues
> > 
> > This fixes a number of piglits:
> >    arb_copy_image-targets (for texture_2d source or dest, non-
> > compressed)
> >    arb_get_texture_multisample/sample_position
> >    arb_texture_rectangle/fbo-blit rect
> >    arb_get_texture__sub_image-cubemap
> > 
> > Signed-off-by: Gert Wollny <gert.wollny at collabora.com>
> > ---
> >  src/vrend_renderer.c | 9 ++++++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> > 
> > diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
> > index 9a22214..4f87925 100644
> > --- a/src/vrend_renderer.c
> > +++ b/src/vrend_renderer.c
> > @@ -5709,6 +5709,7 @@ static int
> > vrend_transfer_send_readpixels(struct vrend_context *ctx,
> >     uint32_t h = u_minify(res->base.height0, info->level);
> >     int elsize = util_format_get_blocksize(res->base.format);
> >     float depth_scale;
> > +   int row_stride = info->stride;
> >  
> >     vrend_use_program(ctx, 0);
> >  
> > @@ -5734,6 +5735,8 @@ static int
> > vrend_transfer_send_readpixels(struct vrend_context *ctx,
> >     } else {
> >        send_size = iov[0].iov_len - info->offset;
> >        data = myptr;
> > +      if (!row_stride)
> > +         row_stride = util_format_get_nblocksx(res->base.format,
> > u_minify(res->base.width0, info->level));
> >     }
> >  
> >     if (res->readback_fb_id == 0 || (int)res->readback_fb_level !=
> > info->level ||
> > @@ -5771,8 +5774,8 @@ static int
> > vrend_transfer_send_readpixels(struct vrend_context *ctx,
> >        glPixelStorei(GL_PACK_INVERT_MESA, 1);
> >     if (!vrend_format_is_ds(res->base.format))
> >        glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
> > -   if (!need_temp && info->stride)
> > -      glPixelStorei(GL_PACK_ROW_LENGTH, info->stride / elsize);
> > +   if (!need_temp && row_stride)
> > +      glPixelStorei(GL_PACK_ROW_LENGTH, row_stride);
> 
> This addition seams to trigger a blank screen on glxgears.
> to reproduce: run vtest server. Run glxgears using vtest backend.
> result: the frame-buffer is black

I can reproduce this virglrenderer: git cd14ff177
mesh: master-git 82fc6bdeb

I'm actually quite surprised that virglrenderer needs to call 
vrend_transfer_send_readpixels for running glxgears, and in fact, when
running glxgears in the qemu guest, it doesn't call that function. 

> 
> changing this last line to:
> 	glPixelStorei(GL_PACK_ROW_LENGTH, row_stride / elsize);
> seams to fix this issue..

I found the problem: vtest sends the actual row stride (something that
qemu never does), when I converted the code I ignored that this value
needs to be corrected.  Send iout a patch shortly.

Best, 
Gert 

> 
> >  
> >     switch (elsize) {
> >     case 1:
> > @@ -5845,7 +5848,7 @@ static int
> > vrend_transfer_send_readpixels(struct vrend_context *ctx,
> >     }
> >     if (vrend_state.have_mesa_invert && actually_invert)
> >        glPixelStorei(GL_PACK_INVERT_MESA, 0);
> > -   if (!need_temp && info->stride)
> > +   if (!need_temp && row_stride)
> >        glPixelStorei(GL_PACK_ROW_LENGTH, 0);
> >     glPixelStorei(GL_PACK_ALIGNMENT, 4);
> >     if (need_temp) {
> > 
> 
> 


More information about the virglrenderer-devel mailing list