Skip to content

Commit a320d70

Browse files
committed
fix image1DArray copy, size of half type, shared USM
1 parent 20980b9 commit a320d70

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

source/adapters/level_zero/image.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ ur_result_t ur2zeImageDesc(const ur_image_format_t *ImageFormat,
357357

358358
ZeImageDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
359359
ZeImageDesc.pNext = ImageDesc->pNext;
360-
ZeImageDesc.arraylevels = ZeImageDesc.flags = 0;
361360
ZeImageDesc.type = ZeImageType;
362361
ZeImageDesc.format = ZeFormatDesc;
363362
ZeImageDesc.width = ur_cast<uint64_t>(ImageDesc->width);
@@ -416,9 +415,9 @@ uint32_t getPixelSizeBytes(const ur_image_format_t *Format) {
416415
case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16:
417416
case UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_565:
418417
case UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_555:
418+
case UR_IMAGE_CHANNEL_TYPE_HALF_FLOAT:
419419
ChannelTypeSizeInBytes = 2;
420420
break;
421-
case UR_IMAGE_CHANNEL_TYPE_HALF_FLOAT:
422421
case UR_IMAGE_CHANNEL_TYPE_INT_101010:
423422
case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT32:
424423
case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32:
@@ -441,11 +440,12 @@ ur_result_t getImageRegionHelper(ze_image_desc_t ZeImageDesc,
441440
UR_ASSERT(Origin, UR_RESULT_ERROR_INVALID_VALUE);
442441
UR_ASSERT(Region, UR_RESULT_ERROR_INVALID_VALUE);
443442

444-
if (ZeImageDesc.type == ZE_IMAGE_TYPE_1D) {
443+
if (ZeImageDesc.type == ZE_IMAGE_TYPE_1D ||
444+
ZeImageDesc.type == ZE_IMAGE_TYPE_1DARRAY) {
445445
Region->height = 1;
446446
Region->depth = 1;
447447
} else if (ZeImageDesc.type == ZE_IMAGE_TYPE_2D ||
448-
ZeImageDesc.type == ZE_IMAGE_TYPE_1DARRAY) {
448+
ZeImageDesc.type == ZE_IMAGE_TYPE_2DARRAY) {
449449
Region->depth = 1;
450450
}
451451

@@ -454,6 +454,7 @@ ur_result_t getImageRegionHelper(ze_image_desc_t ZeImageDesc,
454454
Origin->z == 0) ||
455455
(ZeImageDesc.type == ZE_IMAGE_TYPE_1DARRAY && Origin->z == 0) ||
456456
(ZeImageDesc.type == ZE_IMAGE_TYPE_2D && Origin->z == 0) ||
457+
(ZeImageDesc.type == ZE_IMAGE_TYPE_2DARRAY) ||
457458
(ZeImageDesc.type == ZE_IMAGE_TYPE_3D),
458459
UR_RESULT_ERROR_INVALID_VALUE);
459460

@@ -464,6 +465,7 @@ ur_result_t getImageRegionHelper(ze_image_desc_t ZeImageDesc,
464465
Region->depth == 1) ||
465466
(ZeImageDesc.type == ZE_IMAGE_TYPE_1DARRAY && Region->depth == 1) ||
466467
(ZeImageDesc.type == ZE_IMAGE_TYPE_2D && Region->depth == 1) ||
468+
(ZeImageDesc.type == ZE_IMAGE_TYPE_2DARRAY) ||
467469
(ZeImageDesc.type == ZE_IMAGE_TYPE_3D),
468470
UR_RESULT_ERROR_INVALID_VALUE);
469471
#endif // !NDEBUG
@@ -473,8 +475,12 @@ ur_result_t getImageRegionHelper(ze_image_desc_t ZeImageDesc,
473475
uint32_t OriginZ = ur_cast<uint32_t>(Origin->z);
474476

475477
uint32_t Width = ur_cast<uint32_t>(Region->width);
476-
uint32_t Height = ur_cast<uint32_t>(Region->height);
477-
uint32_t Depth = ur_cast<uint32_t>(Region->depth);
478+
uint32_t Height = (ZeImageDesc.type == ZE_IMAGE_TYPE_1DARRAY)
479+
? ZeImageDesc.arraylevels
480+
: ur_cast<uint32_t>(Region->height);
481+
uint32_t Depth = (ZeImageDesc.type == ZE_IMAGE_TYPE_2DARRAY)
482+
? ZeImageDesc.arraylevels
483+
: ur_cast<uint32_t>(Region->depth);
478484

479485
ZeRegion = {OriginX, OriginY, OriginZ, Width, Height, Depth};
480486

@@ -693,7 +699,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesUnsampledImageCreateExp(
693699
ZeImage = UrImage->ZeImage;
694700
*phMem = nullptr;
695701
}
696-
} else if (MemAllocProperties.type == ZE_MEMORY_TYPE_DEVICE) {
702+
} else if (MemAllocProperties.type == ZE_MEMORY_TYPE_DEVICE ||
703+
MemAllocProperties.type == ZE_MEMORY_TYPE_SHARED) {
697704
ze_image_pitched_exp_desc_t PitchedDesc;
698705
PitchedDesc.stype = ZE_STRUCTURE_TYPE_PITCHED_IMAGE_EXP_DESC;
699706
PitchedDesc.pNext = nullptr;

0 commit comments

Comments
 (0)