freedreno/ir3: add ctx->mem_to_mem()
authorRob Clark <robdclark@gmail.com>
Mon, 18 Dec 2017 20:06:37 +0000 (15:06 -0500)
committerRob Clark <robdclark@gmail.com>
Tue, 19 Dec 2017 20:00:18 +0000 (15:00 -0500)
For dealing with indirect-draw + gl_VertexID, we'll introduce another
case where we need to use CP_MEM_TO_MEM.  Rather than adding more
if(a5xx)/else make this a ctx vfunc.

Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/a4xx/fd4_emit.c
src/gallium/drivers/freedreno/a5xx/fd5_emit.c
src/gallium/drivers/freedreno/freedreno_context.h
src/gallium/drivers/freedreno/ir3/ir3_shader.c

index dca3692b0475cd841b3ba5ea66708dca24029e47..5fec2b6b08a471c8b6483bdf2e629ddbb8e50bf4 100644 (file)
@@ -912,6 +912,26 @@ fd4_emit_ib(struct fd_ringbuffer *ring, struct fd_ringbuffer *target)
        __OUT_IB(ring, true, target);
 }
 
+static void
+fd4_mem_to_mem(struct fd_ringbuffer *ring, struct pipe_resource *dst,
+               unsigned dst_off, struct pipe_resource *src, unsigned src_off,
+               unsigned sizedwords)
+{
+       struct fd_bo *src_bo = fd_resource(src)->bo;
+       struct fd_bo *dst_bo = fd_resource(dst)->bo;
+       unsigned i;
+
+       for (i = 0; i < sizedwords; i++) {
+               OUT_PKT3(ring, CP_MEM_TO_MEM, 3);
+               OUT_RING(ring, 0x00000000);
+               OUT_RELOCW(ring, dst_bo, dst_off, 0, 0);
+               OUT_RELOC (ring, src_bo, src_off, 0, 0);
+
+               dst_off += 4;
+               src_off += 4;
+       }
+}
+
 void
 fd4_emit_init(struct pipe_context *pctx)
 {
@@ -919,4 +939,5 @@ fd4_emit_init(struct pipe_context *pctx)
        ctx->emit_const = fd4_emit_const;
        ctx->emit_const_bo = fd4_emit_const_bo;
        ctx->emit_ib = fd4_emit_ib;
+       ctx->mem_to_mem = fd4_mem_to_mem;
 }
index 08e9bb7bafb1224dcd6c6d9565ec48b6602e5fae..b7ce084a8271bb47c0e8533e05070254f3f17fe9 100644 (file)
@@ -1068,6 +1068,26 @@ fd5_emit_ib(struct fd_ringbuffer *ring, struct fd_ringbuffer *target)
        __OUT_IB5(ring, target);
 }
 
+static void
+fd5_mem_to_mem(struct fd_ringbuffer *ring, struct pipe_resource *dst,
+               unsigned dst_off, struct pipe_resource *src, unsigned src_off,
+               unsigned sizedwords)
+{
+       struct fd_bo *src_bo = fd_resource(src)->bo;
+       struct fd_bo *dst_bo = fd_resource(dst)->bo;
+       unsigned i;
+
+       for (i = 0; i < sizedwords; i++) {
+               OUT_PKT7(ring, CP_MEM_TO_MEM, 5);
+               OUT_RING(ring, 0x00000000);
+               OUT_RELOCW(ring, dst_bo, dst_off, 0, 0);
+               OUT_RELOC (ring, src_bo, src_off, 0, 0);
+
+               dst_off += 4;
+               src_off += 4;
+       }
+}
+
 void
 fd5_emit_init(struct pipe_context *pctx)
 {
@@ -1075,4 +1095,5 @@ fd5_emit_init(struct pipe_context *pctx)
        ctx->emit_const = fd5_emit_const;
        ctx->emit_const_bo = fd5_emit_const_bo;
        ctx->emit_ib = fd5_emit_ib;
+       ctx->mem_to_mem = fd5_mem_to_mem;
 }
index 1e9911ea9bf60f73785ad9aecb554f0b7be8eb46..a4e1e4bb86c511a59b22143f63e2986decfb104a 100644 (file)
@@ -332,6 +332,11 @@ struct fd_context {
        /* blit: */
        void (*blit)(struct fd_context *ctx, const struct pipe_blit_info *info);
 
+       /* simple gpu "memcpy": */
+       void (*mem_to_mem)(struct fd_ringbuffer *ring, struct pipe_resource *dst,
+                       unsigned dst_off, struct pipe_resource *src, unsigned src_off,
+                       unsigned sizedwords);
+
        /*
         * Common pre-cooked VBO state (used for a3xx and later):
         */
index 3337543113db9585ef4c96f9e2829c997462c193..3b1fcdfd5f9bb86a7153931118cbcbdb7d0ed2c8 100644 (file)
@@ -879,20 +879,8 @@ ir3_emit_cs_consts(const struct ir3_shader_variant *v, struct fd_ringbuffer *rin
                                        0x1000);
                                indirect_offset = 0;
 
-                               if (is_a5xx(ctx->screen)) {
-                                       struct fd_bo *src = fd_resource(info->indirect)->bo;
-                                       struct fd_bo *dst = fd_resource(indirect)->bo;
-                                       for (unsigned i = 0; i < 3; i++) {
-                                               unsigned dst_off = i * 4;
-                                               unsigned src_off = (i * 4) + info->indirect_offset;
-                                               OUT_PKT7(ring, CP_MEM_TO_MEM, 5);
-                                               OUT_RING(ring, 0x00000000);
-                                               OUT_RELOCW(ring, dst, dst_off, 0, 0);
-                                               OUT_RELOC (ring, src, src_off, 0, 0);
-                                       }
-                               } else {
-                                       assert(0);
-                               }
+                               ctx->mem_to_mem(ring, indirect, 0, info->indirect,
+                                               info->indirect_offset, 3);
                        } else {
                                pipe_resource_reference(&indirect, info->indirect);
                                indirect_offset = info->indirect_offset;