r600g,radeonsi: share the async dma interface
authorMarek Olšák <marek.olsak@amd.com>
Sun, 22 Sep 2013 00:55:47 +0000 (02:55 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Sun, 29 Sep 2013 13:18:09 +0000 (15:18 +0200)
r600_texture.c is one step closer to r600g.

src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_texture.c
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeonsi/r600_texture.c
src/gallium/drivers/radeonsi/si_state.c

index ca835e3af1b9327c803971c8eef927b93e84518c..754c265c8c5871402f891064cd48c393a9617c29 100644 (file)
@@ -3739,13 +3739,13 @@ static void evergreen_dma_copy_tile(struct r600_context *rctx,
        }
 }
 
-boolean evergreen_dma_blit(struct pipe_context *ctx,
-                       struct pipe_resource *dst,
-                       unsigned dst_level,
-                       unsigned dst_x, unsigned dst_y, unsigned dst_z,
-                       struct pipe_resource *src,
-                       unsigned src_level,
-                       const struct pipe_box *src_box)
+static boolean evergreen_dma_blit(struct pipe_context *ctx,
+                                 struct pipe_resource *dst,
+                                 unsigned dst_level,
+                                 unsigned dst_x, unsigned dst_y, unsigned dst_z,
+                                 struct pipe_resource *src,
+                                 unsigned src_level,
+                                 const struct pipe_box *src_box)
 {
        struct r600_context *rctx = (struct r600_context *)ctx;
        struct r600_texture *rsrc = (struct r600_texture*)src;
@@ -3904,5 +3904,7 @@ void evergreen_init_state_functions(struct r600_context *rctx)
                 rctx->b.b.get_sample_position = evergreen_get_sample_position;
         else
                 rctx->b.b.get_sample_position = cayman_get_sample_position;
+       rctx->b.dma_copy = evergreen_dma_blit;
+
        evergreen_init_compute_state_functions(rctx);
 }
index dfe78b93a715f653e3f29dfa60ad5fc90f4ca36c..d9f2ed2dc0159a1ef104da833f858fbfc92e1ac4 100644 (file)
@@ -1290,10 +1290,8 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)
 
        if (rscreen->b.chip_class >= EVERGREEN) {
                rscreen->b.b.is_format_supported = evergreen_is_format_supported;
-               rscreen->dma_blit = &evergreen_dma_blit;
        } else {
                rscreen->b.b.is_format_supported = r600_is_format_supported;
-               rscreen->dma_blit = &r600_dma_blit;
        }
        rscreen->b.b.context_create = r600_create_context;
        rscreen->b.b.fence_reference = r600_fence_reference;
index fc138605e8c4b7d5b153a226030bbabdc65e84c5..f41c0b58088a3ee68c02a9f8df5baa280198799e 100644 (file)
@@ -201,14 +201,6 @@ struct r600_pipe_fences {
        pipe_mutex                      mutex;
 };
 
-typedef boolean (*r600g_dma_blit_t)(struct pipe_context *ctx,
-                               struct pipe_resource *dst,
-                               unsigned dst_level,
-                               unsigned dst_x, unsigned dst_y, unsigned dst_z,
-                               struct pipe_resource *src,
-                               unsigned src_level,
-                               const struct pipe_box *src_box);
-
 /* logging */
 #define DBG_TEX_DEPTH          (1 << 0)
 #define DBG_COMPUTE            (1 << 1)
