GodotVR / godot-oculus-asset

Asset repository for GDNative Oculus drivers
MIT License
11 stars 2 forks source link

Multi-threaded rendering #2

Open SaracenOne opened 6 years ago

SaracenOne commented 6 years ago

The engine crashes when running the renderer in multi-threaded mode. This does not occur in-editor because multi-threaded rendering is always forced off.

BastiaanOlij commented 6 years ago

Owh fun! love those types of issues.

I wager that it is because the renderer runs in a separate thread from the main game so we're probably missing some mutexes. The main render thread will call both process and submit methods, but just about everything else is called from the main thread.

The question will be whether we can solve it for any GDNative driver by placing the mutexs in the GDNative interface wrapper class in Godot. Might be good anyway because it will also protect any thread sensitive calls into the GDNative layer.

SaracenOne commented 6 years ago

@BastiaanOlij They are a particularly annoying class of errors. I didn't even get any useful debug information from the crash, had to just try narrowing down the problem by looking at what works and what doesn't work. Not sure if there might be some clues garnered from the fact that the plugin doesn't even have to be active to crash the engine, it merely has to be present in a project.

BastiaanOlij commented 6 years ago

Hmm, that is very weird because there should be very little to no interaction. I wonder if it may still call the process method though it should only do that on active interfaces... hmm.

BastiaanOlij commented 5 years ago

Note that I found out this was caused by OpenGL not liking having stuff done in the main thread for use with the render thread.

Worked around this for the openvr plugin but still tweaking the solution for Oculus.