diff --git a/Source/Engine/Level/Scene/SceneRendering.cpp b/Source/Engine/Level/Scene/SceneRendering.cpp index 69d8edf4c..dca3d7c16 100644 --- a/Source/Engine/Level/Scene/SceneRendering.cpp +++ b/Source/Engine/Level/Scene/SceneRendering.cpp @@ -70,7 +70,7 @@ void SceneRendering::Draw(RenderContextBatch& renderContextBatch, DrawCategory c // Draw all visual components _drawListIndex = -1; - if (_drawListSize >= 64 && category == SceneDrawAsync && renderContextBatch.EnableAsync) + /*if (_drawListSize >= 64 && category == SceneDrawAsync && renderContextBatch.EnableAsync) { // Run in async via Job System Function func; @@ -78,7 +78,7 @@ void SceneRendering::Draw(RenderContextBatch& renderContextBatch, DrawCategory c const uint64 waitLabel = JobSystem::Dispatch(func, JobSystem::GetThreadsCount()); renderContextBatch.WaitLabels.Add(waitLabel); } - else + else*/ { // Scene is small so draw on a main-thread DrawActorsJob(0); diff --git a/Source/Engine/Platform/Base/PlatformBase.h b/Source/Engine/Platform/Base/PlatformBase.h index 35cfd8d17..d2486841a 100644 --- a/Source/Engine/Platform/Base/PlatformBase.h +++ b/Source/Engine/Platform/Base/PlatformBase.h @@ -392,7 +392,7 @@ public: static void SetThreadPriority(ThreadPriority priority) = delete; /// - /// Sets a processor affinity mask for the specified thread. + /// Sets a processor affinity mask for the current thread. /// /// /// A thread affinity mask is a bit vector in which each bit represents a logical processor that a thread is allowed to run on. A thread affinity mask must be a subset of the process affinity mask for the containing process of a thread. A thread can only run on the processors its process can run on. Therefore, the thread affinity mask cannot specify a 1 bit for a processor when the process affinity mask specifies a 0 bit for that processor. @@ -400,6 +400,12 @@ public: /// The affinity mask for the thread. static void SetThreadAffinityMask(uint64 affinityMask) = delete; + /// + /// Sets a preferred processor for the current thread. + /// + /// The preferred processor number. + static void SetThreadIdealProcessor(uint32 idealProcessor) = delete; + /// /// Suspends the execution of the current thread until the time-out interval elapses /// diff --git a/Source/Engine/Platform/Win32/Win32Platform.cpp b/Source/Engine/Platform/Win32/Win32Platform.cpp index 0dbf71cab..3265d1a54 100644 --- a/Source/Engine/Platform/Win32/Win32Platform.cpp +++ b/Source/Engine/Platform/Win32/Win32Platform.cpp @@ -368,6 +368,11 @@ void Win32Platform::SetThreadAffinityMask(uint64 affinityMask) ::SetThreadAffinityMask(::GetCurrentThread(), (DWORD_PTR)affinityMask); } +void Win32Platform::SetThreadIdealProcessor(uint32 idealProcessor) +{ + ::SetThreadIdealProcessor(::GetCurrentThread(), idealProcessor); +} + void Win32Platform::Sleep(int32 milliseconds) { if (milliseconds < 0) diff --git a/Source/Engine/Platform/Win32/Win32Platform.h b/Source/Engine/Platform/Win32/Win32Platform.h index 5d020a0fd..02ac53fe8 100644 --- a/Source/Engine/Platform/Win32/Win32Platform.h +++ b/Source/Engine/Platform/Win32/Win32Platform.h @@ -100,6 +100,7 @@ public: } static void SetThreadPriority(ThreadPriority priority); static void SetThreadAffinityMask(uint64 affinityMask); + static void SetThreadIdealProcessor(uint32 idealProcessor); static void Sleep(int32 milliseconds); static double GetTimeSeconds(); static uint64 GetTimeCycles(); diff --git a/Source/Engine/Threading/JobSystem.cpp b/Source/Engine/Threading/JobSystem.cpp index f278d7d02..154b83ff5 100644 --- a/Source/Engine/Threading/JobSystem.cpp +++ b/Source/Engine/Threading/JobSystem.cpp @@ -8,6 +8,7 @@ #include "Engine/Core/Collections/Dictionary.h" #include "Engine/Engine/EngineService.h" #include "Engine/Profiler/ProfilerCPU.h" +#include "Engine/Platform/Win32/IncludeWindowsHeaders.h" #if USE_CSHARP #include "Engine/Scripting/ManagedCLR/MCore.h" #endif @@ -155,7 +156,8 @@ void JobSystemService::Dispose() int32 JobSystemThread::Run() { - Platform::SetThreadAffinityMask(1ull << Index); + //Platform::SetThreadAffinityMask(1ull << Index); + Platform::SetThreadIdealProcessor((uint32)Index); JobData data; bool attachCSharpThread = true;