SoftRasterizer: Force the number of rendering threads to be a power-of-two since any additional threads that are not power-of-two will be wasted.
This commit is contained in:
parent
b6072287c5
commit
cbd488e157
|
@ -448,36 +448,7 @@ public:
|
|||
if (numberThreads == 0)
|
||||
{
|
||||
isCPUCoreCountAuto = YES;
|
||||
|
||||
if (numberCores >= 96)
|
||||
{
|
||||
numberCores = 128;
|
||||
}
|
||||
else if (numberCores >= 48)
|
||||
{
|
||||
numberCores = 64;
|
||||
}
|
||||
else if (numberCores >= 24)
|
||||
{
|
||||
numberCores = 32;
|
||||
}
|
||||
else if (numberCores >= 16)
|
||||
{
|
||||
numberCores = 16;
|
||||
}
|
||||
else if (numberCores >= 8)
|
||||
{
|
||||
numberCores = 8;
|
||||
}
|
||||
else if (numberCores >= 4)
|
||||
{
|
||||
numberCores = 4;
|
||||
}
|
||||
else if (numberCores >= 2)
|
||||
{
|
||||
numberCores = 2;
|
||||
}
|
||||
else
|
||||
if (numberCores < 2)
|
||||
{
|
||||
numberCores = 1;
|
||||
}
|
||||
|
|
|
@ -1444,7 +1444,24 @@ SoftRasterizerRenderer::SoftRasterizerRenderer()
|
|||
|
||||
_HACK_viewer_rasterizerUnit.SetSLI(0, 1, false);
|
||||
|
||||
_threadCount = CommonSettings.num_cores;
|
||||
const size_t coreCount = CommonSettings.num_cores;
|
||||
_threadCount = coreCount;
|
||||
|
||||
// SoftRasterizer works best when the number of threads is a power-of-two.
|
||||
// Ensure that the thread count is set to the previous power-of-two if the
|
||||
// core count isn't already a power-of-two.
|
||||
_threadCount--;
|
||||
_threadCount |= (_threadCount >> 1);
|
||||
_threadCount |= (_threadCount >> 2);
|
||||
_threadCount |= (_threadCount >> 4);
|
||||
_threadCount |= (_threadCount >> 8);
|
||||
_threadCount |= (_threadCount >> 16);
|
||||
_threadCount++;
|
||||
|
||||
if (_threadCount != coreCount)
|
||||
{
|
||||
_threadCount >>= 1;
|
||||
}
|
||||
|
||||
if (_threadCount > SOFTRASTERIZER_MAX_THREADS)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue