summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/brw_bufmgr.c
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2017-05-18 11:26:08 -0700
committerMatt Turner <[email protected]>2017-06-06 11:47:46 -0700
commit2120cfe1affa24f173b135f149d0e385f1f60b73 (patch)
tree08574242ab81b78f97469c08f92aefcff376203c /src/mesa/drivers/dri/i965/brw_bufmgr.c
parentdcb03bf18d3995949ee9e7a0e350f161b24e183f (diff)
i965: Add and use brw_bo_map()
We can encapsulate the logic for choosing the mapping type. This will also help when we add WC mappings. A few functional changes are made in this patch. On non-LLC, what were previously WB mappings are now GTT mappings (in the prefilling debug code in brw_performance_query.c; the shader_time code in brw_program.c; and in the case of an RW mapping in intel_buffer_objects.c). Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_bufmgr.c')
-rw-r--r--src/mesa/drivers/dri/i965/brw_bufmgr.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c b/src/mesa/drivers/dri/i965/brw_bufmgr.c
index b79f5666906..ec9611feb92 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
@@ -658,7 +658,7 @@ set_domain(struct brw_context *brw, const char *action,
}
}
-void *
+static void *
brw_bo_map_cpu(struct brw_context *brw, struct brw_bo *bo, unsigned flags)
{
struct brw_bufmgr *bufmgr = bo->bufmgr;
@@ -740,7 +740,7 @@ map_gtt(struct brw_bo *bo)
return bo->map_gtt;
}
-void *
+static void *
brw_bo_map_gtt(struct brw_context *brw, struct brw_bo *bo, unsigned flags)
{
struct brw_bufmgr *bufmgr = bo->bufmgr;
@@ -814,6 +814,32 @@ brw_bo_map_unsynchronized(struct brw_context *brw, struct brw_bo *bo)
return map;
}
+static bool
+can_map_cpu(struct brw_bo *bo, unsigned flags)
+{
+ if (bo->cache_coherent)
+ return true;
+
+ if (flags & MAP_PERSISTENT)
+ return false;
+
+ if (flags & MAP_COHERENT)
+ return false;
+
+ return !(flags & MAP_WRITE);
+}
+
+void *
+brw_bo_map(struct brw_context *brw, struct brw_bo *bo, unsigned flags)
+{
+ if (bo->tiling_mode != I915_TILING_NONE && !(flags & MAP_RAW))
+ return brw_bo_map_gtt(brw, bo, flags);
+ else if (can_map_cpu(bo, flags))
+ return brw_bo_map_cpu(brw, bo, flags);
+ else
+ return brw_bo_map_gtt(brw, bo, flags);
+}
+
int
brw_bo_unmap(struct brw_bo *bo)
{