diff options
-rw-r--r-- | src/gallium/drivers/freedreno/a3xx/fd3_context.c | 64 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a3xx/fd3_context.h | 20 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a3xx/fd3_draw.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a3xx/fd3_gmem.c | 13 | ||||
-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 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_context.c | 76 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_context.h | 24 |
10 files changed, 116 insertions, 185 deletions
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)); 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)); diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c index ab2faa429d6..402e88f7ca9 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.c +++ b/src/gallium/drivers/freedreno/freedreno_context.c @@ -150,6 +150,82 @@ fd_set_debug_callback(struct pipe_context *pctx, memset(&ctx->debug, 0, sizeof(ctx->debug)); } +/* 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; +} + +void +fd_context_setup_common_vbos(struct fd_context *ctx) +{ + struct pipe_context *pctx = &ctx->base; + + ctx->solid_vbuf = create_solid_vertexbuf(pctx); + ctx->blit_texcoord_vbuf = create_blit_texcoord_vertexbuf(pctx); + + /* setup solid_vbuf_state: */ + 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, + }}); + ctx->solid_vbuf_state.vertexbuf.count = 1; + ctx->solid_vbuf_state.vertexbuf.vb[0].stride = 12; + ctx->solid_vbuf_state.vertexbuf.vb[0].buffer = ctx->solid_vbuf; + + /* setup blit_vbuf_state: */ + 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, + }}); + ctx->blit_vbuf_state.vertexbuf.count = 2; + ctx->blit_vbuf_state.vertexbuf.vb[0].stride = 8; + ctx->blit_vbuf_state.vertexbuf.vb[0].buffer = ctx->blit_texcoord_vbuf; + ctx->blit_vbuf_state.vertexbuf.vb[1].stride = 12; + ctx->blit_vbuf_state.vertexbuf.vb[1].buffer = ctx->solid_vbuf; +} + +void +fd_context_cleanup_common_vbos(struct fd_context *ctx) +{ + struct pipe_context *pctx = &ctx->base; + + pctx->delete_vertex_elements_state(pctx, ctx->solid_vbuf_state.vtx); + pctx->delete_vertex_elements_state(pctx, ctx->blit_vbuf_state.vtx); + + pipe_resource_reference(&ctx->solid_vbuf, NULL); + pipe_resource_reference(&ctx->blit_texcoord_vbuf, NULL); +} + struct pipe_context * fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen, const uint8_t *primtypes, void *priv) diff --git a/src/gallium/drivers/freedreno/freedreno_context.h b/src/gallium/drivers/freedreno/freedreno_context.h index b3674b8115c..ffc4d9ef47c 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.h +++ b/src/gallium/drivers/freedreno/freedreno_context.h @@ -275,6 +275,27 @@ struct fd_context { /* indirect-branch emit: */ void (*emit_ib)(struct fd_ringbuffer *ring, struct fd_ringbuffer *target); + + /* + * Common pre-cooked VBO state (used for a3xx and later): + */ + + /* for clear/gmem->mem vertices, and mem->gmem */ + struct pipe_resource *solid_vbuf; + + /* 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; }; static inline struct fd_context * @@ -315,6 +336,9 @@ fd_supported_prim(struct fd_context *ctx, unsigned prim) return (1 << prim) & ctx->primtype_mask; } +void fd_context_setup_common_vbos(struct fd_context *ctx); +void fd_context_cleanup_common_vbos(struct fd_context *ctx); + struct pipe_context * fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen, const uint8_t *primtypes, void *priv); |