GPU/HW: Don't allow adaptive downsampling at non-pow2 scales
This commit is contained in:
parent
2fbfd53d51
commit
defce709da
|
@ -36,4 +36,17 @@ constexpr bool IsPow2(T value)
|
||||||
{
|
{
|
||||||
return (value & (value - 1)) == 0;
|
return (value & (value - 1)) == 0;
|
||||||
}
|
}
|
||||||
|
template<typename T>
|
||||||
|
constexpr T PreviousPow2(T value)
|
||||||
|
{
|
||||||
|
if (value == static_cast<T>(0))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
value |= (value >> 1);
|
||||||
|
value |= (value >> 2);
|
||||||
|
value |= (value >> 4);
|
||||||
|
value |= (value >> 8);
|
||||||
|
value |= (value >> 16);
|
||||||
|
return value - (value >> 1);
|
||||||
|
}
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "gpu_hw.h"
|
#include "gpu_hw.h"
|
||||||
|
#include "common/align.h"
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/log.h"
|
#include "common/log.h"
|
||||||
#include "common/state_wrapper.h"
|
#include "common/state_wrapper.h"
|
||||||
|
@ -221,10 +222,21 @@ u32 GPU_HW::CalculateResolutionScale() const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_settings.gpu_downsample_mode == GPUDownsampleMode::Adaptive && m_supports_adaptive_downsampling && scale > 1 &&
|
if (g_settings.gpu_downsample_mode == GPUDownsampleMode::Adaptive && m_supports_adaptive_downsampling && scale > 1 &&
|
||||||
(scale % 2) != 0)
|
!Common::IsPow2(scale))
|
||||||
{
|
{
|
||||||
Log_InfoPrintf("Resolution scale %u not supported for adaptive smoothing, using %u", scale, (scale - 1));
|
const u32 new_scale = Common::PreviousPow2(scale);
|
||||||
scale--;
|
Log_InfoPrintf("Resolution scale %ux not supported for adaptive smoothing, using %ux", scale, new_scale);
|
||||||
|
|
||||||
|
if (g_settings.gpu_resolution_scale != 0)
|
||||||
|
{
|
||||||
|
g_host_interface->AddFormattedOSDMessage(
|
||||||
|
10.0f,
|
||||||
|
g_host_interface->TranslateString("OSDMessage",
|
||||||
|
"Resolution scale %ux not supported for adaptive smoothing, using %ux."),
|
||||||
|
scale, new_scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
scale = new_scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
return scale;
|
return scale;
|
||||||
|
|
Loading…
Reference in New Issue