diff options
author | Eric Anholt <[email protected]> | 2018-02-22 17:43:21 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2018-02-23 08:42:13 -0800 |
commit | bc3d16e633fd27b05dfdcda0b7efb000b2c35ed6 (patch) | |
tree | e925a103a0a4f855f690609ad27631bc954935da | |
parent | c824a045ea639b8a93cbc2518b16900402d9150f (diff) |
broadcom/vc4: Add support for YUV textures using unaccelerated blits.
Previously we would assertion fail about having no hardware format. This
is enough to get kmscube -M nv12-2img working.
-rw-r--r-- | src/gallium/drivers/vc4/vc4_blit.c | 29 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_resource.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_state.c | 3 |
3 files changed, 35 insertions, 3 deletions
diff --git a/src/gallium/drivers/vc4/vc4_blit.c b/src/gallium/drivers/vc4/vc4_blit.c index 7f4c76968e7..f23f74c8f16 100644 --- a/src/gallium/drivers/vc4/vc4_blit.c +++ b/src/gallium/drivers/vc4/vc4_blit.c @@ -184,6 +184,32 @@ vc4_blitter_save(struct vc4_context *vc4) } static bool +vc4_yuv_blit(struct pipe_context *pctx, const struct pipe_blit_info *info) +{ + struct vc4_resource *src = vc4_resource(info->src.resource); + struct vc4_resource *dst = vc4_resource(info->dst.resource); + bool ok; + + if (src->tiled) + return false; + if (src->base.format != PIPE_FORMAT_R8_UNORM && + src->base.format != PIPE_FORMAT_R8G8_UNORM) + return false; + + /* YUV blits always turn raster-order to tiled */ + assert(dst->base.format == src->base.format); + assert(dst->tiled); + + /* Do an immediate SW fallback, since the render blit path + * would just recurse. + */ + ok = util_try_blit_via_copy_region(pctx, info); + assert(ok); (void)ok; + + return true; +} + +static bool vc4_render_blit(struct pipe_context *ctx, struct pipe_blit_info *info) { struct vc4_context *vc4 = vc4_context(ctx); @@ -218,6 +244,9 @@ vc4_blit(struct pipe_context *pctx, const struct pipe_blit_info *blit_info) { struct pipe_blit_info info = *blit_info; + if (vc4_yuv_blit(pctx, blit_info)) + return; + if (vc4_tile_blit(pctx, blit_info)) return; diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c index 202f62c8f04..eee17472fce 100644 --- a/src/gallium/drivers/vc4/vc4_resource.c +++ b/src/gallium/drivers/vc4/vc4_resource.c @@ -564,8 +564,10 @@ get_resource_texture_format(struct pipe_resource *prsc) if (prsc->nr_samples > 1) { return ~0; } else { - assert(format == VC4_TEXTURE_TYPE_RGBA8888); - return VC4_TEXTURE_TYPE_RGBA32R; + if (format == VC4_TEXTURE_TYPE_RGBA8888) + return VC4_TEXTURE_TYPE_RGBA32R; + else + return ~0; } } diff --git a/src/gallium/drivers/vc4/vc4_state.c b/src/gallium/drivers/vc4/vc4_state.c index 7bc87b0c4ee..c85618789a6 100644 --- a/src/gallium/drivers/vc4/vc4_state.c +++ b/src/gallium/drivers/vc4/vc4_state.c @@ -581,7 +581,8 @@ vc4_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc, */ if ((cso->u.tex.first_level && (cso->u.tex.first_level != cso->u.tex.last_level)) || - rsc->vc4_format == VC4_TEXTURE_TYPE_RGBA32R) { + rsc->vc4_format == VC4_TEXTURE_TYPE_RGBA32R || + rsc->vc4_format == ~0) { struct vc4_resource *shadow_parent = rsc; struct pipe_resource tmpl = { .target = prsc->target, |