DiligentGraphics / DiligentCore

A modern cross-platform low-level graphics API
http://diligentgraphics.com/diligent-engine/
Apache License 2.0
632 stars 138 forks source link

[bug] :windows 10 : vulkan: release build: dynamic heap exhausted #600

Open WangHoi opened 3 months ago

WangHoi commented 3 months ago

😂 I'm so sorry, found another bug.

Steps to re-produce

  1. In code: Make use of SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC
  2. Run the program in Release build on Windows with Vulkan backend.
  3. Click the taskbar app icon, to minimize the rendering window.

Problem

Diligent Engine: Warning: Space in dynamic heap is almost exhausted. Allocation forced wait time of 2.0 ms. Increase the size of the heap by setting EngineVkCreateInfo::DynamicHeapSize to a greater value or optimize dynamic resource usage

I can also re-produce this issue with builtin sample: GLTFViewer and Tutorial27_PostProcessing.

WangHoi commented 3 months ago

My guess is vulkan swapchain's present somehow not happen with minimized window. Assosiated dynamic heap recycle code, not running.

TheMostDiligent commented 3 months ago

What is you Windows version? GPU? Driver version?

WangHoi commented 3 months ago

Win10 Professional x64 - 22H2 19045.4651 GPU: GTX1070 v556.12 Vulkan: v1.3.224.1

WangHoi commented 3 months ago

When play with and tracking down this bug with sample Tutorial27_PostProcessing, I may found another small bug in that sample.

around Tutorial27_PostProcessing.cpp, line 303:

CurrCamAttribs.f4ViewportSize = float4{Resolution.x, Resolution.y, 1.f / Resolution.x, 1.f / Resolution.y};

After window resize, it is using previous window size. Should update viewport size first:

Resolution.x = m_PostFXFrameDesc.Width;
Resolution.y = m_PostFXFrameDesc.Height;
CurrCamAttribs.f4ViewportSize = float4{Resolution.x, Resolution.y, 1.f / Resolution.x, 1.f / Resolution.y};
MikhailGorobets commented 3 months ago

When play with and tracking down this bug with sample Tutorial27_PostProcessing, I may found another small bug in that sample.

around Tutorial27_PostProcessing.cpp, line 303:

CurrCamAttribs.f4ViewportSize = float4{Resolution.x, Resolution.y, 1.f / Resolution.x, 1.f / Resolution.y};

After window resize, it is using previous window size. Should update viewport size first:

Resolution.x = m_PostFXFrameDesc.Width;
Resolution.y = m_PostFXFrameDesc.Height;
CurrCamAttribs.f4ViewportSize = float4{Resolution.x, Resolution.y, 1.f / Resolution.x, 1.f / Resolution.y};

Everything is correct here; we have Source Size and Output Size. The first value determines the size of the render targets, and the second one determines the window size. They should differ because we are using FSR in this tutorial

MikhailGorobets commented 3 months ago

Got it, I understand what you mean. We just need to move SetupUpsamplingSettings before setting the resolution.

MikhailGorobets commented 3 months ago

https://github.com/DiligentGraphics/DiligentSamples/pull/188

TheMostDiligent commented 3 months ago

Does this reproduce in Debug build?

WangHoi commented 3 months ago

Only reproduce in Release build. And must click the taskbar icon to minimize.

I found that click window's top right minimize button, no warning, strange.