phr00t / FocusEngine

Focus Game Engine. This is Stride/Xenko fast-tracked for Phr00t's Software games. Improvements over the original Focus on Vulkan support, PC platforms, VR, performance & ease. Cherry-picks commits from other forks as needed.
MIT License
97 stars 11 forks source link

Directional Shadowmap renderer stability issues #113

Closed phr00t closed 4 months ago

phr00t commented 5 months ago

With a very high number of shadow casters and the directional shadow system, sometimes flicker begins to happen where rendering seems to get corrupted randomly... likely due to some multithreading problem. Occasionally, the Vulkan device will be lost during this instability. This very rarely happens even with reasonable shadow caster counts. Problem is greatly exacerbated when using multiple cascades.

phr00t commented 5 months ago

Example crash:

image

image

image

phr00t commented 5 months ago

This commit: https://github.com/phr00t/FocusEngine/commit/1cba6b654b212ba5350ffb64d97b513cda048e68

... doesn't help flicker, but I'm hoping will help with the crashing, maybe.

phr00t commented 5 months ago

I still got a "device lost" crashing error, but this time it was outside of shadow rendering (but same context resetting part of drawing). I'm still unsure why this happens, but at least it is very rare (which also makes it very hard to reproduce and debug).

phr00t commented 4 months ago

I fixed it! The flickering was not actually related to shadows at all... shadows just increased the draw count enough to cause a buffer pool to be exhausted. Simply increasing the buffer pool larger solves the problem! I do not notice any significant increase of memory. I'm hoping this also resolves "device lost" Vulkan errors, but I suspect it doesn't. I'm closing this for now as "fixed" and may need to reopen some "device lost" issue later if that problem returns.

Fixed with https://github.com/phr00t/FocusEngine/commit/eb3ee01b72b6e64e1a238a4098d1226e9b9f883a