yshui / index_camera_passthrough

Experimental Valve Index camera passthrough for Linux
MIT License
47 stars 2 forks source link

Use more appropriate vulkano heap sizes #8

Open galister opened 8 months ago

galister commented 8 months ago

Hi, I was mostly doing my own research on this and I thought you might be interested.

Vulkano's default StandardMemoryAllocator allocates around 576MB of memory even if you don't upload anything. This is not great for an overlay app that just wants to display a 720p image.

A typical AMD card is known to expose 3 heaps; 1 DEVICE_LOCAL, 1 HOST_VISIBLE and usually 1 smaller (<1GB) DEVICE_LOCAL | HOST_VISIBLE.

StandardMemoryAllocator::default_new() will allocate 256MB per large (>1GB) heap and 64MB for the small heap, making it seem like your app is using 576MB memory (+ openxr swapchains, as they are not managed by vulkano).

The answer for me was to explicitly set the heap sizes instead of using new_default().

https://github.com/galister/wlx-overlay-s/blob/6842872314ad444b38fdd15b90b784964c0fbdae/src/graphics.rs#L1172-L1209