crocus: don't map scanout buffers as write-back

This essentially ports 6440523077
Author: Keith Packard <keithp@keithp.com>
Date:   Fri Aug 6 16:11:18 2021 -0700

    iris: Map scanout buffers WC instead of WB [v2]

to crocus.

Fixes: f3630548f1 ("crocus: initial gallium driver for Intel gfx 4-7")

Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15313>
(cherry picked from commit e8c3be0eb8)
This commit is contained in:
Dave Airlie 2022-03-10 15:01:20 +10:00 committed by Eric Engestrom
parent 6af52034b2
commit 874f8ca2ac
4 changed files with 17 additions and 1 deletions

View file

@ -346,7 +346,7 @@
"description": "crocus: don't map scanout buffers as write-back",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "f3630548f1da904ec6c63b43ece7e68afdb8867e"
},

View file

@ -430,6 +430,9 @@ bo_alloc_internal(struct crocus_bufmgr *bufmgr,
bo->index = -1;
bo->kflags = 0;
if (flags & BO_ALLOC_SCANOUT)
bo->scanout = 1;
if ((flags & BO_ALLOC_COHERENT) && !bo->cache_coherent) {
struct drm_i915_gem_caching arg = {
.handle = bo->gem_handle,
@ -1011,6 +1014,9 @@ crocus_bo_map_gtt(struct pipe_debug_callback *dbg,
static bool
can_map_cpu(struct crocus_bo *bo, unsigned flags)
{
if (bo->scanout)
return false;
if (bo->cache_coherent)
return true;

View file

@ -141,12 +141,18 @@ struct crocus_bo {
*/
bool userptr;
/**
* Boolean of if this is used for scanout.
*/
bool scanout;
/** Pre-computed hash using _mesa_hash_pointer for cache tracking sets */
uint32_t hash;
};
#define BO_ALLOC_ZEROED (1 << 0)
#define BO_ALLOC_COHERENT (1 << 1)
#define BO_ALLOC_SCANOUT (1 << 2)
/**
* Allocate a buffer object.

View file

@ -699,6 +699,10 @@ crocus_resource_create_with_modifiers(struct pipe_screen *pscreen,
if (templ->usage == PIPE_USAGE_STAGING)
flags |= BO_ALLOC_COHERENT;
/* Scanout buffers need to be WC. */
if (templ->bind & PIPE_BIND_SCANOUT)
flags |= BO_ALLOC_SCANOUT;
uint64_t aux_size = 0;
uint32_t aux_preferred_alloc_flags;