aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGil Pitney <gil.pitney@linaro.org>2015-07-22 22:09:00 +0000
committerGil Pitney <gil.pitney@linaro.org>2015-07-22 22:09:00 +0000
commit791ca3d2e8745e1abe2c2c66db41a20ec51bd6ea (patch)
tree9310c10b2b78cf982e121f572f61d91db237d858
parent0d99b82aae804520c1fedef4d78a5f4437512fe0 (diff)
downloadshamrock-791ca3d2e8745e1abe2c2c66db41a20ec51bd6ea.tar.gz
Add new v1.2 cl_mem flags to Buffer and SubBuffer creation functions.
The flags: CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ON | CL_MEM_HOST_NO_ACCESS were missing in the validation of flags to clCreateBuffer() and clCreateSubBuffer(). In addition, sub-buffer creation functions needed logic to conditionally inherit flags from the parent buffer. This patch enables the Khronos conformance test: % test_api get_buffer_info to PASS. Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
-rw-r--r--src/core/memobject.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/core/memobject.cpp b/src/core/memobject.cpp
index bd8736f..3e2eeb1 100644
--- a/src/core/memobject.cpp
+++ b/src/core/memobject.cpp
@@ -56,8 +56,10 @@ MemObject::MemObject(Context *ctx, cl_mem_flags flags, void *host_ptr,
// Check the flags value
const cl_mem_flags all_flags = CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY |
CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR |
- CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR
- |CL_MEM_USE_MSMC_TI;
+ CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR |
+ CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY |
+ CL_MEM_HOST_NO_ACCESS |
+ CL_MEM_USE_MSMC_TI;
if ((flags & CL_MEM_READ_WRITE) && (flags & CL_MEM_READ_ONLY))
{
@@ -540,15 +542,24 @@ SubBuffer::SubBuffer(class Buffer *parent, size_t offset, size_t size,
}
// OpenCL 1.2: SubBuffer should inherit some of parent Buffer flags
+ // Conditionally inherit read/write parent flags, if none spec'd for sub-buffer:
cl_mem_flags parent_rw_flags = parent->flags()
& (CL_MEM_READ_WRITE | CL_MEM_READ_ONLY | CL_MEM_WRITE_ONLY);
cl_mem_flags my_rw_flags = p_flags
& (CL_MEM_READ_WRITE | CL_MEM_READ_ONLY | CL_MEM_WRITE_ONLY);
- // parent be READ_WRITE, subBuffer be READ_ONLY/WRITE_ONLY (Spec allows)
if (! my_rw_flags) p_flags |= parent_rw_flags;
+
+ // Unconditionally inherit parents 'hostptr' flags:
cl_mem_flags parent_hostptr_flags = parent->flags()
& (CL_MEM_USE_HOST_PTR | CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR);
if (parent_hostptr_flags) p_flags |= parent_hostptr_flags;
+
+ // Conditionally inherit 'host use' parent flags, if none spec'd for sub-buffer:
+ cl_mem_flags parent_host_use_flags = parent->flags()
+ & (CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS);
+ cl_mem_flags my_host_use_flags = p_flags
+ & (CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS);
+ if (! my_host_use_flags) p_flags |= parent_host_use_flags;
}
SubBuffer::~SubBuffer()