1 D3D device per thread, or a single device with mutexes ?
#1
Posted 10 February 2008 - 12:10 AM
best to create two D3Ddevices and use two threads, or just to create a
single device and render the scenes sequentially ?
I am wondering if the two parallel renders would actually be done simultaneously on the card. If not then there would be no point in doing this
and both renders could be done using a single device, and resources such as
any textures which are the common for both scenes would be shared rather than held twice (once per device).
Of course I could use a single device and two threads but I guess it would
probably need mutexes around the beginscene/endscene area which would
effectively eliminate the parallelism.
Cheers.
Bring back the Z80 I say...
#2
Posted 10 February 2008 - 01:16 AM
If you'll notice, when you use the device, you always are using a pointer to it (->). To me, that would mean you could have 50 of them, but they're all pointing back to the same device. It's a good idea on their part because anything else would needlessly take up enourmous amounts of memory.
Using multiple devices, I doubt it, but rendering multiple scenes with different GPU threads is a good idea (if it's possible).
#3
Posted 10 February 2008 - 03:15 AM
#4
Posted 10 February 2008 - 11:04 AM
want to do a beginscene..endscene then I would have to use a mutex to
prevent them from confusing each other ?
#5
Posted 10 February 2008 - 03:11 PM
#6
Posted 11 February 2008 - 10:09 AM
#7
Posted 11 February 2008 - 07:02 PM
#8
Posted 12 February 2008 - 07:41 PM
Hawkwind said:
Well then , you have your answer :)
TBH what I do to get good threading ability is i build my own command buffer ini a given frame in 1 thread while an alternate thread kicks out the previous frames command buffer. If the rendering finishes in time then my thread manager can re-assign those threads to logic and physics tasks until everything is complete. This has a few advantages
1) I get slighlty better concurrency even on a single processor machine because i find the D3DDevice stalls and at these times the next frames worth of data can be partially calculated, i assume at least. The difference is of the order of 0.01% though so its not really noticeable (And, hence, its not a problem on a single processor machine).
2) Because everything goes through the command buffer i can swap between rendering techniques on subsequent frames. Really good for checking differences between different rendering techniques such as Deferred and non-deferred rendering.
3) Performance on a multi processor machine is sweet! :D
#9
Posted 12 February 2008 - 07:44 PM
CheshireCat said:
Even on consoles its still something to avoid doing. Don't forget if you ask somethign to render in the middle of something else you can mess up all kinds of render states and such like. So either way you are going to be synchornising all the threads against each other and you'd lose any potential performance gains. Not to mention the fact that it would screw up all kinds of sort by shader and such like optimisations.
#10
Posted 13 February 2008 - 06:42 AM
Goz said:
#11
Posted 15 February 2008 - 06:54 PM
CheshireCat said:
Fair point .. Was thinking you were talking about some kind of immediate mode renderer. With display lists yeah you can get a bonus but you'd probably still get better performance by sorting all your shader and render state changes, and the like, in 1 big command buffer. That said you can always sort the command buffers into each other :)
#12
Posted 15 February 2008 - 09:45 PM
#13
Posted 16 February 2008 - 08:43 AM
CheshireCat said:
Well thats nto true ... there is still a cost. On Wii, for example i got 3% of a frame back by removing redundant state changes (As a result I tried not to pre-compile states changes, only vertex data chunks). PS2 was the same too. Don't see why 360 or PS3 would be any different. It still costs time to change a vertex or pixel shader for example. Sure .. the cost isn't quite as bad as on PC (No security ring changes) but that doesn't mean its free ... a pipeline flush is still a pipeline flush.
#14
Posted 16 February 2008 - 09:15 AM
#15
Posted 16 February 2008 - 02:03 PM
CheshireCat said:
Hmmm ... i was told that an X-Box 360 shader switch was INCREDIBLY expensive. The unified shader acrhictecture doesn't mean multiple different shaders can run simultaneously it just means the system can be rebalanced when there is more pixel shader intensive work (or indeed vertex shader work) going on ... Maybe im wrong ... but im fairly sure im not ... ah well.
But yeah i agree with ya on the CPU usage part. Its the same on Wii (and thus GC), X-Box and PS2 as well ... Though i tend to think of the GPU as another processor and one that should be encouraged to run without stalls as much as the CPU. Its all about performance in the end ...
#16
Posted 16 February 2008 - 04:01 PM
Goz said:
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












