Skip to main content
gamedev.net
🔒 Locked

Loading while Rendering

Started by DrGUI Dec 13, 2005 at 12:50 PM 3 replies 600+ views
Original Post
DrGUI
DrGUI
Hey Do you think DirectX would mind if I loaded vertex buffers and textures etc from one thread while rendering a pretty screen on the main thread to keep the user happy? Or would I be forced to just load resources into memory on the loader thread and create resources from the main thread? Thanks a lot
Armadon
Armadon
Quote:

Do you think DirectX would mind if I loaded vertex buffers and textures etc from one thread while rendering a pretty screen on the main thread to keep the user happy?

I don't see why not. If you keep the thread safety and manage the device and your resources properly. I don't see any problems and might even be very efficient. Keep in mind that multithreaded applications can become a horror if you are doing things incorrectly. Remember to initialize the device with the D3DCREATE_MULTITHREADED flag.


I hope this helps.
Take care.
jollyjeffers
jollyjeffers
As Pieter's post indicated, if you create your device to be thread safe it will work. However, just setting that flag will force the runtime to take CritSec's which can hurt performance [smile]

Using "worker threads" is a good idea if you expect loading/streaming to be used heavily. However, you are best off keeping all of Direct3D in a single thread.

If your core thread creates/owns/maintains Direct3D, it can then farm out networking/file IO to the workers. The workers go about their business and prepare a packet of data in the correct format (i.e. matching exactly) the vertex buffers layout. The worker thread passes this back to the central thread which does a quick lock/memcpy/unlock operation at an appropriate time.

I've read about (on these forums and elsewhere) some very clever resource streaming mechanisms that are based on the "worker thread" principle. However, I think you'll be best off by keeping Direct3D on its own [smile]

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
Bezben
Bezben
You don't need a seperate thread to do this, a very simple way I've used is to write a small function that draws a loading... image to the back buffer, and a rect of variable size as a loading bar. Oh, and an outline for the rect is nice too. If you don't clear the backbuffer you can get away with just updating the progress bar bit.
DrGUI
DrGUI
Thanks

Yes, I want to keep the device non-multithreaded, so I guess I'll have to use the method Jack described.

But I've already got a 'Loading...' image so perhaps it's just not worth the effort...

Thanks again everyone ++

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.