Skip to content

Commit 0db57da

Browse files
committed
[Bindless][Exp] Fix urBindlessImagesImageGetInfoExp failing with mipmap images
This patch fixes a crash due to urBindlessImagesImageGetInfoExp expecting a CUarray instead of a CUmipmappedArray.
1 parent 78c003e commit 0db57da

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

source/adapters/cuda/image.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,8 +953,17 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp(
953953
ur_context_handle_t, ur_exp_image_mem_native_handle_t hImageMem,
954954
ur_image_info_t propName, void *pPropValue, size_t *pPropSizeRet) {
955955

956+
CUarray hCUarray;
957+
CUresult Err = cuMipmappedArrayGetLevel(
958+
&hCUarray, reinterpret_cast<CUmipmappedArray>(hImageMem), 0);
959+
960+
// If cuMipmappedArrayGetLevel failed, hImageMem is already CUarray.
961+
if (Err != CUDA_SUCCESS) {
962+
hCUarray = reinterpret_cast<CUarray>(hImageMem);
963+
}
964+
956965
CUDA_ARRAY3D_DESCRIPTOR ArrayDesc;
957-
UR_CHECK_ERROR(cuArray3DGetDescriptor(&ArrayDesc, (CUarray)hImageMem));
966+
UR_CHECK_ERROR(cuArray3DGetDescriptor(&ArrayDesc, hCUarray));
958967
switch (propName) {
959968
case UR_IMAGE_INFO_WIDTH:
960969
if (pPropValue) {

0 commit comments

Comments
 (0)