[Mesa-dev] [PATCH 1/3] clover: Check invalid flag combinations in clCreateBuffer.

Jan Vesely jan.vesely at rutgers.edu
Sun Dec 15 14:28:14 PST 2013


Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
 src/gallium/state_trackers/clover/api/memory.cpp | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/gallium/state_trackers/clover/api/memory.cpp b/src/gallium/state_trackers/clover/api/memory.cpp
index 785a509..15f5b7f 100644
--- a/src/gallium/state_trackers/clover/api/memory.cpp
+++ b/src/gallium/state_trackers/clover/api/memory.cpp
@@ -43,6 +43,21 @@ clCreateBuffer(cl_context d_ctx, cl_mem_flags flags, size_t size,
                  CL_MEM_COPY_HOST_PTR))
       throw error(CL_INVALID_VALUE);
 
+   if ((flags & CL_MEM_WRITE_ONLY) && (flags & CL_MEM_READ_ONLY))
+      throw error(CL_INVALID_VALUE);
+
+   if ((flags & CL_MEM_READ_WRITE) && (flags & CL_MEM_READ_ONLY))
+      throw error(CL_INVALID_VALUE);
+
+   if ((flags & CL_MEM_READ_WRITE) && (flags & CL_MEM_WRITE_ONLY))
+      throw error(CL_INVALID_VALUE);
+
+   if ((flags & CL_MEM_COPY_HOST_PTR) && (flags & CL_MEM_USE_HOST_PTR))
+      throw error(CL_INVALID_VALUE);
+
+   if ((flags & CL_MEM_ALLOC_HOST_PTR) && (flags & CL_MEM_USE_HOST_PTR))
+      throw error(CL_INVALID_VALUE);
+
    ret_error(r_errcode, CL_SUCCESS);
    return new root_buffer(ctx, flags, size, host_ptr);
 
-- 
1.8.3.1



More information about the mesa-dev mailing list