diff options
author | Brian Paul <[email protected]> | 2016-06-23 08:11:25 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2016-06-30 14:32:06 -0600 |
commit | 5f1335878e26784e2b006622fd315f89b66782f4 (patch) | |
tree | 04bd3c6332d10f0262a7721ad45451c2d275b1ca /src/gallium | |
parent | a029d9f074c510d86c487b249f4ca535e8782df7 (diff) |
gallium/util: add tight_format_check param to util_can_blit_via_copy_region()
The VMware driver will use this for implementing GL_ARB_copy_image.
Reviewed-by: Marek Olšák <[email protected]>
Reviewed-by: Roland Scheidegger <[email protected]>
Reviewed-by: Charmaine Lee <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/auxiliary/util/u_surface.c | 38 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_surface.h | 3 |
2 files changed, 30 insertions, 11 deletions
diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c index e2229bc7d13..e0234f8d15e 100644 --- a/src/gallium/auxiliary/util/u_surface.c +++ b/src/gallium/auxiliary/util/u_surface.c @@ -687,19 +687,37 @@ get_sample_count(const struct pipe_resource *res) } +/** + * Check if a blit() command can be implemented with a resource_copy_region(). + * If tight_format_check is true, only allow the resource_copy_region() if + * the blit src/dst formats are identical, ignoring the resource formats. + * Otherwise, check for format casting and compatibility. + */ boolean -util_can_blit_via_copy_region(const struct pipe_blit_info *blit) +util_can_blit_via_copy_region(const struct pipe_blit_info *blit, + boolean tight_format_check) { - unsigned mask = util_format_get_mask(blit->dst.format); + const struct util_format_description *src_desc, *dst_desc; - /* No format conversions. */ - if (blit->src.resource->format != blit->src.format || - blit->dst.resource->format != blit->dst.format || - !util_is_format_compatible( - util_format_description(blit->src.resource->format), - util_format_description(blit->dst.resource->format))) { - return FALSE; + src_desc = util_format_description(blit->src.resource->format); + dst_desc = util_format_description(blit->dst.resource->format); + + if (tight_format_check) { + /* no format conversions allowed */ + if (blit->src.format != blit->dst.format) { + return FALSE; + } } + else { + /* do loose format compatibility checking */ + if (blit->src.resource->format != blit->src.format || + blit->dst.resource->format != blit->dst.format || + !util_is_format_compatible(src_desc, dst_desc)) { + return FALSE; + } + } + + unsigned mask = util_format_get_mask(blit->dst.format); /* No masks, no filtering, no scissor, no blending */ if ((blit->mask & mask) != mask || @@ -752,7 +770,7 @@ boolean util_try_blit_via_copy_region(struct pipe_context *ctx, const struct pipe_blit_info *blit) { - if (util_can_blit_via_copy_region(blit)) { + if (util_can_blit_via_copy_region(blit, FALSE)) { ctx->resource_copy_region(ctx, blit->dst.resource, blit->dst.level, blit->dst.box.x, blit->dst.box.y, blit->dst.box.z, diff --git a/src/gallium/auxiliary/util/u_surface.h b/src/gallium/auxiliary/util/u_surface.h index bda2e1e9243..64a685b8264 100644 --- a/src/gallium/auxiliary/util/u_surface.h +++ b/src/gallium/auxiliary/util/u_surface.h @@ -99,7 +99,8 @@ util_clear_depth_stencil(struct pipe_context *pipe, unsigned width, unsigned height); boolean -util_can_blit_via_copy_region(const struct pipe_blit_info *blit); +util_can_blit_via_copy_region(const struct pipe_blit_info *blit, + boolean tight_format_check); extern boolean util_try_blit_via_copy_region(struct pipe_context *ctx, |