SWDEV-298434 - Delete texture references resources before deleting the ptr.

Change-Id: Ib616aadd45eced1b10891c908e986bbeddc08288


[ROCm/clr commit: 7145c500b3]
This commit is contained in:
kjayapra-amd
2021-11-08 11:05:08 -05:00
committed by Karthik Jayaprakash
parent a1917d6593
commit e9238ae2f1
3 changed files with 25 additions and 9 deletions
+23 -9
View File
@@ -309,7 +309,6 @@ hipError_t hipCreateTextureObject(hipTextureObject_t* pTexObject,
HIP_RETURN(ihipCreateTextureObject(pTexObject, pResDesc, pTexDesc, pResViewDesc));
}
hipError_t ihipDestroyTextureObject(hipTextureObject_t texObject) {
if (texObject == nullptr) {
return hipSuccess;
@@ -332,6 +331,28 @@ hipError_t ihipDestroyTextureObject(hipTextureObject_t texObject) {
return hipFree(texObject);
}
hipError_t ihipUnbindTexture(textureReference* texRef) {
hipError_t hip_error = hipSuccess;
do {
if (texRef == nullptr) {
hip_error = hipErrorInvalidValue;
break;
}
hip_error = ihipDestroyTextureObject(texRef->textureObject);
if (hip_error != hipSuccess) {
break;
}
const_cast<textureReference*>(texRef)->textureObject = nullptr;
} while (0);
return hip_error;
}
hipError_t hipDestroyTextureObject(hipTextureObject_t texObject) {
HIP_INIT_API(hipDestroyTextureObject, texObject);
@@ -593,14 +614,7 @@ hipError_t hipBindTextureToMipmappedArray(const textureReference* texref,
hipError_t hipUnbindTexture(const textureReference* texref) {
HIP_INIT_API(hipUnbindTexture, texref);
if (texref == nullptr) {
HIP_RETURN(hipErrorInvalidValue);
}
const hipTextureObject_t textureObject = texref->textureObject;
const_cast<textureReference*>(texref)->textureObject = nullptr;
HIP_RETURN(ihipDestroyTextureObject(textureObject));
HIP_RETURN(ihipUnbindTexture(const_cast<textureReference*>(texref)));
}
hipError_t hipBindTexture(size_t* offset,