Skip to content

Commit 76361a8

Browse files
Merge pull request #1961 from DBDuncan/duncan/num-channels-mipmap-fix
[Bindless][Exp] Fix urBindlessImagesImageGetInfoExp failing with mipmap images
2 parents b4195cb + 0db57da commit 76361a8

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
@@ -961,8 +961,17 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp(
961961
ur_context_handle_t, ur_exp_image_mem_native_handle_t hImageMem,
962962
ur_image_info_t propName, void *pPropValue, size_t *pPropSizeRet) {
963963

964+
CUarray hCUarray;
965+
CUresult Err = cuMipmappedArrayGetLevel(
966+
&hCUarray, reinterpret_cast<CUmipmappedArray>(hImageMem), 0);
967+
968+
// If cuMipmappedArrayGetLevel failed, hImageMem is already CUarray.
969+
if (Err != CUDA_SUCCESS) {
970+
hCUarray = reinterpret_cast<CUarray>(hImageMem);
971+
}
972+
964973
CUDA_ARRAY3D_DESCRIPTOR ArrayDesc;
965-
UR_CHECK_ERROR(cuArray3DGetDescriptor(&ArrayDesc, (CUarray)hImageMem));
974+
UR_CHECK_ERROR(cuArray3DGetDescriptor(&ArrayDesc, hCUarray));
966975
switch (propName) {
967976
case UR_IMAGE_INFO_WIDTH:
968977
if (pPropValue) {

0 commit comments

Comments
 (0)