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 @@ -221,6 +221,10 @@ struct ur_device_handle_t_ : _ur_object {
221221 ZeCache<ZeStruct<ze_mutable_command_list_exp_properties_t >>
222222 ZeDeviceMutableCmdListsProperties;
223223
224+ // Map device bindless image offset to corresponding host image handle.
225+ std::unordered_map<ur_exp_image_native_handle_t , ze_image_handle_t >
226+ ZeOffsetToImageHandleMap;
227+
224228 // unique ephemeral identifer of the device in the adapter
225229 DeviceId Id;
226230};
Original file line number Diff line number Diff line change @@ -496,6 +496,8 @@ ur_result_t bindlessImagesCreateImpl(ur_context_handle_t hContext,
496496 (ZeImageTranslated, &DeviceOffset));
497497 *phImage = DeviceOffset;
498498
499+ hDevice->ZeOffsetToImageHandleMap [*phImage] = ZeImage;
500+
499501 return UR_RESULT_SUCCESS;
500502}
501503
@@ -675,9 +677,16 @@ UR_APIEXPORT ur_result_t UR_APICALL
675677urBindlessImagesUnsampledImageHandleDestroyExp (
676678 ur_context_handle_t hContext, ur_device_handle_t hDevice,
677679 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+ }
681690
682691 return UR_RESULT_SUCCESS;
683692}
You can’t perform that action at this time.
0 commit comments