From 8f417d910b72bdde41904198a2ef70aece672965 Mon Sep 17 00:00:00 2001 From: Tao Sang Date: Mon, 13 Nov 2023 14:42:59 -0500 Subject: [PATCH] SWDEV-432180 - Support hipArraySurfaceLoadStore Make hipExternalMemoryGetMappedMipmappedArray() accept hipArraySurfaceLoadStore. Make hipCreateSurfaceObject() check hipArraySurfaceLoadStore flag. If flag is hipArrayDefault, hipCreateSurfaceObject() will also pass to prevent failure of catch2/swissknife tests. Change-Id: Ifb7db2db14e0c2208a9661cfa33887ec61ab26a5 [ROCm/clr commit: 1c442658caf286bd293e3645105beac47615f25a] --- projects/clr/hipamd/src/hip_memory.cpp | 4 ++-- projects/clr/hipamd/src/hip_surface.cpp | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/projects/clr/hipamd/src/hip_memory.cpp b/projects/clr/hipamd/src/hip_memory.cpp index 08e8f1aa75..6085f26f1d 100644 --- a/projects/clr/hipamd/src/hip_memory.cpp +++ b/projects/clr/hipamd/src/hip_memory.cpp @@ -4265,6 +4265,7 @@ hipError_t ihipMipmappedArrayGetLevel(hipArray_t* level_array_pptr, (*level_array_pptr)->NumChannels = hip::getNumChannels((*level_array_pptr)->desc); (*level_array_pptr)->isDrv = 0; (*level_array_pptr)->textureType = 0; + (*level_array_pptr)->flags = mipmapped_array_ptr->flags; amd::ScopedLock lock(hip::hipArraySetLock); hip::hipArraySet.insert(*level_array_pptr); @@ -4338,8 +4339,7 @@ hipError_t hipExternalMemoryGetMappedMipmappedArray( hipMipmappedArray_t* mipmap, hipExternalMemory_t extMem, const hipExternalMemoryMipmappedArrayDesc* mipmapDesc) { HIP_INIT_API(hipExternalMemoryGetMappedMipmappedArray, mipmap, extMem, mipmapDesc); - if (mipmap == nullptr || extMem == nullptr || mipmapDesc == nullptr || - mipmapDesc->flags != hipArrayDefault) { + if (mipmap == nullptr || extMem == nullptr || mipmapDesc == nullptr) { HIP_RETURN(hipErrorInvalidValue); } CHECK_STREAM_CAPTURE_SUPPORTED(); diff --git a/projects/clr/hipamd/src/hip_surface.cpp b/projects/clr/hipamd/src/hip_surface.cpp index fcc7835120..96e1f2479c 100644 --- a/projects/clr/hipamd/src/hip_surface.cpp +++ b/projects/clr/hipamd/src/hip_surface.cpp @@ -60,6 +60,11 @@ hipError_t ihipCreateSurfaceObject(hipSurfaceObject_t* pSurfObject, return hipErrorInvalidValue; } + if (pResDesc->res.array.array->flags != hipArrayDefault && + (pResDesc->res.array.array->flags & hipArraySurfaceLoadStore) == 0) { + return hipErrorInvalidValue; + } + amd::Image* image = nullptr; cl_mem memObj = reinterpret_cast(pResDesc->res.array.array->data); if (!is_valid(memObj)) {