SWDEV-342007 - Fix hipArray Allocation APIs
- Capture error status of ihipImageCreate - Return hipErrorOutOfMemory when image creation fails Change-Id: If127a515447cc362d55fccd3eae304271da252d5
Dieser Commit ist enthalten in:
committet von
Rakesh Roy
Ursprung
bf5826ee93
Commit
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);
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren