Devsh-Graphics-Programming / Nabla

Vulkan, OptiX and CUDA Interoperation Modular Rendering Library and Framework for PC/Linux/Android
http://devsh.eu
Apache License 2.0
478 stars 59 forks source link

Tracking Device Memory Usage and Budget #764

Open Erfan-Ahmadi opened 1 day ago

Erfan-Ahmadi commented 1 day ago

Basically what VK_EXT_memory_budget provides. reports the current usage and budget on each memory heap. This extension is not supported good enough for it to be in core Nabla [1].

  1. we can emulate the "usage" by tracking our allocates and frees. (using atomics per device)

    The VkPhysicalDeviceMemoryBudgetPropertiesEXT::heapUsage will display the current process estimated heap usage.

  2. We can emulate "budget" heuristically, by returning 80% of total heap size. (like VMA)

    The VkPhysicalDeviceMemoryBudgetPropertiesEXT::heapBudget values can be used as a guideline for how much total memory from each heap the current process can use at any given time, before allocations may start failing or causing performance degradation. The values may change based on other activity in the system that is outside the scope and control of the Vulkan implementation.

another option is to not return this at all unless the extension is available and log error and return invalid value?

The extension returns those values per "process" but I don't think we can only track per device.

I would like more feedback on this. maybe it's just better not to use this extension at all and just track usage per device.

Erfan-Ahmadi commented 1 day ago

IDEA: We can adjust our heap budget heuristic when hitting allocation failures.

Erfan-Ahmadi commented 1 day ago

https://discord.com/channels/593902898015109131/723305695046533151/1301552319628054550

Yes just shove it in device limits Fallback paths not worth the man hours of effort