freedreno/ir3: add ctx->mem_to_mem()

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>
This commit is contained in:
Rob Clark 2017-12-18 15:06:37 -05:00
parent 0536737983
commit d7cb509fd3
4 changed files with 49 additions and 14 deletions

View 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;
}

View 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;
}

View 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):
*/

View 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;