iris: Force lmem cpu accessible for bos with clear-color

KMD needs to be able to read and write the clear-color from CPU.
i915 can workaround it but Xe KMD will reject page flips with
clear-color bos that can be read from CPU.

So here it make sure that bos with the clear color information
are placed in a lmem portion that is CPU-visible, that is important in
PCIe small bar systems.
And as CCS in discrete GPUs are only supported in lmem this bo can't
become a IRIS_HEAP_DEVICE_LOCAL_PREFERRED(lmem + smem).

So here the IRIS_HEAP_DEVICE_LOCAL_CPU_VISIBLE_SMALL_BAR heap is selected.

Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26700>
This commit is contained in:
José Roberto de Souza 2023-09-01 08:58:54 -07:00 committed by Marge Bot
parent 8a9168584c
commit 283d8ca98a

View file

@ -476,7 +476,7 @@ iris_resource_disable_aux(struct iris_resource *res)
static unsigned
iris_resource_alloc_flags(const struct iris_screen *screen,
const struct pipe_resource *templ,
enum isl_aux_usage aux_usage)
struct iris_resource *res)
{
if (templ->flags & IRIS_RESOURCE_FLAG_DEVICE_MEM)
return BO_ALLOC_PLAIN;
@ -505,9 +505,14 @@ iris_resource_alloc_flags(const struct iris_screen *screen,
flags |= BO_ALLOC_SMEM | BO_ALLOC_COHERENT;
if (screen->devinfo->verx10 >= 125 && screen->devinfo->has_local_mem &&
isl_aux_usage_has_ccs(aux_usage)) {
isl_aux_usage_has_ccs(res->aux.usage)) {
assert((flags & BO_ALLOC_SMEM) == 0);
flags |= BO_ALLOC_LMEM;
/* For displayable surfaces with clear color,
* the KMD will need to access the clear color via CPU.
*/
if (res->mod_info && res->mod_info->supports_clear_color)
flags |= BO_ALLOC_CPU_VISIBLE;
}
if ((templ->bind & PIPE_BIND_SHARED) ||
@ -1078,7 +1083,7 @@ iris_resource_create_for_buffer(struct pipe_screen *pscreen,
name = "scratch surface state";
}
unsigned flags = iris_resource_alloc_flags(screen, templ, res->aux.usage);
unsigned flags = iris_resource_alloc_flags(screen, templ, res);
res->bo = iris_bo_alloc(screen->bufmgr, name, templ->width0,
iris_buffer_alignment(templ->width0),
@ -1142,7 +1147,7 @@ iris_resource_create_for_image(struct pipe_screen *pscreen,
const char *name = "miptree";
enum iris_memory_zone memzone = IRIS_MEMZONE_OTHER;
unsigned flags = iris_resource_alloc_flags(screen, templ, res->aux.usage);
unsigned flags = iris_resource_alloc_flags(screen, templ, res);
/* These are for u_upload_mgr buffers only */
assert(!(templ->flags & (IRIS_RESOURCE_FLAG_SHADER_MEMZONE |