File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
source/adapters/level_zero Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -219,4 +219,8 @@ struct ur_device_handle_t_ : _ur_object {
219
219
ZeCache<struct ze_global_memsize > ZeGlobalMemSize;
220
220
ZeCache<ZeStruct<ze_mutable_command_list_exp_properties_t >>
221
221
ZeDeviceMutableCmdListsProperties;
222
+
223
+ // Map device bindless image offset to corresponding host image handle.
224
+ std::unordered_map<ur_exp_image_native_handle_t , ze_image_handle_t >
225
+ ZeOffsetToImageHandleMap;
222
226
};
Original file line number Diff line number Diff line change @@ -496,6 +496,8 @@ ur_result_t bindlessImagesCreateImpl(ur_context_handle_t hContext,
496
496
(ZeImageTranslated, &DeviceOffset));
497
497
*phImage = DeviceOffset;
498
498
499
+ hDevice->ZeOffsetToImageHandleMap [*phImage] = ZeImage;
500
+
499
501
return UR_RESULT_SUCCESS;
500
502
}
501
503
@@ -675,9 +677,16 @@ UR_APIEXPORT ur_result_t UR_APICALL
675
677
urBindlessImagesUnsampledImageHandleDestroyExp (
676
678
ur_context_handle_t hContext, ur_device_handle_t hDevice,
677
679
ur_exp_image_native_handle_t hImage) {
678
- std::ignore = hContext;
679
- std::ignore = hDevice;
680
- std::ignore = hImage;
680
+ UR_ASSERT (hContext && hDevice && hImage, UR_RESULT_ERROR_INVALID_NULL_HANDLE);
681
+
682
+ auto item = hDevice->ZeOffsetToImageHandleMap .find (hImage);
683
+
684
+ if (item != hDevice->ZeOffsetToImageHandleMap .end ()) {
685
+ ZE2UR_CALL (zeImageDestroy, (item->second ));
686
+ hDevice->ZeOffsetToImageHandleMap .erase (item);
687
+ } else {
688
+ return UR_RESULT_ERROR_INVALID_NULL_HANDLE;
689
+ }
681
690
682
691
return UR_RESULT_SUCCESS;
683
692
}
You can’t perform that action at this time.
0 commit comments