iris: New compressed heaps for scanout buffers (xe2)

Two new heaps are introduced to use a different PAT entry
for compressed buffers to display.

Signed-off-by: Jianxun Zhang <jianxun.zhang@intel.com>
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29928>
This commit is contained in:
Jianxun Zhang 2024-07-23 11:31:47 -07:00
parent ca092db7ce
commit 6eeb079653
2 changed files with 41 additions and 13 deletions

View file

@ -777,7 +777,9 @@ iris_slab_alloc(void *priv,
switch (heap) {
case IRIS_HEAP_SYSTEM_MEMORY_UNCACHED_COMPRESSED:
case IRIS_HEAP_SYSTEM_MEMORY_UNCACHED_COMPRESSED_SCANOUT:
case IRIS_HEAP_DEVICE_LOCAL_COMPRESSED:
case IRIS_HEAP_DEVICE_LOCAL_COMPRESSED_SCANOUT:
flags |= BO_ALLOC_COMPRESSED;
break;
case IRIS_HEAP_SYSTEM_MEMORY_CACHED_COHERENT:
@ -854,9 +856,12 @@ flags_to_heap(struct iris_bufmgr *bufmgr, enum bo_alloc_flags flags)
const struct intel_device_info *devinfo = &bufmgr->devinfo;
if (bufmgr->vram.size > 0) {
if (flags & BO_ALLOC_COMPRESSED)
return IRIS_HEAP_DEVICE_LOCAL_COMPRESSED;
if (flags & BO_ALLOC_COMPRESSED) {
if (flags & BO_ALLOC_SCANOUT)
return IRIS_HEAP_DEVICE_LOCAL_COMPRESSED_SCANOUT;
return IRIS_HEAP_DEVICE_LOCAL_COMPRESSED;
}
/* Discrete GPUs currently always snoop CPU caches. */
if ((flags & BO_ALLOC_SMEM) || (flags & BO_ALLOC_CACHED_COHERENT))
return IRIS_HEAP_SYSTEM_MEMORY_CACHED_COHERENT;
@ -882,8 +887,12 @@ flags_to_heap(struct iris_bufmgr *bufmgr, enum bo_alloc_flags flags)
assert(!devinfo->has_llc);
assert(!(flags & BO_ALLOC_LMEM));
if (flags & BO_ALLOC_COMPRESSED)
if (flags & BO_ALLOC_COMPRESSED) {
if (flags & BO_ALLOC_SCANOUT)
return IRIS_HEAP_SYSTEM_MEMORY_UNCACHED_COMPRESSED_SCANOUT;
return IRIS_HEAP_SYSTEM_MEMORY_UNCACHED_COMPRESSED;
}
if (flags & (BO_ALLOC_SCANOUT | BO_ALLOC_SHARED))
return IRIS_HEAP_SYSTEM_MEMORY_UNCACHED;
@ -1139,15 +1148,15 @@ alloc_fresh_bo(struct iris_bufmgr *bufmgr, uint64_t bo_size, enum bo_alloc_flags
case IRIS_HEAP_DEVICE_LOCAL:
case IRIS_HEAP_DEVICE_LOCAL_CPU_VISIBLE_SMALL_BAR:
case IRIS_HEAP_DEVICE_LOCAL_COMPRESSED:
case IRIS_HEAP_DEVICE_LOCAL_COMPRESSED_SCANOUT:
regions[num_regions++] = bufmgr->vram.region;
break;
case IRIS_HEAP_SYSTEM_MEMORY_CACHED_COHERENT:
regions[num_regions++] = bufmgr->sys.region;
break;
case IRIS_HEAP_SYSTEM_MEMORY_UNCACHED_COMPRESSED:
/* not valid, compressed in discrete is always created with
* IRIS_HEAP_DEVICE_LOCAL_PREFERRED_COMPRESSED
*/
case IRIS_HEAP_SYSTEM_MEMORY_UNCACHED_COMPRESSED_SCANOUT:
/* Discrete GPUs have dedicated compressed heaps. */
case IRIS_HEAP_SYSTEM_MEMORY_UNCACHED:
/* not valid; discrete cards always enable snooping */
case IRIS_HEAP_MAX:
@ -1179,8 +1188,11 @@ iris_heap_to_string[IRIS_HEAP_MAX] = {
[IRIS_HEAP_SYSTEM_MEMORY_CACHED_COHERENT] = "system-cached-coherent",
[IRIS_HEAP_SYSTEM_MEMORY_UNCACHED] = "system-uncached",
[IRIS_HEAP_SYSTEM_MEMORY_UNCACHED_COMPRESSED] = "system-uncached-compressed",
[IRIS_HEAP_SYSTEM_MEMORY_UNCACHED_COMPRESSED_SCANOUT] =
"system-uncached-compressed-scanout",
[IRIS_HEAP_DEVICE_LOCAL] = "local",
[IRIS_HEAP_DEVICE_LOCAL_COMPRESSED] = "local-compressed",
[IRIS_HEAP_DEVICE_LOCAL_COMPRESSED_SCANOUT] = "local-compressed-scanout",
[IRIS_HEAP_DEVICE_LOCAL_PREFERRED] = "local-preferred",
[IRIS_HEAP_DEVICE_LOCAL_CPU_VISIBLE_SMALL_BAR] = "local-cpu-visible-small-bar",
};
@ -1201,7 +1213,9 @@ heap_to_mmap_mode(struct iris_bufmgr *bufmgr, enum iris_heap heap)
case IRIS_HEAP_SYSTEM_MEMORY_UNCACHED:
return IRIS_MMAP_WC;
case IRIS_HEAP_SYSTEM_MEMORY_UNCACHED_COMPRESSED:
case IRIS_HEAP_SYSTEM_MEMORY_UNCACHED_COMPRESSED_SCANOUT:
case IRIS_HEAP_DEVICE_LOCAL_COMPRESSED:
case IRIS_HEAP_DEVICE_LOCAL_COMPRESSED_SCANOUT:
/* compressed bos are not mmaped */
return IRIS_MMAP_NONE;
default:
@ -2675,12 +2689,8 @@ const struct intel_device_info_pat_entry *
iris_heap_to_pat_entry(const struct intel_device_info *devinfo,
enum iris_heap heap, bool scanout)
{
if (scanout) {
if (iris_heap_is_compressed(heap) == false)
if (scanout && !iris_heap_is_compressed(heap)) {
return &devinfo->pat.scanout;
WARN_ONCE(iris_heap_is_compressed(heap),
"update heap_to_pat_entry when compressed scanout pat entries are added");
}
switch (heap) {
@ -2695,6 +2705,9 @@ iris_heap_to_pat_entry(const struct intel_device_info *devinfo,
case IRIS_HEAP_SYSTEM_MEMORY_UNCACHED_COMPRESSED:
case IRIS_HEAP_DEVICE_LOCAL_COMPRESSED:
return &devinfo->pat.compressed;
case IRIS_HEAP_SYSTEM_MEMORY_UNCACHED_COMPRESSED_SCANOUT:
case IRIS_HEAP_DEVICE_LOCAL_COMPRESSED_SCANOUT:
return &devinfo->pat.compressed_scanout;
default:
unreachable("invalid heap for platforms using PAT entries");
}

View file

@ -183,6 +183,12 @@ enum iris_heap {
/** IRIS_HEAP_SYSTEM_MEMORY_UNCACHED + compressed, only supported in Xe2 */
IRIS_HEAP_SYSTEM_MEMORY_UNCACHED_COMPRESSED,
/** Only supported in Xe2, this heap has a different compression-enabled
* PAT entry for buffers to display, compared to the
* IRIS_HEAP_SYSTEM_MEMORY_UNCACHED_COMPRESSED
*/
IRIS_HEAP_SYSTEM_MEMORY_UNCACHED_COMPRESSED_SCANOUT,
/** Device-local memory (VRAM). Cannot be placed in system memory! */
IRIS_HEAP_DEVICE_LOCAL,
IRIS_HEAP_MAX_NO_VRAM = IRIS_HEAP_DEVICE_LOCAL,
@ -190,6 +196,12 @@ enum iris_heap {
/** Device-local compressed memory, only supported in Xe2 */
IRIS_HEAP_DEVICE_LOCAL_COMPRESSED,
/** Only supported in Xe2, this heap has a different compression-enabled
* PAT entry for buffers to display, compared to the
* IRIS_HEAP_DEVICE_LOCAL_COMPRESSED
*/
IRIS_HEAP_DEVICE_LOCAL_COMPRESSED_SCANOUT,
/** Device-local memory that may be evicted to system memory if needed. */
IRIS_HEAP_DEVICE_LOCAL_PREFERRED,
@ -213,14 +225,17 @@ iris_heap_is_device_local(enum iris_heap heap)
return heap == IRIS_HEAP_DEVICE_LOCAL ||
heap == IRIS_HEAP_DEVICE_LOCAL_PREFERRED ||
heap == IRIS_HEAP_DEVICE_LOCAL_CPU_VISIBLE_SMALL_BAR ||
heap == IRIS_HEAP_DEVICE_LOCAL_COMPRESSED;
heap == IRIS_HEAP_DEVICE_LOCAL_COMPRESSED ||
heap == IRIS_HEAP_DEVICE_LOCAL_COMPRESSED_SCANOUT;
}
static inline bool
iris_heap_is_compressed(enum iris_heap heap)
{
return heap == IRIS_HEAP_SYSTEM_MEMORY_UNCACHED_COMPRESSED ||
heap == IRIS_HEAP_DEVICE_LOCAL_COMPRESSED;
heap == IRIS_HEAP_SYSTEM_MEMORY_UNCACHED_COMPRESSED_SCANOUT ||
heap == IRIS_HEAP_DEVICE_LOCAL_COMPRESSED ||
heap == IRIS_HEAP_DEVICE_LOCAL_COMPRESSED_SCANOUT;
}
#define IRIS_BATCH_COUNT 3