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); }