Skip to content

Commit

Permalink
VideoCommon: Define scalar any() and all() functions in GLSL
Browse files Browse the repository at this point in the history
This fixes bounding box shaders failing to compile under Vulkan, due to
differences between GLSL and HLSL in the return value of vector
comparisons and what types these functions accept. I included all() for
the sake of completeness.
  • Loading branch information
Techjar committed Jun 12, 2021
1 parent 0c6e00c commit f278d92
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Source/Core/VideoCommon/PixelShaderGen.cpp
Expand Up @@ -372,6 +372,13 @@ 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
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");
Expand Down

0 comments on commit f278d92

Please sign in to comment.