From 561fd226d421b8d6505b80bcb6c3d90fd3c9a007 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Sat, 13 Aug 2016 11:39:25 -0400 Subject: freedreno/a3xx+a4xx: move common VBOs to fd_context These are the same for a3xx and later. (a2xx could probably use them too, but due to limited hw support and ancient downstream kernels, it isn't so easy to test.) Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a3xx/fd3_context.c | 64 +----------------------- src/gallium/drivers/freedreno/a3xx/fd3_context.h | 20 -------- src/gallium/drivers/freedreno/a3xx/fd3_draw.c | 6 +-- src/gallium/drivers/freedreno/a3xx/fd3_gmem.c | 13 ++--- 4 files changed, 9 insertions(+), 94 deletions(-) (limited to 'src/gallium/drivers/freedreno/a3xx') diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_context.c b/src/gallium/drivers/freedreno/a3xx/fd3_context.c index 2ffc2e0e53a..af5e60a7e63 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_context.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_context.c @@ -47,44 +47,13 @@ fd3_context_destroy(struct pipe_context *pctx) fd_bo_del(fd3_ctx->fs_pvt_mem); fd_bo_del(fd3_ctx->vsc_size_mem); - pctx->delete_vertex_elements_state(pctx, fd3_ctx->solid_vbuf_state.vtx); - pctx->delete_vertex_elements_state(pctx, fd3_ctx->blit_vbuf_state.vtx); - - pipe_resource_reference(&fd3_ctx->solid_vbuf, NULL); - pipe_resource_reference(&fd3_ctx->blit_texcoord_vbuf, NULL); + fd_context_cleanup_common_vbos(&fd3_ctx->base); u_upload_destroy(fd3_ctx->border_color_uploader); fd_context_destroy(pctx); } -/* TODO we could combine a few of these small buffers (solid_vbuf, - * blit_texcoord_vbuf, and vsc_size_mem, into a single buffer and - * save a tiny bit of memory - */ - -static struct pipe_resource * -create_solid_vertexbuf(struct pipe_context *pctx) -{ - static const float init_shader_const[] = { - -1.000000, +1.000000, +1.000000, - +1.000000, -1.000000, +1.000000, - }; - struct pipe_resource *prsc = pipe_buffer_create(pctx->screen, - PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE, sizeof(init_shader_const)); - pipe_buffer_write(pctx, prsc, 0, - sizeof(init_shader_const), init_shader_const); - return prsc; -} - -static struct pipe_resource * -create_blit_texcoord_vertexbuf(struct pipe_context *pctx) -{ - struct pipe_resource *prsc = pipe_buffer_create(pctx->screen, - PIPE_BIND_CUSTOM, PIPE_USAGE_DYNAMIC, 16); - return prsc; -} - static const uint8_t primtypes[PIPE_PRIM_MAX] = { [PIPE_PRIM_POINTS] = DI_PT_POINTLIST, [PIPE_PRIM_LINES] = DI_PT_LINELIST, @@ -134,36 +103,7 @@ fd3_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) fd3_ctx->vsc_size_mem = fd_bo_new(screen->dev, 0x1000, DRM_FREEDRENO_GEM_TYPE_KMEM); - fd3_ctx->solid_vbuf = create_solid_vertexbuf(pctx); - fd3_ctx->blit_texcoord_vbuf = create_blit_texcoord_vertexbuf(pctx); - - /* setup solid_vbuf_state: */ - fd3_ctx->solid_vbuf_state.vtx = pctx->create_vertex_elements_state( - pctx, 1, (struct pipe_vertex_element[]){{ - .vertex_buffer_index = 0, - .src_offset = 0, - .src_format = PIPE_FORMAT_R32G32B32_FLOAT, - }}); - fd3_ctx->solid_vbuf_state.vertexbuf.count = 1; - fd3_ctx->solid_vbuf_state.vertexbuf.vb[0].stride = 12; - fd3_ctx->solid_vbuf_state.vertexbuf.vb[0].buffer = fd3_ctx->solid_vbuf; - - /* setup blit_vbuf_state: */ - fd3_ctx->blit_vbuf_state.vtx = pctx->create_vertex_elements_state( - pctx, 2, (struct pipe_vertex_element[]){{ - .vertex_buffer_index = 0, - .src_offset = 0, - .src_format = PIPE_FORMAT_R32G32_FLOAT, - }, { - .vertex_buffer_index = 1, - .src_offset = 0, - .src_format = PIPE_FORMAT_R32G32B32_FLOAT, - }}); - fd3_ctx->blit_vbuf_state.vertexbuf.count = 2; - fd3_ctx->blit_vbuf_state.vertexbuf.vb[0].stride = 8; - fd3_ctx->blit_vbuf_state.vertexbuf.vb[0].buffer = fd3_ctx->blit_texcoord_vbuf; - fd3_ctx->blit_vbuf_state.vertexbuf.vb[1].stride = 12; - fd3_ctx->blit_vbuf_state.vertexbuf.vb[1].buffer = fd3_ctx->solid_vbuf; + fd_context_setup_common_vbos(&fd3_ctx->base); fd3_query_context_init(pctx); diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_context.h b/src/gallium/drivers/freedreno/a3xx/fd3_context.h index 07354110361..873c344ad13 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_context.h +++ b/src/gallium/drivers/freedreno/a3xx/fd3_context.h @@ -48,26 +48,6 @@ struct fd3_context { */ struct fd_bo *vsc_size_mem; - /* vertex buf used for clear/gmem->mem vertices, and mem->gmem - * vertices: - */ - struct pipe_resource *solid_vbuf; - - /* vertex buf used for mem->gmem tex coords: - */ - struct pipe_resource *blit_texcoord_vbuf; - - /* vertex state for solid_vbuf: - * - solid_vbuf / 12 / R32G32B32_FLOAT - */ - struct fd_vertex_state solid_vbuf_state; - - /* vertex state for blit_prog: - * - blit_texcoord_vbuf / 8 / R32G32_FLOAT - * - solid_vbuf / 12 / R32G32B32_FLOAT - */ - struct fd_vertex_state blit_vbuf_state; - struct u_upload_mgr *border_color_uploader; struct pipe_resource *border_color_buf; diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_draw.c b/src/gallium/drivers/freedreno/a3xx/fd3_draw.c index 44ae1f9db8a..9e6a8bc9193 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_draw.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_draw.c @@ -207,11 +207,10 @@ reset_viewport(struct fd_ringbuffer *ring, struct pipe_framebuffer_state *pfb) static void fd3_clear_binning(struct fd_context *ctx, unsigned dirty) { - struct fd3_context *fd3_ctx = fd3_context(ctx); struct fd_ringbuffer *ring = ctx->batch->binning; struct fd3_emit emit = { .debug = &ctx->debug, - .vtx = &fd3_ctx->solid_vbuf_state, + .vtx = &ctx->solid_vbuf_state, .prog = &ctx->solid_prog, .key = { .binning_pass = true, @@ -247,14 +246,13 @@ static void fd3_clear(struct fd_context *ctx, unsigned buffers, const union pipe_color_union *color, double depth, unsigned stencil) { - struct fd3_context *fd3_ctx = fd3_context(ctx); struct pipe_framebuffer_state *pfb = &ctx->batch->framebuffer; struct fd_ringbuffer *ring = ctx->batch->draw; unsigned dirty = ctx->dirty; unsigned i; struct fd3_emit emit = { .debug = &ctx->debug, - .vtx = &fd3_ctx->solid_vbuf_state, + .vtx = &ctx->solid_vbuf_state, .prog = &ctx->solid_prog, .key = { .half_precision = fd_half_precision(pfb), diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c b/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c index ec0a77b4140..51c858ace9e 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c @@ -158,12 +158,11 @@ static void emit_binning_workaround(struct fd_batch *batch) { struct fd_context *ctx = batch->ctx; - struct fd3_context *fd3_ctx = fd3_context(ctx); struct fd_gmem_stateobj *gmem = &ctx->gmem; struct fd_ringbuffer *ring = batch->gmem; struct fd3_emit emit = { .debug = &ctx->debug, - .vtx = &fd3_ctx->solid_vbuf_state, + .vtx = &ctx->solid_vbuf_state, .prog = &ctx->solid_prog, .key = { .half_precision = true, @@ -182,7 +181,7 @@ emit_binning_workaround(struct fd_batch *batch) OUT_RING(ring, A3XX_RB_COPY_CONTROL_MSAA_RESOLVE(MSAA_ONE) | A3XX_RB_COPY_CONTROL_MODE(0) | A3XX_RB_COPY_CONTROL_GMEM_BASE(0)); - OUT_RELOCW(ring, fd_resource(fd3_ctx->solid_vbuf)->bo, 0x20, 0, -1); /* RB_COPY_DEST_BASE */ + OUT_RELOCW(ring, fd_resource(ctx->solid_vbuf)->bo, 0x20, 0, -1); /* RB_COPY_DEST_BASE */ OUT_RING(ring, A3XX_RB_COPY_DEST_PITCH_PITCH(128)); OUT_RING(ring, A3XX_RB_COPY_DEST_INFO_TILE(LINEAR) | A3XX_RB_COPY_DEST_INFO_FORMAT(RB_R8G8B8A8_UNORM) | @@ -351,12 +350,11 @@ static void fd3_emit_tile_gmem2mem(struct fd_batch *batch, struct fd_tile *tile) { struct fd_context *ctx = batch->ctx; - struct fd3_context *fd3_ctx = fd3_context(ctx); struct fd_ringbuffer *ring = batch->gmem; struct pipe_framebuffer_state *pfb = &batch->framebuffer; struct fd3_emit emit = { .debug = &ctx->debug, - .vtx = &fd3_ctx->solid_vbuf_state, + .vtx = &ctx->solid_vbuf_state, .prog = &ctx->solid_prog, .key = { .half_precision = true, @@ -533,13 +531,12 @@ static void fd3_emit_tile_mem2gmem(struct fd_batch *batch, struct fd_tile *tile) { struct fd_context *ctx = batch->ctx; - struct fd3_context *fd3_ctx = fd3_context(ctx); struct fd_gmem_stateobj *gmem = &ctx->gmem; struct fd_ringbuffer *ring = batch->gmem; struct pipe_framebuffer_state *pfb = &batch->framebuffer; struct fd3_emit emit = { .debug = &ctx->debug, - .vtx = &fd3_ctx->blit_vbuf_state, + .vtx = &ctx->blit_vbuf_state, .sprite_coord_enable = 1, /* NOTE: They all use the same VP, this is for vtx bufs. */ .prog = &ctx->blit_prog[0], @@ -559,7 +556,7 @@ fd3_emit_tile_mem2gmem(struct fd_batch *batch, struct fd_tile *tile) y1 = ((float)tile->yoff + bin_h) / ((float)pfb->height); OUT_PKT3(ring, CP_MEM_WRITE, 5); - OUT_RELOCW(ring, fd_resource(fd3_ctx->blit_texcoord_vbuf)->bo, 0, 0, 0); + OUT_RELOCW(ring, fd_resource(ctx->blit_texcoord_vbuf)->bo, 0, 0, 0); OUT_RING(ring, fui(x0)); OUT_RING(ring, fui(y0)); OUT_RING(ring, fui(x1)); -- cgit v1.2.3