vsg-dev / VulkanSceneGraph

Vulkan & C++17 based Scene Graph Project
http://www.vulkanscenegraph.org
MIT License
1.32k stars 212 forks source link

Failed to allocate DeviceMemory and Crash #1071

Closed newmyl closed 6 months ago

newmyl commented 10 months ago

I have convert a .osgb model to .vsgb. The .vsgb file is very large and its size is 5GB.
I have two computers. In computer A, the GPU is Quadra P2000 whose GPU memory is 5GB. In computer B, the GPU is an integrated type and has no GPU memory at all. When I loaded the model in computer A, it throwed and expction "Failed to allocate DeviceMemory" and the program crashed. When I loaded the model in computer B, it loaded the model succesfully and performed very well. I opened the task manager in computer A and found that the program had used up the whole GPU memory, but in computer A, the shared GPU memory is 32GB which has been used only about 4.5GB. Computer B has no discrete GPU and the program used the shared GPU memory directly. The shared GPU memory in computer B is 32GB, so the model is loaded succesfully. Is there any way to manually manage which memory the program uses? The computer A's GPU is far better than the computer B's, but the model can be loaded on the computer B instead of the computer A. How can I avoid this situation? Many thanks. The two pictures below are the captures of the task manager.

微信截图_20240116135647 微信截图_20240116141450

robertosfield commented 6 months ago

Currently the VSG's compile traversal that creates all the Vulkan objects, allocates memory and transfer data to the GPU attempts to allocate data on the GPU for all arrays and textures. I don't have any extreme scene graphs like yours to test against but presume it's this attempt to allocate on the GPU that is issue.

It's possible to explicitly set up the vsg::BufferInfo and associated vlk/vsg::Buffer and vsg::DeviceMemory for data in the scene graph prior to the standard compile traversal, this would allow you decide what data is stored where.

Longer term I'd like to add more controls into the compile traversal to help control what parts of the scene graph are cache in GPU memory vs main memory. I haven't done any specific design work so this is aspirational at this point.

As a general comment, really large single databases may well be poor fit right from the start. The OSG and VSG both have the PagedLOD node and associated DatabasePager for handling really large datasets. Using paging it's possible to comfortably work with multi-terrabyte databases.