Module: Mesa Branch: staging/22.0 Commit: 6822ea6304d213a3d343dac13d9561a61dda548e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6822ea6304d213a3d343dac13d9561a61dda548e
Author: Dave Airlie <[email protected]> Date: Thu Mar 10 15:01:20 2022 +1000 crocus: don't map scanout buffers as write-back This essentially ports 64405230774210488dedbc54d73ba394ec6ae802 Author: Keith Packard <[email protected]> Date: Fri Aug 6 16:11:18 2021 -0700 iris: Map scanout buffers WC instead of WB [v2] to crocus. Fixes: f3630548f1da ("crocus: initial gallium driver for Intel gfx 4-7") Reviewed-by: Zoltán Böszörményi <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15313> (cherry picked from commit e8c3be0eb84bbefe1486f2543125c35b278ac1cf) --- .pick_status.json | 2 +- src/gallium/drivers/crocus/crocus_bufmgr.c | 6 ++++++ src/gallium/drivers/crocus/crocus_bufmgr.h | 6 ++++++ src/gallium/drivers/crocus/crocus_resource.c | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index d7a3baad239..ac5ab8e45d2 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -679,7 +679,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" }, diff --git a/src/gallium/drivers/crocus/crocus_bufmgr.c b/src/gallium/drivers/crocus/crocus_bufmgr.c index aa70271ffee..d3fe5ee42f5 100644 --- a/src/gallium/drivers/crocus/crocus_bufmgr.c +++ b/src/gallium/drivers/crocus/crocus_bufmgr.c @@ -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; diff --git a/src/gallium/drivers/crocus/crocus_bufmgr.h b/src/gallium/drivers/crocus/crocus_bufmgr.h index e4310448440..de550d99fa7 100644 --- a/src/gallium/drivers/crocus/crocus_bufmgr.h +++ b/src/gallium/drivers/crocus/crocus_bufmgr.h @@ -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. diff --git a/src/gallium/drivers/crocus/crocus_resource.c b/src/gallium/drivers/crocus/crocus_resource.c index 3ee44e7713a..436a776360b 100644 --- a/src/gallium/drivers/crocus/crocus_resource.c +++ b/src/gallium/drivers/crocus/crocus_resource.c @@ -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;
