SWDEV-342007 - Fix hipArray Allocation APIs
- Capture error status of ihipImageCreate - Return hipErrorOutOfMemory when image creation fails Change-Id: If127a515447cc362d55fccd3eae304271da252d5
Этот коммит содержится в:
коммит произвёл
Rakesh Roy
родитель
bf5826ee93
Коммит
62069a5ae8
@@ -790,23 +790,28 @@ amd::Image* ihipImageCreate(const cl_channel_order channelOrder,
|
||||
const size_t imageRowPitch,
|
||||
const size_t imageSlicePitch,
|
||||
const uint32_t numMipLevels,
|
||||
amd::Memory* buffer) {
|
||||
amd::Memory* buffer,
|
||||
hipError_t& status) {
|
||||
status = hipSuccess;
|
||||
const amd::Image::Format imageFormat({channelOrder, channelType});
|
||||
if (!imageFormat.isValid()) {
|
||||
LogPrintfError("Invalid Image format for channel Order:%u Type:%u \n", channelOrder,
|
||||
channelType);
|
||||
status = hipErrorInvalidValue;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
amd::Context& context = *hip::getCurrentDevice()->asContext();
|
||||
if (!imageFormat.isSupported(context, imageType)) {
|
||||
LogPrintfError("Image type: %u not supported \n", imageType);
|
||||
status = hipErrorInvalidValue;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const std::vector<amd::Device*>& devices = context.devices();
|
||||
if (!devices[0]->info().imageSupport_) {
|
||||
LogPrintfError("Device: 0x%x does not support image \n", devices[0]);
|
||||
status = hipErrorInvalidValue;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -824,6 +829,7 @@ amd::Image* ihipImageCreate(const cl_channel_order channelOrder,
|
||||
imageDepth,
|
||||
imageArraySize)) {
|
||||
DevLogError("Image does not have valid dimensions \n");
|
||||
status = hipErrorInvalidValue;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -836,10 +842,12 @@ amd::Image* ihipImageCreate(const cl_channel_order channelOrder,
|
||||
|
||||
if (mip_levels < numMipLevels) {
|
||||
LogPrintfError("Invalid Mip Levels: %d", numMipLevels);
|
||||
status = hipErrorInvalidValue;
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
LogPrintfError("Mipmap not supported on one of the devices, Mip Level: %d", numMipLevels);
|
||||
status = hipErrorInvalidValue;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@@ -910,11 +918,13 @@ amd::Image* ihipImageCreate(const cl_channel_order channelOrder,
|
||||
}
|
||||
|
||||
if (image == nullptr) {
|
||||
status = hipErrorOutOfMemory;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!image->create(nullptr)) {
|
||||
LogPrintfError("Cannot create image: 0x%x \n", image);
|
||||
status = hipErrorOutOfMemory;
|
||||
delete image;
|
||||
return nullptr;
|
||||
}
|
||||
@@ -951,7 +961,7 @@ hipError_t ihipArrayCreate(hipArray** array,
|
||||
pAllocateArray->Height,
|
||||
pAllocateArray->Depth,
|
||||
pAllocateArray->Flags);
|
||||
|
||||
hipError_t status = hipSuccess;
|
||||
amd::Image* image = ihipImageCreate(channelOrder,
|
||||
channelType,
|
||||
imageType,
|
||||
@@ -963,10 +973,11 @@ hipError_t ihipArrayCreate(hipArray** array,
|
||||
0, /* row pitch */
|
||||
0, /* slice pitch */
|
||||
numMipmapLevels,
|
||||
nullptr /* buffer */);
|
||||
nullptr, /* buffer */
|
||||
status);
|
||||
|
||||
if (image == nullptr) {
|
||||
return hipErrorInvalidValue;
|
||||
return status;
|
||||
}
|
||||
|
||||
cl_mem memObj = as_cl<amd::Memory>(image);
|
||||
@@ -3379,6 +3390,7 @@ hipError_t ihipMipmapArrayCreate(hipMipmappedArray_t* mipmapped_array_pptr,
|
||||
mipmapped_array_desc_ptr->Depth,
|
||||
mipmapped_array_desc_ptr->Flags);
|
||||
|
||||
hipError_t status = hipSuccess;
|
||||
// Create a new amd::Image with mipmap
|
||||
amd::Image* image = ihipImageCreate(channel_order,
|
||||
channel_type,
|
||||
@@ -3390,10 +3402,11 @@ hipError_t ihipMipmapArrayCreate(hipMipmappedArray_t* mipmapped_array_pptr,
|
||||
0 /* row pitch */,
|
||||
0 /* slice pitch */,
|
||||
num_mipmap_levels,
|
||||
nullptr /* buffer */);
|
||||
nullptr, /* buffer */
|
||||
status);
|
||||
|
||||
if (image == nullptr) {
|
||||
return hipErrorInvalidValue;
|
||||
return status;
|
||||
}
|
||||
|
||||
cl_mem cl_mem_obj = as_cl<amd::Memory>(image);
|
||||
|
||||
@@ -70,7 +70,8 @@ amd::Image* ihipImageCreate(const cl_channel_order channelOrder,
|
||||
const size_t imageRowPitch,
|
||||
const size_t imageSlicePitch,
|
||||
const uint32_t numMipLevels,
|
||||
amd::Memory* buffer);
|
||||
amd::Memory* buffer,
|
||||
hipError_t& status);
|
||||
|
||||
hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
|
||||
const hipResourceDesc* pResDesc,
|
||||
@@ -252,6 +253,7 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
|
||||
const cl_mem_object_type imageType = hip::getCLMemObjectType(pResDesc->resType);
|
||||
const size_t imageSizeInBytes = pResDesc->res.linear.sizeInBytes;
|
||||
amd::Memory* buffer = getMemoryObjectWithOffset(pResDesc->res.linear.devPtr, imageSizeInBytes);
|
||||
hipError_t status = hipSuccess;
|
||||
image = ihipImageCreate(channelOrder,
|
||||
channelType,
|
||||
imageType,
|
||||
@@ -262,10 +264,11 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
|
||||
0, /* imageRowPitch */
|
||||
0, /* imageSlicePitch */
|
||||
0, /* numMipLevels */
|
||||
buffer);
|
||||
buffer,
|
||||
status);
|
||||
buffer->release();
|
||||
if (image == nullptr) {
|
||||
return hipErrorInvalidValue;
|
||||
return status;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -277,6 +280,7 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
|
||||
const size_t imageSizeInBytes = pResDesc->res.pitch2D.width * imageFormat.getElementSize() +
|
||||
pResDesc->res.pitch2D.pitchInBytes * (pResDesc->res.pitch2D.height - 1);
|
||||
amd::Memory* buffer = getMemoryObjectWithOffset(pResDesc->res.pitch2D.devPtr, imageSizeInBytes);
|
||||
hipError_t status = hipSuccess;
|
||||
image = ihipImageCreate(channelOrder,
|
||||
channelType,
|
||||
imageType,
|
||||
@@ -287,10 +291,11 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
|
||||
pResDesc->res.pitch2D.pitchInBytes, /* imageRowPitch */
|
||||
0, /* imageSlicePitch */
|
||||
0, /* numMipLevels */
|
||||
buffer);
|
||||
buffer,
|
||||
status);
|
||||
buffer->release();
|
||||
if (image == nullptr) {
|
||||
return hipErrorInvalidValue;
|
||||
return status;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user