Skip to content

Commit

Permalink
- Write out a warning if std::thread::hardware_concurrency returns zero.
Browse files Browse the repository at this point in the history
- If the number of cores cannot be determined, turn of multithreading in the software renderer as it is most likely a low end system
  • Loading branch information
dpjudas authored and madame-rachelle committed May 14, 2019
1 parent 9a1dab5 commit e2fc3f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/rendering/polyrenderer/poly_renderthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void PolyRenderThreads::RenderThreadSlices(int totalcount, std::function<void(Po

int numThreads = std::thread::hardware_concurrency();
if (numThreads == 0)
numThreads = 4;
numThreads = 1;

if (r_scene_multithreaded == 0 || r_multithreaded == 0)
numThreads = 1;
Expand Down
11 changes: 10 additions & 1 deletion src/rendering/swrenderer/scene/r_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,16 @@ namespace swrenderer
{
int numThreads = std::thread::hardware_concurrency();
if (numThreads == 0)
numThreads = 4;
{
static bool firstCall = true;
if (firstCall)
{
firstCall = false;
Printf("Warning: Unable to determine number of CPU cores/threads for this computer. To improve performance, please type 'r_multithreaded x' in the console, where x is the number of threads to use.\n");
}

numThreads = 1;
}

if (r_scene_multithreaded == 0 || r_multithreaded == 0)
numThreads = 1;
Expand Down

0 comments on commit e2fc3f2

Please sign in to comment.