From 257cf11b520bb25ea0ae104041b174c8b289bc82 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Tue, 7 Aug 2018 19:45:00 +0200 Subject: [PATCH] vrend: correct blit/copy_image code path Gallium copy_image redirects calls to resource_copy_region for equal src and dst formats or if at least one of the two is compressed. Handle the condition for selecting blit vs. glCopyImageSubRegion accordingly. Fixes piglit: bptc-float-modes Signed-off-by: Gert Wollny Signed-off-by: Dave Airlie --- src/vrend_formats.c | 6 +++++- src/vrend_renderer.c | 28 +++++++++++++++------------- src/vrend_renderer.h | 3 ++- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/vrend_formats.c b/src/vrend_formats.c index 34371c9..c9afe88 100644 --- a/src/vrend_formats.c +++ b/src/vrend_formats.c @@ -581,7 +581,8 @@ static boolean format_compressed_compressed_copy_compatible(enum pipe_format src return false; } -boolean format_is_copy_compatible(enum pipe_format src, enum pipe_format dst) +boolean format_is_copy_compatible(enum pipe_format src, enum pipe_format dst, + boolean allow_compressed) { int r; @@ -594,6 +595,9 @@ boolean format_is_copy_compatible(enum pipe_format src, enum pipe_format dst) return util_is_format_compatible(src_desc, dst_desc); } + if (!allow_compressed) + return false; + /* compressed-uncompressed */ r = format_uncompressed_compressed_copy_compatible(src, dst); if (r) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 17af9b0..fb1744a 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -7033,13 +7033,12 @@ void vrend_renderer_resource_copy_region(struct vrend_context *ctx, return; } - if (has_feature(feat_copy_image)) { - if (format_is_copy_compatible(src_res->base.format,dst_res->base.format) && - src_res->base.nr_samples == dst_res->base.nr_samples) { - vrend_copy_sub_image(src_res, dst_res, src_level, src_box, - dst_level, dstx, dsty, dstz); - return; - } + if (has_feature(feat_copy_image) && + format_is_copy_compatible(src_res->base.format,dst_res->base.format, true) && + src_res->base.nr_samples == dst_res->base.nr_samples) { + vrend_copy_sub_image(src_res, dst_res, src_level, src_box, + dst_level, dstx, dsty, dstz); + return; } if (!vrend_format_can_render(src_res->base.format) || @@ -7325,13 +7324,16 @@ void vrend_renderer_blit(struct vrend_context *ctx, if (info->render_condition_enable == false) vrend_pause_render_condition(ctx, true); - /* The gallium blit function can be called for a general blit that may - * scale, convert the data, and apply some rander states or if is called via - * glCopyImageSubData. For the latter case forward the call to the - * glCopyImageSubData function, otherwise use a framebuffer blit. - */ + /* The Gallium blit function can be called for a general blit that may + * scale, convert the data, and apply some rander states, or it is called via + * glCopyImageSubData. If the src or the dst image are equal, or the two + * images formats are the same, then Galliums such calles are redirected + * to resource_copy_region, in this case and if no render states etx need + * to be applied, forward the call to glCopyImageSubData, otherwise do a + * normal blit. */ if (has_feature(feat_copy_image) && !info->render_condition_enable && - format_is_copy_compatible(info->src.format,info->dst.format) && + (src_res->base.format != dst_res->base.format) && + format_is_copy_compatible(info->src.format,info->dst.format, false) && !info->scissor_enable && (info->filter == PIPE_TEX_FILTER_NEAREST) && !info->alpha_blend && (info->mask == PIPE_MASK_RGBA) && (src_res->base.nr_samples == dst_res->base.nr_samples) && diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h index 06fff6f..c189d82 100644 --- a/src/vrend_renderer.h +++ b/src/vrend_renderer.h @@ -390,7 +390,8 @@ void vrend_fb_bind_texture(struct vrend_resource *res, uint32_t level, uint32_t layer); bool vrend_is_ds_format(enum virgl_formats format); bool vrend_format_is_emulated_alpha(enum virgl_formats format); -boolean format_is_copy_compatible(enum pipe_format src, enum pipe_format dst); +boolean format_is_copy_compatible(enum pipe_format src, enum pipe_format dst, + boolean allow_compressed); /* blitter interface */ void vrend_renderer_blit_gl(struct vrend_context *ctx,