mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 21:50:12 +01:00
etnaviv: move dummy BOs to screen
The dummy texture descriptor and the dummy render target relocs are not ever changed by a context operation, so we can save some space by moving them to the screen and potentially share them and the BOs backing them between multiple contexts. Also don't hold two pointers to the same BO, one in the reloc and one raw, but always just use the reloc one. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17448>
This commit is contained in:
parent
f7f74a984b
commit
2c08decc8f
6 changed files with 43 additions and 40 deletions
|
|
@ -108,12 +108,6 @@ etna_context_destroy(struct pipe_context *pctx)
|
|||
if (ctx->flush_resources)
|
||||
_mesa_set_destroy(ctx->flush_resources, NULL);
|
||||
|
||||
if (ctx->dummy_desc_bo)
|
||||
etna_bo_del(ctx->dummy_desc_bo);
|
||||
|
||||
if (ctx->dummy_rt)
|
||||
etna_bo_del(ctx->dummy_rt);
|
||||
|
||||
util_copy_framebuffer_state(&ctx->framebuffer_s, NULL);
|
||||
|
||||
if (ctx->blitter)
|
||||
|
|
@ -635,30 +629,6 @@ etna_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
|
|||
slab_create_child(&ctx->transfer_pool, &screen->transfer_pool);
|
||||
list_inithead(&ctx->active_acc_queries);
|
||||
|
||||
/* create dummy RT buffer, used when rendering with no color buffer */
|
||||
ctx->dummy_rt = etna_bo_new(ctx->screen->dev, 64 * 64 * 4,
|
||||
DRM_ETNA_GEM_CACHE_WC);
|
||||
if (!ctx->dummy_rt)
|
||||
goto fail;
|
||||
|
||||
ctx->dummy_rt_reloc.bo = ctx->dummy_rt;
|
||||
ctx->dummy_rt_reloc.offset = 0;
|
||||
ctx->dummy_rt_reloc.flags = ETNA_RELOC_READ | ETNA_RELOC_WRITE;
|
||||
|
||||
if (screen->specs.halti >= 5) {
|
||||
/* Create an empty dummy texture descriptor */
|
||||
ctx->dummy_desc_bo = etna_bo_new(ctx->screen->dev, 0x100, DRM_ETNA_GEM_CACHE_WC);
|
||||
if (!ctx->dummy_desc_bo)
|
||||
goto fail;
|
||||
uint32_t *buf = etna_bo_map(ctx->dummy_desc_bo);
|
||||
etna_bo_cpu_prep(ctx->dummy_desc_bo, DRM_ETNA_PREP_WRITE);
|
||||
memset(buf, 0, 0x100);
|
||||
etna_bo_cpu_fini(ctx->dummy_desc_bo);
|
||||
ctx->DUMMY_DESC_ADDR.bo = ctx->dummy_desc_bo;
|
||||
ctx->DUMMY_DESC_ADDR.offset = 0;
|
||||
ctx->DUMMY_DESC_ADDR.flags = ETNA_RELOC_READ;
|
||||
}
|
||||
|
||||
return pctx;
|
||||
|
||||
fail:
|
||||
|
|
|
|||
|
|
@ -191,13 +191,6 @@ struct etna_context {
|
|||
/* list of accumulated HW queries */
|
||||
struct list_head active_acc_queries;
|
||||
|
||||
struct etna_bo *dummy_rt;
|
||||
struct etna_reloc dummy_rt_reloc;
|
||||
|
||||
/* Dummy texture descriptor (if needed) */
|
||||
struct etna_bo *dummy_desc_bo;
|
||||
struct etna_reloc DUMMY_DESC_ADDR;
|
||||
|
||||
/* set of resources used by currently-unsubmitted renders */
|
||||
struct hash_table *pending_resources;
|
||||
|
||||
|
|
|
|||
|
|
@ -85,6 +85,12 @@ etna_screen_destroy(struct pipe_screen *pscreen)
|
|||
{
|
||||
struct etna_screen *screen = etna_screen(pscreen);
|
||||
|
||||
if (screen->dummy_desc_reloc.bo)
|
||||
etna_bo_del(screen->dummy_desc_reloc.bo);
|
||||
|
||||
if (screen->dummy_rt_reloc.bo)
|
||||
etna_bo_del(screen->dummy_rt_reloc.bo);
|
||||
|
||||
if (screen->perfmon)
|
||||
etna_perfmon_del(screen->perfmon);
|
||||
|
||||
|
|
@ -1158,6 +1164,33 @@ etna_screen_create(struct etna_device *dev, struct etna_gpu *gpu,
|
|||
if (screen->drm_version >= ETNA_DRM_VERSION_PERFMON)
|
||||
etna_pm_query_setup(screen);
|
||||
|
||||
|
||||
/* create dummy RT buffer, used when rendering with no color buffer */
|
||||
screen->dummy_rt_reloc.bo = etna_bo_new(screen->dev, 64 * 64 * 4,
|
||||
DRM_ETNA_GEM_CACHE_WC);
|
||||
if (!screen->dummy_rt_reloc.bo)
|
||||
goto fail;
|
||||
|
||||
screen->dummy_rt_reloc.offset = 0;
|
||||
screen->dummy_rt_reloc.flags = ETNA_RELOC_READ | ETNA_RELOC_WRITE;
|
||||
|
||||
if (screen->specs.halti >= 5) {
|
||||
void *buf;
|
||||
|
||||
/* create an empty dummy texture descriptor */
|
||||
screen->dummy_desc_reloc.bo = etna_bo_new(screen->dev, 0x100,
|
||||
DRM_ETNA_GEM_CACHE_WC);
|
||||
if (!screen->dummy_desc_reloc.bo)
|
||||
goto fail;
|
||||
|
||||
buf = etna_bo_map(screen->dummy_desc_reloc.bo);
|
||||
etna_bo_cpu_prep(screen->dummy_desc_reloc.bo, DRM_ETNA_PREP_WRITE);
|
||||
memset(buf, 0, 0x100);
|
||||
etna_bo_cpu_fini(screen->dummy_desc_reloc.bo);
|
||||
screen->dummy_desc_reloc.offset = 0;
|
||||
screen->dummy_desc_reloc.flags = ETNA_RELOC_READ;
|
||||
}
|
||||
|
||||
return pscreen;
|
||||
|
||||
fail:
|
||||
|
|
|
|||
|
|
@ -95,6 +95,12 @@ struct etna_screen {
|
|||
struct etna_compiler *compiler;
|
||||
nir_shader_compiler_options options;
|
||||
struct util_queue shader_compiler_queue;
|
||||
|
||||
/* dummy render target for GPUs that can't fully disable the color pipe */
|
||||
struct etna_reloc dummy_rt_reloc;
|
||||
|
||||
/* dummy texture descriptor */
|
||||
struct etna_reloc dummy_desc_reloc;
|
||||
};
|
||||
|
||||
static inline struct etna_screen *
|
||||
|
|
|
|||
|
|
@ -242,9 +242,9 @@ etna_set_framebuffer_state(struct pipe_context *pctx,
|
|||
cs->TS_COLOR_STATUS_BASE.bo = NULL;
|
||||
cs->TS_COLOR_SURFACE_BASE.bo = NULL;
|
||||
|
||||
cs->PE_COLOR_ADDR = ctx->dummy_rt_reloc;
|
||||
cs->PE_COLOR_ADDR = screen->dummy_rt_reloc;
|
||||
for (int i = 0; i < screen->specs.pixel_pipes; i++)
|
||||
cs->PE_PIPE_COLOR_ADDR[i] = ctx->dummy_rt_reloc;
|
||||
cs->PE_PIPE_COLOR_ADDR[i] = screen->dummy_rt_reloc;
|
||||
}
|
||||
|
||||
if (fb->zsbuf != NULL) {
|
||||
|
|
|
|||
|
|
@ -322,7 +322,8 @@ etna_emit_texture_desc(struct etna_context *ctx)
|
|||
etna_set_state_reloc(stream, VIVS_NTE_DESCRIPTOR_ADDR(x), &sv->DESC_ADDR);
|
||||
} else {
|
||||
/* dummy texture descriptors for unused samplers */
|
||||
etna_set_state_reloc(stream, VIVS_NTE_DESCRIPTOR_ADDR(x), &ctx->DUMMY_DESC_ADDR);
|
||||
etna_set_state_reloc(stream, VIVS_NTE_DESCRIPTOR_ADDR(x),
|
||||
&ctx->screen->dummy_desc_reloc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue