iris: Allocate main and aux surfaces together

On Gen12, the CCS buffer address doesn't have to be referenced in state
packets. In the case of a stencil buffer with CCS, the kernel won't know
the location of the CCS unless an extra call is made to pin its address.
To avoid this extra call, make the CCS part of the main surface.

v2. Update comment above bo_size. (Jordan)

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
This commit is contained in:
Nanley Chery 2019-10-24 09:14:07 -07:00 committed by Sagar Ghuge
parent ff5bc81b51
commit 0a2a9a4a5b

View file

@ -349,6 +349,8 @@ iris_get_num_logical_layers(const struct iris_resource *res, unsigned level)
static enum isl_aux_state ** static enum isl_aux_state **
create_aux_state_map(struct iris_resource *res, enum isl_aux_state initial) create_aux_state_map(struct iris_resource *res, enum isl_aux_state initial)
{ {
assert(res->aux.state == NULL);
uint32_t total_slices = 0; uint32_t total_slices = 0;
for (uint32_t level = 0; level < res->surf.levels; level++) for (uint32_t level = 0; level < res->surf.levels; level++)
total_slices += iris_get_num_logical_layers(res, level); total_slices += iris_get_num_logical_layers(res, level);
@ -553,16 +555,14 @@ iris_resource_configure_aux(struct iris_screen *screen,
break; break;
} }
if (!res->aux.state) { /* Create the aux_state for the auxiliary buffer. */
/* Create the aux_state for the auxiliary buffer. */ res->aux.state = create_aux_state_map(res, initial_state);
res->aux.state = create_aux_state_map(res, initial_state); if (!res->aux.state)
if (!res->aux.state) return false;
return false;
}
/* Increase the aux offset if the main and aux surfaces will share a BO. */ /* Increase the aux offset if the main and aux surfaces will share a BO. */
assert(!res->mod_info || res->mod_info->aux.usage == res->aux.usage); res->aux.offset =
res->aux.offset = res->mod_info ? !res->mod_info || res->mod_info->aux_usage == res->aux.usage ?
ALIGN(res->surf.size_B, res->aux.surf.alignment_B) : 0; ALIGN(res->surf.size_B, res->aux.surf.alignment_B) : 0;
uint64_t size = res->aux.surf.size_B; uint64_t size = res->aux.surf.size_B;
@ -861,19 +861,11 @@ iris_resource_create_with_modifiers(struct pipe_screen *pscreen,
goto fail; goto fail;
} }
const bool aux_enabled = res->aux.surf.size_B > 0; /* Modifiers require the aux data to be in the same buffer as the main
const bool separate_aux = aux_enabled && !res->mod_info; * surface, but we combine them even when a modifiers is not being used.
uint64_t bo_size; */
const uint64_t bo_size =
if (aux_enabled && !separate_aux) { MAX2(res->surf.size_B, res->aux.offset + aux_size);
/* Allocate aux data with main surface. This is required for modifiers
* with aux data (ccs).
*/
bo_size = res->aux.offset + aux_size;
} else {
bo_size = res->surf.size_B;
}
uint32_t alignment = MAX2(4096, res->surf.alignment_B); uint32_t alignment = MAX2(4096, res->surf.alignment_B);
res->bo = iris_bo_alloc_tiled(screen->bufmgr, name, bo_size, alignment, res->bo = iris_bo_alloc_tiled(screen->bufmgr, name, bo_size, alignment,
memzone, memzone,
@ -883,19 +875,14 @@ iris_resource_create_with_modifiers(struct pipe_screen *pscreen,
if (!res->bo) if (!res->bo)
goto fail; goto fail;
if (aux_enabled) { if (aux_size > 0) {
if (separate_aux) { res->aux.bo = res->bo;
if (!iris_resource_alloc_separate_aux(screen, res)) iris_bo_reference(res->aux.bo);
goto fail; unsigned clear_color_state_size =
} else { iris_get_aux_clear_color_state_size(screen);
res->aux.bo = res->bo; if (!iris_resource_init_aux_buf(res, flags, clear_color_state_size))
iris_bo_reference(res->aux.bo); goto fail;
unsigned clear_color_state_size = map_aux_addresses(screen, res);
iris_get_aux_clear_color_state_size(screen);
if (!iris_resource_init_aux_buf(res, flags, clear_color_state_size))
goto fail;
map_aux_addresses(screen, res);
}
} }
return &res->base; return &res->base;