From 88f6f3d5816499e4e265a72d02b1df7813c5f7be Mon Sep 17 00:00:00 2001 From: Vladislav Sytchenko Date: Tue, 10 Aug 2021 11:35:01 -0400 Subject: [PATCH] SWDEV-297808 - Correct sampler destruction logic If the texture object was created from an array, then the array owns the image SRD. Otherwise, if the texture object is a view, or was created from a buffer, then it owns the image SRD. The texture object always owns the sampler SRD. Change-Id: Id88360c23b2b82418c8c3ae2dd569f427574d420 --- hipamd/src/hip_texture.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hipamd/src/hip_texture.cpp b/hipamd/src/hip_texture.cpp index 744b0815cb..6e6360bee1 100644 --- a/hipamd/src/hip_texture.cpp +++ b/hipamd/src/hip_texture.cpp @@ -327,11 +327,15 @@ hipError_t ihipDestroyTextureObject(hipTextureObject_t texObject) { const bool isImageFromBuffer = (type == hipResourceTypeLinear) || (type == hipResourceTypePitch2D); const bool isImageView = ((type == hipResourceTypeArray) || (type == hipResourceTypeMipmappedArray)) && !texObject->image->isParent(); + // If the texture object was created from an array, then the array owns the image SRD. + // Otherwise, if the texture object is a view, or was created from a buffer, then it owns the image SRD. if (isImageFromBuffer || isImageView) { texObject->image->release(); - texObject->sampler->release(); } + // The texture object always owns the sampler SRD. + texObject->sampler->release(); + // TODO Should call ihipFree() to not polute the api trace. return hipFree(texObject); }