[Mesa-dev] [PATCH] clover: Add support for CL_MAP_WRITE_INVALIDATE_REGION

Bruno Jiménez brunojimen at gmail.com
Thu Aug 7 03:44:36 PDT 2014


OpenCL 1.2 CL_MAP_WRITE_INVALIDATE_REGION sounds a lot like
PIPE_TRANSFER_DISCARD_RANGE:

>From OpenCL 1.2 spec:
    The contents of the region being mapped are to be discarded.

>From p_defines.h:
    Discards the memory within the mapped region.
---
 src/gallium/state_trackers/clover/core/resource.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/gallium/state_trackers/clover/core/resource.cpp b/src/gallium/state_trackers/clover/core/resource.cpp
index 7b8a40a..f7d24ef 100644
--- a/src/gallium/state_trackers/clover/core/resource.cpp
+++ b/src/gallium/state_trackers/clover/core/resource.cpp
@@ -172,8 +172,14 @@ mapping::mapping(command_queue &q, resource &r,
                  const resource::vector &origin,
                  const resource::vector &region) :
    pctx(q.pipe) {
+   if (((flags & CL_MAP_WRITE) || (flags & CL_MAP_READ)) &&
+        (flags & CL_MAP_WRITE_INVALIDATE_REGION))
+       throw error(CL_INVALID_VALUE);
+
    unsigned usage = ((flags & CL_MAP_WRITE ? PIPE_TRANSFER_WRITE : 0 ) |
                      (flags & CL_MAP_READ ? PIPE_TRANSFER_READ : 0 ) |
+                     (flags & CL_MAP_WRITE_INVALIDATE_REGION ?
+                        PIPE_TRANSFER_DISCARD_RANGE : 0) |
                      (!blocking ? PIPE_TRANSFER_UNSYNCHRONIZED : 0));
 
    p = pctx->transfer_map(pctx, r.pipe, 0, usage,
-- 
2.0.4



More information about the mesa-dev mailing list