Module: Mesa Branch: staging/22.3 Commit: 54648dc9ab9022f76b0f8bd13244870a6a0202cb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=54648dc9ab9022f76b0f8bd13244870a6a0202cb
Author: Lionel Landwerlin <[email protected]> Date: Tue Nov 15 14:26:38 2022 +0200 iris: move bindless surface state heap inside the surface state heap We're about to make scratch surface states part of the surface state heap. Because those are required to be in the low 26bits parts surface state heap (we're limited in bits handed in the CFE_STATE, 3DSTATE_VS, etc... instructions), this change splits the 32bit surface state heap as follow: - 8Mb of surface states for scratch - 1Gb - 8Mb of binding tables - 3Gb of surface states That way all of the surfaces are located within a 4Gb region visible from STATE_BASE_ADDRESS::SurfaceStateBaseAddress Signed-off-by: Lionel Landwerlin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20087> --- src/gallium/drivers/iris/iris_bufmgr.c | 25 +++++++++++++------------ src/gallium/drivers/iris/iris_bufmgr.h | 10 +++++----- src/gallium/drivers/iris/iris_context.c | 6 +++--- src/gallium/drivers/iris/iris_context.h | 2 +- src/gallium/drivers/iris/iris_program.c | 2 +- src/gallium/drivers/iris/iris_resource.c | 8 ++++---- src/gallium/drivers/iris/iris_resource.h | 2 +- src/gallium/drivers/iris/iris_state.c | 2 +- 8 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c index 5e65a6def61..2e2beee70d7 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.c +++ b/src/gallium/drivers/iris/iris_bufmgr.c @@ -136,7 +136,7 @@ memzone_name(enum iris_memory_zone memzone) const char *names[] = { [IRIS_MEMZONE_SHADER] = "shader", [IRIS_MEMZONE_BINDER] = "binder", - [IRIS_MEMZONE_BINDLESS] = "scratchsurf", + [IRIS_MEMZONE_SCRATCH] = "scratchsurf", [IRIS_MEMZONE_SURFACE] = "surface", [IRIS_MEMZONE_DYNAMIC] = "dynamic", [IRIS_MEMZONE_OTHER] = "other", @@ -354,10 +354,10 @@ enum iris_memory_zone iris_memzone_for_address(uint64_t address) { STATIC_ASSERT(IRIS_MEMZONE_OTHER_START > IRIS_MEMZONE_DYNAMIC_START); - STATIC_ASSERT(IRIS_MEMZONE_DYNAMIC_START > IRIS_MEMZONE_SURFACE_START); - STATIC_ASSERT(IRIS_MEMZONE_SURFACE_START > IRIS_MEMZONE_BINDLESS_START); - STATIC_ASSERT(IRIS_MEMZONE_BINDLESS_START > IRIS_MEMZONE_BINDER_START); + STATIC_ASSERT(IRIS_MEMZONE_SURFACE_START > IRIS_MEMZONE_SCRATCH_START); + STATIC_ASSERT(IRIS_MEMZONE_SCRATCH_START == IRIS_MEMZONE_BINDER_START); STATIC_ASSERT(IRIS_MEMZONE_BINDER_START > IRIS_MEMZONE_SHADER_START); + STATIC_ASSERT(IRIS_MEMZONE_DYNAMIC_START > IRIS_MEMZONE_SURFACE_START); STATIC_ASSERT(IRIS_BORDER_COLOR_POOL_ADDRESS == IRIS_MEMZONE_DYNAMIC_START); if (address >= IRIS_MEMZONE_OTHER_START) @@ -372,12 +372,12 @@ iris_memzone_for_address(uint64_t address) if (address >= IRIS_MEMZONE_SURFACE_START) return IRIS_MEMZONE_SURFACE; - if (address >= IRIS_MEMZONE_BINDLESS_START) - return IRIS_MEMZONE_BINDLESS; - - if (address >= IRIS_MEMZONE_BINDER_START) + if (address >= (IRIS_MEMZONE_BINDER_START + IRIS_SCRATCH_ZONE_SIZE)) return IRIS_MEMZONE_BINDER; + if (address >= IRIS_MEMZONE_SCRATCH_START) + return IRIS_MEMZONE_SCRATCH; + return IRIS_MEMZONE_SHADER; } @@ -2488,12 +2488,13 @@ iris_bufmgr_create(struct intel_device_info *devinfo, int fd, bool bo_reuse) util_vma_heap_init(&bufmgr->vma_allocator[IRIS_MEMZONE_SHADER], PAGE_SIZE, _4GB_minus_1 - PAGE_SIZE); util_vma_heap_init(&bufmgr->vma_allocator[IRIS_MEMZONE_BINDER], - IRIS_MEMZONE_BINDER_START, IRIS_BINDER_ZONE_SIZE); - util_vma_heap_init(&bufmgr->vma_allocator[IRIS_MEMZONE_BINDLESS], - IRIS_MEMZONE_BINDLESS_START, IRIS_BINDLESS_SIZE); + IRIS_MEMZONE_BINDER_START + IRIS_SCRATCH_ZONE_SIZE, + IRIS_BINDER_ZONE_SIZE - IRIS_SCRATCH_ZONE_SIZE); + util_vma_heap_init(&bufmgr->vma_allocator[IRIS_MEMZONE_SCRATCH], + IRIS_MEMZONE_SCRATCH_START, IRIS_SCRATCH_ZONE_SIZE); util_vma_heap_init(&bufmgr->vma_allocator[IRIS_MEMZONE_SURFACE], IRIS_MEMZONE_SURFACE_START, _4GB_minus_1 - - IRIS_BINDER_ZONE_SIZE - IRIS_BINDLESS_SIZE); + IRIS_BINDER_ZONE_SIZE - IRIS_SCRATCH_ZONE_SIZE); /* Wa_2209859288: the Tigerlake PRM's workarounds volume says: * diff --git a/src/gallium/drivers/iris/iris_bufmgr.h b/src/gallium/drivers/iris/iris_bufmgr.h index 01cf854cb21..68a1c989cf2 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.h +++ b/src/gallium/drivers/iris/iris_bufmgr.h @@ -73,7 +73,7 @@ struct iris_syncobj; enum iris_memory_zone { IRIS_MEMZONE_SHADER, IRIS_MEMZONE_BINDER, - IRIS_MEMZONE_BINDLESS, + IRIS_MEMZONE_SCRATCH, IRIS_MEMZONE_SURFACE, IRIS_MEMZONE_DYNAMIC, IRIS_MEMZONE_OTHER, @@ -84,13 +84,13 @@ enum iris_memory_zone { /* Intentionally exclude single buffer "zones" */ #define IRIS_MEMZONE_COUNT (IRIS_MEMZONE_OTHER + 1) -#define IRIS_BINDLESS_SIZE (8 * 1024 * 1024) -#define IRIS_BINDER_ZONE_SIZE ((1ull << 30) - IRIS_BINDLESS_SIZE) +#define IRIS_SCRATCH_ZONE_SIZE (8 * 1024 * 1024) +#define IRIS_BINDER_ZONE_SIZE ((1ull << 30) - IRIS_SCRATCH_ZONE_SIZE) #define IRIS_MEMZONE_SHADER_START (0ull * (1ull << 32)) #define IRIS_MEMZONE_BINDER_START (1ull * (1ull << 32)) -#define IRIS_MEMZONE_BINDLESS_START (IRIS_MEMZONE_BINDER_START + IRIS_BINDER_ZONE_SIZE) -#define IRIS_MEMZONE_SURFACE_START (IRIS_MEMZONE_BINDLESS_START + IRIS_BINDLESS_SIZE) +#define IRIS_MEMZONE_SCRATCH_START IRIS_MEMZONE_BINDER_START +#define IRIS_MEMZONE_SURFACE_START (IRIS_MEMZONE_BINDER_START + IRIS_BINDER_ZONE_SIZE) #define IRIS_MEMZONE_DYNAMIC_START (2ull * (1ull << 32)) #define IRIS_MEMZONE_OTHER_START (3ull * (1ull << 32)) diff --git a/src/gallium/drivers/iris/iris_context.c b/src/gallium/drivers/iris/iris_context.c index e244e2666a7..47d1e023b4a 100644 --- a/src/gallium/drivers/iris/iris_context.c +++ b/src/gallium/drivers/iris/iris_context.c @@ -243,7 +243,7 @@ iris_destroy_context(struct pipe_context *ctx) iris_destroy_ctx_measure(ice); u_upload_destroy(ice->state.surface_uploader); - u_upload_destroy(ice->state.bindless_uploader); + u_upload_destroy(ice->state.scratch_surface_uploader); u_upload_destroy(ice->state.dynamic_uploader); u_upload_destroy(ice->query_buffer_uploader); @@ -343,9 +343,9 @@ iris_create_context(struct pipe_screen *pscreen, void *priv, unsigned flags) u_upload_create(ctx, 64 * 1024, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE, IRIS_RESOURCE_FLAG_SURFACE_MEMZONE | IRIS_RESOURCE_FLAG_DEVICE_MEM); - ice->state.bindless_uploader = + ice->state.scratch_surface_uploader = u_upload_create(ctx, 64 * 1024, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE, - IRIS_RESOURCE_FLAG_BINDLESS_MEMZONE | + IRIS_RESOURCE_FLAG_SCRATCH_MEMZONE | IRIS_RESOURCE_FLAG_DEVICE_MEM); ice->state.dynamic_uploader = u_upload_create(ctx, 64 * 1024, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE, diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h index d03afdeea8f..e4ea494817a 100644 --- a/src/gallium/drivers/iris/iris_context.h +++ b/src/gallium/drivers/iris/iris_context.h @@ -826,7 +826,7 @@ struct iris_context { struct iris_state_ref null_fb; struct u_upload_mgr *surface_uploader; - struct u_upload_mgr *bindless_uploader; + struct u_upload_mgr *scratch_surface_uploader; struct u_upload_mgr *dynamic_uploader; struct iris_binder binder; diff --git a/src/gallium/drivers/iris/iris_program.c b/src/gallium/drivers/iris/iris_program.c index d7ced54483d..f7918110547 100644 --- a/src/gallium/drivers/iris/iris_program.c +++ b/src/gallium/drivers/iris/iris_program.c @@ -2430,7 +2430,7 @@ iris_get_scratch_surf(struct iris_context *ice, struct iris_bo *scratch_bo = iris_get_scratch_space(ice, per_thread_scratch, MESA_SHADER_COMPUTE); - void *map = upload_state(ice->state.bindless_uploader, ref, + void *map = upload_state(ice->state.scratch_surface_uploader, ref, screen->isl_dev.ss.size, 64); isl_buffer_fill_state(&screen->isl_dev, map, diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index e01fe1f0925..56dee15e320 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -1122,9 +1122,9 @@ iris_resource_create_for_buffer(struct pipe_screen *pscreen, } else if (templ->flags & IRIS_RESOURCE_FLAG_DYNAMIC_MEMZONE) { memzone = IRIS_MEMZONE_DYNAMIC; name = "dynamic state"; - } else if (templ->flags & IRIS_RESOURCE_FLAG_BINDLESS_MEMZONE) { - memzone = IRIS_MEMZONE_BINDLESS; - name = "bindless surface state"; + } else if (templ->flags & IRIS_RESOURCE_FLAG_SCRATCH_MEMZONE) { + memzone = IRIS_MEMZONE_SCRATCH; + name = "scratch surface state"; } unsigned flags = iris_resource_alloc_flags(screen, templ, res->aux.usage); @@ -1196,7 +1196,7 @@ iris_resource_create_with_modifiers(struct pipe_screen *pscreen, assert(!(templ->flags & (IRIS_RESOURCE_FLAG_SHADER_MEMZONE | IRIS_RESOURCE_FLAG_SURFACE_MEMZONE | IRIS_RESOURCE_FLAG_DYNAMIC_MEMZONE | - IRIS_RESOURCE_FLAG_BINDLESS_MEMZONE))); + IRIS_RESOURCE_FLAG_SCRATCH_MEMZONE))); /* Modifiers require the aux data to be in the same buffer as the main * surface, but we combine them even when a modifier is not being used. diff --git a/src/gallium/drivers/iris/iris_resource.h b/src/gallium/drivers/iris/iris_resource.h index 92411573a59..a60fba56719 100644 --- a/src/gallium/drivers/iris/iris_resource.h +++ b/src/gallium/drivers/iris/iris_resource.h @@ -44,7 +44,7 @@ struct iris_format_info { #define IRIS_RESOURCE_FLAG_SHADER_MEMZONE (PIPE_RESOURCE_FLAG_DRV_PRIV << 0) #define IRIS_RESOURCE_FLAG_SURFACE_MEMZONE (PIPE_RESOURCE_FLAG_DRV_PRIV << 1) #define IRIS_RESOURCE_FLAG_DYNAMIC_MEMZONE (PIPE_RESOURCE_FLAG_DRV_PRIV << 2) -#define IRIS_RESOURCE_FLAG_BINDLESS_MEMZONE (PIPE_RESOURCE_FLAG_DRV_PRIV << 3) +#define IRIS_RESOURCE_FLAG_SCRATCH_MEMZONE (PIPE_RESOURCE_FLAG_DRV_PRIV << 3) #define IRIS_RESOURCE_FLAG_DEVICE_MEM (PIPE_RESOURCE_FLAG_DRV_PRIV << 4) /** diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index d0c0e03fe8d..062a2f3aa20 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -5330,7 +5330,7 @@ pin_scratch_space(struct iris_context *ice, false, IRIS_DOMAIN_NONE); scratch_addr = ref->offset + iris_resource_bo(ref->res)->address - - IRIS_MEMZONE_BINDLESS_START; + IRIS_MEMZONE_SCRATCH_START; assert((scratch_addr & 0x3f) == 0 && scratch_addr < (1 << 26)); #else scratch_addr = scratch_bo->address;
