Necessity of multi-threading on train plugins with functions that is CPU-cosy
2 posters
Page 1 of 1
Necessity of multi-threading on train plugins with functions that is CPU-cosy
As much as I have been programming, in which I've also been programming on train plugins for BVE & openBVE, I started to figure out that the main program (e.g. the oB) would somehow have a reduction on the frame-rate of the graphics when I started a "game-play" session with my plugin(s). And this may become more severe(?) if the plugin contains ATO functionality with lots of mathematical calculations.
Since I'm thinking about coding quite a huge in size of plugin, which contains pretty much functions like above mentioned and what I've posted (as demonstration) before. To make the "gameplay" experience not to be reduced too much due to the plugin part, I would love to hear if you have any comments about such idea.
Since I'm thinking about coding quite a huge in size of plugin, which contains pretty much functions like above mentioned and what I've posted (as demonstration) before. To make the "gameplay" experience not to be reduced too much due to the plugin part, I would love to hear if you have any comments about such idea.
Re: Necessity of multi-threading on train plugins with functions that is CPU-cosy
I'd be *very* surprised if you managed to get a plugin to cause any effect on OpenBVE.
Time for some technical details as to what's using CPU inside the main thread (Plymouth Route + Dinmore Manor- Complex plugin running various animations and a steam engine simulation, a relatively minimal set of animated world objects, primarily signals and a few large conglomerate objects):
OpenGL system calls (Rendering faces): ~20%
JIT Object loading ~20%
3D exterior calculations ~10%
Updating world animated objects ~5%
Everything else is a mixture of small percentages, but nothing particularly interesting.
Plugins are loaded into a separate thread, and then the Plugin.Elapse call is made once a frame.
If you're updating 100s of variables and using them to run animations, then I suppose this would cause a knock-on effect on the 3D exterior calculations value, but otherwise optimizing object loading & trying to improve the speed of the OpenGL calls in the main thread would be far better than worrying about the CPU impact of your plugin
(I've been fiddling with converting to the Tao framework as opposed to OpenTK, but I haven't made things any faster...)
Cheers
Chris Lees
http://www.bvecornwall.co.uk
Time for some technical details as to what's using CPU inside the main thread (Plymouth Route + Dinmore Manor- Complex plugin running various animations and a steam engine simulation, a relatively minimal set of animated world objects, primarily signals and a few large conglomerate objects):
OpenGL system calls (Rendering faces): ~20%
JIT Object loading ~20%
3D exterior calculations ~10%
Updating world animated objects ~5%
Everything else is a mixture of small percentages, but nothing particularly interesting.
Plugins are loaded into a separate thread, and then the Plugin.Elapse call is made once a frame.
If you're updating 100s of variables and using them to run animations, then I suppose this would cause a knock-on effect on the 3D exterior calculations value, but otherwise optimizing object loading & trying to improve the speed of the OpenGL calls in the main thread would be far better than worrying about the CPU impact of your plugin
(I've been fiddling with converting to the Tao framework as opposed to OpenTK, but I haven't made things any faster...)
Cheers
Chris Lees
http://www.bvecornwall.co.uk
Re: Necessity of multi-threading on train plugins with functions that is CPU-cosy
Maybe I have to dig into those codes to see if it's really caused by graphics...
Similar topics
» **ALPHA** OS_ATS in C#
» Even though the AI train hasn't stop completely, the AI train is open the doors.
» Localized train.txt (Different versions of train.txt depending on language)
» Trains with plugins lose power
» New plugin that can handle a plurality of plugins
» Even though the AI train hasn't stop completely, the AI train is open the doors.
» Localized train.txt (Different versions of train.txt depending on language)
» Trains with plugins lose power
» New plugin that can handle a plurality of plugins
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum