broadcom/vc4: Add support for YUV textures using unaccelerated blits.
authorEric Anholt <eric@anholt.net>
Fri, 23 Feb 2018 01:43:21 +0000 (17:43 -0800)
committerEric Anholt <eric@anholt.net>
Fri, 23 Feb 2018 16:42:13 +0000 (08:42 -0800)
Previously we would assertion fail about having no hardware format.  This
is enough to get kmscube -M nv12-2img working.

src/gallium/drivers/vc4/vc4_blit.c
src/gallium/drivers/vc4/vc4_resource.c
src/gallium/drivers/vc4/vc4_state.c

index 7f4c76968e775920a1f37d2ed59693fd11d1be77..f23f74c8f16987c1ff733d8ea17bcd53738070dd 100644 (file)
@@ -183,6 +183,32 @@ vc4_blitter_save(struct vc4_context *vc4)
                         vc4->fragtex.num_textures, vc4->fragtex.textures);
 }
 
+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)
 {
@@ -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;
 
index 202f62c8f0459dd2b42e2fb61277a8160c0a3acc..eee17472fceeed03af8ed165135628d0e4f9b669 100644 (file)
@@ -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;
                 }
         }
 
index 7bc87b0c4ee31099d85c190798d1f5c37a9fef10..c85618789a6dee7ba5f9ae6509de15a445a9fdae 100644 (file)
@@ -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,