v3d: Fix blitting from a linear winsys BO.
authorEric Anholt <eric@anholt.net>
Mon, 18 Jun 2018 22:46:53 +0000 (15:46 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 19 Jun 2018 16:42:20 +0000 (09:42 -0700)
This is the case for the simulator environment, and broke many blitter
tests by trying to texture from linear while the HW can only actually do
UIF/UBLINEAR/LT.  Just make a temporary and copy into it with the CPU,
then blit from that.

This is the kind of path that should use the TFU, but I haven't exposed
that hardware yet.

Fixes dEQP-GLES3.functional.fbo.blit.default_framebuffer.*

src/gallium/drivers/v3d/v3d_blit.c

index 6e609fb..1a0406a 100644 (file)
@@ -195,6 +195,40 @@ static bool
 v3d_render_blit(struct pipe_context *ctx, struct pipe_blit_info *info)
 {
         struct v3d_context *v3d = v3d_context(ctx);
+        struct v3d_resource *src = v3d_resource(info->src.resource);
+        struct pipe_resource *tiled = NULL;
+
+        if (!src->tiled) {
+                struct pipe_box box = {
+                        .x = 0,
+                        .y = 0,
+                        .width = u_minify(info->src.resource->width0,
+                                           info->src.level),
+                        .height = u_minify(info->src.resource->height0,
+                                           info->src.level),
+                        .depth = 1,
+                };
+                struct pipe_resource tmpl = {
+                        .target = info->src.resource->target,
+                        .format = info->src.resource->format,
+                        .width0 = box.width,
+                        .height0 = box.height,
+                        .depth0 = 1,
+                        .array_size = 1,
+                };
+                tiled = ctx->screen->resource_create(ctx->screen, &tmpl);
+                if (!tiled) {
+                        fprintf(stderr, "Failed to create tiled blit temp\n");
+                        return false;
+                }
+                ctx->resource_copy_region(ctx,
+                                          tiled, 0,
+                                          0, 0, 0,
+                                          info->src.resource, info->src.level,
+                                          &box);
+                info->src.level = 0;
+                info->src.resource = tiled;
+        }
 
         if (!util_blitter_is_blit_supported(v3d->blitter, info)) {
                 fprintf(stderr, "blit unsupported %s -> %s\n",
@@ -206,6 +240,8 @@ v3d_render_blit(struct pipe_context *ctx, struct pipe_blit_info *info)
         v3d_blitter_save(v3d);
         util_blitter_blit(v3d->blitter, info);
 
+        pipe_resource_reference(&tiled, NULL);
+
         return true;
 }