Nox wrote:would it be enought to check the referencecount of a IMeshBuffer
If the driver grabbed and dropped the
IMeshBuffer pointers, then this is a possible solution. One very serious issue to consider is that there is no guarantee that an
IMeshBuffer derived class is on the heap. If this were to happen, you could pretty much guarantee application crashes.
hybrid wrote:This results in (hopefully...) 60 times per second, resulting in about 5.5 minutes until deletion. Something which should be configurable, but not too far from a sensable value.
Unless the cached data can actually be reused, keeping it in a cache is useless and wasteful. Another issue to consider is that it _may_ result in incorrect behavior.
Consider the following scenerio. Application allocates a mesh buffer on the heap. Lets say that the mesh buffer resides in memory at address A. This mesh buffer is rendered. In the process, the driver creates a
SHWBufferLink for it, and creates a map entry that maps A to that
SHWBufferLink. Some time later the mesh buffer is deallocated. The
SHWBufferLink for A remains in the map. A new
SMeshBuffer is allocated, and that object happens to reside at the same address as the old mesh buffer. This is allowed. Now the map entry from A will map to the
SHWBufferLink from the old mesh buffer.
It appears that this can happen, even though the author jumped through a bunch of hoops to avoid it (the changeID field in the vertex and index buffers and the changeID fields in the buffer link). Unfortunately, this additional code doesn't help if the changeID values happen to match, which seems to be a possible case.
Travis