SWDEV-409815 - Fix image view cache issue

Add a view bit to avoid original resource destruction when parent
dependency doesn't exist with the image view cache

Change-Id: I8277afd575af8f29951c5d1a9f7d94d784251657


[ROCm/clr commit: b49e8e78e1]
This commit is contained in:
German Andryeyev
2023-07-14 15:05:19 -04:00
bovenliggende 20add33513
commit e62940f7df
3 gewijzigde bestanden met toevoegingen van 5 en 2 verwijderingen
@@ -1443,8 +1443,8 @@ void Image::destroy() {
hsa_status_t status = hsa_ext_image_destroy(dev().getBackendDevice(), hsaImageObject_);
assert(status == HSA_STATUS_SUCCESS);
}
if (owner()->parent() != nullptr) {
// Don't destroy memory if it's a view. Parent will destroy the original allocation.
if ((owner()->parent() != nullptr) || owner()->ImageView()) {
return;
}
@@ -593,6 +593,7 @@ Image::Image(const Format& format, Image& parent, uint baseMipLevel, cl_mem_flag
size_ = getWidth() * getHeight() * parent.getDepth() * format.getElementSize();
}
initDimension();
image_view_ = true;
}
Image::Image(Context& context, Type type, Flags flags, const Format& format, size_t width,
@@ -204,6 +204,7 @@ class Memory : public amd::RuntimeObject {
uint32_t p2pAccess_ : 1; //!< Memory object allows P2P access
uint32_t ipcShared_ : 1; //!< Memory shared between processes
uint32_t largeBarSystem_ : 1; //!< VRAM is visiable for host
uint32_t image_view_: 1; //!< Memory object is an image view
};
uint32_t flagsEx_;
};
@@ -326,6 +327,7 @@ class Memory : public amd::RuntimeObject {
Memory* parent() const { return parent_; }
void SetParent(amd::Memory* parent) { parent_ = parent; }
bool isParent() const { return isParent_; }
bool ImageView() const { return image_view_; }
size_t getOrigin() const { return origin_; }
size_t getSize() const { return size_; }