From b9e475bbff1012b99b85f6cff3b2424fb5300233 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Tue, 5 Mar 2019 09:55:55 +0100 Subject: [PATCH] vrend,blit: Use the GL fallback on GLES in more cases The GL fallback also must be used on GLES if the target surface is a multi-sample surface or if the region blitted from a multi-sample surface is not equal to the target region. This patch results in piglit reporing regressions with multisample-blit * depth on a GLES host. However, these piglits make bits to MS surfaces which is not supported by glBlitFramebuffer on GLES. The old code took that path, and mesa would actually report an error when compiled with -DDEBUG butthe piglits still reported success. Unfortunately, resolving the MS propperly is quite a challange for depth textures, and requires information that is not available in the blit info (zNear and zFar), so getting these piglits to act correcly on GLES hosts seems quite impossible. v2: Also use fallback on GLES if the source is multi-sample and the formats of source and dest are not equal Signed-off-by: Gert Wollny Reviewed-by: Gurchetan Singh --- src/vrend_renderer.c | 51 +++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 84fd826..4215a2b 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -7646,6 +7646,42 @@ static void vrend_renderer_blit_int(struct vrend_context *ctx, use_gl = true; } + if (!dst_res->y_0_top) { + dst_y1 = info->dst.box.y + info->dst.box.height; + dst_y2 = info->dst.box.y; + } else { + dst_y1 = dst_res->base.height0 - info->dst.box.y - info->dst.box.height; + dst_y2 = dst_res->base.height0 - info->dst.box.y; + } + + if (!src_res->y_0_top) { + src_y1 = info->src.box.y + info->src.box.height; + src_y2 = info->src.box.y; + } else { + src_y1 = src_res->base.height0 - info->src.box.y - info->src.box.height; + src_y2 = src_res->base.height0 - info->src.box.y; + } + + /* GLES generally doesn't support blitting to a multi-sample FB, and also not + * from a multi-sample FB where the regions are not exatly the same or the + * source and target format are different. For + * downsampling DS blits to zero samples we solve this by doing two blits */ + if (vrend_state.use_gles && + (info->mask & PIPE_MASK_RGBA) && + (dst_res->base.nr_samples > 1 || + (src_res->base.nr_samples > 1 && + (info->src.box.x != info->dst.box.x || + info->src.box.width != info->dst.box.width || + dst_y1 != src_y1 || dst_y2 != src_y2 || + info->src.format != info->dst.format)) + ) + ) { + VREND_DEBUG(dbg_blit, ctx, "Use GL fallback because dst:ms:%d src:ms:%d (%d %d %d %d) -> (%d %d %d %d)\n", + dst_res->base.nr_samples, src_res->base.nr_samples, info->src.box.x, info->src.box.x + info->src.box.width, + src_y1, src_y2, info->dst.box.x, info->dst.box.x + info->dst.box.width, dst_y1, dst_y2); + use_gl = true; + } + /* for 3D mipmapped blits - hand roll time */ if (info->src.box.depth != info->dst.box.depth) use_gl = true; @@ -7676,21 +7712,6 @@ static void vrend_renderer_blit_int(struct vrend_context *ctx, if (info->mask & PIPE_MASK_RGBA) glmask |= GL_COLOR_BUFFER_BIT; - if (!dst_res->y_0_top) { - dst_y1 = info->dst.box.y + info->dst.box.height; - dst_y2 = info->dst.box.y; - } else { - dst_y1 = dst_res->base.height0 - info->dst.box.y - info->dst.box.height; - dst_y2 = dst_res->base.height0 - info->dst.box.y; - } - - if (!src_res->y_0_top) { - src_y1 = info->src.box.y + info->src.box.height; - src_y2 = info->src.box.y; - } else { - src_y1 = src_res->base.height0 - info->src.box.y - info->src.box.height; - src_y2 = src_res->base.height0 - info->src.box.y; - } if (info->scissor_enable) { glScissor(info->scissor.minx, info->scissor.miny, info->scissor.maxx - info->scissor.minx, info->scissor.maxy - info->scissor.miny);