OpenGL and Multi-Core CPU

Started by
5 comments, last by Kalidor 18 years, 1 month ago
I noticed the benmarks on multi-core CPU's aren't better than a single core CPU of the same speed. I've read that computer games aren't multi-threaded. It's seems pretty confusing. Can't you simply call CreateThread like in VC++? I would hate to think DOOM 3 runs in some huge single case loop. Do they mean single threaded in terms of rendering (only one draw thread)? This makes sense because OpenGL allows for multiple contexts but only one per thread. In this case, will mutliple-core CPU's benefit OpenGL? Or is there a way to render with muliple threads? Just a general question mostly for fun.
Advertisement
the games can profit from multi cores,
but not really in terms of rendering,

but everything else can seperated, if you plan carefully.
Physics, AI, World Pre Loading etc. etc. can work on the second core
and fetch new data to the rendering process.


Marc
>>fetch new data to the rendering process


I'm curious. Could you explain further?
Quote:Original post by fathom88
>>fetch new data to the rendering process


I'm curious. Could you explain further?


The rendering process obviousely comes last in the game loop/cycle, as all information must be ready and updated. Basically, and I do any of my games this way, is that you have a process queue, and everything gets processed when needed/requested. They all perform calculations on a large chunk of data, such as your mesh data/texture data/etc... The renderer, which now uses the GPU, then takes all this data and renders the scene. In single threaded applications, there's no problems with this, but in multi-threaded applications, problems arise such as you modifying data during the render cycle that shouldn't be changed. People usually put a lock on the renderer, and perhaps have a buffer where they can store things for the next render.
We should do this the Microsoft way: "WAHOOOO!!! IT COMPILES! SHIP IT!"
ID released a patch for Quake4, that adds multithreading to the engine; go to http://www.firingsquad.com/hardware/quake_4_dual-core_performance. The performance increase on Pentium D & Athlon X2 is very big (of course if game settings don't make it fillrate limited). Even Pentiums with HyperThreading advance from this a bit. If more games are written with multithreading in mind, I guess dual-core CPUs will become standard...
Quote:Or is there a way to render with muliple threads?


Nope, opengl can only be used in the same thread it was initialised in.

Quote:Original post by MENTAL
Nope, opengl can only be used in the same thread it was initialised in.
That's not exactly true. It can be used in any thread as long as the OpenGL context is made current in that thread, but it can only be current in a single thread at a time. It's usually best to avoid the context switches and just do all OpenGL work inside the thread that created the context though.

This topic is closed to new replies.

Advertisement