Skip to content

Commit

Permalink
[Bindless][CUDA] Mipmap interop
Browse files Browse the repository at this point in the history
Extends the CUDA adapter to allow for mipmap interop with bindless images
  • Loading branch information
Seanst98 committed Mar 13, 2024
1 parent 1cf9a08 commit 3ca422a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions source/adapters/cuda/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1006,17 +1006,23 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp(
ArrayDesc.Format = format;

CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC mipmapDesc = {};
mipmapDesc.numLevels = 1;
mipmapDesc.numLevels = pImageDesc->numMipLevel;
mipmapDesc.arrayDesc = ArrayDesc;

// External memory is mapped to a CUmipmappedArray
// If desired, a CUarray is retrieved from the mipmaps 0th level
CUmipmappedArray memMipMap;
UR_CHECK_ERROR(cuExternalMemoryGetMappedMipmappedArray(
&memMipMap, (CUexternalMemory)hInteropMem, &mipmapDesc));

CUarray memArray;
UR_CHECK_ERROR(cuMipmappedArrayGetLevel(&memArray, memMipMap, 0));
if (pImageDesc->numMipLevel > 1) {
*phImageMem = (ur_exp_image_mem_handle_t)memMipMap;
} else {
CUarray memArray;
UR_CHECK_ERROR(cuMipmappedArrayGetLevel(&memArray, memMipMap, 0));

*phImageMem = (ur_exp_image_mem_handle_t)memArray;
*phImageMem = (ur_exp_image_mem_handle_t)memArray;
}

} catch (ur_result_t Err) {
return Err;
Expand Down

0 comments on commit 3ca422a

Please sign in to comment.