Browse Source

Added command line option to disable worker threads.

Lasse Öörni 14 years ago
parent
commit
d470af37cb
2 changed files with 10 additions and 7 deletions
  1. 5 4
      Docs/GettingStarted.dox
  2. 5 3
      Engine/Engine/Engine.cpp

+ 5 - 4
Docs/GettingStarted.dox

@@ -105,13 +105,14 @@ Urho3D.exe understands the following command line options:
 -v          Enable vertical sync
 -v          Enable vertical sync
 -t          Enable triple buffering
 -t          Enable triple buffering
 -w          Start in windowed mode
 -w          Start in windowed mode
+-b<length>  Sound buffer length in milliseconds
+-r<freq>    Sound mixing frequency in Hz
 -headless   Headless mode. No application window will be created
 -headless   Headless mode. No application window will be created
 -lqshadows  Use low-quality (1-sample) shadow filtering
 -lqshadows  Use low-quality (1-sample) shadow filtering
--b<length>  Sound buffer length in milliseconds
--r<freq>    Mixing frequency in Hz
--noflush    Disable GPU command queue flushing
--nolimit    Disable frame limiter
 -noshadows  Disable rendering of shadows
 -noshadows  Disable rendering of shadows
+-nolimit    Disable frame limiter
+-noflush    Disable GPU command queue flushing
+-nothreads  Disable worker threads
 -nosound    Disable sound output
 -nosound    Disable sound output
 -noip       Disable sound mixing interpolation
 -noip       Disable sound mixing interpolation
 -sm2        Force SM2.0 rendering
 -sm2        Force SM2.0 rendering

+ 5 - 3
Engine/Engine/Engine.cpp

@@ -88,6 +88,7 @@ bool Engine::Initialize(const String& windowTitle, const String& logName, const
     bool stereo = true;
     bool stereo = true;
     bool interpolate = true;
     bool interpolate = true;
     bool flush = true;
     bool flush = true;
+    bool threads = true;
     
     
     for (unsigned i = 0; i < arguments.Size(); ++i)
     for (unsigned i = 0; i < arguments.Size(); ++i)
     {
     {
@@ -111,6 +112,8 @@ bool Engine::Initialize(const String& windowTitle, const String& logName, const
                 lqShadows = true;
                 lqShadows = true;
             else if (argument == "noflush")
             else if (argument == "noflush")
                 flush = false;
                 flush = false;
+            else if (argument == "nothreads")
+                threads = false;
             else if (argument == "sm2")
             else if (argument == "sm2")
                 forceSM2 = true;
                 forceSM2 = true;
             else if (argument == "fallback")
             else if (argument == "fallback")
@@ -174,12 +177,11 @@ bool Engine::Initialize(const String& windowTitle, const String& logName, const
     
     
     // Set amount of worker threads according to the free CPU cores. Leave one for the main thread and another for
     // Set amount of worker threads according to the free CPU cores. Leave one for the main thread and another for
     // GPU & audio drivers, and clamp to a maximum of four for now
     // GPU & audio drivers, and clamp to a maximum of four for now
-    WorkQueue* queue = GetSubsystem<WorkQueue>();
     int numCores = GetNumCPUCores();
     int numCores = GetNumCPUCores();
-    if (numCores > 1)
+    if (threads && numCores > 1)
     {
     {
         int numThreads = Clamp(numCores - 2, 1, 4);
         int numThreads = Clamp(numCores - 2, 1, 4);
-        queue->CreateThreads(numThreads);
+        GetSubsystem<WorkQueue>()->CreateThreads(numThreads);
         
         
         String workerThreadString = "Created " + String(numThreads) + " worker thread";
         String workerThreadString = "Created " + String(numThreads) + " worker thread";
         if (numThreads > 1)
         if (numThreads > 1)