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

Gert Wollny gert.wollny at collabora.com
Wed Jul 18 08:36:13 UTC 2018


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);
 
    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) {
-- 
2.17.1



More information about the virglrenderer-devel mailing list