mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-10 15:12:56 +08:00
Remove OCL object from MemoryProperties 8/n
Refactor MemoryPropertiesFlags to bitfield Related-To: NEO-3132 Change-Id: I7092b16d15cec962e94c992696bd9845ce86f642 Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
90266b4a37
commit
84c801e28b
@@ -31,8 +31,8 @@ bool NEO::MemoryPropertiesParser::parseMemoryProperties(const cl_mem_properties_
|
||||
|
||||
void MemoryPropertiesParser::fillPoliciesInProperties(AllocationProperties &allocationProperties, const MemoryPropertiesFlags &memoryProperties) {
|
||||
fillCachePolicyInProperties(allocationProperties,
|
||||
memoryProperties.locallyUncachedResource,
|
||||
memoryProperties.readOnly,
|
||||
memoryProperties.flags.locallyUncachedResource,
|
||||
memoryProperties.flags.readOnly,
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,54 +17,54 @@ MemoryPropertiesFlags MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(M
|
||||
MemoryPropertiesFlags memoryPropertiesFlags;
|
||||
|
||||
if (isValueSet(properties.flags, CL_MEM_READ_WRITE)) {
|
||||
memoryPropertiesFlags.readWrite = true;
|
||||
memoryPropertiesFlags.flags.readWrite = true;
|
||||
}
|
||||
if (isValueSet(properties.flags, CL_MEM_WRITE_ONLY)) {
|
||||
memoryPropertiesFlags.writeOnly = true;
|
||||
memoryPropertiesFlags.flags.writeOnly = true;
|
||||
}
|
||||
if (isValueSet(properties.flags, CL_MEM_READ_ONLY)) {
|
||||
memoryPropertiesFlags.readOnly = true;
|
||||
memoryPropertiesFlags.flags.readOnly = true;
|
||||
}
|
||||
if (isValueSet(properties.flags, CL_MEM_USE_HOST_PTR)) {
|
||||
memoryPropertiesFlags.useHostPtr = true;
|
||||
memoryPropertiesFlags.flags.useHostPtr = true;
|
||||
}
|
||||
if (isValueSet(properties.flags, CL_MEM_ALLOC_HOST_PTR)) {
|
||||
memoryPropertiesFlags.allocHostPtr = true;
|
||||
memoryPropertiesFlags.flags.allocHostPtr = true;
|
||||
}
|
||||
if (isValueSet(properties.flags, CL_MEM_COPY_HOST_PTR)) {
|
||||
memoryPropertiesFlags.copyHostPtr = true;
|
||||
memoryPropertiesFlags.flags.copyHostPtr = true;
|
||||
}
|
||||
if (isValueSet(properties.flags, CL_MEM_HOST_WRITE_ONLY)) {
|
||||
memoryPropertiesFlags.hostWriteOnly = true;
|
||||
memoryPropertiesFlags.flags.hostWriteOnly = true;
|
||||
}
|
||||
if (isValueSet(properties.flags, CL_MEM_HOST_READ_ONLY)) {
|
||||
memoryPropertiesFlags.hostReadOnly = true;
|
||||
memoryPropertiesFlags.flags.hostReadOnly = true;
|
||||
}
|
||||
if (isValueSet(properties.flags, CL_MEM_HOST_NO_ACCESS)) {
|
||||
memoryPropertiesFlags.hostNoAccess = true;
|
||||
memoryPropertiesFlags.flags.hostNoAccess = true;
|
||||
}
|
||||
if (isValueSet(properties.flags, CL_MEM_KERNEL_READ_AND_WRITE)) {
|
||||
memoryPropertiesFlags.kernelReadAndWrite = true;
|
||||
memoryPropertiesFlags.flags.kernelReadAndWrite = true;
|
||||
}
|
||||
if (isValueSet(properties.flags, CL_MEM_FORCE_LINEAR_STORAGE_INTEL) ||
|
||||
isValueSet(properties.flags_intel, CL_MEM_FORCE_LINEAR_STORAGE_INTEL)) {
|
||||
memoryPropertiesFlags.forceLinearStorage = true;
|
||||
memoryPropertiesFlags.flags.forceLinearStorage = true;
|
||||
}
|
||||
if (isValueSet(properties.flags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) {
|
||||
memoryPropertiesFlags.accessFlagsUnrestricted = true;
|
||||
memoryPropertiesFlags.flags.accessFlagsUnrestricted = true;
|
||||
}
|
||||
if (isValueSet(properties.flags, CL_MEM_NO_ACCESS_INTEL)) {
|
||||
memoryPropertiesFlags.noAccess = true;
|
||||
memoryPropertiesFlags.flags.noAccess = true;
|
||||
}
|
||||
if (isValueSet(properties.flags, CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL) ||
|
||||
isValueSet(properties.flags_intel, CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL)) {
|
||||
memoryPropertiesFlags.allowUnrestrictedSize = true;
|
||||
memoryPropertiesFlags.flags.allowUnrestrictedSize = true;
|
||||
}
|
||||
if (isValueSet(properties.flags_intel, CL_MEM_LOCALLY_UNCACHED_RESOURCE)) {
|
||||
memoryPropertiesFlags.locallyUncachedResource = true;
|
||||
memoryPropertiesFlags.flags.locallyUncachedResource = true;
|
||||
}
|
||||
if (isValueSet(properties.flags, CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL)) {
|
||||
memoryPropertiesFlags.forceSharedPhysicalMemory = true;
|
||||
memoryPropertiesFlags.flags.forceSharedPhysicalMemory = true;
|
||||
}
|
||||
|
||||
addExtraMemoryPropertiesFlags(memoryPropertiesFlags, properties);
|
||||
|
||||
@@ -340,13 +340,13 @@ void Buffer::checkMemory(MemoryPropertiesFlags memoryProperties,
|
||||
}
|
||||
|
||||
if (hostPtr) {
|
||||
if (!(memoryProperties.useHostPtr || memoryProperties.copyHostPtr)) {
|
||||
if (!(memoryProperties.flags.useHostPtr || memoryProperties.flags.copyHostPtr)) {
|
||||
errcodeRet = CL_INVALID_HOST_PTR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (memoryProperties.useHostPtr) {
|
||||
if (memoryProperties.flags.useHostPtr) {
|
||||
if (hostPtr) {
|
||||
auto fragment = memoryManager->getHostPtrManager()->getFragment(hostPtr);
|
||||
if (fragment && fragment->driverAllocation) {
|
||||
@@ -364,7 +364,7 @@ void Buffer::checkMemory(MemoryPropertiesFlags memoryProperties,
|
||||
}
|
||||
}
|
||||
|
||||
if (memoryProperties.copyHostPtr) {
|
||||
if (memoryProperties.flags.copyHostPtr) {
|
||||
if (hostPtr) {
|
||||
copyMemoryFromHostPtr = true;
|
||||
} else {
|
||||
@@ -377,11 +377,11 @@ void Buffer::checkMemory(MemoryPropertiesFlags memoryProperties,
|
||||
GraphicsAllocation::AllocationType Buffer::getGraphicsAllocationType(const MemoryPropertiesFlags &properties, bool sharedContext,
|
||||
ContextType contextType, bool renderCompressedBuffers,
|
||||
bool isLocalMemoryEnabled, bool preferCompression) {
|
||||
if (is32bit || sharedContext || properties.forceSharedPhysicalMemory) {
|
||||
if (is32bit || sharedContext || properties.flags.forceSharedPhysicalMemory) {
|
||||
return GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
|
||||
}
|
||||
|
||||
if (properties.useHostPtr && !isLocalMemoryEnabled) {
|
||||
if (properties.flags.useHostPtr && !isLocalMemoryEnabled) {
|
||||
return GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
|
||||
}
|
||||
|
||||
@@ -393,7 +393,7 @@ GraphicsAllocation::AllocationType Buffer::getGraphicsAllocationType(const Memor
|
||||
|
||||
bool Buffer::isReadOnlyMemoryPermittedByFlags(const MemoryPropertiesFlags &properties) {
|
||||
// Host won't access or will only read and kernel will only read
|
||||
return (properties.hostNoAccess || properties.hostReadOnly) && properties.readOnly;
|
||||
return (properties.flags.hostNoAccess || properties.flags.hostReadOnly) && properties.flags.readOnly;
|
||||
}
|
||||
|
||||
Buffer *Buffer::createSubBuffer(cl_mem_flags flags,
|
||||
|
||||
@@ -181,7 +181,7 @@ Image *Image::create(Context *context,
|
||||
auto hostPtrRowPitch = imageDesc->image_row_pitch ? imageDesc->image_row_pitch : imageWidth * surfaceFormat->ImageElementSizeInBytes;
|
||||
auto hostPtrSlicePitch = imageDesc->image_slice_pitch ? imageDesc->image_slice_pitch : hostPtrRowPitch * imageHeight;
|
||||
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties);
|
||||
imgInfo.linearStorage = context->isSharedContext || !GmmHelper::allowTiling(*imageDesc) || memoryProperties.forceLinearStorage;
|
||||
imgInfo.linearStorage = context->isSharedContext || !GmmHelper::allowTiling(*imageDesc) || memoryProperties.flags.forceLinearStorage;
|
||||
imgInfo.preferRenderCompression = MemObjHelper::isSuitableForRenderCompression(!imgInfo.linearStorage, memoryProperties,
|
||||
context->peekContextType(), true);
|
||||
|
||||
@@ -461,7 +461,7 @@ cl_int Image::validate(Context *context,
|
||||
((parentBuffer->getFlags() & CL_MEM_USE_HOST_PTR) && (reinterpret_cast<uint64_t>(parentBuffer->getHostPtr()) % (*baseAddressAlignment))) ||
|
||||
(minimumBufferSize > parentBuffer->getSize())) {
|
||||
return CL_INVALID_IMAGE_FORMAT_DESCRIPTOR;
|
||||
} else if (memoryProperties.useHostPtr || memoryProperties.copyHostPtr) {
|
||||
} else if (memoryProperties.flags.useHostPtr || memoryProperties.flags.copyHostPtr) {
|
||||
return CL_INVALID_VALUE;
|
||||
}
|
||||
}
|
||||
@@ -549,7 +549,7 @@ cl_int Image::validatePlanarYUV(Context *context,
|
||||
errorCode = CL_INVALID_IMAGE_DESCRIPTOR;
|
||||
break;
|
||||
}
|
||||
if (!memoryProperties.hostNoAccess) {
|
||||
if (!memoryProperties.flags.hostNoAccess) {
|
||||
errorCode = CL_INVALID_VALUE;
|
||||
break;
|
||||
} else {
|
||||
@@ -575,7 +575,7 @@ cl_int Image::validatePlanarYUV(Context *context,
|
||||
cl_int Image::validatePackedYUV(const MemoryPropertiesFlags &memoryProperties, const cl_image_desc *imageDesc) {
|
||||
cl_int errorCode = CL_SUCCESS;
|
||||
while (true) {
|
||||
if (!memoryProperties.readOnly) {
|
||||
if (!memoryProperties.flags.readOnly) {
|
||||
errorCode = CL_INVALID_VALUE;
|
||||
break;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user