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
This commit is contained in:
Vladislav Sytchenko
2021-08-10 11:35:01 -04:00
parent b41d5d73d4
commit 88f6f3d581
+5 -1
View File
@@ -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);
}