Jump to content

Multithreaded Scene Loader


ParaToxic
 Share

Recommended Posts

Hei ya I would like to make a loader for gamestarts with a video and a loader for meshes / textures.

 

I would like to make a video at the start like in all games and load at the same time the stuff for the game.

 

The problem is that I can't do that with Threads ( loading a mesh in a second thread close the whole app )

And playing the video in a other thread needs the created GL Context.....

 

An other idea was to load the data in a ifstream to some buffers ( in a thread) and "copy that to the memory" ( I saw that LE loads the data from the memory when you load the same asset the second time )

 

Have somebody a idea ?

Link to comment
Share on other sites

But I need a Context for video playing, because the Data is loaded into a GLTexture.

Not sure if it's a best way for playing video.

 

And how should I separate the App ??

I'm not sure. That was just an idea. You can create a standalone app for player and run it from game app in separate thread with waiting for finishing. And after closing player app your thread will get control and continue execution. So you will know that video is finished.

Link to comment
Share on other sites

Actually only LoadModel is not thread-safe, because it gets the texture size from the GPU, which returns 0 for other threads.

From all that I've seen in the past from people that have tried it, most of the commands are not thread safe and can cause crashes if run asynchronously, what makes you believe the others are all 'thread safe'?

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

Well I have seen examples where mutli-threaded calls to basic Entity functions caused crashes. The general concensus as I understand it has always been that Leadwerks is NOT thread safe!

 

What mechanisms are in place to ensure, for example, that only one thread reads or writes shared data at any time?

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

You can use mutexes to avoid that 2 threads use LE2 commands at the same time. But I prefer to do all heavy calculations on other threads only (like AI, raycasts, etc...), and let the main thread handle all the LE2 commands. Then I just unlock the mutex and inform the main thread that it can read now, so the main thread can read the calculated data and do its LE2 commands on the data.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Except that when you tell people it is thread safe they assume you don't have to use mutexes. Avoid misinformation please, it's not helpful to people.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

As long as you are not using seperate contextes for each thread and use shared memory there is no way making it threadsafe.

 

@metatron: As far as i remember your mt sample was based on loading the meshes seperatly before loading the scene in another thread. And due the instanced nature of le this might have worked. But as soon as you load a new mesh outside the mainthread le/opengl will crash and this has nothing to do with mutexes.

  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...