BVE WorldWide
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Necessity of multi-threading on train plugins with functions that is CPU-cosy

2 posters

Go down

Necessity of multi-threading on train plugins with functions that is CPU-cosy Empty Necessity of multi-threading on train plugins with functions that is CPU-cosy

Post by hkmtrhah Mon Apr 13, 2015 9:08 am

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.
hkmtrhah
hkmtrhah

Posts : 34
Join date : 2013-06-19
Location : Hong Kong

http://about.me/hkgsherlock

Back to top Go down

Necessity of multi-threading on train plugins with functions that is CPU-cosy Empty Re: Necessity of multi-threading on train plugins with functions that is CPU-cosy

Post by leezer3 Mon Apr 13, 2015 10:05 pm

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 Smile

(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

leezer3

Posts : 1978
Join date : 2011-08-23

http://www.bvecornwall.co.uk

Back to top Go down

Necessity of multi-threading on train plugins with functions that is CPU-cosy Empty Re: Necessity of multi-threading on train plugins with functions that is CPU-cosy

Post by hkmtrhah Tue Apr 14, 2015 7:28 am

Maybe I have to dig into those codes to see if it's really caused by graphics...
hkmtrhah
hkmtrhah

Posts : 34
Join date : 2013-06-19
Location : Hong Kong

http://about.me/hkgsherlock

Back to top Go down

Necessity of multi-threading on train plugins with functions that is CPU-cosy Empty Re: Necessity of multi-threading on train plugins with functions that is CPU-cosy

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum