From 5e0520b6e032e13244105bcd4de27841581d18c1 Mon Sep 17 00:00:00 2001 From: Techjar Date: Tue, 20 Jul 2021 05:18:14 -0400 Subject: [PATCH] VideoCommon: Expand vector comparisons instead of overloading any() For whatever stupid reason, Mali drivers do not allow overloading built-in functions. --- Source/Core/VideoCommon/PixelShaderGen.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index a264843377..f6bc32fe4c 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -371,16 +371,6 @@ void WritePixelShaderCommonHeader(ShaderCode& out, APIType api_type, "int3 iround(float3 x) {{ return int3(round(x)); }}\n" "int4 iround(float4 x) {{ return int4(round(x)); }}\n\n"); - // GLSL's any() and all() only accept vector types, while HLSL's also accept scalar types. We're - // adding these for convenience because while vector comparisons return a bool scalar in GLSL, - // allowing the results to be used directly in an if statement, they return a bool vector in HLSL, - // necessitating the use of any() or all() to reduce it to a scalar. - if (api_type == APIType::OpenGL || api_type == APIType::Vulkan) - { - out.Write("bool any(bool b) {{ return b; }}\n" - "bool all(bool b) {{ return b; }}\n\n"); - } - if (api_type == APIType::OpenGL || api_type == APIType::Vulkan) { out.Write("SAMPLER_BINDING(0) uniform sampler2DArray samp[8];\n"); @@ -504,8 +494,11 @@ void UpdateBoundingBox(float2 rawpos) {{ // // For a more detailed explanation, see https://dolp.in/pr9801 int2 int_efb_scale = iround(1 / {efb_scale}.xy); - if (any(int2(rawpos) % int_efb_scale != int_efb_scale >> 1)) // divide by two + if (int(rawpos.x) % int_efb_scale.x != int_efb_scale.x >> 1 || + int(rawpos.y) % int_efb_scale.y != int_efb_scale.y >> 1) // right shift for fast divide by two + {{ return; + }} // The rightmost shaded pixel is not included in the right bounding box register, // such that width = right - left + 1. This has been verified on hardware.