diff options
author | Rob Clark <[email protected]> | 2016-08-13 11:39:25 -0400 |
---|---|---|
committer | Rob Clark <[email protected]> | 2016-08-13 13:59:03 -0400 |
commit | 561fd226d421b8d6505b80bcb6c3d90fd3c9a007 (patch) | |
tree | dd338e4245f42ccc2c9c60885177ee30b595fe80 /src/gallium/drivers/freedreno/a4xx | |
parent | a49fb4ab2d5b062a418e930dc46cb2c79380852e (diff) |
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 <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno/a4xx')
-rw-r--r-- | src/gallium/drivers/freedreno/a4xx/fd4_context.c | 64 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a4xx/fd4_context.h | 20 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a4xx/fd4_draw.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a4xx/fd4_gmem.c | 8 |
4 files changed, 7 insertions, 91 deletions
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_context.c b/src/gallium/drivers/freedreno/a4xx/fd4_context.c index 62cfda97ac3..8ef715f1b7f 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_context.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_context.c @@ -47,44 +47,13 @@ fd4_context_destroy(struct pipe_context *pctx) fd_bo_del(fd4_ctx->fs_pvt_mem); fd_bo_del(fd4_ctx->vsc_size_mem); - pctx->delete_vertex_elements_state(pctx, fd4_ctx->solid_vbuf_state.vtx); - pctx->delete_vertex_elements_state(pctx, fd4_ctx->blit_vbuf_state.vtx); - - pipe_resource_reference(&fd4_ctx->solid_vbuf, NULL); - pipe_resource_reference(&fd4_ctx->blit_texcoord_vbuf, NULL); + fd_context_cleanup_common_vbos(&fd4_ctx->base); u_upload_destroy(fd4_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 @@ fd4_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) fd4_ctx->vsc_size_mem = fd_bo_new(screen->dev, 0x1000, DRM_FREEDRENO_GEM_TYPE_KMEM); - fd4_ctx->solid_vbuf = create_solid_vertexbuf(pctx); - fd4_ctx->blit_texcoord_vbuf = create_blit_texcoord_vertexbuf(pctx); - - /* setup solid_vbuf_state: */ - fd4_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, - }}); - fd4_ctx->solid_vbuf_state.vertexbuf.count = 1; - fd4_ctx->solid_vbuf_state.vertexbuf.vb[0].stride = 12; - fd4_ctx->solid_vbuf_state.vertexbuf.vb[0].buffer = fd4_ctx->solid_vbuf; - - /* setup blit_vbuf_state: */ - fd4_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, - }}); - fd4_ctx->blit_vbuf_state.vertexbuf.count = 2; - fd4_ctx->blit_vbuf_state.vertexbuf.vb[0].stride = 8; - fd4_ctx->blit_vbuf_state.vertexbuf.vb[0].buffer = fd4_ctx->blit_texcoord_vbuf; - fd4_ctx->blit_vbuf_state.vertexbuf.vb[1].stride = 12; - fd4_ctx->blit_vbuf_state.vertexbuf.vb[1].buffer = fd4_ctx->solid_vbuf; + fd_context_setup_common_vbos(&fd4_ctx->base); fd4_query_context_init(pctx); diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_context.h b/src/gallium/drivers/freedreno/a4xx/fd4_context.h index 9467fc529bf..4c06644a9fa 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_context.h +++ b/src/gallium/drivers/freedreno/a4xx/fd4_context.h @@ -49,26 +49,6 @@ struct fd4_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/a4xx/fd4_draw.c b/src/gallium/drivers/freedreno/a4xx/fd4_draw.c index f217619848a..200e4f26876 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_draw.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_draw.c @@ -217,11 +217,10 @@ reset_viewport(struct fd_ringbuffer *ring, struct pipe_framebuffer_state *pfb) static void fd4_clear_binning(struct fd_context *ctx, unsigned dirty) { - struct fd4_context *fd4_ctx = fd4_context(ctx); struct fd_ringbuffer *ring = ctx->batch->binning; struct fd4_emit emit = { .debug = &ctx->debug, - .vtx = &fd4_ctx->solid_vbuf_state, + .vtx = &ctx->solid_vbuf_state, .prog = &ctx->solid_prog, .key = { .binning_pass = true, @@ -251,7 +250,6 @@ static void fd4_clear(struct fd_context *ctx, unsigned buffers, const union pipe_color_union *color, double depth, unsigned stencil) { - struct fd4_context *fd4_ctx = fd4_context(ctx); struct fd_ringbuffer *ring = ctx->batch->draw; struct pipe_framebuffer_state *pfb = &ctx->batch->framebuffer; unsigned char mrt_comp[A4XX_MAX_RENDER_TARGETS] = {0}; @@ -259,7 +257,7 @@ fd4_clear(struct fd_context *ctx, unsigned buffers, unsigned i; struct fd4_emit emit = { .debug = &ctx->debug, - .vtx = &fd4_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/a4xx/fd4_gmem.c b/src/gallium/drivers/freedreno/a4xx/fd4_gmem.c index 32541fe06f0..5b7dc032045 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_gmem.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_gmem.c @@ -188,13 +188,12 @@ static void fd4_emit_tile_gmem2mem(struct fd_batch *batch, struct fd_tile *tile) { struct fd_context *ctx = batch->ctx; - struct fd4_context *fd4_ctx = fd4_context(ctx); struct fd_gmem_stateobj *gmem = &ctx->gmem; struct fd_ringbuffer *ring = batch->gmem; struct pipe_framebuffer_state *pfb = &batch->framebuffer; struct fd4_emit emit = { .debug = &ctx->debug, - .vtx = &fd4_ctx->solid_vbuf_state, + .vtx = &ctx->solid_vbuf_state, .prog = &ctx->solid_prog, .key = { .half_precision = true, @@ -327,13 +326,12 @@ static void fd4_emit_tile_mem2gmem(struct fd_batch *batch, struct fd_tile *tile) { struct fd_context *ctx = batch->ctx; - struct fd4_context *fd4_ctx = fd4_context(ctx); struct fd_gmem_stateobj *gmem = &ctx->gmem; struct fd_ringbuffer *ring = batch->gmem; struct pipe_framebuffer_state *pfb = &batch->framebuffer; struct fd4_emit emit = { .debug = &ctx->debug, - .vtx = &fd4_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], @@ -355,7 +353,7 @@ fd4_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(fd4_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)); |