diff options
author | Aaron Watry <[email protected]> | 2018-04-07 13:44:53 -0500 |
---|---|---|
committer | Aaron Watry <[email protected]> | 2018-04-19 20:57:37 -0500 |
commit | 354b12681bc01d967849e05fae2677a3e1c5ca3a (patch) | |
tree | e154a315b1b8716dd6e986ed2dbf3446a3c9fd9c | |
parent | c366f422f0a68e6e440f419c506af24052159b6d (diff) |
clover: Fix host access validation for sub-buffer creation
From CL 1.2 Section 5.2.1:
CL_INVALID_VALUE if buffer was created with CL_MEM_HOST_WRITE_ONLY and
flags specify CL_MEM_HOST_READ_ONLY , or if buffer was created with
CL_MEM_HOST_READ_ONLY and flags specify CL_MEM_HOST_WRITE_ONLY , or if
buffer was created with CL_MEM_HOST_NO_ACCESS and flags specify
CL_MEM_HOST_READ_ONLY or CL_MEM_HOST_WRITE_ONLY .
Fixes CL 1.2 CTS test/api get_buffer_info
v2: Correct host_access_flags check (Francisco)
Signed-off-by: Aaron Watry <[email protected]>
Reviewed-by: Francisco Jerez <[email protected]>
-rw-r--r-- | src/gallium/state_trackers/clover/api/memory.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/gallium/state_trackers/clover/api/memory.cpp b/src/gallium/state_trackers/clover/api/memory.cpp index 9b3cd8b1f5c..df4b9baa1d9 100644 --- a/src/gallium/state_trackers/clover/api/memory.cpp +++ b/src/gallium/state_trackers/clover/api/memory.cpp @@ -57,8 +57,13 @@ namespace { parent.flags() & host_access_flags) | (parent.flags() & host_ptr_flags)); - if (~flags & parent.flags() & - ((dev_access_flags & ~CL_MEM_READ_WRITE) | host_access_flags)) + if (~flags & parent.flags() & (dev_access_flags & ~CL_MEM_READ_WRITE)) + throw error(CL_INVALID_VALUE); + + // Check if new host access flags cause a mismatch between + // host-read/write-only. + if (!(flags & CL_MEM_HOST_NO_ACCESS) && + (~flags & parent.flags() & host_access_flags)) throw error(CL_INVALID_VALUE); return flags; |