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>
This commit is contained in:
Dave Airlie
2022-03-10 15:01:20 +10:00
committed by Marge Bot
parent 42e78ba125
commit e8c3be0eb8
3 changed files with 16 additions and 0 deletions
@@ -429,6 +429,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,
@@ -1010,6 +1013,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;
@@ -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.
@@ -708,6 +708,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;