diff --git a/hipamd/include/hip/nvcc_detail/hip_runtime_api.h b/hipamd/include/hip/nvcc_detail/hip_runtime_api.h index 5684596e13..d2f81c8b7b 100644 --- a/hipamd/include/hip/nvcc_detail/hip_runtime_api.h +++ b/hipamd/include/hip/nvcc_detail/hip_runtime_api.h @@ -1398,6 +1398,11 @@ inline static hipError_t hipUnbindTexture(struct texture* tex) return hipCUDAErrorTohipError(cudaUnbindTexture(tex)); } +template +inline static hipError_t hipUnbindTexture(struct texture &tex) { + return hipCUDAErrorTohipError(cudaUnbindTexture(tex)); +} + inline static hipError_t hipBindTexture(size_t* offset, textureReference* tex, const void* devPtr, const hipChannelFormatDesc* desc, size_t size = UINT_MAX){ return hipCUDAErrorTohipError(cudaBindTexture(offset, tex, devPtr, desc, size)); diff --git a/hipamd/samples/2_Cookbook/11_texture_driver/texture2dDrv.cpp b/hipamd/samples/2_Cookbook/11_texture_driver/texture2dDrv.cpp index 3be6d12b31..7c22e19d5d 100755 --- a/hipamd/samples/2_Cookbook/11_texture_driver/texture2dDrv.cpp +++ b/hipamd/samples/2_Cookbook/11_texture_driver/texture2dDrv.cpp @@ -124,6 +124,7 @@ bool runTest(int argc, char** argv) { } } } + HIP_CHECK(hipUnbindTexture(tex)); HIP_CHECK(hipFree(dData)); HIP_CHECK(hipFreeArray(array)); return testResult; diff --git a/hipamd/src/hip_texture.cpp b/hipamd/src/hip_texture.cpp index 6d4ef24673..8820878fc0 100644 --- a/hipamd/src/hip_texture.cpp +++ b/hipamd/src/hip_texture.cpp @@ -634,16 +634,15 @@ hipError_t hipBindTextureToMipmappedArray(textureReference* tex, return ihipLogStatus(hip_status); } -hipError_t ihipUnbindTextureImpl(TlsData *tls, const hipTextureObject_t& textureObject) { +hipError_t ihipUnbindTextureImpl(const hipTextureObject_t& textureObject) { hipError_t hip_status = hipSuccess; - + TlsData* tls=tls_get_ptr(); auto ctx = ihipGetTlsDefaultCtx(); if (ctx) { hc::accelerator acc = ctx->getDevice()->_acc; auto device = ctx->getWriteableDevice(); hsa_agent_t* agent = static_cast(acc.get_hsa_agent()); - hipTexture* pTexture = textureHash[textureObject]; if (pTexture != nullptr) { hsa_ext_image_destroy(*agent, pTexture->image); @@ -659,7 +658,7 @@ hipError_t ihipUnbindTextureImpl(TlsData *tls, const hipTextureObject_t& texture hipError_t hipUnbindTexture(const textureReference* tex) { HIP_INIT_API(hipUnbindTexture, tex); hipError_t hip_status = hipSuccess; - hip_status = ihipUnbindTextureImpl(tls, tex->textureObject); + hip_status = ihipUnbindTextureImpl(tex->textureObject); return ihipLogStatus(hip_status); } diff --git a/hipamd/tests/src/texture/hipNormalizedFloatValueTex.cpp b/hipamd/tests/src/texture/hipNormalizedFloatValueTex.cpp index e519605157..fd2e8ccf0f 100644 --- a/hipamd/tests/src/texture/hipNormalizedFloatValueTex.cpp +++ b/hipamd/tests/src/texture/hipNormalizedFloatValueTex.cpp @@ -91,6 +91,7 @@ bool textureTest(enum hipArray_Format texFormat) } hipFree(dData); hipFree(dOutputData); + hipUnbindTexture(textureNormalizedVal_1D); delete [] hOutputData; return testResult; } diff --git a/hipamd/tests/src/texture/hipTextureRef2D.cpp b/hipamd/tests/src/texture/hipTextureRef2D.cpp index 2fb4097b0a..b476ae8062 100644 --- a/hipamd/tests/src/texture/hipTextureRef2D.cpp +++ b/hipamd/tests/src/texture/hipTextureRef2D.cpp @@ -90,6 +90,7 @@ int runTest(int argc, char** argv) { } } } + HIPCHECK(hipUnbindTexture(tex)); hipFree(dData); hipFreeArray(hipArray); return testResult;