revelator / The-Darkmod-Experimental

Fork for darkmod devs to toy with new ideas.
GNU Lesser General Public License v3.0
4 stars 1 forks source link

Threading #1

Open nbohr1more opened 9 years ago

nbohr1more commented 9 years ago

Since the forums are down, I thought I would leave this here for posterity:

From the other thread:

While I'm speculating wildly, has anyone ever split the renderer front end and back end across two processors, like it was originally designed to be done? Has the problem of 2 processes writing to the same gl context been solved by new tech? Or if not, perhaps by using gpu skinning so there's vastly less for the front end to write to the gpu, and so moving what's left to the back end?

Here's John Carmack's solution:

John Carmack - This was explicitly to support dual processor systems. It worked well on my dev system, but it never seemed stable enough in broad use, so we backed off from it. Interestingly, we only just found out last year why it was problematic (the same thing applied to Rage’s r_useSMP option, which we had to disable on the PC) – on windows, OpenGL can only safely draw to a window that was created by the same thread. We created the window on the launch thread, but then did all the rendering on a separate render thread. It would be nice if doing this just failed with a clear error, but instead it works on some systems and randomly fails on others for no apparent reason.

The Doom 4 codebase now jumps through hoops to create the game window from the render thread and pump messages on it, but the better solution, which I have implemented in another project under development, is to leave the rendering on the launch thread, and run the game logic in the spawned thread.

revelator commented 9 years ago

That would be an interresting option if we could get it stable :) i think thats the same pitfall i ran into when i tried to use openmp on the render thread, it simply failed on my machine but since noone else has tried the build i cant comment on if it would work for others. It seems to work on linux though since the patch was originally for that system.

nbohr1more commented 9 years ago

Yeah, it basically looks like "if you open a GL window with this thread, any draw commands must also come from this thread" that means that the frontend render code can be moved to another (spawned) thread as long as no GL calls are done from it. So I guess the gist is: Start GL, spawn game, spawn frontend, feed back to original GL thread to execute backend.

revelator commented 9 years ago

would need a callback interface i guess hmm ill see what i can dig up about doing something like that. Is the darkmod forums still down ? site seems to be up but i cannot post. Last two days i also got SQL errors when trying to reach the site.

revelator commented 9 years ago

Btw i have added you as collaborator of this project so you now have full access :)

nbohr1more commented 9 years ago

Thanks! Yes... we're all waiting on the forum mod (modetwo) to fix this. Hopefully we don't end-up with a Doom3world.org situation... I guess I should start making a webarchive of the forums soonish...