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

Francisco Jerez currojerez at riseup.net
Fri Aug 8 08:10:19 PDT 2014


Bruno Jiménez <brunojimen at gmail.com> writes:

> 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.
>
> v2: Move the code for validating flags to the front-end as
>     suggested by Francisco Jerez

Looks good to me, pushed as ec73778f1fd6e14623422d62605fc69dc8fb7aa4.

> ---
>  src/gallium/state_trackers/clover/api/transfer.cpp  | 13 +++++++++++++
>  src/gallium/state_trackers/clover/core/resource.cpp |  2 ++
>  2 files changed, 15 insertions(+)
>
> diff --git a/src/gallium/state_trackers/clover/api/transfer.cpp b/src/gallium/state_trackers/clover/api/transfer.cpp
> index 07d8a73..37c3074 100644
> --- a/src/gallium/state_trackers/clover/api/transfer.cpp
> +++ b/src/gallium/state_trackers/clover/api/transfer.cpp
> @@ -168,6 +168,17 @@ namespace {
>     }
>  
>     ///
> +   /// Checks that the mapping flags are correct
> +   ///
> +   void
> +   validate_flags(const cl_map_flags flags) {
> +      if (((flags & CL_MAP_WRITE) || (flags & CL_MAP_READ)) &&
> +           (flags & CL_MAP_WRITE_INVALIDATE_REGION))
> +         throw error(CL_INVALID_VALUE);
> +   }
> +
> +
> +   ///
>     /// Class that encapsulates the task of mapping an object of type
>     /// \a T.  The return value of get() should be implicitly
>     /// convertible to \a void *.
> @@ -629,6 +640,7 @@ clEnqueueMapBuffer(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
>  
>     validate_common(q, deps);
>     validate_object(q, mem, obj_origin, obj_pitch, region);
> +   validate_flags(flags);
>  
>     void *map = mem.resource(q).add_map(q, flags, blocking, obj_origin, region);
>  
> @@ -656,6 +668,7 @@ clEnqueueMapImage(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
>  
>     validate_common(q, deps);
>     validate_object(q, img, origin, region);
> +   validate_flags(flags);
>  
>     void *map = img.resource(q).add_map(q, flags, blocking, origin, region);
>  
> diff --git a/src/gallium/state_trackers/clover/core/resource.cpp b/src/gallium/state_trackers/clover/core/resource.cpp
> index 7b8a40a..34c0cd5 100644
> --- a/src/gallium/state_trackers/clover/core/resource.cpp
> +++ b/src/gallium/state_trackers/clover/core/resource.cpp
> @@ -174,6 +174,8 @@ mapping::mapping(command_queue &q, resource &r,
>     pctx(q.pipe) {
>     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
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140808/cfffd20a/attachment.sig>


More information about the mesa-dev mailing list