SWDEV-342007 - Fix hipArray Allocation APIs
- Capture error status of ihipImageCreate - Return hipErrorOutOfMemory when image creation fails Change-Id: If127a515447cc362d55fccd3eae304271da252d5
Cette révision appartient à :
1 Parent
bf5826ee93
révision
62069a5ae8
2 fichiers modifiés
+29
-11
Aucun fichier ne correspond à votre recherche
@@ -790,23 +790,28 @@ amd::Image* ihipImageCreate(const cl_channel_order channelOrder,
|
|||||||
const size_t imageRowPitch,
|
const size_t imageRowPitch,
|
||||||
const size_t imageSlicePitch,
|
const size_t imageSlicePitch,
|
||||||
const uint32_t numMipLevels,
|
const uint32_t numMipLevels,
|
||||||
amd::Memory* buffer) {
|
amd::Memory* buffer,
|
||||||
|
hipError_t& status) {
|
||||||
|
status = hipSuccess;
|
||||||
const amd::Image::Format imageFormat({channelOrder, channelType});
|
const amd::Image::Format imageFormat({channelOrder, channelType});
|
||||||
if (!imageFormat.isValid()) {
|
if (!imageFormat.isValid()) {
|
||||||
LogPrintfError("Invalid Image format for channel Order:%u Type:%u \n", channelOrder,
|
LogPrintfError("Invalid Image format for channel Order:%u Type:%u \n", channelOrder,
|
||||||
channelType);
|
channelType);
|
||||||
|
status = hipErrorInvalidValue;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
amd::Context& context = *hip::getCurrentDevice()->asContext();
|
amd::Context& context = *hip::getCurrentDevice()->asContext();
|
||||||
if (!imageFormat.isSupported(context, imageType)) {
|
if (!imageFormat.isSupported(context, imageType)) {
|
||||||
LogPrintfError("Image type: %u not supported \n", imageType);
|
LogPrintfError("Image type: %u not supported \n", imageType);
|
||||||
|
status = hipErrorInvalidValue;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<amd::Device*>& devices = context.devices();
|
const std::vector<amd::Device*>& devices = context.devices();
|
||||||
if (!devices[0]->info().imageSupport_) {
|
if (!devices[0]->info().imageSupport_) {
|
||||||
LogPrintfError("Device: 0x%x does not support image \n", devices[0]);
|
LogPrintfError("Device: 0x%x does not support image \n", devices[0]);
|
||||||
|
status = hipErrorInvalidValue;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -824,6 +829,7 @@ amd::Image* ihipImageCreate(const cl_channel_order channelOrder,
|
|||||||
imageDepth,
|
imageDepth,
|
||||||
imageArraySize)) {
|
imageArraySize)) {
|
||||||
DevLogError("Image does not have valid dimensions \n");
|
DevLogError("Image does not have valid dimensions \n");
|
||||||
|
status = hipErrorInvalidValue;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -836,10 +842,12 @@ amd::Image* ihipImageCreate(const cl_channel_order channelOrder,
|
|||||||
|
|
||||||
if (mip_levels < numMipLevels) {
|
if (mip_levels < numMipLevels) {
|
||||||
LogPrintfError("Invalid Mip Levels: %d", numMipLevels);
|
LogPrintfError("Invalid Mip Levels: %d", numMipLevels);
|
||||||
|
status = hipErrorInvalidValue;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogPrintfError("Mipmap not supported on one of the devices, Mip Level: %d", numMipLevels);
|
LogPrintfError("Mipmap not supported on one of the devices, Mip Level: %d", numMipLevels);
|
||||||
|
status = hipErrorInvalidValue;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -910,11 +918,13 @@ amd::Image* ihipImageCreate(const cl_channel_order channelOrder,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (image == nullptr) {
|
if (image == nullptr) {
|
||||||
|
status = hipErrorOutOfMemory;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!image->create(nullptr)) {
|
if (!image->create(nullptr)) {
|
||||||
LogPrintfError("Cannot create image: 0x%x \n", image);
|
LogPrintfError("Cannot create image: 0x%x \n", image);
|
||||||
|
status = hipErrorOutOfMemory;
|
||||||
delete image;
|
delete image;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -951,7 +961,7 @@ hipError_t ihipArrayCreate(hipArray** array,
|
|||||||
pAllocateArray->Height,
|
pAllocateArray->Height,
|
||||||
pAllocateArray->Depth,
|
pAllocateArray->Depth,
|
||||||
pAllocateArray->Flags);
|
pAllocateArray->Flags);
|
||||||
|
hipError_t status = hipSuccess;
|
||||||
amd::Image* image = ihipImageCreate(channelOrder,
|
amd::Image* image = ihipImageCreate(channelOrder,
|
||||||
channelType,
|
channelType,
|
||||||
imageType,
|
imageType,
|
||||||
@@ -963,10 +973,11 @@ hipError_t ihipArrayCreate(hipArray** array,
|
|||||||
0, /* row pitch */
|
0, /* row pitch */
|
||||||
0, /* slice pitch */
|
0, /* slice pitch */
|
||||||
numMipmapLevels,
|
numMipmapLevels,
|
||||||
nullptr /* buffer */);
|
nullptr, /* buffer */
|
||||||
|
status);
|
||||||
|
|
||||||
if (image == nullptr) {
|
if (image == nullptr) {
|
||||||
return hipErrorInvalidValue;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_mem memObj = as_cl<amd::Memory>(image);
|
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->Depth,
|
||||||
mipmapped_array_desc_ptr->Flags);
|
mipmapped_array_desc_ptr->Flags);
|
||||||
|
|
||||||
|
hipError_t status = hipSuccess;
|
||||||
// Create a new amd::Image with mipmap
|
// Create a new amd::Image with mipmap
|
||||||
amd::Image* image = ihipImageCreate(channel_order,
|
amd::Image* image = ihipImageCreate(channel_order,
|
||||||
channel_type,
|
channel_type,
|
||||||
@@ -3390,10 +3402,11 @@ hipError_t ihipMipmapArrayCreate(hipMipmappedArray_t* mipmapped_array_pptr,
|
|||||||
0 /* row pitch */,
|
0 /* row pitch */,
|
||||||
0 /* slice pitch */,
|
0 /* slice pitch */,
|
||||||
num_mipmap_levels,
|
num_mipmap_levels,
|
||||||
nullptr /* buffer */);
|
nullptr, /* buffer */
|
||||||
|
status);
|
||||||
|
|
||||||
if (image == nullptr) {
|
if (image == nullptr) {
|
||||||
return hipErrorInvalidValue;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_mem cl_mem_obj = as_cl<amd::Memory>(image);
|
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 imageRowPitch,
|
||||||
const size_t imageSlicePitch,
|
const size_t imageSlicePitch,
|
||||||
const uint32_t numMipLevels,
|
const uint32_t numMipLevels,
|
||||||
amd::Memory* buffer);
|
amd::Memory* buffer,
|
||||||
|
hipError_t& status);
|
||||||
|
|
||||||
hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
|
hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
|
||||||
const hipResourceDesc* pResDesc,
|
const hipResourceDesc* pResDesc,
|
||||||
@@ -252,6 +253,7 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
|
|||||||
const cl_mem_object_type imageType = hip::getCLMemObjectType(pResDesc->resType);
|
const cl_mem_object_type imageType = hip::getCLMemObjectType(pResDesc->resType);
|
||||||
const size_t imageSizeInBytes = pResDesc->res.linear.sizeInBytes;
|
const size_t imageSizeInBytes = pResDesc->res.linear.sizeInBytes;
|
||||||
amd::Memory* buffer = getMemoryObjectWithOffset(pResDesc->res.linear.devPtr, imageSizeInBytes);
|
amd::Memory* buffer = getMemoryObjectWithOffset(pResDesc->res.linear.devPtr, imageSizeInBytes);
|
||||||
|
hipError_t status = hipSuccess;
|
||||||
image = ihipImageCreate(channelOrder,
|
image = ihipImageCreate(channelOrder,
|
||||||
channelType,
|
channelType,
|
||||||
imageType,
|
imageType,
|
||||||
@@ -262,10 +264,11 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
|
|||||||
0, /* imageRowPitch */
|
0, /* imageRowPitch */
|
||||||
0, /* imageSlicePitch */
|
0, /* imageSlicePitch */
|
||||||
0, /* numMipLevels */
|
0, /* numMipLevels */
|
||||||
buffer);
|
buffer,
|
||||||
|
status);
|
||||||
buffer->release();
|
buffer->release();
|
||||||
if (image == nullptr) {
|
if (image == nullptr) {
|
||||||
return hipErrorInvalidValue;
|
return status;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -277,6 +280,7 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
|
|||||||
const size_t imageSizeInBytes = pResDesc->res.pitch2D.width * imageFormat.getElementSize() +
|
const size_t imageSizeInBytes = pResDesc->res.pitch2D.width * imageFormat.getElementSize() +
|
||||||
pResDesc->res.pitch2D.pitchInBytes * (pResDesc->res.pitch2D.height - 1);
|
pResDesc->res.pitch2D.pitchInBytes * (pResDesc->res.pitch2D.height - 1);
|
||||||
amd::Memory* buffer = getMemoryObjectWithOffset(pResDesc->res.pitch2D.devPtr, imageSizeInBytes);
|
amd::Memory* buffer = getMemoryObjectWithOffset(pResDesc->res.pitch2D.devPtr, imageSizeInBytes);
|
||||||
|
hipError_t status = hipSuccess;
|
||||||
image = ihipImageCreate(channelOrder,
|
image = ihipImageCreate(channelOrder,
|
||||||
channelType,
|
channelType,
|
||||||
imageType,
|
imageType,
|
||||||
@@ -287,10 +291,11 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
|
|||||||
pResDesc->res.pitch2D.pitchInBytes, /* imageRowPitch */
|
pResDesc->res.pitch2D.pitchInBytes, /* imageRowPitch */
|
||||||
0, /* imageSlicePitch */
|
0, /* imageSlicePitch */
|
||||||
0, /* numMipLevels */
|
0, /* numMipLevels */
|
||||||
buffer);
|
buffer,
|
||||||
|
status);
|
||||||
buffer->release();
|
buffer->release();
|
||||||
if (image == nullptr) {
|
if (image == nullptr) {
|
||||||
return hipErrorInvalidValue;
|
return status;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Référencer dans un nouveau ticket
Bloquer un utilisateur