Hilarius86 wrote: ↑Thu Oct 14, 2021 4:18 pm
VS2017, Win10x64, Ogre-next (2.1)
If I generate a VertexBuffer with BT_DEFAULT_DYNAMIC the size gets multiplied by 3.
Code: Select all
void D3D11VaoManager::allocateVbo(...)
if( bufferType >= BT_DYNAMIC_DEFAULT )
{
bufferType = BT_DYNAMIC_DEFAULT; //Persitent mapping not supported in D3D11.
sizeBytes *= mDynamicBufferMultiplier;
}
Why does that happen? I ported from 1.11 and my RAM usage seems to have tripled. I kept the workflow of generating a mesh, submesh and vertexbuffer, locking/mapping the buffer and filling it with data followed by unmapping mostly unchanged apart from using the new API. If I switch to a different buffer type below dynamic, I would have to use upload instead of mapping and restructure the code. Just wanting to make sure thats reasonable before moving forward.
BT_DEFAULT_DYNAMIC is optimized
for data that is modified every frame from scratch. It's rare to have to have a lot of this type of data except for particle FXs.
We triple (double if you set "VaoManager::mDynamicBufferMultiplier" in miscSettings to 2 for double buffering) the buffer size because Ogre manually synchronizes data to prevent arbitrary stalls. Ogre 1.x let the driver handle synchronization.
Hilarius86 wrote: ↑Thu Oct 14, 2021 4:18 pm
If I switch to a different buffer type below dynamic, I would have to use upload instead of mapping and restructure the code. Just wanting to make sure thats reasonable before moving forward.
If your code was structured to map the buffer, then I recommend you simply use a malloc'ed memory ptr:
Code: Select all
// Old code
void *data = buffer->map( ... );
// write to data
buffer->unmap();
// New code
void *data = OGRE_MALLOC_SIMD( ..., MEMCATEGORY_GEOMETRY );
// write to data
buffer->upload( data, 0, numElements );
OGRE_FREE_SIMD( data, MEMCATEGORY_GEOMETRY ); // Or leave the pointer around for reuse later
Hilarius86 wrote: ↑Thu Oct 14, 2021 4:18 pm
Next thing is destruction of manual objects that are not loaded from disk. The ram usage is quite high and is not reduced in the same magnitude when destroying objects . I followed the trail and saw that my vbos get deallocated after a few frames (destroyDelayedBuffers) and are repurposed as free buffers. I don't mind the performance hit to reallocate, but for me it seems unintuative that the ram usage stays high even after deallocation of the vbos.
For some more background: the program is not creating new objects while rendering, but halting rendering to change the scene and only starts after finishing. There is no logic loop, but only starts rendering with mouse input.
Memory is not released immediately.
We have VaoManager::cleanupEmptyPools to release memory immediately but it can be slow as it must perform a defragment step.
You can also fine tune "VaoManager::VERTEX_IMMUTABLE", "VaoManager::VERTEX_DEFAULT" et al. (see c_vboTypes in OgreD3D11VaoManager.cpp) to tune how much memory the pools allocate by default. You can get a good estimate of how much you'll need by watching VaoManager::getMemoryStats output.
I can't remember how much was implemented in Ogre 2.1 as memory management increased tremendously in 2.2, we have the following samples to fine tune and monitor memory:
- Samples/2.0/Tutorials/Tutorial_Memory
- Samples/2.0/Tests/MemoryCleanup
- Samples/2.0/Tests/TextureResidency (Ogre 2.2+)
Last but not least, I assume most of your issues are coming from geometry? Ogre 2.1 has poor texture memory management because it loads all textures as soon as their materials are parsed and this is usually the main cause of memory consumption in Ogre 2.1 based applications, something which got fixed in Ogre 2.2
For debugging texture memory issues you can see the
manual section.
Cheers