diff --git a/runtime/mem_obj/buffer.cpp b/runtime/mem_obj/buffer.cpp index 8e888a2951e50..b89a9e4913558 100644 --- a/runtime/mem_obj/buffer.cpp +++ b/runtime/mem_obj/buffer.cpp @@ -18,6 +18,7 @@ #include "runtime/gmm_helper/gmm_helper.h" #include "runtime/helpers/hw_helper.h" #include "runtime/helpers/hw_info.h" +#include "runtime/helpers/memory_properties_flags_helpers.h" #include "runtime/helpers/timestamp_packet.h" #include "runtime/helpers/validators.h" #include "runtime/mem_obj/mem_obj_helper.h" @@ -151,7 +152,8 @@ Buffer *Buffer::create(Context *context, memoryManager->isLocalMemorySupported(), HwHelper::get(context->getDevice(0)->getHardwareInfo().platform.eRenderCoreFamily).obtainRenderBufferCompressionPreference(size)); - checkMemory(properties.flags, size, hostPtr, errcodeRet, alignementSatisfied, copyMemoryFromHostPtr, memoryManager); + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties); + checkMemory(memoryProperties, size, hostPtr, errcodeRet, alignementSatisfied, copyMemoryFromHostPtr, memoryManager); if (errcodeRet != CL_SUCCESS) { return nullptr; @@ -323,7 +325,7 @@ Buffer *Buffer::createSharedBuffer(Context *context, cl_mem_flags flags, Sharing return sharedBuffer; } -void Buffer::checkMemory(cl_mem_flags flags, +void Buffer::checkMemory(MemoryPropertiesFlags memoryProperties, size_t size, void *hostPtr, cl_int &errcodeRet, @@ -340,13 +342,13 @@ void Buffer::checkMemory(cl_mem_flags flags, } if (hostPtr) { - if (!(flags & (CL_MEM_USE_HOST_PTR | CL_MEM_COPY_HOST_PTR))) { + if (!(memoryProperties.useHostPtr || memoryProperties.copyHostPtr)) { errcodeRet = CL_INVALID_HOST_PTR; return; } } - if (flags & CL_MEM_USE_HOST_PTR) { + if (memoryProperties.useHostPtr) { if (hostPtr) { auto fragment = memoryManager->getHostPtrManager()->getFragment(hostPtr); if (fragment && fragment->driverAllocation) { @@ -364,7 +366,7 @@ void Buffer::checkMemory(cl_mem_flags flags, } } - if (flags & CL_MEM_COPY_HOST_PTR) { + if (memoryProperties.copyHostPtr) { if (hostPtr) { copyMemoryFromHostPtr = true; } else { diff --git a/runtime/mem_obj/buffer.h b/runtime/mem_obj/buffer.h index 1dcb45fd3e85f..69b4f3b27a918 100644 --- a/runtime/mem_obj/buffer.h +++ b/runtime/mem_obj/buffer.h @@ -13,6 +13,7 @@ #include "runtime/memory_manager/memory_constants.h" #include "igfxfmid.h" +#include "memory_properties_flags.h" namespace NEO { class Buffer; @@ -139,7 +140,7 @@ class Buffer : public MemObj { Buffer(); - static void checkMemory(cl_mem_flags flags, + static void checkMemory(MemoryPropertiesFlags memoryProperties, size_t size, void *hostPtr, cl_int &errcodeRet,