freedreno/a6xx: Also validate format in blitter path
authorRob Clark <robdclark@chromium.org>
Sun, 13 Jun 2021 20:34:27 +0000 (13:34 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 15 Jun 2021 19:09:24 +0000 (19:09 +0000)
Since we can be blitting using a format that is different from the
resource's native format, we also need to validate and demote if
necessary, similar to sampler-views, image-views, and fb state.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11371>

src/gallium/drivers/freedreno/a6xx/fd6_blitter.c

index 8ca0d95..e0af9b3 100644 (file)
@@ -906,12 +906,18 @@ handle_rgba_blit(struct fd_context *ctx,
    if (!can_do_blit(info))
       return false;
 
+   struct fd_resource *src = fd_resource(info->src.resource);
+   struct fd_resource *dst = fd_resource(info->dst.resource);
+
+   fd6_validate_format(ctx, src, info->src.format);
+   fd6_validate_format(ctx, dst, info->dst.format);
+
    batch = fd_bc_alloc_batch(&ctx->screen->batch_cache, ctx, true);
 
    fd_screen_lock(ctx->screen);
 
-   fd_batch_resource_read(batch, fd_resource(info->src.resource));
-   fd_batch_resource_write(batch, fd_resource(info->dst.resource));
+   fd_batch_resource_read(batch, src);
+   fd_batch_resource_write(batch, dst);
 
    fd_screen_unlock(ctx->screen);
 
@@ -937,8 +943,8 @@ handle_rgba_blit(struct fd_context *ctx,
 
    if ((info->src.resource->target == PIPE_BUFFER) &&
        (info->dst.resource->target == PIPE_BUFFER)) {
-      assert(fd_resource(info->src.resource)->layout.tile_mode == TILE6_LINEAR);
-      assert(fd_resource(info->dst.resource)->layout.tile_mode == TILE6_LINEAR);
+      assert(src->layout.tile_mode == TILE6_LINEAR);
+      assert(dst->layout.tile_mode == TILE6_LINEAR);
       emit_blit_buffer(ctx, batch->draw, info);
    } else {
       /* I don't *think* we need to handle blits between buffer <-> !buffer */
@@ -956,7 +962,7 @@ handle_rgba_blit(struct fd_context *ctx,
 
    fd_batch_unlock_submit(batch);
 
-   fd_resource(info->dst.resource)->valid = true;
+   dst->valid = true;
 
    fd_batch_flush(batch);
    fd_batch_reference(&batch, NULL);