diff options
author | Rob Clark <[email protected]> | 2018-12-13 09:14:48 -0500 |
---|---|---|
committer | Rob Clark <[email protected]> | 2018-12-13 15:51:01 -0500 |
commit | 4ec2f6129b9283d81b5dc8d95d304b243ec5145c (patch) | |
tree | 20b3ef3e351e9b2e7087d217d365501388095356 /src/gallium | |
parent | 57b76ee2a877057e1d32f9719cada69cc17562e2 (diff) |
freedreno: move fd_resource_copy_region()
Code-motion prep for next patch.
Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_blitter.c | 64 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_blitter.h | 8 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_resource.c | 63 |
3 files changed, 73 insertions, 62 deletions
diff --git a/src/gallium/drivers/freedreno/freedreno_blitter.c b/src/gallium/drivers/freedreno/freedreno_blitter.c index 6fab261df9c..f1ed5381bfc 100644 --- a/src/gallium/drivers/freedreno/freedreno_blitter.c +++ b/src/gallium/drivers/freedreno/freedreno_blitter.c @@ -25,9 +25,11 @@ */ #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); +} diff --git a/src/gallium/drivers/freedreno/freedreno_blitter.h b/src/gallium/drivers/freedreno/freedreno_blitter.h index 9d213b577b5..1fe85a840a6 100644 --- a/src/gallium/drivers/freedreno/freedreno_blitter.h +++ b/src/gallium/drivers/freedreno/freedreno_blitter.h @@ -33,4 +33,12 @@ 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_ */ diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index e59dc96ce35..06e68af3a82 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -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) { |