I'm designing an engine for my big 3D game project, and I want to make sure everything is very scalable to processors with many cores, without having more threads than necessary spawned at a time.
This is the architecture I'm considering right now in terms of different threads:
- 1 scheduling thread
- Runs the main loop
- Spawns work and I/O jobs
- Sends draw/compute calls to the GPU
- 1 I/O thread
- Blocks on calls to fread and fwrite
- Spawns work jobs for decoding
- 1 sound thread
- Runs from within OpenAL or satisfies SDL audio callbacks
- n worker threads, where n = ncores - 3
- Run serial work jobs (embarassingly parallel jobs will be run on the GPU)
While this makes sense to me for processors like Intel i7's or AMD FX's which generally have more than 4 (logical) cores, for a 4-core processor like an i5, there is only one worker thread.
Should the scheduling thread also be able to run work jobs? If so, is it safe enough to have any thread be able to send draw/compute calls to the GPU (using OpenGL 4)?