perf(vulkan): use double viewport math only when scale < 1

Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit is contained in:
Zephyron
2026-02-10 17:19:50 +10:00
parent 48fa6d0e03
commit 66ca68a52e

View File

@@ -67,13 +67,14 @@ struct DrawParams {
VkViewport GetViewportState(const Device& device, const Maxwell& regs, size_t index, float scale) { VkViewport GetViewportState(const Device& device, const Maxwell& regs, size_t index, float scale) {
const auto& src = regs.viewport_transform[index]; const auto& src = regs.viewport_transform[index];
const auto conv = [scale](float value) { const auto conv = [scale](float value) {
const double new_value = static_cast<double>(value) * static_cast<double>(scale); if (scale >= 1.0f) {
if (scale < 1.0f) { return value * scale;
const bool sign = std::signbit(value);
double rounded = std::round(std::abs(new_value));
return static_cast<float>(sign ? -rounded : rounded);
} }
return static_cast<float>(new_value); // Use double only when scaling down to avoid sub-pixel jitter (MP4 fix)
const double new_value = static_cast<double>(value) * static_cast<double>(scale);
const bool sign = std::signbit(value);
const double rounded = std::round(std::abs(new_value));
return static_cast<float>(sign ? -rounded : rounded);
}; };
const float x = conv(src.translate_x - src.scale_x); const float x = conv(src.translate_x - src.scale_x);
const float width = conv(src.scale_x * 2.0f); const float width = conv(src.scale_x * 2.0f);