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

SharpVulkan.SharpVulkanException: 'A Vulkan error of type [ErrorDeviceLost] occurred.' #42

Closed phr00t closed 5 years ago

phr00t commented 5 years ago

Rarely on a start, we get the following error:

SharpVulkan.SharpVulkanException: 'A Vulkan error of type [ErrorDeviceLost] occurred.'

vulkan-crash

Might be related to the texture rendering fixes I made here: https://github.com/phr00t/xenko/commit/87fc17d947ac042a177847de2a2f70d65f19820b -- specifically skipping a descriptor update write when one may be expected. Might be more reliable to use the 1x1 texture suggested by xen2 to pass along until the real texture comes around.

Simply running the game again is likely to work, so might be related to threading issues.

Here is some documentation on lost devices (4.2.3, scroll down a bit): https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#devsandqueues-devices

phr00t commented 5 years ago

This commit hopefully resolves this problem: https://github.com/phr00t/xenko/commit/e213ee9a0bdd386e481deae83c69413337caf75a

Will monitor for a bit... if I don't have issues, I'll consider this issue closed.

phr00t commented 5 years ago

I was ALMOST ready to close this issue, since it does seem to be happening much more rarely... until I got the same exception in the same place:

Xenko.Graphics.dll!Xenko.Graphics.Texture.InitializeImage(Xenko.Graphics.DataBox[] dataBoxes) Line 382  C#

Xenko.Graphics.dll!Xenko.Graphics.Texture.InitializeFromImpl(Xenko.Graphics.DataBox[] dataBoxes) Line 172 C# Xenko.Graphics.dll!Xenko.Graphics.Texture.InitializeFrom(Xenko.Graphics.Texture parentTexture, Xenko.Graphics.TextureDescription description, Xenko.Graphics.TextureViewDescription viewDescription, Xenko.Graphics.DataBox[] textureDatas) Line 516 C# Xenko.Graphics.dll!Xenko.Graphics.Texture.New(Xenko.Graphics.GraphicsDevice graphicsDevice, Xenko.Graphics.TextureDescription description, Xenko.Graphics.TextureViewDescription viewDescription, Xenko.Graphics.DataBox[] boxes) Line 1109 C# Xenko.Rendering.dll!Xenko.Streaming.StreamingTexture.StreamingTask(int residency) Line 351 C# mscorlib.dll!System.Threading.Tasks.Task.Execute() Unknown mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown mscorlib.dll!System.Threading.Tasks.Task.ExecuteWithThreadLocal(ref System.Threading.Tasks.Task currentTaskSlot) Unknown mscorlib.dll!System.Threading.Tasks.Task.ExecuteEntry(bool bPreventDoubleExecution) Unknown mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() Unknown

The texture it seemed to be trying to initialize was a 512x512 texture I had placed on a procedurally generated sphere.

phr00t commented 5 years ago

Made another commit that will hopefully address this: https://github.com/phr00t/xenko/commit/b71444afb0959f5c797947db0a4813ccef786b29

Monitoring...

phr00t commented 5 years ago

Made yet another set of changes, which helped shadow maps, and may improve this issue further: https://github.com/phr00t/xenko/commit/f9d8a8c538f2330a2b5752288c18f44d6ed3517f

Haven't experienced this crash in awhile. Going to close for now. If it happens, I'll reopen.