microsoft / DirectX-Graphics-Samples

This repo contains the DirectX Graphics samples that demonstrate how to build graphics intensive applications on Windows.
MIT License
5.89k stars 2k forks source link

A Small Bug Of MiniEngine #788

Closed pixel-Teee closed 2 years ago

pixel-Teee commented 2 years ago

Bug Place:MiniEngine/LinearAllocator.cpp 131 line

Need to change to: if (m_CurrPage != nullptr) { m_RetiredPages.push_back(m_CurrPage); m_CurrPage = nullptr; m_CurrOffset = 0; } sm_PageManager[m_AllocationType].FreeLargePages(FenceId, m_LargetPageList); m_LargetPageList.clear();

I copy you engine code, but when allocate one times of texture, i leak the LinearAllocationPage. Because this texture is large, so this call the CommandContext::Initialize, this function first allocate one context from the pool, if pool is empty and create a new context, then this context's LinearAllocator member's m_CurrPage member will be nullptr, and when context call finish function, this function will skip the FreeLargePages function because of if(m_CurrPage == nullptr) return; .

But mini engine's code first create an texture called diffuse_ibl.dds, this texture's size is not too large, so he will not be call AllocateLargePage function, and put a context to context pool, context's LinearAllocator's member's m_CurrPage member is not nullptr, and when create a lage texture, this will not lead to a buffer leak.

But when first create a texture, this will lead to leak.

stanard commented 2 years ago

Thank you for reporting this logic error. I'll take a look at fixing it at my soonest convenience. Alternatively, if you would like to submit a PR, I can approve it more quickly.

stanard commented 2 years ago

I pushed the fix just now.

pixel-Teee commented 2 years ago

Thanks you work~