Wrapping device objects & refcounters behavior question #369
dolphineye74
started this conversation in
General
Replies: 1 comment 1 reply
-
It is intended to handle cases when one ref-counted object is part of another, like default texture view. In this case, default texture views use ref counting object from the parent object instead of creating its own. As a result, you can do And pView will keep the texture object alive while internally it is part of the parent texture object.
The API does not give this option. For internal use, there is this version of Release. Why do you need this BTW? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I was playing a bit with Diligent recently, and I came across the need to create device object proxies to have some kind of create/destroy listener pattern in my app.
Goal
The gist of my original idea was something along what I did for my material system:
First approach
My original idea was as simple as follows, similar to what was done with the reloadable pipeline proxy:
Pseudo-code usage example of how I use my textures with my material system:
The problem I am facing is that the original texture creates default views that will increments the texture's ref count.
My proxy does not benefit from this ref count increment, so once I pass the texture view to my material, the original proxy texture is destroyed.
Second approach
I tried with another approach via the
IObject* pOwnerparameter ofMakeNewRCObjto share the reference counters of my original texture with my proxy:Now my proxy's destructor is never called :/
Based on what I could read, it seems that specifying a
pOwnerjust prevents the creation of a new reference counter object.The underlying object's memory is properly allocated, but it is never freed as the shared ref counters will only destroy the original object it owns (i.e: my original texture).
Conclusion
I haven't found any reliable way to properly wrap a device object and it appears the
pOwnerparameters ofMakeNewRCObjcan lead to memory leak situations if used.Questions :
Is there any reason behind
pOwnerin the first place?Any good tips to figure out when a device object is destroyed?
Beta Was this translation helpful? Give feedback.
All reactions