mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Pass Device when creating MemoryProperties
Related-To: NEO-4651 Change-Id: Ie1f7f55d4817612de83bfb2a372fd7ac35c11930 Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
7f5aa241b2
commit
78d07b9b37
@@ -1131,7 +1131,7 @@ cl_int CL_API_CALL clGetImageParamsINTEL(cl_context context,
|
||||
"imageDesc", imageDesc,
|
||||
"imageRowPitch", imageRowPitch,
|
||||
"imageSlicePitch", imageSlicePitch);
|
||||
ClSurfaceFormatInfo *surfaceFormat = nullptr;
|
||||
const ClSurfaceFormatInfo *surfaceFormat = nullptr;
|
||||
cl_mem_flags memFlags = CL_MEM_READ_ONLY;
|
||||
retVal = validateObjects(context);
|
||||
auto pContext = castToObject<Context>(context);
|
||||
@@ -1145,8 +1145,11 @@ cl_int CL_API_CALL clGetImageParamsINTEL(cl_context context,
|
||||
retVal = Image::validateImageFormat(imageFormat);
|
||||
}
|
||||
if (CL_SUCCESS == retVal) {
|
||||
surfaceFormat = (ClSurfaceFormatInfo *)Image::getSurfaceFormatFromTable(memFlags, imageFormat, pContext->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
|
||||
retVal = Image::validate(pContext, MemoryPropertiesHelper::createMemoryProperties(memFlags, 0, 0), surfaceFormat, imageDesc, nullptr);
|
||||
auto pClDevice = pContext->getDevice(0);
|
||||
surfaceFormat = Image::getSurfaceFormatFromTable(memFlags, imageFormat,
|
||||
pClDevice->getHardwareInfo().capabilityTable.supportsOcl21Features);
|
||||
retVal = Image::validate(pContext, MemoryPropertiesHelper::createMemoryProperties(memFlags, 0, 0, &pClDevice->getDevice()),
|
||||
surfaceFormat, imageDesc, nullptr);
|
||||
}
|
||||
if (CL_SUCCESS == retVal) {
|
||||
retVal = Image::getImageParams(pContext, memFlags, surfaceFormat, imageDesc, imageRowPitch, imageSlicePitch);
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
void MemoryPropertiesHelper::addExtraMemoryProperties(MemoryProperties &properties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel) {
|
||||
void MemoryPropertiesHelper::addExtraMemoryProperties(MemoryProperties &properties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel,
|
||||
const Device *pDevice) {
|
||||
}
|
||||
DeviceBitfield MemoryPropertiesHelper::adjustDeviceBitfield(const MemoryProperties &memoryProperties, DeviceBitfield deviceBitfield) {
|
||||
return deviceBitfield;
|
||||
@@ -38,7 +39,7 @@ bool MemoryPropertiesHelper::parseMemoryProperties(const cl_mem_properties_intel
|
||||
}
|
||||
}
|
||||
|
||||
memoryProperties = MemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, allocflags);
|
||||
memoryProperties = MemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, allocflags, nullptr);
|
||||
|
||||
switch (objectType) {
|
||||
case MemoryPropertiesHelper::ObjType::BUFFER:
|
||||
|
||||
@@ -25,9 +25,11 @@ class MemoryPropertiesHelper {
|
||||
IMAGE,
|
||||
};
|
||||
|
||||
static void addExtraMemoryProperties(MemoryProperties &properties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel);
|
||||
static void addExtraMemoryProperties(MemoryProperties &properties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel,
|
||||
const Device *pDevice);
|
||||
|
||||
static MemoryProperties createMemoryProperties(cl_mem_flags flags, cl_mem_flags_intel flagsIntel, cl_mem_alloc_flags_intel allocflags);
|
||||
static MemoryProperties createMemoryProperties(cl_mem_flags flags, cl_mem_flags_intel flagsIntel,
|
||||
cl_mem_alloc_flags_intel allocflags, const Device *pDevice);
|
||||
|
||||
static bool parseMemoryProperties(const cl_mem_properties_intel *properties, MemoryProperties &memoryProperties,
|
||||
cl_mem_flags &flags, cl_mem_flags_intel &flagsIntel, cl_mem_alloc_flags_intel &allocflags,
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
MemoryProperties MemoryPropertiesHelper::createMemoryProperties(cl_mem_flags flags, cl_mem_flags_intel flagsIntel, cl_mem_alloc_flags_intel allocflags) {
|
||||
MemoryProperties MemoryPropertiesHelper::createMemoryProperties(cl_mem_flags flags, cl_mem_flags_intel flagsIntel,
|
||||
cl_mem_alloc_flags_intel allocflags, const Device *pDevice) {
|
||||
MemoryProperties memoryProperties;
|
||||
|
||||
if (isValueSet(flags, CL_MEM_READ_WRITE)) {
|
||||
@@ -81,7 +82,7 @@ MemoryProperties MemoryPropertiesHelper::createMemoryProperties(cl_mem_flags fla
|
||||
memoryProperties.flags.resource48Bit = true;
|
||||
}
|
||||
|
||||
addExtraMemoryProperties(memoryProperties, flags, flagsIntel);
|
||||
addExtraMemoryProperties(memoryProperties, flags, flagsIntel, pDevice);
|
||||
|
||||
return memoryProperties;
|
||||
}
|
||||
|
||||
@@ -107,20 +107,18 @@ cl_mem Buffer::validateInputAndCreateBuffer(cl_context context,
|
||||
}
|
||||
|
||||
MemoryProperties memoryProperties{};
|
||||
if ((false == isFieldValid(flags, MemObjHelper::validFlagsForBuffer)) ||
|
||||
(false == MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flagsIntel, *pContext))) {
|
||||
cl_mem_alloc_flags_intel allocflags = 0;
|
||||
cl_mem_flags_intel emptyFlagsIntel = 0;
|
||||
if ((false == MemoryPropertiesHelper::parseMemoryProperties(nullptr, memoryProperties, flags, emptyFlagsIntel, allocflags,
|
||||
MemoryPropertiesHelper::ObjType::BUFFER, *pContext)) ||
|
||||
(false == MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, emptyFlagsIntel, *pContext))) {
|
||||
retVal = CL_INVALID_VALUE;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
cl_mem_alloc_flags_intel allocflags = 0;
|
||||
if (false == MemoryPropertiesHelper::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
|
||||
MemoryPropertiesHelper::ObjType::BUFFER, *pContext)) {
|
||||
retVal = CL_INVALID_PROPERTY;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flagsIntel, *pContext)) {
|
||||
if ((false == MemoryPropertiesHelper::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
|
||||
MemoryPropertiesHelper::ObjType::BUFFER, *pContext)) ||
|
||||
(false == MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flagsIntel, *pContext))) {
|
||||
retVal = CL_INVALID_PROPERTY;
|
||||
return nullptr;
|
||||
}
|
||||
@@ -156,7 +154,8 @@ Buffer *Buffer::create(Context *context,
|
||||
size_t size,
|
||||
void *hostPtr,
|
||||
cl_int &errcodeRet) {
|
||||
return create(context, MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0), flags, 0, size, hostPtr, errcodeRet);
|
||||
return create(context, MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context->getDevice(0)->getDevice()),
|
||||
flags, 0, size, hostPtr, errcodeRet);
|
||||
}
|
||||
|
||||
Buffer *Buffer::create(Context *context,
|
||||
@@ -369,7 +368,10 @@ Buffer *Buffer::create(Context *context,
|
||||
|
||||
Buffer *Buffer::createSharedBuffer(Context *context, cl_mem_flags flags, SharingHandler *sharingHandler,
|
||||
GraphicsAllocation *graphicsAllocation) {
|
||||
auto sharedBuffer = createBufferHw(context, MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0), flags, 0, graphicsAllocation->getUnderlyingBufferSize(), nullptr, nullptr, graphicsAllocation, false, false, false);
|
||||
auto sharedBuffer = createBufferHw(
|
||||
context, MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context->getDevice(0)->getDevice()),
|
||||
flags, 0, graphicsAllocation->getUnderlyingBufferSize(), nullptr, nullptr, graphicsAllocation,
|
||||
false, false, false);
|
||||
|
||||
sharedBuffer->setSharingHandler(sharingHandler);
|
||||
return sharedBuffer;
|
||||
@@ -467,7 +469,8 @@ Buffer *Buffer::createSubBuffer(cl_mem_flags flags,
|
||||
const cl_buffer_region *region,
|
||||
cl_int &errcodeRet) {
|
||||
DEBUG_BREAK_IF(nullptr == createFunction);
|
||||
MemoryProperties memoryProperties = MemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0);
|
||||
MemoryProperties memoryProperties =
|
||||
MemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &this->context->getDevice(0)->getDevice());
|
||||
auto buffer = createFunction(this->context, memoryProperties, flags, 0, region->size,
|
||||
ptrOffset(this->memoryStorage, region->origin),
|
||||
this->hostPtr ? ptrOffset(this->hostPtr, region->origin) : nullptr,
|
||||
@@ -628,7 +631,7 @@ Buffer *Buffer::createBufferHwFromDevice(const Device *device,
|
||||
|
||||
auto funcCreate = bufferFactory[hwInfo.platform.eRenderCoreFamily].createBufferFunction;
|
||||
DEBUG_BREAK_IF(nullptr == funcCreate);
|
||||
MemoryProperties memoryProperties = MemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0);
|
||||
MemoryProperties memoryProperties = MemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, device);
|
||||
auto pBuffer = funcCreate(nullptr, memoryProperties, flags, flagsIntel, size, memoryStorage, hostPtr, gfxAllocation,
|
||||
zeroCopy, isHostPtrSVM, isImageRedescribed);
|
||||
pBuffer->offset = offset;
|
||||
|
||||
@@ -447,9 +447,13 @@ Image *Image::createImageHw(Context *context, const MemoryProperties &memoryProp
|
||||
|
||||
Image *Image::createSharedImage(Context *context, SharingHandler *sharingHandler, const McsSurfaceInfo &mcsSurfaceInfo,
|
||||
GraphicsAllocation *graphicsAllocation, GraphicsAllocation *mcsAllocation,
|
||||
cl_mem_flags flags, cl_mem_flags_intel flagsIntel, const ClSurfaceFormatInfo *surfaceFormat, ImageInfo &imgInfo, uint32_t cubeFaceIndex, uint32_t baseMipLevel, uint32_t mipCount) {
|
||||
auto sharedImage = createImageHw(context, MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0), flags, flagsIntel, graphicsAllocation->getUnderlyingBufferSize(),
|
||||
nullptr, surfaceFormat->OCLImageFormat, Image::convertDescriptor(imgInfo.imgDesc), false, graphicsAllocation, false, baseMipLevel, mipCount, surfaceFormat);
|
||||
cl_mem_flags flags, cl_mem_flags_intel flagsIntel, const ClSurfaceFormatInfo *surfaceFormat,
|
||||
ImageInfo &imgInfo, uint32_t cubeFaceIndex, uint32_t baseMipLevel, uint32_t mipCount) {
|
||||
auto sharedImage = createImageHw(
|
||||
context, MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context->getDevice(0)->getDevice()),
|
||||
flags, flagsIntel, graphicsAllocation->getUnderlyingBufferSize(), nullptr,
|
||||
surfaceFormat->OCLImageFormat, Image::convertDescriptor(imgInfo.imgDesc), false,
|
||||
graphicsAllocation, false, baseMipLevel, mipCount, surfaceFormat);
|
||||
sharedImage->setSharingHandler(sharingHandler);
|
||||
sharedImage->setMcsAllocation(mcsAllocation);
|
||||
sharedImage->setQPitch(imgInfo.qPitch);
|
||||
@@ -919,7 +923,8 @@ Image *Image::redescribeFillImage() {
|
||||
imageFormatNew.image_channel_data_type = surfaceFormat->OCLImageFormat.image_channel_data_type;
|
||||
|
||||
DEBUG_BREAK_IF(nullptr == createFunction);
|
||||
MemoryProperties memoryProperties = MemoryPropertiesHelper::createMemoryProperties(flags | CL_MEM_USE_HOST_PTR, flagsIntel, 0);
|
||||
MemoryProperties memoryProperties = MemoryPropertiesHelper::createMemoryProperties(flags | CL_MEM_USE_HOST_PTR, flagsIntel, 0,
|
||||
&context->getDevice(0)->getDevice());
|
||||
auto image = createFunction(context,
|
||||
memoryProperties,
|
||||
flags | CL_MEM_USE_HOST_PTR,
|
||||
@@ -975,7 +980,8 @@ Image *Image::redescribe() {
|
||||
imageFormatNew.image_channel_data_type = surfaceFormat->OCLImageFormat.image_channel_data_type;
|
||||
|
||||
DEBUG_BREAK_IF(nullptr == createFunction);
|
||||
MemoryProperties memoryProperties = MemoryPropertiesHelper::createMemoryProperties(flags | CL_MEM_USE_HOST_PTR, flagsIntel, 0);
|
||||
MemoryProperties memoryProperties = MemoryPropertiesHelper::createMemoryProperties(flags | CL_MEM_USE_HOST_PTR, flagsIntel, 0,
|
||||
&context->getDevice(0)->getDevice());
|
||||
auto image = createFunction(context,
|
||||
memoryProperties,
|
||||
flags | CL_MEM_USE_HOST_PTR,
|
||||
@@ -1037,7 +1043,7 @@ cl_int Image::writeNV12Planes(const void *hostPtr, size_t hostPtrRowPitch) {
|
||||
// Create NV12 UV Plane image
|
||||
std::unique_ptr<Image> imageYPlane(Image::create(
|
||||
context,
|
||||
MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0),
|
||||
MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context->getDevice(0)->getDevice()),
|
||||
flags,
|
||||
0,
|
||||
surfaceFormat,
|
||||
@@ -1061,7 +1067,7 @@ cl_int Image::writeNV12Planes(const void *hostPtr, size_t hostPtrRowPitch) {
|
||||
// Create NV12 UV Plane image
|
||||
std::unique_ptr<Image> imageUVPlane(Image::create(
|
||||
context,
|
||||
MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0),
|
||||
MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context->getDevice(0)->getDevice()),
|
||||
flags,
|
||||
0,
|
||||
surfaceFormat,
|
||||
@@ -1127,21 +1133,21 @@ cl_mem Image::validateAndCreateImage(cl_context context,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MemoryProperties memoryProperties{};
|
||||
cl_mem_flags_intel emptyFlagsIntel = 0;
|
||||
cl_mem_alloc_flags_intel allocflags = 0;
|
||||
MemoryProperties memoryProperties = MemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, allocflags);
|
||||
if ((false == isFieldValid(flags, MemObjHelper::validFlagsForImage)) ||
|
||||
(false == MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flagsIntel, imageDesc->mem_object, *pContext))) {
|
||||
if ((false == MemoryPropertiesHelper::parseMemoryProperties(nullptr, memoryProperties, flags, emptyFlagsIntel, allocflags,
|
||||
MemoryPropertiesHelper::ObjType::IMAGE, *pContext)) ||
|
||||
(false == MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, emptyFlagsIntel, imageDesc->mem_object,
|
||||
*pContext))) {
|
||||
errcodeRet = CL_INVALID_VALUE;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (false == MemoryPropertiesHelper::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
|
||||
MemoryPropertiesHelper::ObjType::IMAGE, *pContext)) {
|
||||
errcodeRet = CL_INVALID_PROPERTY;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flagsIntel, imageDesc->mem_object, *pContext)) {
|
||||
if ((false == MemoryPropertiesHelper::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
|
||||
MemoryPropertiesHelper::ObjType::IMAGE, *pContext)) ||
|
||||
(false == MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flagsIntel, imageDesc->mem_object,
|
||||
*pContext))) {
|
||||
errcodeRet = CL_INVALID_PROPERTY;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ Pipe::Pipe(Context *context,
|
||||
GraphicsAllocation *gfxAllocation)
|
||||
: MemObj(context,
|
||||
CL_MEM_OBJECT_PIPE,
|
||||
MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0),
|
||||
MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context->getDevice(0)->getDevice()),
|
||||
flags,
|
||||
0,
|
||||
static_cast<size_t>(packetSize * (maxPackets + 1) + intelPipeHeaderReservedSpace),
|
||||
@@ -54,7 +54,8 @@ Pipe *Pipe::create(Context *context,
|
||||
MemoryManager *memoryManager = context->getMemoryManager();
|
||||
DEBUG_BREAK_IF(!memoryManager);
|
||||
|
||||
MemoryProperties memoryProperties = MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0);
|
||||
MemoryProperties memoryProperties =
|
||||
MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context->getDevice(0)->getDevice());
|
||||
while (true) {
|
||||
auto size = static_cast<size_t>(packetSize * (maxPackets + 1) + intelPipeHeaderReservedSpace);
|
||||
auto rootDeviceIndex = context->getDevice(0)->getRootDeviceIndex();
|
||||
|
||||
@@ -99,7 +99,8 @@ Image *D3DSurface::create(Context *context, cl_dx9_surface_info_khr *surfaceInfo
|
||||
imgInfo.imgDesc.imageWidth /= 2;
|
||||
imgInfo.imgDesc.imageHeight /= 2;
|
||||
}
|
||||
MemoryProperties memoryProperties = MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0);
|
||||
MemoryProperties memoryProperties =
|
||||
MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context->getDevice(0)->getDevice());
|
||||
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(rootDeviceIndex, imgInfo,
|
||||
true, // allocateMemory
|
||||
memoryProperties, context->getDevice(0)->getHardwareInfo(),
|
||||
|
||||
Reference in New Issue
Block a user