Improve error handling for unsupported image creation

Change-Id: I4aeec25f32164b8cf71a78d742b7de254e97aed2
Signed-off-by: Jim Snow <jim.m.snow@intel.com>
This commit is contained in:
Jim Snow
2020-05-18 16:34:51 -07:00
parent 95aaac204d
commit 5dc7c2368e
2 changed files with 11 additions and 2 deletions

View File

@@ -35,6 +35,10 @@ bool ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_image_d
UNRECOVERABLE_IF(device == nullptr);
this->device = device;
if (imgInfo.surfaceFormat->GMMSurfaceFormat == GMM_FORMAT_INVALID) {
return false;
}
typename RENDER_SURFACE_STATE::SURFACE_TYPE surfaceType;
switch (desc->type) {
case ZE_IMAGE_TYPE_1D:

View File

@@ -16,7 +16,9 @@ namespace L0 {
ImageAllocatorFn imageFactory[IGFX_MAX_PRODUCT] = {};
ImageImp::~ImageImp() {
this->device->getNEODevice()->getMemoryManager()->freeGraphicsMemory(this->allocation);
if (this->device != nullptr) {
this->device->getNEODevice()->getMemoryManager()->freeGraphicsMemory(this->allocation);
}
}
ze_result_t ImageImp::destroy() {
@@ -33,7 +35,10 @@ Image *Image::create(uint32_t productFamily, Device *device, const ze_image_desc
ImageImp *image = nullptr;
if (allocator) {
image = static_cast<ImageImp *>((*allocator)());
image->initialize(device, desc);
if (!image->initialize(device, desc)) {
image->destroy();
image = nullptr;
}
}
return image;