@@ -260,7 +252,6 @@ struct r600_screen {
        struct r600_resource            *trace_bo;
        uint32_t                        *trace_ptr;
        unsigned                        cs_count;
-       r600g_dma_blit_t                dma_blit;
 
        /* Auxiliary context. Mainly used to initialize resources.
         * It must be locked prior to using and flushed before unlocking. */
@@ -739,13 +730,6 @@ void r600_dma_copy(struct r600_context *rctx,
                uint64_t dst_offset,
                uint64_t src_offset,
                uint64_t size);
-boolean r600_dma_blit(struct pipe_context *ctx,
-                       struct pipe_resource *dst,
-                       unsigned dst_level,
-                       unsigned dst_x, unsigned dst_y, unsigned dst_z,
-                       struct pipe_resource *src,
-                       unsigned src_level,
-                       const struct pipe_box *src_box);
 void r600_flag_resource_cache_flush(struct r600_context *rctx,
                                    struct pipe_resource *res);
 
@@ -758,13 +742,6 @@ void evergreen_dma_copy(struct r600_context *rctx,
                uint64_t dst_offset,
                uint64_t src_offset,
                uint64_t size);
-boolean evergreen_dma_blit(struct pipe_context *ctx,
-                       struct pipe_resource *dst,
-                       unsigned dst_level,
-                       unsigned dst_x, unsigned dst_y, unsigned dst_z,
-                       struct pipe_resource *src,
-                       unsigned src_level,
-                       const struct pipe_box *src_box);
 
 /* r600_state_common.c */
 void r600_init_common_state_functions(struct r600_context *rctx);
index 5411f743a6303b718d25618554d4c786829285fb..36ceb8336e236a637973350eb72677d10fb0c27b 100644 (file)
@@ -3119,13 +3119,13 @@ static boolean r600_dma_copy_tile(struct r600_context *rctx,
        return TRUE;
 }
 
-boolean r600_dma_blit(struct pipe_context *ctx,
-                       struct pipe_resource *dst,
-                       unsigned dst_level,
-                       unsigned dst_x, unsigned dst_y, unsigned dst_z,
-                       struct pipe_resource *src,
-                       unsigned src_level,
-                       const struct pipe_box *src_box)
+static boolean r600_dma_blit(struct pipe_context *ctx,
+                            struct pipe_resource *dst,
+                            unsigned dst_level,
+                            unsigned dst_x, unsigned dst_y, unsigned dst_z,
+                            struct pipe_resource *src,
+                            unsigned src_level,
+                            const struct pipe_box *src_box)
 {
        struct r600_context *rctx = (struct r600_context *)ctx;
        struct r600_texture *rsrc = (struct r600_texture*)src;
@@ -3263,7 +3263,7 @@ void r600_init_state_functions(struct r600_context *rctx)
        rctx->b.b.set_framebuffer_state = r600_set_framebuffer_state;
        rctx->b.b.set_polygon_stipple = r600_set_polygon_stipple;
        rctx->b.b.set_scissor_states = r600_set_scissor_states;
-
        rctx->b.b.get_sample_position = r600_get_sample_position;
+       rctx->b.dma_copy = r600_dma_blit;
 }
 /* this function must be last */
index a86e4c91be8950186de2519baa1ed87eb447c1f7..508340826e73a50415b9b85e74b2ab1a15c86656 100644 (file)
@@ -81,9 +81,9 @@ static void r600_copy_to_staging_texture(struct pipe_context *ctx, struct r600_t
                return;
        }
 
-       if (!rctx->screen->dma_blit(ctx, dst, 0, 0, 0, 0,
-                                   src, transfer->level,
-                                   &transfer->box)) {
+       if (!rctx->b.dma_copy(ctx, dst, 0, 0, 0, 0,
+                             src, transfer->level,
+                             &transfer->box)) {
                ctx->resource_copy_region(ctx, dst, 0, 0, 0, 0,
                                          src, transfer->level, &transfer->box);
        }
@@ -107,9 +107,9 @@ static void r600_copy_from_staging_texture(struct pipe_context *ctx, struct r600
                return;
        }
 
-       if (!rctx->screen->dma_blit(ctx, dst, transfer->level,
-                                   transfer->box.x, transfer->box.y, transfer->box.z,
-                                   src, 0, &sbox)) {
+       if (!rctx->b.dma_copy(ctx, dst, transfer->level,
+                             transfer->box.x, transfer->box.y, transfer->box.z,
+                             src, 0, &sbox)) {
                ctx->resource_copy_region(ctx, dst, transfer->level,
                                          transfer->box.x, transfer->box.y, transfer->box.z,
                                          src, 0, &sbox);
index 63439655fd2fac86fb0ff5113b56dca32b8a3d55..d83876df824b9e77484d6fe23e7d91ae0cd9c932 100644 (file)
@@ -203,6 +203,16 @@ struct r600_common_context {
 
        /* Additional context states. */
        unsigned flags; /* flush flags */
+
+       /* Copy one resource to another using async DMA.
+        * False is returned if the copy couldn't be done. */
+       boolean (*dma_copy)(struct pipe_context *ctx,
+                           struct pipe_resource *dst,
+                           unsigned dst_level,
+                           unsigned dst_x, unsigned dst_y, unsigned dst_z,
+                           struct pipe_resource *src,
+                           unsigned src_level,
+                           const struct pipe_box *src_box);
 };
 
 /* r600_common_pipe.c */
index 9a2f7101850dc8cb6626c00bc11f0414e9c94dbd..69ca892b5f8bd81a4f873649d0acbab508876a86 100644 (file)
@@ -73,6 +73,7 @@ static void r600_copy_region_with_blit(struct pipe_context *pipe,
 /* Copy from a full GPU texture to a transfer's staging one. */
 static void r600_copy_to_staging_texture(struct pipe_context *ctx, struct r600_transfer *rtransfer)
 {
+       struct r600_context *rctx = (struct r600_context*)ctx;
        struct pipe_transfer *transfer = (struct pipe_transfer*)rtransfer;
        struct pipe_resource *dst = &rtransfer->staging->b.b;
        struct pipe_resource *src = transfer->resource;
@@ -83,13 +84,18 @@ static void r600_copy_to_staging_texture(struct pipe_context *ctx, struct r600_t
                return;
        }
 
-       ctx->resource_copy_region(ctx, dst, 0, 0, 0, 0,
-                                 src, transfer->level, &transfer->box);
+       if (!rctx->b.dma_copy(ctx, dst, 0, 0, 0, 0,
+                             src, transfer->level,
+                             &transfer->box)) {
+               ctx->resource_copy_region(ctx, dst, 0, 0, 0, 0,
+                                         src, transfer->level, &transfer->box);
+       }
 }
 
 /* Copy from a transfer's staging texture to a full GPU one. */
 static void r600_copy_from_staging_texture(struct pipe_context *ctx, struct r600_transfer *rtransfer)
 {
+       struct r600_context *rctx = (struct r600_context*)ctx;
        struct pipe_transfer *transfer = (struct pipe_transfer*)rtransfer;
        struct pipe_resource *dst = transfer->resource;
        struct pipe_resource *src = &rtransfer->staging->b.b;
@@ -104,9 +110,13 @@ static void r600_copy_from_staging_texture(struct pipe_context *ctx, struct r600
                return;
        }
 
-       ctx->resource_copy_region(ctx, dst, transfer->level,
-                                 transfer->box.x, transfer->box.y, transfer->box.z,
-                                 src, 0, &sbox);
+       if (!rctx->b.dma_copy(ctx, dst, transfer->level,
+                             transfer->box.x, transfer->box.y, transfer->box.z,
+                             src, 0, &sbox)) {
+               ctx->resource_copy_region(ctx, dst, transfer->level,
+                                         transfer->box.x, transfer->box.y, transfer->box.z,
+                                         src, 0, &sbox);
+       }
 }
 
 static unsigned r600_texture_get_offset(struct r600_texture *rtex, unsigned level,
index 400d947376d5600237f1267994d42a29bdb113a7..5f60045f77d77dd3b9cf145712b5de3dac0801e2 100644 (file)
@@ -2955,6 +2955,18 @@ static void r600_surface_destroy(struct pipe_context *pipe,
        FREE(surface);
 }
 
+static boolean si_dma_copy(struct pipe_context *ctx,
+                          struct pipe_resource *dst,
+                          unsigned dst_level,
+                          unsigned dst_x, unsigned dst_y, unsigned dst_z,
+                          struct pipe_resource *src,
+                          unsigned src_level,
+                          const struct pipe_box *src_box)
+{
+       /* XXX implement this or share evergreen_dma_blit with r600g */
+       return FALSE;
+}
+
 void si_init_state_functions(struct r600_context *rctx)
 {
        int i;
@@ -3018,6 +3030,7 @@ void si_init_state_functions(struct r600_context *rctx)
        rctx->b.b.set_polygon_stipple = si_set_polygon_stipple;
        rctx->b.b.create_surface = r600_create_surface;
        rctx->b.b.surface_destroy = r600_surface_destroy;
+       rctx->b.dma_copy = si_dma_copy;
 
        rctx->b.b.draw_vbo = si_draw_vbo;
 }