diff options
| author | Léo Lam <leo@leolam.fr> | 2021-06-13 11:15:11 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-13 11:15:11 +0200 |
| commit | dd26106848e2cadb89f8dc3a1425b4b76b9a28b0 (patch) | |
| tree | 6879848ba5b120c15b82cfce900ba5c0f4faed0e /Source/Core/VideoCommon/PixelShaderGen.cpp | |
| parent | 38424d0c59b480d7a3301a5f61c03e99b685dc42 (diff) | |
| parent | 3da0976a8190211e43e285896bfb6dcd80dd7d50 (diff) | |
Merge pull request #9807 from Techjar/fix-glsl-any
VideoCommon: Define scalar any() and all() functions in GLSL
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/PixelShaderGen.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index 988e85b199..5b9b6fa411 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -372,6 +372,16 @@ 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"); |
