From 366cac13cef9e89bf4a69bdd934061f929c1d9ee Mon Sep 17 00:00:00 2001 From: KOPRajs Date: Mon, 20 May 2024 16:00:24 +0200 Subject: [PATCH] Calculate separate POT (Power-Of-Two) texture width and height --- .../cores/RetroPlayer/shaders/ShaderUtils.cpp | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/xbmc/cores/RetroPlayer/shaders/ShaderUtils.cpp b/xbmc/cores/RetroPlayer/shaders/ShaderUtils.cpp index 763fa383e62de..7d73100e34ae4 100644 --- a/xbmc/cores/RetroPlayer/shaders/ShaderUtils.cpp +++ b/xbmc/cores/RetroPlayer/shaders/ShaderUtils.cpp @@ -13,15 +13,24 @@ using namespace SHADER; float2 CShaderUtils::GetOptimalTextureSize(float2 videoSize) { - unsigned sizeMax = videoSize.Max(); - unsigned size = 1; + unsigned textureWidth = 1; + unsigned textureHeight = 1; - // Find smallest possible power-of-two size that can contain input texture + // Find smallest possible power-of-two sized width that can contain the input texture while (true) { - if (size >= sizeMax) + if (textureWidth >= videoSize.x) break; - size *= 2; + textureWidth *= 2; } - return float2(size, size); + + // Find smallest possible power-of-two sized height that can contain the input texture + while (true) + { + if (textureHeight >= videoSize.y) + break; + textureHeight *= 2; + } + + return float2(textureWidth, textureHeight); }