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

Vulkan PipelineState Memory Access Violation #49

Closed phr00t closed 5 years ago

phr00t commented 5 years ago

A system memory access violation happens on this line:

https://github.com/phr00t/xenko/blob/master/sources/engine/Xenko.Graphics/Vulkan/PipelineState.Vulkan.cs#L199

Sometimes on startup for specific projects. Sometimes the same application will run fine, sometimes not with no changes. This points to a timing or threading issue, plausibly similar to the texture problem on load. Looking into it...

phr00t commented 5 years ago

Here is the project that the PipelineState Memory Access Violation happens with (permission from author to share):

https://mega.nz/#!O2JTBApa!lNTGE4qRLR1vl_0_puuOMBYv8RtlNhPWBf53WWVumnQ

When building with Vulkan & starting the application, it will crash with the violation about 90% of the time.

phr00t commented 5 years ago

This one is very weird and unpredictable.

I started to suspect it had to do with the number of objects to render at project start -- since reducing the number made it crash less, and adding them back seemed to make it crash more. However, after adding many more objects, the problem completely vanished & I'm having trouble reproducing this crash at all.

I was going to try and add some synchronization to the CreateGraphicsPipelines call, but now that I can't rely on the problem happening -- I can't know if the synchronization would help.

Shelving this issue for the meantime until it comes back in a more reproducible state.

phr00t commented 5 years ago

xen2 from Discord mentioned it might be an async destruction issue (an object being used for the native pipeline generation being destroyed at the same time the generation is happening).

wozeparrot commented 5 years ago

Actually, I managed to get this to happen with a brand new project, no changes just build.

phr00t commented 5 years ago

https://i.kym-cdn.com/photos/images/newsfeed/000/002/109/orly_owl.jpg

How often does it happen with a brand new project?

I've never had it happen to my current project, and I've never seen it happen on a new project. I've only seen it with your project linked here, and it was very inconsistent. We really need to nail down what is causing this, or at least what makes it more likely to happen. If you can narrow it down to some feature, shader, mesh, post-processing filter etc. that'd be really helpful!

wozeparrot commented 5 years ago

It happens all the time, its preventing me from doing anything with xenko.

phr00t commented 5 years ago

I just opened up a new project and saw the same error. I'm looking into it...

EDIT: only happened that once. Opened the new project in a debug environment, and I can't reproduce it anymore... uuggghhhh

phr00t commented 5 years ago

This update might have improved things:

https://github.com/phr00t/xenko/commit/32e3d9187ea12bacbcda996b9088362f1200375a

It seems to have happened more frequently on AMD hardware, and not NVIDIA hardware. The above fix made it work on my AMD test machine. Looking forward to more testing!

phr00t commented 5 years ago

Appears to be fixed.