diff options
-rw-r--r-- | src/gallium/drivers/freedreno/a2xx/fd2_draw.c | 7 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a2xx/fd2_gmem.c | 29 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a3xx/fd3_draw.c | 7 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a3xx/fd3_gmem.c | 30 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_draw.c | 12 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_draw.h | 22 |
6 files changed, 55 insertions, 52 deletions
diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_draw.c b/src/gallium/drivers/freedreno/a2xx/fd2_draw.c index 8e1ca0fec41..13945e4a4dd 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_draw.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_draw.c @@ -270,11 +270,8 @@ fd2_clear(struct fd_context *ctx, unsigned buffers, OUT_RING(ring, 3); /* VGT_MAX_VTX_INDX */ OUT_RING(ring, 0); /* VGT_MIN_VTX_INDX */ - OUT_PKT3(ring, CP_DRAW_INDX, 3); - OUT_RING(ring, 0x00000000); - OUT_RING(ring, DRAW(DI_PT_RECTLIST, DI_SRC_SEL_AUTO_INDEX, - INDEX_SIZE_IGN, IGNORE_VISIBILITY)); - OUT_RING(ring, 3); /* NumIndices */ + fd_draw(ctx, DI_PT_RECTLIST, DI_SRC_SEL_AUTO_INDEX, 3, + INDEX_SIZE_IGN, 0, 0, NULL); OUT_PKT3(ring, CP_SET_CONSTANT, 2); OUT_RING(ring, CP_REG(REG_A2XX_A220_RB_LRZ_VSC_CONTROL)); diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c b/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c index 2c34b8af28a..d024f2d3c59 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c @@ -31,6 +31,7 @@ #include "util/u_memory.h" #include "util/u_inlines.h" +#include "freedreno_draw.h" #include "freedreno_state.h" #include "freedreno_resource.h" @@ -55,9 +56,10 @@ static uint32_t fmt2swap(enum pipe_format format) /* transfer from gmem to system memory (ie. normal RAM) */ static void -emit_gmem2mem_surf(struct fd_ringbuffer *ring, uint32_t base, +emit_gmem2mem_surf(struct fd_context *ctx, uint32_t base, struct pipe_surface *psurf) { + struct fd_ringbuffer *ring = ctx->ring; struct fd_resource *rsc = fd_resource(psurf->texture); uint32_t swap = fmt2swap(psurf->format); @@ -89,11 +91,8 @@ emit_gmem2mem_surf(struct fd_ringbuffer *ring, uint32_t base, OUT_RING(ring, 3); /* VGT_MAX_VTX_INDX */ OUT_RING(ring, 0); /* VGT_MIN_VTX_INDX */ - OUT_PKT3(ring, CP_DRAW_INDX, 3); - OUT_RING(ring, 0x00000000); - OUT_RING(ring, DRAW(DI_PT_RECTLIST, DI_SRC_SEL_AUTO_INDEX, - INDEX_SIZE_IGN, IGNORE_VISIBILITY)); - OUT_RING(ring, 3); /* NumIndices */ + fd_draw(ctx, DI_PT_RECTLIST, DI_SRC_SEL_AUTO_INDEX, 3, + INDEX_SIZE_IGN, 0, 0, NULL); } static void @@ -163,10 +162,10 @@ fd2_emit_tile_gmem2mem(struct fd_context *ctx, uint32_t xoff, uint32_t yoff, A2XX_RB_COPY_DEST_OFFSET_Y(yoff)); if (ctx->resolve & (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL)) - emit_gmem2mem_surf(ring, bin_w * bin_h, pfb->zsbuf); + emit_gmem2mem_surf(ctx, bin_w * bin_h, pfb->zsbuf); if (ctx->resolve & FD_BUFFER_COLOR) - emit_gmem2mem_surf(ring, 0, pfb->cbufs[0]); + emit_gmem2mem_surf(ctx, 0, pfb->cbufs[0]); OUT_PKT3(ring, CP_SET_CONSTANT, 2); OUT_RING(ring, CP_REG(REG_A2XX_RB_MODECONTROL)); @@ -176,9 +175,10 @@ fd2_emit_tile_gmem2mem(struct fd_context *ctx, uint32_t xoff, uint32_t yoff, /* transfer from system memory to gmem */ static void -emit_mem2gmem_surf(struct fd_ringbuffer *ring, uint32_t base, +emit_mem2gmem_surf(struct fd_context *ctx, uint32_t base, struct pipe_surface *psurf) { + struct fd_ringbuffer *ring = ctx->ring; struct fd_resource *rsc = fd_resource(psurf->texture); uint32_t swiz; @@ -214,11 +214,8 @@ emit_mem2gmem_surf(struct fd_ringbuffer *ring, uint32_t base, OUT_RING(ring, 3); /* VGT_MAX_VTX_INDX */ OUT_RING(ring, 0); /* VGT_MIN_VTX_INDX */ - OUT_PKT3(ring, CP_DRAW_INDX, 3); - OUT_RING(ring, 0x00000000); - OUT_RING(ring, DRAW(DI_PT_RECTLIST, DI_SRC_SEL_AUTO_INDEX, - INDEX_SIZE_IGN, IGNORE_VISIBILITY)); - OUT_RING(ring, 3); /* NumIndices */ + fd_draw(ctx, DI_PT_RECTLIST, DI_SRC_SEL_AUTO_INDEX, 3, + INDEX_SIZE_IGN, 0, 0, NULL); } static void @@ -322,10 +319,10 @@ fd2_emit_tile_mem2gmem(struct fd_context *ctx, uint32_t xoff, uint32_t yoff, OUT_RING(ring, 0x00000000); if (ctx->restore & (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL)) - emit_mem2gmem_surf(ring, bin_w * bin_h, pfb->zsbuf); + emit_mem2gmem_surf(ctx, bin_w * bin_h, pfb->zsbuf); if (ctx->restore & FD_BUFFER_COLOR) - emit_mem2gmem_surf(ring, 0, pfb->cbufs[0]); + emit_mem2gmem_surf(ctx, 0, pfb->cbufs[0]); /* TODO blob driver seems to toss in a CACHE_FLUSH after each DRAW_INDX.. */ } diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_draw.c b/src/gallium/drivers/freedreno/a3xx/fd3_draw.c index 953d45e1738..eb4df609a8c 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_draw.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_draw.c @@ -217,11 +217,8 @@ fd3_clear(struct fd_context *ctx, unsigned buffers, OUT_PKT3(ring, CP_EVENT_WRITE, 1); OUT_RING(ring, PERFCOUNTER_STOP); - OUT_PKT3(ring, CP_DRAW_INDX, 3); - OUT_RING(ring, 0x00000000); - OUT_RING(ring, DRAW(DI_PT_RECTLIST, DI_SRC_SEL_AUTO_INDEX, - INDEX_SIZE_IGN, IGNORE_VISIBILITY)); - OUT_RING(ring, 2); /* NumIndices */ + fd_draw(ctx, DI_PT_RECTLIST, DI_SRC_SEL_AUTO_INDEX, 2, + INDEX_SIZE_IGN, 0, 0, NULL); OUT_PKT3(ring, CP_WAIT_FOR_IDLE, 1); OUT_RING(ring, 0x00000000); diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c b/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c index cdc880ed562..0b0e575049c 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c @@ -32,6 +32,7 @@ #include "util/u_inlines.h" #include "util/u_format.h" +#include "freedreno_draw.h" #include "freedreno_state.h" #include "freedreno_resource.h" @@ -108,10 +109,11 @@ depth_base(struct fd_gmem_stateobj *gmem) /* transfer from gmem to system memory (ie. normal RAM) */ static void -emit_gmem2mem_surf(struct fd_ringbuffer *ring, +emit_gmem2mem_surf(struct fd_context *ctx, enum adreno_rb_copy_control_mode mode, uint32_t base, struct pipe_surface *psurf) { + struct fd_ringbuffer *ring = ctx->ring; struct fd_resource *rsc = fd_resource(psurf->texture); struct fd_resource_slice *slice = &rsc->slices[psurf->u.tex.level]; @@ -127,11 +129,8 @@ emit_gmem2mem_surf(struct fd_ringbuffer *ring, A3XX_RB_COPY_DEST_INFO_ENDIAN(ENDIAN_NONE) | A3XX_RB_COPY_DEST_INFO_SWAP(fd3_pipe2swap(psurf->format))); - OUT_PKT3(ring, CP_DRAW_INDX, 3); - OUT_RING(ring, 0x00000000); - OUT_RING(ring, DRAW(DI_PT_RECTLIST, DI_SRC_SEL_AUTO_INDEX, - INDEX_SIZE_IGN, IGNORE_VISIBILITY)); - OUT_RING(ring, 2); /* NumIndices */ + fd_draw(ctx, DI_PT_RECTLIST, DI_SRC_SEL_AUTO_INDEX, 2, + INDEX_SIZE_IGN, 0, 0, NULL); } static void @@ -223,11 +222,11 @@ fd3_emit_tile_gmem2mem(struct fd_context *ctx, uint32_t xoff, uint32_t yoff, fd_resource(pfb->cbufs[0]->texture); base = depth_base(&ctx->gmem) * rsc->cpp; } - emit_gmem2mem_surf(ring, RB_COPY_DEPTH_STENCIL, base, pfb->zsbuf); + emit_gmem2mem_surf(ctx, RB_COPY_DEPTH_STENCIL, base, pfb->zsbuf); } if (ctx->resolve & FD_BUFFER_COLOR) { - emit_gmem2mem_surf(ring, RB_COPY_RESOLVE, 0, pfb->cbufs[0]); + emit_gmem2mem_surf(ctx, RB_COPY_RESOLVE, 0, pfb->cbufs[0]); } OUT_PKT0(ring, REG_A3XX_RB_MODE_CONTROL, 1); @@ -243,18 +242,17 @@ fd3_emit_tile_gmem2mem(struct fd_context *ctx, uint32_t xoff, uint32_t yoff, /* transfer from system memory to gmem */ static void -emit_mem2gmem_surf(struct fd_ringbuffer *ring, uint32_t base, +emit_mem2gmem_surf(struct fd_context *ctx, uint32_t base, struct pipe_surface *psurf, uint32_t bin_w) { + struct fd_ringbuffer *ring = ctx->ring; + emit_mrt(ring, 1, &psurf, &base, bin_w); fd3_emit_gmem_restore_tex(ring, psurf); - OUT_PKT3(ring, CP_DRAW_INDX, 3); - OUT_RING(ring, 0x00000000); - OUT_RING(ring, DRAW(DI_PT_RECTLIST, DI_SRC_SEL_AUTO_INDEX, - INDEX_SIZE_IGN, IGNORE_VISIBILITY)); - OUT_RING(ring, 2); /* NumIndices */ + fd_draw(ctx, DI_PT_RECTLIST, DI_SRC_SEL_AUTO_INDEX, 2, + INDEX_SIZE_IGN, 0, 0, NULL); } static void @@ -371,10 +369,10 @@ fd3_emit_tile_mem2gmem(struct fd_context *ctx, uint32_t xoff, uint32_t yoff, bin_h = gmem->bin_h; if (ctx->restore & (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL)) - emit_mem2gmem_surf(ring, depth_base(gmem), pfb->zsbuf, bin_w); + emit_mem2gmem_surf(ctx, depth_base(gmem), pfb->zsbuf, bin_w); if (ctx->restore & FD_BUFFER_COLOR) - emit_mem2gmem_surf(ring, 0, pfb->cbufs[0], bin_w); + emit_mem2gmem_surf(ctx, 0, pfb->cbufs[0], bin_w); OUT_PKT0(ring, REG_A3XX_GRAS_SC_CONTROL, 1); OUT_RING(ring, A3XX_GRAS_SC_CONTROL_RENDER_MODE(RB_RENDERING_PASS) | diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index 4a98ab40f9e..d1f1c43d7b4 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -75,7 +75,6 @@ size2indextype(unsigned index_size) void fd_draw_emit(struct fd_context *ctx, const struct pipe_draw_info *info) { - struct fd_ringbuffer *ring = ctx->ring; struct pipe_index_buffer *idx = &ctx->indexbuf; struct fd_bo *idx_bo = NULL; enum pc_di_index_size idx_type = INDEX_SIZE_IGN; @@ -98,15 +97,8 @@ fd_draw_emit(struct fd_context *ctx, const struct pipe_draw_info *info) src_sel = DI_SRC_SEL_AUTO_INDEX; } - OUT_PKT3(ring, CP_DRAW_INDX, info->indexed ? 5 : 3); - OUT_RING(ring, 0x00000000); /* viz query info. */ - OUT_RING(ring, DRAW(mode2primtype(info->mode), - src_sel, idx_type, IGNORE_VISIBILITY)); - OUT_RING(ring, info->count); /* NumIndices */ - if (info->indexed) { - OUT_RELOC(ring, idx_bo, idx_offset, 0, 0); - OUT_RING (ring, idx_size); - } + fd_draw(ctx, mode2primtype(info->mode), src_sel, info->count, + idx_type, idx_size, idx_offset, idx_bo); } static void diff --git a/src/gallium/drivers/freedreno/freedreno_draw.h b/src/gallium/drivers/freedreno/freedreno_draw.h index 26a1dbbcaf1..7fb0abe2111 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.h +++ b/src/gallium/drivers/freedreno/freedreno_draw.h @@ -33,6 +33,8 @@ #include "pipe/p_context.h" #include "freedreno_context.h" +#include "freedreno_screen.h" +#include "freedreno_util.h" struct fd_ringbuffer; @@ -40,4 +42,24 @@ void fd_draw_emit(struct fd_context *ctx, const struct pipe_draw_info *info); void fd_draw_init(struct pipe_context *pctx); +static inline void +fd_draw(struct fd_context *ctx, enum pc_di_primtype primtype, + enum pc_di_src_sel src_sel, uint32_t count, + enum pc_di_index_size idx_type, + uint32_t idx_size, uint32_t idx_offset, + struct fd_bo *idx_bo) +{ + struct fd_ringbuffer *ring = ctx->ring; + + OUT_PKT3(ring, CP_DRAW_INDX, idx_bo ? 5 : 3); + OUT_RING(ring, 0x00000000); /* viz query info. */ + OUT_RING(ring, DRAW(primtype, src_sel, + idx_type, IGNORE_VISIBILITY)); + OUT_RING(ring, count); /* NumIndices */ + if (idx_bo) { + OUT_RELOC(ring, idx_bo, idx_offset, 0, 0); + OUT_RING (ring, idx_size); + } +} + #endif /* FREEDRENO_DRAW_H_ */ |