Mesa (master): i965: Assert that we don' t use CPU write maps to non-coherent buffers.
Kenneth Graunke
kwg at kemper.freedesktop.org
Mon Jul 10 23:06:40 UTC 2017
Module: Mesa
Branch: master
Commit: 7250cbafb90271579a1d07160498e902996cbc97
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7250cbafb90271579a1d07160498e902996cbc97
Author: Kenneth Graunke <kenneth at whitecape.org>
Date: Sat Jul 1 01:55:52 2017 -0700
i965: Assert that we don't use CPU write maps to non-coherent buffers.
Using CPU maps of non-coherent buffers can get us in a lot of trouble,
and WC maps are a reasonable alternative anyway. Guard against shooting
ourselves in the foot by adding an assert, and comment.
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
---
src/mesa/drivers/dri/i965/brw_bufmgr.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c b/src/mesa/drivers/dri/i965/brw_bufmgr.c
index d9b37bfae3..11251f15ed 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
@@ -669,6 +669,12 @@ brw_bo_map_cpu(struct brw_context *brw, struct brw_bo *bo, unsigned flags)
{
struct brw_bufmgr *bufmgr = bo->bufmgr;
+ /* We disallow CPU maps for writing to non-coherent buffers, as the
+ * CPU map can become invalidated when a batch is flushed out, which
+ * can happen at unpredictable times. You should use WC maps instead.
+ */
+ assert(bo->cache_coherent || !(flags & MAP_WRITE));
+
if (!bo->map_cpu) {
struct drm_i915_gem_mmap mmap_arg;
void *map;
More information about the mesa-commit
mailing list