Multithread question

Started by
2 comments, last by Tispe 10 years ago

Hi Guys,

Just wondering, is it possible to draw to a dynamic texture from within another thread?

The reason I ask is that I am doing some intensive calculations on a dynamic texture (per frame) which is eating up my frames per second in a large way.

So, I was thining (if possible) to do the calculations in a separate thread and display the texture when the calulations are complete (hopefully bringing up FPS again).

I would love to hear your thoughts on this :)

Advertisement
You can map/lock the texture on the main thread, then pass the mapped pointer/size to your 2nd thread, then have the main thread unmap/unlock the texture after the 2nd thread is done writing to it.

So yes - the main thread must do the map/unmap, but in the middle, you can write into the mapped buffer however you like ;)
Thanks Hodgman :)

I think (after all that) that I am barking up the wrong tree.

I think I might be pushing too much onto my dynamic texture each frame. I am sending 1600 x 900 frames to my dynamic texture each frame. At this resolution I only manage around 40 FPS.

Is this typical for this size or would you still expect a higher frame rate?

Consider pipelining this, so that you have two identical textures which are updated every other frame for maximum utilization. The other thread is updating one texture while the main thread renders from the other.

This topic is closed to new replies.

Advertisement