freedreno: move fd_resource_copy_region()
authorRob Clark <robdclark@gmail.com>
Thu, 13 Dec 2018 14:14:48 +0000 (09:14 -0500)
committerRob Clark <robdclark@gmail.com>
Thu, 13 Dec 2018 20:51:01 +0000 (15:51 -0500)
Code-motion prep for next patch.

Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/freedreno_blitter.c
src/gallium/drivers/freedreno/freedreno_blitter.h
src/gallium/drivers/freedreno/freedreno_resource.c

index 6fab261df9c3431498a73d00b78b057dea55d1bd..f1ed5381bfc3b04fbbf5eeb7ffa78493ff3da212 100644 (file)
  */
 
 #include "util/u_blitter.h"
+#include "util/u_surface.h"
 
 #include "freedreno_blitter.h"
 #include "freedreno_context.h"
+#include "freedreno_resource.h"
 
 /* generic blit using u_blitter.. slightly modified version of util_blitter_blit
  * which also handles PIPE_BUFFER:
@@ -110,3 +112,65 @@ fd_blitter_blit(struct fd_context *ctx, const struct pipe_blit_info *info)
        pipe_surface_reference(&dst_view, NULL);
        pipe_sampler_view_reference(&src_view, NULL);
 }
+
+/**
+ * _copy_region using pipe (3d engine)
+ */
+static bool
+fd_blitter_pipe_copy_region(struct fd_context *ctx,
+               struct pipe_resource *dst,
+               unsigned dst_level,
+               unsigned dstx, unsigned dsty, unsigned dstz,
+               struct pipe_resource *src,
+               unsigned src_level,
+               const struct pipe_box *src_box)
+{
+       /* not until we allow rendertargets to be buffers */
+       if (dst->target == PIPE_BUFFER || src->target == PIPE_BUFFER)
+               return false;
+
+       if (!util_blitter_is_copy_supported(ctx->blitter, dst, src))
+               return false;
+
+       /* TODO we could discard if dst box covers dst level fully.. */
+       fd_blitter_pipe_begin(ctx, false, false, FD_STAGE_BLIT);
+       util_blitter_copy_texture(ctx->blitter,
+                       dst, dst_level, dstx, dsty, dstz,
+                       src, src_level, src_box);
+       fd_blitter_pipe_end(ctx);
+
+       return true;
+}
+
+/**
+ * Copy a block of pixels from one resource to another.
+ * The resource must be of the same format.
+ * Resources with nr_samples > 1 are not allowed.
+ */
+void
+fd_resource_copy_region(struct pipe_context *pctx,
+               struct pipe_resource *dst,
+               unsigned dst_level,
+               unsigned dstx, unsigned dsty, unsigned dstz,
+               struct pipe_resource *src,
+               unsigned src_level,
+               const struct pipe_box *src_box)
+{
+       struct fd_context *ctx = fd_context(pctx);
+
+       /* TODO if we have 2d core, or other DMA engine that could be used
+        * for simple copies and reasonably easily synchronized with the 3d
+        * core, this is where we'd plug it in..
+        */
+
+       /* try blit on 3d pipe: */
+       if (fd_blitter_pipe_copy_region(ctx,
+                       dst, dst_level, dstx, dsty, dstz,
+                       src, src_level, src_box))
+               return;
+
+       /* else fallback to pure sw: */
+       util_resource_copy_region(pctx,
+                       dst, dst_level, dstx, dsty, dstz,
+                       src, src_level, src_box);
+}
index 9d213b577b5e76157807ea9bfb43af672c587e97..1fe85a840a6071e697b3368f0b27d582d3099b88 100644 (file)
 
 void fd_blitter_blit(struct fd_context *ctx, const struct pipe_blit_info *info);
 
+void fd_resource_copy_region(struct pipe_context *pctx,
+               struct pipe_resource *dst,
+               unsigned dst_level,
+               unsigned dstx, unsigned dsty, unsigned dstz,
+               struct pipe_resource *src,
+               unsigned src_level,
+               const struct pipe_box *src_box);
+
 #endif /* FREEDRENO_BLIT_H_ */
index e59dc96ce35d4cc152daa3e3f9ab0e240ec8d76d..06e68af3a829d7bba3d593e33436c33a2a3f68a3 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "freedreno_resource.h"
 #include "freedreno_batch_cache.h"
+#include "freedreno_blitter.h"
 #include "freedreno_fence.h"
 #include "freedreno_screen.h"
 #include "freedreno_surface.h"
@@ -957,68 +958,6 @@ fail:
        return NULL;
 }
 
-/**
- * _copy_region using pipe (3d engine)
- */
-static bool
-fd_blitter_pipe_copy_region(struct fd_context *ctx,
-               struct pipe_resource *dst,
-               unsigned dst_level,
-               unsigned dstx, unsigned dsty, unsigned dstz,
-               struct pipe_resource *src,
-               unsigned src_level,
-               const struct pipe_box *src_box)
-{
-       /* not until we allow rendertargets to be buffers */
-       if (dst->target == PIPE_BUFFER || src->target == PIPE_BUFFER)
-               return false;
-
-       if (!util_blitter_is_copy_supported(ctx->blitter, dst, src))
-               return false;
-
-       /* TODO we could discard if dst box covers dst level fully.. */
-       fd_blitter_pipe_begin(ctx, false, false, FD_STAGE_BLIT);
-       util_blitter_copy_texture(ctx->blitter,
-                       dst, dst_level, dstx, dsty, dstz,
-                       src, src_level, src_box);
-       fd_blitter_pipe_end(ctx);
-
-       return true;
-}
-
-/**
- * Copy a block of pixels from one resource to another.
- * The resource must be of the same format.
- * Resources with nr_samples > 1 are not allowed.
- */
-static void
-fd_resource_copy_region(struct pipe_context *pctx,
-               struct pipe_resource *dst,
-               unsigned dst_level,
-               unsigned dstx, unsigned dsty, unsigned dstz,
-               struct pipe_resource *src,
-               unsigned src_level,
-               const struct pipe_box *src_box)
-{
-       struct fd_context *ctx = fd_context(pctx);
-
-       /* TODO if we have 2d core, or other DMA engine that could be used
-        * for simple copies and reasonably easily synchronized with the 3d
-        * core, this is where we'd plug it in..
-        */
-
-       /* try blit on 3d pipe: */
-       if (fd_blitter_pipe_copy_region(ctx,
-                       dst, dst_level, dstx, dsty, dstz,
-                       src, src_level, src_box))
-               return;
-
-       /* else fallback to pure sw: */
-       util_resource_copy_region(pctx,
-                       dst, dst_level, dstx, dsty, dstz,
-                       src, src_level, src_box);
-}
-
 bool
 fd_render_condition_check(struct pipe_context *pctx)
 {