diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c index 74b63ce1f18..9eeff1cef42 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_context.c +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c @@ -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: diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.h b/src/gallium/drivers/etnaviv/etnaviv_context.h index a887555a6f2..02523c6aa0d 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_context.h +++ b/src/gallium/drivers/etnaviv/etnaviv_context.h @@ -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; diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c b/src/gallium/drivers/etnaviv/etnaviv_screen.c index ef28bdce30f..552cec33bc8 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c @@ -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: diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.h b/src/gallium/drivers/etnaviv/etnaviv_screen.h index e3d72968453..744855e29a2 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_screen.h +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.h @@ -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 * diff --git a/src/gallium/drivers/etnaviv/etnaviv_state.c b/src/gallium/drivers/etnaviv/etnaviv_state.c index 1f9883ce748..6cc7d92cdde 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_state.c +++ b/src/gallium/drivers/etnaviv/etnaviv_state.c @@ -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) { diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture_desc.c b/src/gallium/drivers/etnaviv/etnaviv_texture_desc.c index 68ae15e2f90..fa63c1a2f65 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_texture_desc.c +++ b/src/gallium/drivers/etnaviv/etnaviv_texture_desc.c @@ -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); } } }