freedreno: catch failing fd_blit and fallback to software blit
authorJonathan Marek <jonathan@marek.ca>
Tue, 26 Feb 2019 16:54:56 +0000 (11:54 -0500)
committerRob Clark <robdclark@gmail.com>
Wed, 27 Feb 2019 18:46:28 +0000 (18:46 +0000)
Fixes cases where the fd_blit fails and never happens (ex: blit to etc1)

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
src/gallium/drivers/freedreno/freedreno_blitter.c
src/gallium/drivers/freedreno/freedreno_blitter.h
src/gallium/drivers/freedreno/freedreno_resource.c

index f779f0fefb2bc83bcd7f7e7a21d420ae6be3504d..2687d1e426b5f5b271ac65c253830e59a7729523 100644 (file)
@@ -249,17 +249,17 @@ fd_blitter_clear(struct pipe_context *pctx, unsigned buffers,
  * Optimal hardware path for blitting pixels.
  * Scaling, format conversion, up- and downsampling (resolve) are allowed.
  */
-void
+bool
 fd_blit(struct pipe_context *pctx, const struct pipe_blit_info *blit_info)
 {
        struct fd_context *ctx = fd_context(pctx);
        struct pipe_blit_info info = *blit_info;
 
        if (info.render_condition_enable && !fd_render_condition_check(pctx))
-               return;
+               return true;
 
        if (ctx->blit && ctx->blit(ctx, &info))
-               return;
+               return true;
 
        if (info.mask & PIPE_MASK_S) {
                DBG("cannot blit stencil, skipping");
@@ -270,10 +270,10 @@ fd_blit(struct pipe_context *pctx, const struct pipe_blit_info *blit_info)
                DBG("blit unsupported %s -> %s",
                                util_format_short_name(info.src.resource->format),
                                util_format_short_name(info.dst.resource->format));
-               return;
+               return false;
        }
 
-       fd_blitter_blit(ctx, &info);
+       return fd_blitter_blit(ctx, &info);
 }
 
 /**
index 1a58ad69959538b402a7d5eea81e8e3b8b02a927..669893961e882d621ef46ca4e2ef1ae1b9c7a4a2 100644 (file)
@@ -45,6 +45,6 @@ void fd_resource_copy_region(struct pipe_context *pctx,
                unsigned src_level,
                const struct pipe_box *src_box);
 
-void fd_blit(struct pipe_context *pctx, const struct pipe_blit_info *blit_info);
+bool fd_blit(struct pipe_context *pctx, const struct pipe_blit_info *blit_info);
 
 #endif /* FREEDRENO_BLIT_H_ */
index 144d725fdec8b1fc0283155b6576cbfafed72ea1..5635d8ffde7b7621b24a1604544c761f6526d664 100644 (file)
@@ -126,10 +126,7 @@ do_blit(struct fd_context *ctx, const struct pipe_blit_info *blit, bool fallback
        struct pipe_context *pctx = &ctx->base;
 
        /* TODO size threshold too?? */
-       if (!fallback) {
-               /* do blit on gpu: */
-               pctx->blit(pctx, blit);
-       } else {
+       if (fallback || !fd_blit(pctx, blit)) {
                /* do blit on cpu: */
                util_resource_copy_region(pctx,
                                blit->dst.resource, blit->dst.level, blit->dst.box.x,
@@ -1255,6 +1252,13 @@ fd_get_sample_position(struct pipe_context *context,
        pos_out[1] = ptr[sample_index][1] / 16.0f;
 }
 
+static void
+fd_blit_pipe(struct pipe_context *pctx, const struct pipe_blit_info *blit_info)
+{
+       /* wrap fd_blit to return void */
+       fd_blit(pctx, blit_info);
+}
+
 void
 fd_resource_context_init(struct pipe_context *pctx)
 {
@@ -1266,7 +1270,7 @@ fd_resource_context_init(struct pipe_context *pctx)
        pctx->create_surface = fd_create_surface;
        pctx->surface_destroy = fd_surface_destroy;
        pctx->resource_copy_region = fd_resource_copy_region;
-       pctx->blit = fd_blit;
+       pctx->blit = fd_blit_pipe;
        pctx->flush_resource = fd_flush_resource;
        pctx->invalidate_resource = fd_invalidate_resource;
        pctx->get_sample_position = fd_get_sample_position;