Kode / Kinc

Modern low level game library and hardware abstraction.
http://kinc.tech
zlib License
511 stars 121 forks source link

Potential fix for memory leak when resizing a display when using the D3D12 backend #827

Closed FelixK15 closed 9 months ago

FelixK15 commented 9 months ago

Changed how render targets are acquired/created in the d3d12 backend to fix https://github.com/Kode/Kinc/issues/810

I'm pretty sure the source of the memory leak was a double created render target in the original code. First the render target was created using CreateCommittedResource() and then, at the end of render_target_init(), the render_target->impl.renderTarget ptr was overwritten by either

render_target->impl.renderTarget = swapChainRenderTargets[framebuffer_index];

or

swapChain->GetBuffer(framebuffer_index, IID_PPV_ARGS(&render_target->impl.renderTarget));

This fix was only added after a visual inspection and has only been validated with the Input test. More thorough testing is definitely needed to validate correctness.

RobDangerous commented 9 months ago

Indeed, renderTarget was assigned twice. Super thanks!