Fix memory flags validation for Images

HostPtr flags are never accepted when parent memory object is provided

Change-Id: If1d55e0456d6ab8605dbae5476780c2cb5f811ca
Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski
2019-03-18 10:31:08 +01:00
committed by sys_ocldev
parent 7a7bb50328
commit 751740d987
2 changed files with 28 additions and 20 deletions

View File

@@ -113,17 +113,25 @@ TEST(MemObjHelper, givenInvalidPropertiesWhenValidatingMemoryPropertiesThenFalse
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr));
}
struct Image1dWithAccessFlagsUnrestricted : public Image1dDefaults {
enum { flags = CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL };
};
TEST(MemObjHelper, givenParentMemObjAndHostPtrFlagsWhenValidatingMemoryPropertiesForImageThenFalseIsReturned) {
MemoryProperties properties;
MockContext context;
auto image = clUniquePtr(Image1dHelper<>::create(&context));
auto imageWithAccessFlagsUnrestricted = clUniquePtr(ImageHelper<Image1dWithAccessFlagsUnrestricted>::create(&context));
properties.flags = CL_MEM_USE_HOST_PTR;
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, image.get()));
cl_mem_flags hostPtrFlags[] = {CL_MEM_USE_HOST_PTR, CL_MEM_ALLOC_HOST_PTR, CL_MEM_COPY_HOST_PTR};
properties.flags = CL_MEM_ALLOC_HOST_PTR;
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, image.get()));
for (auto hostPtrFlag : hostPtrFlags) {
properties.flags = hostPtrFlag;
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, image.get()));
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, imageWithAccessFlagsUnrestricted.get()));
properties.flags = CL_MEM_COPY_HOST_PTR;
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, image.get()));
properties.flags |= CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL;
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, image.get()));
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, imageWithAccessFlagsUnrestricted.get()));
}
}