SFML community forums

Help => Graphics => Topic started by: Glocke on January 30, 2015, 11:29:31 am

Title: Distributed Rendering
Post by: Glocke on January 30, 2015, 11:29:31 am
Hi, I am experimenting with distributed rendering. Fortunately it works ;D But I'm not quite sure whether my approach is "right" or as any downsides.

Basic Idea: Rendering multiple views in parallel by drawing an array of sf::Drawables to a sf::RenderTexture. So I created a Camera-class holding the used view, a render texture and a C++11 Thread to perform drawing. On each frame the drawing-threads are restarted, the main thread is waiting for them and then it applies the render texture to the actual rendering target.

I know some basic stuff about concurrency, but I lack of experience about using in "real life". So I'm not sure whether..

It's just a theoretical aspect, but drawing in parallel should be more efficient. But I don't know how expensive the "merge" (getting texture from the render texture and applying it to window) is. :-\
Of course the scenes need to be much more complex ^^ Distributed rendering of two shapes seems overkill .. well, just some kind of minimal-code ^^

Well, here's my current code (btw using linux, so XInitThreads is used) :) (inside the spoiler)
(click to show/hide)

Kind regards
Glocke
Title: Re: Distributed Rendering
Post by: Laurent on January 30, 2015, 11:51:59 am
Your graphics driver and GPU are made for single threaded access. You won't gain anything by rendering in parallel from multiple threads, except unnecessary internal driver synchronization work.
Title: Re: Distributed Rendering
Post by: Glocke on January 30, 2015, 11:54:29 am
Your graphics driver and GPU are made for single threaded access. You won't gain anything by rendering in parallel from multiple threads, except unnecessary internal driver synchronization work.
As I expected xD Damn :-[ But thanks for correction :)
Title: Re: Distributed Rendering
Post by: Laurent on January 30, 2015, 12:02:42 pm
But since you have a working implementation, don't stop there, you should run a benchmark multi-threaded vs single-threaded (with more than 2 entities of course) ;)
Title: Re: Distributed Rendering
Post by: Glocke on January 30, 2015, 01:51:53 pm
But since you have a working implementation, don't stop there, you should run a benchmark multi-threaded vs single-threaded (with more than 2 entities of course) ;)
Well I just did that right now: No measurable difference. I wrote a single-threaded and a multi-threaded (2 threads) both using much more shapes ^^ . Boach approaches rendered within ~300ms per frame :D

But I think the process of culling visible objects could be parallelized for multiple views with measurable difference between single- and multi-threaded.