Open bgourlie opened 5 years ago
Hey 👋 I'm currently failing to build it (running out of stack memory on my nightly compiler?) and haven't looked too closely on the code so far, but I assume this is most likely due to differences in the command buffer memory allocation behaviors between vulkan and dx12, which we need to address on our side. Btw, the colour-uniform example leaks memory on both backends due to not freeing nor recycling cmd buffers for some reason. The easiest way to avoid any issues is to reuse command buffers and periodically reset the command pool with resource release flag.
I was running into that last week but a rustup update
fixed it. Also, I've added some commits that have made the branch referenced in the repro steps incompatible with the dx12 backend (actually an HLSL compatibility issue which I do not believe to be a bug, sampling non-float textures), so I've updated the repro steps to reference a particular commit. In hindsight I should have created a branch specifically for the repro!
the colour-uniform example leaks memory on both backends due to not freeing nor recycling cmd buffers for some reason
reason being - it used on gfx-hal recycling the command buffers in the wrong way (without fences and such), and this logic was recently removed for good.
I was able to fix the big DX12 memory leak and the much smaller Vulkan memory leak by pre-recording and reusing my command buffers.
I'm still very much a vulkan noob so I'm not sure if my issue (as well as the memory leak in the example) is due to incorrect usage or an actual bug in gfx-hal.
Short info header:
I have a WIP renderer for my NES emulator that I derived from the colour_uniform example. When running with the dx12 backend, it leaks ~22mb per second. I found a potentially related (closed) issue here.
You can reproduce using the following steps:
git clone https://github.com/bgourlie/rs-nes
cd rs-nes
git checkout 93dc581d52705772c57a58774ee3de3755b1d844
cd rs-nes-renderer
cargo run --features dx12 --release -- ../test_roms/lawn_mower.nes
Memory leak can then be observed using the task manager. Also note that you won't see any meaningful output when running this ROM, however if you have a mario bros rom handy you will. There is no memory leak when running using the Vulkan backend.