diff --git a/3rdparty/spirv-cross/CMakeLists.txt b/3rdparty/spirv-cross/CMakeLists.txt index 79566a86c..9e51d222c 100644 --- a/3rdparty/spirv-cross/CMakeLists.txt +++ b/3rdparty/spirv-cross/CMakeLists.txt @@ -195,7 +195,7 @@ endif() if (SPIRV_CROSS_SHARED) set(spirv-cross-abi-major 0) - set(spirv-cross-abi-minor 2) + set(spirv-cross-abi-minor 3) set(spirv-cross-abi-patch 0) set(SPIRV_CROSS_VERSION ${spirv-cross-abi-major}.${spirv-cross-abi-minor}.${spirv-cross-abi-patch}) set(SPIRV_CROSS_INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib) diff --git a/3rdparty/spirv-cross/checkout_glslang_spirv_tools.sh b/3rdparty/spirv-cross/checkout_glslang_spirv_tools.sh index 2ccc6c89e..2ed5af3c5 100755 --- a/3rdparty/spirv-cross/checkout_glslang_spirv_tools.sh +++ b/3rdparty/spirv-cross/checkout_glslang_spirv_tools.sh @@ -1,8 +1,8 @@ #!/bin/bash -GLSLANG_REV=c9e03360e2a78a95a8571292aefa5ddbdbf66daf -SPIRV_TOOLS_REV=e2279da7148d19bd21c6d47ffc96ee4176f43dba -SPIRV_HEADERS_REV=8bea0a266ac9b718aa0818d9e3a47c0b77c2cb23 +GLSLANG_REV=a51d3d9f223361165127ded3cd2e59d81e22d91f +SPIRV_TOOLS_REV=bdcb155163d453fa67a03f59b4d5e00bd7c0f209 +SPIRV_HEADERS_REV=03a081524afabdde274d885880c2fef213e46a59 if [ -d external/glslang ]; then echo "Updating glslang to revision $GLSLANG_REV." diff --git a/3rdparty/spirv-cross/main.cpp b/3rdparty/spirv-cross/main.cpp index 9faa5a315..fdde8a3bb 100644 --- a/3rdparty/spirv-cross/main.cpp +++ b/3rdparty/spirv-cross/main.cpp @@ -496,6 +496,7 @@ struct CLIArguments bool msl_pad_fragment_output = false; bool msl_domain_lower_left = false; bool msl_argument_buffers = false; + bool glsl_emit_push_constant_as_ubo = false; vector msl_discrete_descriptor_sets; vector pls_in; vector pls_out; @@ -547,6 +548,7 @@ static void print_help() "\t[--iterations iter]\n" "\t[--cpp]\n" "\t[--cpp-interface-name ]\n" + "\t[--glsl-emit-push-constant-as-ubo]\n" "\t[--msl]\n" "\t[--msl-version ]\n" "\t[--msl-capture-output]\n" @@ -714,6 +716,7 @@ static int main_inner(int argc, char *argv[]) cbs.add("--reflect", [&args](CLIParser &parser) { args.reflect = parser.next_value_string("json"); }); cbs.add("--cpp-interface-name", [&args](CLIParser &parser) { args.cpp_interface_name = parser.next_string(); }); cbs.add("--metal", [&args](CLIParser &) { args.msl = true; }); // Legacy compatibility + cbs.add("--glsl-emit-push-constant-as-ubo", [&args](CLIParser &) { args.glsl_emit_push_constant_as_ubo = true; }); cbs.add("--msl", [&args](CLIParser &) { args.msl = true; }); cbs.add("--hlsl", [&args](CLIParser &) { args.hlsl = true; }); cbs.add("--hlsl-enable-compat", [&args](CLIParser &) { args.hlsl_compat = true; }); @@ -986,6 +989,7 @@ static int main_inner(int argc, char *argv[]) opts.vertex.fixup_clipspace = args.fixup; opts.vertex.flip_vert_y = args.yflip; opts.vertex.support_nonzero_base_instance = args.support_nonzero_baseinstance; + opts.emit_push_constant_as_uniform_buffer = args.glsl_emit_push_constant_as_ubo; compiler->set_common_options(opts); // Set HLSL specific options. diff --git a/3rdparty/spirv-cross/reference/opt/shaders-hlsl/asm/comp/nmin-max-clamp.asm.comp b/3rdparty/spirv-cross/reference/opt/shaders-hlsl/asm/comp/nmin-max-clamp.asm.comp new file mode 100644 index 000000000..7acd67d0b --- /dev/null +++ b/3rdparty/spirv-cross/reference/opt/shaders-hlsl/asm/comp/nmin-max-clamp.asm.comp @@ -0,0 +1,87 @@ +RWByteAddressBuffer _4 : register(u0); + +void comp_main() +{ + _4.Store(0, asuint(isnan(asfloat(_4.Load(96))) ? asfloat(_4.Load(48)) : (isnan(asfloat(_4.Load(48))) ? asfloat(_4.Load(96)) : min(asfloat(_4.Load(48)), asfloat(_4.Load(96)))))); + bool2 _146 = isnan(asfloat(_4.Load2(56))); + bool2 _147 = isnan(asfloat(_4.Load2(104))); + float2 _148 = min(asfloat(_4.Load2(56)), asfloat(_4.Load2(104))); + float2 _149 = float2(_146.x ? asfloat(_4.Load2(104)).x : _148.x, _146.y ? asfloat(_4.Load2(104)).y : _148.y); + _4.Store2(8, asuint(float2(_147.x ? asfloat(_4.Load2(56)).x : _149.x, _147.y ? asfloat(_4.Load2(56)).y : _149.y))); + bool3 _151 = isnan(asfloat(_4.Load3(64))); + bool3 _152 = isnan(asfloat(_4.Load3(112))); + float3 _153 = min(asfloat(_4.Load3(64)), asfloat(_4.Load3(112))); + float3 _154 = float3(_151.x ? asfloat(_4.Load3(112)).x : _153.x, _151.y ? asfloat(_4.Load3(112)).y : _153.y, _151.z ? asfloat(_4.Load3(112)).z : _153.z); + _4.Store3(16, asuint(float3(_152.x ? asfloat(_4.Load3(64)).x : _154.x, _152.y ? asfloat(_4.Load3(64)).y : _154.y, _152.z ? asfloat(_4.Load3(64)).z : _154.z))); + bool4 _156 = isnan(asfloat(_4.Load4(80))); + bool4 _157 = isnan(asfloat(_4.Load4(128))); + float4 _158 = min(asfloat(_4.Load4(80)), asfloat(_4.Load4(128))); + float4 _159 = float4(_156.x ? asfloat(_4.Load4(128)).x : _158.x, _156.y ? asfloat(_4.Load4(128)).y : _158.y, _156.z ? asfloat(_4.Load4(128)).z : _158.z, _156.w ? asfloat(_4.Load4(128)).w : _158.w); + _4.Store4(32, asuint(float4(_157.x ? asfloat(_4.Load4(80)).x : _159.x, _157.y ? asfloat(_4.Load4(80)).y : _159.y, _157.z ? asfloat(_4.Load4(80)).z : _159.z, _157.w ? asfloat(_4.Load4(80)).w : _159.w))); + _4.Store(0, asuint(isnan(asfloat(_4.Load(96))) ? asfloat(_4.Load(48)) : (isnan(asfloat(_4.Load(48))) ? asfloat(_4.Load(96)) : max(asfloat(_4.Load(48)), asfloat(_4.Load(96)))))); + bool2 _166 = isnan(asfloat(_4.Load2(56))); + bool2 _167 = isnan(asfloat(_4.Load2(104))); + float2 _168 = max(asfloat(_4.Load2(56)), asfloat(_4.Load2(104))); + float2 _169 = float2(_166.x ? asfloat(_4.Load2(104)).x : _168.x, _166.y ? asfloat(_4.Load2(104)).y : _168.y); + _4.Store2(8, asuint(float2(_167.x ? asfloat(_4.Load2(56)).x : _169.x, _167.y ? asfloat(_4.Load2(56)).y : _169.y))); + bool3 _171 = isnan(asfloat(_4.Load3(64))); + bool3 _172 = isnan(asfloat(_4.Load3(112))); + float3 _173 = max(asfloat(_4.Load3(64)), asfloat(_4.Load3(112))); + float3 _174 = float3(_171.x ? asfloat(_4.Load3(112)).x : _173.x, _171.y ? asfloat(_4.Load3(112)).y : _173.y, _171.z ? asfloat(_4.Load3(112)).z : _173.z); + _4.Store3(16, asuint(float3(_172.x ? asfloat(_4.Load3(64)).x : _174.x, _172.y ? asfloat(_4.Load3(64)).y : _174.y, _172.z ? asfloat(_4.Load3(64)).z : _174.z))); + bool4 _176 = isnan(asfloat(_4.Load4(80))); + bool4 _177 = isnan(asfloat(_4.Load4(128))); + float4 _178 = max(asfloat(_4.Load4(80)), asfloat(_4.Load4(128))); + float4 _179 = float4(_176.x ? asfloat(_4.Load4(128)).x : _178.x, _176.y ? asfloat(_4.Load4(128)).y : _178.y, _176.z ? asfloat(_4.Load4(128)).z : _178.z, _176.w ? asfloat(_4.Load4(128)).w : _178.w); + _4.Store4(32, asuint(float4(_177.x ? asfloat(_4.Load4(80)).x : _179.x, _177.y ? asfloat(_4.Load4(80)).y : _179.y, _177.z ? asfloat(_4.Load4(80)).z : _179.z, _177.w ? asfloat(_4.Load4(80)).w : _179.w))); + float _180 = isnan(asfloat(_4.Load(48))) ? asfloat(_4.Load(0)) : (isnan(asfloat(_4.Load(0))) ? asfloat(_4.Load(48)) : max(asfloat(_4.Load(0)), asfloat(_4.Load(48)))); + _4.Store(0, asuint(isnan(asfloat(_4.Load(96))) ? _180 : (isnan(_180) ? asfloat(_4.Load(96)) : min(_180, asfloat(_4.Load(96)))))); + bool2 _193 = isnan(asfloat(_4.Load2(8))); + bool2 _194 = isnan(asfloat(_4.Load2(56))); + float2 _195 = max(asfloat(_4.Load2(8)), asfloat(_4.Load2(56))); + float2 _196 = float2(_193.x ? asfloat(_4.Load2(56)).x : _195.x, _193.y ? asfloat(_4.Load2(56)).y : _195.y); + float2 _191 = float2(_194.x ? asfloat(_4.Load2(8)).x : _196.x, _194.y ? asfloat(_4.Load2(8)).y : _196.y); + bool2 _198 = isnan(_191); + bool2 _199 = isnan(asfloat(_4.Load2(104))); + float2 _200 = min(_191, asfloat(_4.Load2(104))); + float2 _201 = float2(_198.x ? asfloat(_4.Load2(104)).x : _200.x, _198.y ? asfloat(_4.Load2(104)).y : _200.y); + _4.Store2(8, asuint(float2(_199.x ? _191.x : _201.x, _199.y ? _191.y : _201.y))); + bool3 _204 = isnan(asfloat(_4.Load3(16))); + bool3 _205 = isnan(asfloat(_4.Load3(64))); + float3 _206 = max(asfloat(_4.Load3(16)), asfloat(_4.Load3(64))); + float3 _207 = float3(_204.x ? asfloat(_4.Load3(64)).x : _206.x, _204.y ? asfloat(_4.Load3(64)).y : _206.y, _204.z ? asfloat(_4.Load3(64)).z : _206.z); + float3 _202 = float3(_205.x ? asfloat(_4.Load3(16)).x : _207.x, _205.y ? asfloat(_4.Load3(16)).y : _207.y, _205.z ? asfloat(_4.Load3(16)).z : _207.z); + bool3 _209 = isnan(_202); + bool3 _210 = isnan(asfloat(_4.Load3(112))); + float3 _211 = min(_202, asfloat(_4.Load3(112))); + float3 _212 = float3(_209.x ? asfloat(_4.Load3(112)).x : _211.x, _209.y ? asfloat(_4.Load3(112)).y : _211.y, _209.z ? asfloat(_4.Load3(112)).z : _211.z); + _4.Store3(16, asuint(float3(_210.x ? _202.x : _212.x, _210.y ? _202.y : _212.y, _210.z ? _202.z : _212.z))); + bool4 _215 = isnan(asfloat(_4.Load4(32))); + bool4 _216 = isnan(asfloat(_4.Load4(80))); + float4 _217 = max(asfloat(_4.Load4(32)), asfloat(_4.Load4(80))); + float4 _218 = float4(_215.x ? asfloat(_4.Load4(80)).x : _217.x, _215.y ? asfloat(_4.Load4(80)).y : _217.y, _215.z ? asfloat(_4.Load4(80)).z : _217.z, _215.w ? asfloat(_4.Load4(80)).w : _217.w); + float4 _213 = float4(_216.x ? asfloat(_4.Load4(32)).x : _218.x, _216.y ? asfloat(_4.Load4(32)).y : _218.y, _216.z ? asfloat(_4.Load4(32)).z : _218.z, _216.w ? asfloat(_4.Load4(32)).w : _218.w); + bool4 _220 = isnan(_213); + bool4 _221 = isnan(asfloat(_4.Load4(128))); + float4 _222 = min(_213, asfloat(_4.Load4(128))); + float4 _223 = float4(_220.x ? asfloat(_4.Load4(128)).x : _222.x, _220.y ? asfloat(_4.Load4(128)).y : _222.y, _220.z ? asfloat(_4.Load4(128)).z : _222.z, _220.w ? asfloat(_4.Load4(128)).w : _222.w); + _4.Store4(32, asuint(float4(_221.x ? _213.x : _223.x, _221.y ? _213.y : _223.y, _221.z ? _213.z : _223.z, _221.w ? _213.w : _223.w))); + for (int _139 = 0; _139 < 2; ) + { + bool2 _225 = isnan(asfloat(_4.Load2(56))); + bool2 _226 = isnan(asfloat(_4.Load2(104))); + float2 _227 = min(asfloat(_4.Load2(56)), asfloat(_4.Load2(104))); + float2 _228 = float2(_225.x ? asfloat(_4.Load2(104)).x : _227.x, _225.y ? asfloat(_4.Load2(104)).y : _227.y); + _4.Store2(8, asuint(float2(_226.x ? asfloat(_4.Load2(56)).x : _228.x, _226.y ? asfloat(_4.Load2(56)).y : _228.y))); + float _229 = isnan(asfloat(_4.Load(56))) ? asfloat(_4.Load(0)) : (isnan(asfloat(_4.Load(0))) ? asfloat(_4.Load(56)) : max(asfloat(_4.Load(0)), asfloat(_4.Load(56)))); + _4.Store(0, asuint(isnan(asfloat(_4.Load(60))) ? _229 : (isnan(_229) ? asfloat(_4.Load(60)) : min(_229, asfloat(_4.Load(60)))))); + _139++; + continue; + } +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/3rdparty/spirv-cross/reference/opt/shaders/asm/comp/nmin-max-clamp.asm.comp b/3rdparty/spirv-cross/reference/opt/shaders/asm/comp/nmin-max-clamp.asm.comp new file mode 100644 index 000000000..5ef1bc91a --- /dev/null +++ b/3rdparty/spirv-cross/reference/opt/shaders/asm/comp/nmin-max-clamp.asm.comp @@ -0,0 +1,47 @@ +#version 450 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer SSBO +{ + float a1; + vec2 a2; + vec3 a3; + vec4 a4; + float b1; + vec2 b2; + vec3 b3; + vec4 b4; + float c1; + vec2 c2; + vec3 c3; + vec4 c4; +} _4; + +void main() +{ + _4.a1 = isnan(_4.c1) ? _4.b1 : (isnan(_4.b1) ? _4.c1 : min(_4.b1, _4.c1)); + _4.a2 = mix(mix(min(_4.b2, _4.c2), _4.c2, isnan(_4.b2)), _4.b2, isnan(_4.c2)); + _4.a3 = mix(mix(min(_4.b3, _4.c3), _4.c3, isnan(_4.b3)), _4.b3, isnan(_4.c3)); + _4.a4 = mix(mix(min(_4.b4, _4.c4), _4.c4, isnan(_4.b4)), _4.b4, isnan(_4.c4)); + _4.a1 = isnan(_4.c1) ? _4.b1 : (isnan(_4.b1) ? _4.c1 : max(_4.b1, _4.c1)); + _4.a2 = mix(mix(max(_4.b2, _4.c2), _4.c2, isnan(_4.b2)), _4.b2, isnan(_4.c2)); + _4.a3 = mix(mix(max(_4.b3, _4.c3), _4.c3, isnan(_4.b3)), _4.b3, isnan(_4.c3)); + _4.a4 = mix(mix(max(_4.b4, _4.c4), _4.c4, isnan(_4.b4)), _4.b4, isnan(_4.c4)); + float _180 = isnan(_4.b1) ? _4.a1 : (isnan(_4.a1) ? _4.b1 : max(_4.a1, _4.b1)); + _4.a1 = isnan(_4.c1) ? _180 : (isnan(_180) ? _4.c1 : min(_180, _4.c1)); + vec2 _191 = mix(mix(max(_4.a2, _4.b2), _4.b2, isnan(_4.a2)), _4.a2, isnan(_4.b2)); + _4.a2 = mix(mix(min(_191, _4.c2), _4.c2, isnan(_191)), _191, isnan(_4.c2)); + vec3 _202 = mix(mix(max(_4.a3, _4.b3), _4.b3, isnan(_4.a3)), _4.a3, isnan(_4.b3)); + _4.a3 = mix(mix(min(_202, _4.c3), _4.c3, isnan(_202)), _202, isnan(_4.c3)); + vec4 _213 = mix(mix(max(_4.a4, _4.b4), _4.b4, isnan(_4.a4)), _4.a4, isnan(_4.b4)); + _4.a4 = mix(mix(min(_213, _4.c4), _4.c4, isnan(_213)), _213, isnan(_4.c4)); + for (int _139 = 0; _139 < 2; ) + { + _4.a2 = mix(mix(min(_4.b2, _4.c2), _4.c2, isnan(_4.b2)), _4.b2, isnan(_4.c2)); + float _229 = isnan(_4.b2.x) ? _4.a1 : (isnan(_4.a1) ? _4.b2.x : max(_4.a1, _4.b2.x)); + _4.a1 = isnan(_4.b2.y) ? _229 : (isnan(_229) ? _4.b2.y : min(_229, _4.b2.y)); + _139++; + continue; + } +} + diff --git a/3rdparty/spirv-cross/reference/opt/shaders/asm/geom/unroll-glposition-load.asm.geom b/3rdparty/spirv-cross/reference/opt/shaders/asm/geom/unroll-glposition-load.asm.geom new file mode 100644 index 000000000..d1f8963fa --- /dev/null +++ b/3rdparty/spirv-cross/reference/opt/shaders/asm/geom/unroll-glposition-load.asm.geom @@ -0,0 +1,22 @@ +#version 450 +layout(triangles) in; +layout(max_vertices = 3, triangle_strip) out; + +void main() +{ + vec4 _35_unrolled[3]; + for (int i = 0; i < int(3); i++) + { + _35_unrolled[i] = gl_in[i].gl_Position; + } + vec4 param[3] = _35_unrolled; + for (int _73 = 0; _73 < 3; ) + { + gl_Position = param[_73]; + EmitVertex(); + _73++; + continue; + } + EndPrimitive(); +} + diff --git a/3rdparty/spirv-cross/reference/opt/shaders/asm/tese/unroll-input-array-load.asm.tese b/3rdparty/spirv-cross/reference/opt/shaders/asm/tese/unroll-input-array-load.asm.tese new file mode 100644 index 000000000..731ed3fab --- /dev/null +++ b/3rdparty/spirv-cross/reference/opt/shaders/asm/tese/unroll-input-array-load.asm.tese @@ -0,0 +1,17 @@ +#version 450 +layout(quads) in; + +struct ControlPoint +{ + vec4 baz; +}; + +layout(location = 0) patch in vec4 input_foo; +layout(location = 1) patch in vec4 input_bar; +layout(location = 2) in ControlPoint CPData[]; + +void main() +{ + gl_Position = (((input_foo + input_bar) + vec2(gl_TessCoord.xy).xyxy) + CPData[0u].baz) + CPData[3u].baz; +} + diff --git a/3rdparty/spirv-cross/reference/opt/shaders/vulkan/frag/push-constant-as-ubo.push-ubo.vk.frag b/3rdparty/spirv-cross/reference/opt/shaders/vulkan/frag/push-constant-as-ubo.push-ubo.vk.frag new file mode 100644 index 000000000..21618f888 --- /dev/null +++ b/3rdparty/spirv-cross/reference/opt/shaders/vulkan/frag/push-constant-as-ubo.push-ubo.vk.frag @@ -0,0 +1,14 @@ +#version 450 + +layout(std140) uniform UBO +{ + float ubo[4]; +} _14; + +layout(location = 0) out float FragColor; + +void main() +{ + FragColor = _14.ubo[1]; +} + diff --git a/3rdparty/spirv-cross/reference/opt/shaders/vulkan/frag/push-constant-as-ubo.push-ubo.vk.frag.vk b/3rdparty/spirv-cross/reference/opt/shaders/vulkan/frag/push-constant-as-ubo.push-ubo.vk.frag.vk new file mode 100644 index 000000000..8ca4f23ac --- /dev/null +++ b/3rdparty/spirv-cross/reference/opt/shaders/vulkan/frag/push-constant-as-ubo.push-ubo.vk.frag.vk @@ -0,0 +1,14 @@ +#version 450 + +layout(push_constant, std140) uniform UBO +{ + float ubo[4]; +} _14; + +layout(location = 0) out float FragColor; + +void main() +{ + FragColor = _14.ubo[1]; +} + diff --git a/3rdparty/spirv-cross/reference/shaders-hlsl/asm/comp/nmin-max-clamp.asm.comp b/3rdparty/spirv-cross/reference/shaders-hlsl/asm/comp/nmin-max-clamp.asm.comp new file mode 100644 index 000000000..a6e88684f --- /dev/null +++ b/3rdparty/spirv-cross/reference/shaders-hlsl/asm/comp/nmin-max-clamp.asm.comp @@ -0,0 +1,84 @@ +RWByteAddressBuffer _4 : register(u0); + +void comp_main() +{ + _4.Store(0, asuint(isnan(asfloat(_4.Load(96))) ? asfloat(_4.Load(48)) : (isnan(asfloat(_4.Load(48))) ? asfloat(_4.Load(96)) : min(asfloat(_4.Load(48)), asfloat(_4.Load(96)))))); + bool2 _145 = isnan(asfloat(_4.Load2(56))); + bool2 _146 = isnan(asfloat(_4.Load2(104))); + float2 _147 = min(asfloat(_4.Load2(56)), asfloat(_4.Load2(104))); + float2 _148 = float2(_145.x ? asfloat(_4.Load2(104)).x : _147.x, _145.y ? asfloat(_4.Load2(104)).y : _147.y); + _4.Store2(8, asuint(float2(_146.x ? asfloat(_4.Load2(56)).x : _148.x, _146.y ? asfloat(_4.Load2(56)).y : _148.y))); + bool3 _150 = isnan(asfloat(_4.Load3(64))); + bool3 _151 = isnan(asfloat(_4.Load3(112))); + float3 _152 = min(asfloat(_4.Load3(64)), asfloat(_4.Load3(112))); + float3 _153 = float3(_150.x ? asfloat(_4.Load3(112)).x : _152.x, _150.y ? asfloat(_4.Load3(112)).y : _152.y, _150.z ? asfloat(_4.Load3(112)).z : _152.z); + _4.Store3(16, asuint(float3(_151.x ? asfloat(_4.Load3(64)).x : _153.x, _151.y ? asfloat(_4.Load3(64)).y : _153.y, _151.z ? asfloat(_4.Load3(64)).z : _153.z))); + bool4 _155 = isnan(asfloat(_4.Load4(80))); + bool4 _156 = isnan(asfloat(_4.Load4(128))); + float4 _157 = min(asfloat(_4.Load4(80)), asfloat(_4.Load4(128))); + float4 _158 = float4(_155.x ? asfloat(_4.Load4(128)).x : _157.x, _155.y ? asfloat(_4.Load4(128)).y : _157.y, _155.z ? asfloat(_4.Load4(128)).z : _157.z, _155.w ? asfloat(_4.Load4(128)).w : _157.w); + _4.Store4(32, asuint(float4(_156.x ? asfloat(_4.Load4(80)).x : _158.x, _156.y ? asfloat(_4.Load4(80)).y : _158.y, _156.z ? asfloat(_4.Load4(80)).z : _158.z, _156.w ? asfloat(_4.Load4(80)).w : _158.w))); + _4.Store(0, asuint(isnan(asfloat(_4.Load(96))) ? asfloat(_4.Load(48)) : (isnan(asfloat(_4.Load(48))) ? asfloat(_4.Load(96)) : max(asfloat(_4.Load(48)), asfloat(_4.Load(96)))))); + bool2 _165 = isnan(asfloat(_4.Load2(56))); + bool2 _166 = isnan(asfloat(_4.Load2(104))); + float2 _167 = max(asfloat(_4.Load2(56)), asfloat(_4.Load2(104))); + float2 _168 = float2(_165.x ? asfloat(_4.Load2(104)).x : _167.x, _165.y ? asfloat(_4.Load2(104)).y : _167.y); + _4.Store2(8, asuint(float2(_166.x ? asfloat(_4.Load2(56)).x : _168.x, _166.y ? asfloat(_4.Load2(56)).y : _168.y))); + bool3 _170 = isnan(asfloat(_4.Load3(64))); + bool3 _171 = isnan(asfloat(_4.Load3(112))); + float3 _172 = max(asfloat(_4.Load3(64)), asfloat(_4.Load3(112))); + float3 _173 = float3(_170.x ? asfloat(_4.Load3(112)).x : _172.x, _170.y ? asfloat(_4.Load3(112)).y : _172.y, _170.z ? asfloat(_4.Load3(112)).z : _172.z); + _4.Store3(16, asuint(float3(_171.x ? asfloat(_4.Load3(64)).x : _173.x, _171.y ? asfloat(_4.Load3(64)).y : _173.y, _171.z ? asfloat(_4.Load3(64)).z : _173.z))); + bool4 _175 = isnan(asfloat(_4.Load4(80))); + bool4 _176 = isnan(asfloat(_4.Load4(128))); + float4 _177 = max(asfloat(_4.Load4(80)), asfloat(_4.Load4(128))); + float4 _178 = float4(_175.x ? asfloat(_4.Load4(128)).x : _177.x, _175.y ? asfloat(_4.Load4(128)).y : _177.y, _175.z ? asfloat(_4.Load4(128)).z : _177.z, _175.w ? asfloat(_4.Load4(128)).w : _177.w); + _4.Store4(32, asuint(float4(_176.x ? asfloat(_4.Load4(80)).x : _178.x, _176.y ? asfloat(_4.Load4(80)).y : _178.y, _176.z ? asfloat(_4.Load4(80)).z : _178.z, _176.w ? asfloat(_4.Load4(80)).w : _178.w))); + float _179 = isnan(asfloat(_4.Load(48))) ? asfloat(_4.Load(0)) : (isnan(asfloat(_4.Load(0))) ? asfloat(_4.Load(48)) : max(asfloat(_4.Load(0)), asfloat(_4.Load(48)))); + _4.Store(0, asuint(isnan(asfloat(_4.Load(96))) ? _179 : (isnan(_179) ? asfloat(_4.Load(96)) : min(_179, asfloat(_4.Load(96)))))); + bool2 _192 = isnan(asfloat(_4.Load2(8))); + bool2 _193 = isnan(asfloat(_4.Load2(56))); + float2 _194 = max(asfloat(_4.Load2(8)), asfloat(_4.Load2(56))); + float2 _195 = float2(_192.x ? asfloat(_4.Load2(56)).x : _194.x, _192.y ? asfloat(_4.Load2(56)).y : _194.y); + float2 _190 = float2(_193.x ? asfloat(_4.Load2(8)).x : _195.x, _193.y ? asfloat(_4.Load2(8)).y : _195.y); + bool2 _197 = isnan(_190); + bool2 _198 = isnan(asfloat(_4.Load2(104))); + float2 _199 = min(_190, asfloat(_4.Load2(104))); + float2 _200 = float2(_197.x ? asfloat(_4.Load2(104)).x : _199.x, _197.y ? asfloat(_4.Load2(104)).y : _199.y); + _4.Store2(8, asuint(float2(_198.x ? _190.x : _200.x, _198.y ? _190.y : _200.y))); + bool3 _203 = isnan(asfloat(_4.Load3(16))); + bool3 _204 = isnan(asfloat(_4.Load3(64))); + float3 _205 = max(asfloat(_4.Load3(16)), asfloat(_4.Load3(64))); + float3 _206 = float3(_203.x ? asfloat(_4.Load3(64)).x : _205.x, _203.y ? asfloat(_4.Load3(64)).y : _205.y, _203.z ? asfloat(_4.Load3(64)).z : _205.z); + float3 _201 = float3(_204.x ? asfloat(_4.Load3(16)).x : _206.x, _204.y ? asfloat(_4.Load3(16)).y : _206.y, _204.z ? asfloat(_4.Load3(16)).z : _206.z); + bool3 _208 = isnan(_201); + bool3 _209 = isnan(asfloat(_4.Load3(112))); + float3 _210 = min(_201, asfloat(_4.Load3(112))); + float3 _211 = float3(_208.x ? asfloat(_4.Load3(112)).x : _210.x, _208.y ? asfloat(_4.Load3(112)).y : _210.y, _208.z ? asfloat(_4.Load3(112)).z : _210.z); + _4.Store3(16, asuint(float3(_209.x ? _201.x : _211.x, _209.y ? _201.y : _211.y, _209.z ? _201.z : _211.z))); + bool4 _214 = isnan(asfloat(_4.Load4(32))); + bool4 _215 = isnan(asfloat(_4.Load4(80))); + float4 _216 = max(asfloat(_4.Load4(32)), asfloat(_4.Load4(80))); + float4 _217 = float4(_214.x ? asfloat(_4.Load4(80)).x : _216.x, _214.y ? asfloat(_4.Load4(80)).y : _216.y, _214.z ? asfloat(_4.Load4(80)).z : _216.z, _214.w ? asfloat(_4.Load4(80)).w : _216.w); + float4 _212 = float4(_215.x ? asfloat(_4.Load4(32)).x : _217.x, _215.y ? asfloat(_4.Load4(32)).y : _217.y, _215.z ? asfloat(_4.Load4(32)).z : _217.z, _215.w ? asfloat(_4.Load4(32)).w : _217.w); + bool4 _219 = isnan(_212); + bool4 _220 = isnan(asfloat(_4.Load4(128))); + float4 _221 = min(_212, asfloat(_4.Load4(128))); + float4 _222 = float4(_219.x ? asfloat(_4.Load4(128)).x : _221.x, _219.y ? asfloat(_4.Load4(128)).y : _221.y, _219.z ? asfloat(_4.Load4(128)).z : _221.z, _219.w ? asfloat(_4.Load4(128)).w : _221.w); + _4.Store4(32, asuint(float4(_220.x ? _212.x : _222.x, _220.y ? _212.y : _222.y, _220.z ? _212.z : _222.z, _220.w ? _212.w : _222.w))); + float _223; + for (int i = 0; i < 2; i++, _223 = isnan(asfloat(_4.Load(56))) ? asfloat(_4.Load(0)) : (isnan(asfloat(_4.Load(0))) ? asfloat(_4.Load(56)) : max(asfloat(_4.Load(0)), asfloat(_4.Load(56)))), _4.Store(0, asuint(isnan(asfloat(_4.Load(60))) ? _223 : (isnan(_223) ? asfloat(_4.Load(60)) : min(_223, asfloat(_4.Load(60))))))) + { + bool2 _235 = isnan(asfloat(_4.Load2(56))); + bool2 _236 = isnan(asfloat(_4.Load2(104))); + float2 _237 = min(asfloat(_4.Load2(56)), asfloat(_4.Load2(104))); + float2 _238 = float2(_235.x ? asfloat(_4.Load2(104)).x : _237.x, _235.y ? asfloat(_4.Load2(104)).y : _237.y); + _4.Store2(8, asuint(float2(_236.x ? asfloat(_4.Load2(56)).x : _238.x, _236.y ? asfloat(_4.Load2(56)).y : _238.y))); + } +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/3rdparty/spirv-cross/reference/shaders/asm/comp/nmin-max-clamp.asm.comp b/3rdparty/spirv-cross/reference/shaders/asm/comp/nmin-max-clamp.asm.comp new file mode 100644 index 000000000..54c452c5d --- /dev/null +++ b/3rdparty/spirv-cross/reference/shaders/asm/comp/nmin-max-clamp.asm.comp @@ -0,0 +1,44 @@ +#version 450 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer SSBO +{ + float a1; + vec2 a2; + vec3 a3; + vec4 a4; + float b1; + vec2 b2; + vec3 b3; + vec4 b4; + float c1; + vec2 c2; + vec3 c3; + vec4 c4; +} _4; + +void main() +{ + _4.a1 = isnan(_4.c1) ? _4.b1 : (isnan(_4.b1) ? _4.c1 : min(_4.b1, _4.c1)); + _4.a2 = mix(mix(min(_4.b2, _4.c2), _4.c2, isnan(_4.b2)), _4.b2, isnan(_4.c2)); + _4.a3 = mix(mix(min(_4.b3, _4.c3), _4.c3, isnan(_4.b3)), _4.b3, isnan(_4.c3)); + _4.a4 = mix(mix(min(_4.b4, _4.c4), _4.c4, isnan(_4.b4)), _4.b4, isnan(_4.c4)); + _4.a1 = isnan(_4.c1) ? _4.b1 : (isnan(_4.b1) ? _4.c1 : max(_4.b1, _4.c1)); + _4.a2 = mix(mix(max(_4.b2, _4.c2), _4.c2, isnan(_4.b2)), _4.b2, isnan(_4.c2)); + _4.a3 = mix(mix(max(_4.b3, _4.c3), _4.c3, isnan(_4.b3)), _4.b3, isnan(_4.c3)); + _4.a4 = mix(mix(max(_4.b4, _4.c4), _4.c4, isnan(_4.b4)), _4.b4, isnan(_4.c4)); + float _179 = isnan(_4.b1) ? _4.a1 : (isnan(_4.a1) ? _4.b1 : max(_4.a1, _4.b1)); + _4.a1 = isnan(_4.c1) ? _179 : (isnan(_179) ? _4.c1 : min(_179, _4.c1)); + vec2 _190 = mix(mix(max(_4.a2, _4.b2), _4.b2, isnan(_4.a2)), _4.a2, isnan(_4.b2)); + _4.a2 = mix(mix(min(_190, _4.c2), _4.c2, isnan(_190)), _190, isnan(_4.c2)); + vec3 _201 = mix(mix(max(_4.a3, _4.b3), _4.b3, isnan(_4.a3)), _4.a3, isnan(_4.b3)); + _4.a3 = mix(mix(min(_201, _4.c3), _4.c3, isnan(_201)), _201, isnan(_4.c3)); + vec4 _212 = mix(mix(max(_4.a4, _4.b4), _4.b4, isnan(_4.a4)), _4.a4, isnan(_4.b4)); + _4.a4 = mix(mix(min(_212, _4.c4), _4.c4, isnan(_212)), _212, isnan(_4.c4)); + float _223; + for (int i = 0; i < 2; i++, _223 = isnan(_4.b2.x) ? _4.a1 : (isnan(_4.a1) ? _4.b2.x : max(_4.a1, _4.b2.x)), _4.a1 = isnan(_4.b2.y) ? _223 : (isnan(_223) ? _4.b2.y : min(_223, _4.b2.y))) + { + _4.a2 = mix(mix(min(_4.b2, _4.c2), _4.c2, isnan(_4.b2)), _4.b2, isnan(_4.c2)); + } +} + diff --git a/3rdparty/spirv-cross/reference/shaders/asm/geom/unroll-glposition-load.asm.geom b/3rdparty/spirv-cross/reference/shaders/asm/geom/unroll-glposition-load.asm.geom new file mode 100644 index 000000000..de437fae6 --- /dev/null +++ b/3rdparty/spirv-cross/reference/shaders/asm/geom/unroll-glposition-load.asm.geom @@ -0,0 +1,35 @@ +#version 450 +layout(triangles) in; +layout(max_vertices = 3, triangle_strip) out; + +struct SceneOut +{ + vec4 pos; +}; + +void _main(vec4 positions[3], SceneOut OUT) +{ + for (int i = 0; i < 3; i++) + { + SceneOut o; + o.pos = positions[i]; + gl_Position = o.pos; + EmitVertex(); + } + EndPrimitive(); +} + +void main() +{ + vec4 _35_unrolled[3]; + for (int i = 0; i < int(3); i++) + { + _35_unrolled[i] = gl_in[i].gl_Position; + } + vec4 positions[3] = _35_unrolled; + vec4 param[3] = positions; + SceneOut param_1; + _main(param, param_1); + SceneOut OUT = param_1; +} + diff --git a/3rdparty/spirv-cross/reference/shaders/asm/tese/unroll-input-array-load.asm.tese b/3rdparty/spirv-cross/reference/shaders/asm/tese/unroll-input-array-load.asm.tese new file mode 100644 index 000000000..34970b82e --- /dev/null +++ b/3rdparty/spirv-cross/reference/shaders/asm/tese/unroll-input-array-load.asm.tese @@ -0,0 +1,48 @@ +#version 450 +layout(quads) in; + +struct HS_INPUT +{ + vec4 foo; + vec4 bar; +}; + +struct ControlPoint +{ + vec4 baz; +}; + +struct DS_OUTPUT +{ + vec4 pos; +}; + +layout(location = 0) patch in vec4 input_foo; +layout(location = 1) patch in vec4 input_bar; +layout(location = 2) in ControlPoint CPData[]; + +DS_OUTPUT _main(HS_INPUT _input, vec2 uv, ControlPoint CPData_1[4]) +{ + DS_OUTPUT o; + o.pos = (((_input.foo + _input.bar) + uv.xyxy) + CPData_1[0].baz) + CPData_1[3].baz; + return o; +} + +void main() +{ + HS_INPUT _input; + _input.foo = input_foo; + _input.bar = input_bar; + vec2 uv = vec2(gl_TessCoord.xy); + ControlPoint _54_unrolled[4]; + for (int i = 0; i < int(4); i++) + { + _54_unrolled[i] = CPData[i]; + } + ControlPoint CPData_1[4] = _54_unrolled; + HS_INPUT param = _input; + vec2 param_1 = uv; + ControlPoint param_2[4] = CPData_1; + gl_Position = _main(param, param_1, param_2).pos; +} + diff --git a/3rdparty/spirv-cross/reference/shaders/vulkan/frag/push-constant-as-ubo.push-ubo.vk.frag b/3rdparty/spirv-cross/reference/shaders/vulkan/frag/push-constant-as-ubo.push-ubo.vk.frag new file mode 100644 index 000000000..21618f888 --- /dev/null +++ b/3rdparty/spirv-cross/reference/shaders/vulkan/frag/push-constant-as-ubo.push-ubo.vk.frag @@ -0,0 +1,14 @@ +#version 450 + +layout(std140) uniform UBO +{ + float ubo[4]; +} _14; + +layout(location = 0) out float FragColor; + +void main() +{ + FragColor = _14.ubo[1]; +} + diff --git a/3rdparty/spirv-cross/reference/shaders/vulkan/frag/push-constant-as-ubo.push-ubo.vk.frag.vk b/3rdparty/spirv-cross/reference/shaders/vulkan/frag/push-constant-as-ubo.push-ubo.vk.frag.vk new file mode 100644 index 000000000..8ca4f23ac --- /dev/null +++ b/3rdparty/spirv-cross/reference/shaders/vulkan/frag/push-constant-as-ubo.push-ubo.vk.frag.vk @@ -0,0 +1,14 @@ +#version 450 + +layout(push_constant, std140) uniform UBO +{ + float ubo[4]; +} _14; + +layout(location = 0) out float FragColor; + +void main() +{ + FragColor = _14.ubo[1]; +} + diff --git a/3rdparty/spirv-cross/shaders-hlsl/asm/comp/nmin-max-clamp.asm.comp b/3rdparty/spirv-cross/shaders-hlsl/asm/comp/nmin-max-clamp.asm.comp new file mode 100644 index 000000000..6c060eeda --- /dev/null +++ b/3rdparty/spirv-cross/shaders-hlsl/asm/comp/nmin-max-clamp.asm.comp @@ -0,0 +1,203 @@ +; SPIR-V +; Version: 1.3 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 139 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 450 + OpName %main "main" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "a1" + OpMemberName %SSBO 1 "a2" + OpMemberName %SSBO 2 "a3" + OpMemberName %SSBO 3 "a4" + OpMemberName %SSBO 4 "b1" + OpMemberName %SSBO 5 "b2" + OpMemberName %SSBO 6 "b3" + OpMemberName %SSBO 7 "b4" + OpMemberName %SSBO 8 "c1" + OpMemberName %SSBO 9 "c2" + OpMemberName %SSBO 10 "c3" + OpMemberName %SSBO 11 "c4" + OpName %_ "" + OpName %i "i" + OpMemberDecorate %SSBO 0 Offset 0 + OpMemberDecorate %SSBO 1 Offset 8 + OpMemberDecorate %SSBO 2 Offset 16 + OpMemberDecorate %SSBO 3 Offset 32 + OpMemberDecorate %SSBO 4 Offset 48 + OpMemberDecorate %SSBO 5 Offset 56 + OpMemberDecorate %SSBO 6 Offset 64 + OpMemberDecorate %SSBO 7 Offset 80 + OpMemberDecorate %SSBO 8 Offset 96 + OpMemberDecorate %SSBO 9 Offset 104 + OpMemberDecorate %SSBO 10 Offset 112 + OpMemberDecorate %SSBO 11 Offset 128 + OpDecorate %SSBO BufferBlock + OpDecorate %_ DescriptorSet 0 + OpDecorate %_ Binding 0 + %void = OpTypeVoid + %7 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 + %v3float = OpTypeVector %float 3 + %v4float = OpTypeVector %float 4 + %SSBO = OpTypeStruct %float %v2float %v3float %v4float %float %v2float %v3float %v4float %float %v2float %v3float %v4float +%_ptr_Uniform_SSBO = OpTypePointer Uniform %SSBO + %_ = OpVariable %_ptr_Uniform_SSBO Uniform + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_4 = OpConstant %int 4 +%_ptr_Uniform_float = OpTypePointer Uniform %float + %int_8 = OpConstant %int 8 + %int_1 = OpConstant %int 1 + %int_5 = OpConstant %int 5 +%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float + %int_9 = OpConstant %int 9 + %int_2 = OpConstant %int 2 + %int_6 = OpConstant %int 6 +%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float + %int_10 = OpConstant %int 10 + %int_3 = OpConstant %int 3 + %int_7 = OpConstant %int 7 +%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float + %int_11 = OpConstant %int 11 +%_ptr_Function_int = OpTypePointer Function %int + %bool = OpTypeBool + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %main = OpFunction %void None %7 + %35 = OpLabel + %i = OpVariable %_ptr_Function_int Function + %36 = OpAccessChain %_ptr_Uniform_float %_ %int_4 + %37 = OpLoad %float %36 + %38 = OpAccessChain %_ptr_Uniform_float %_ %int_8 + %39 = OpLoad %float %38 + %40 = OpExtInst %float %1 NMin %37 %39 + %41 = OpAccessChain %_ptr_Uniform_float %_ %int_0 + OpStore %41 %40 + %42 = OpAccessChain %_ptr_Uniform_v2float %_ %int_5 + %43 = OpLoad %v2float %42 + %44 = OpAccessChain %_ptr_Uniform_v2float %_ %int_9 + %45 = OpLoad %v2float %44 + %46 = OpExtInst %v2float %1 NMin %43 %45 + %47 = OpAccessChain %_ptr_Uniform_v2float %_ %int_1 + OpStore %47 %46 + %48 = OpAccessChain %_ptr_Uniform_v3float %_ %int_6 + %49 = OpLoad %v3float %48 + %50 = OpAccessChain %_ptr_Uniform_v3float %_ %int_10 + %51 = OpLoad %v3float %50 + %52 = OpExtInst %v3float %1 NMin %49 %51 + %53 = OpAccessChain %_ptr_Uniform_v3float %_ %int_2 + OpStore %53 %52 + %54 = OpAccessChain %_ptr_Uniform_v4float %_ %int_7 + %55 = OpLoad %v4float %54 + %56 = OpAccessChain %_ptr_Uniform_v4float %_ %int_11 + %57 = OpLoad %v4float %56 + %58 = OpExtInst %v4float %1 NMin %55 %57 + %59 = OpAccessChain %_ptr_Uniform_v4float %_ %int_3 + OpStore %59 %58 + %60 = OpAccessChain %_ptr_Uniform_float %_ %int_4 + %61 = OpLoad %float %60 + %62 = OpAccessChain %_ptr_Uniform_float %_ %int_8 + %63 = OpLoad %float %62 + %64 = OpExtInst %float %1 NMax %61 %63 + %65 = OpAccessChain %_ptr_Uniform_float %_ %int_0 + OpStore %65 %64 + %66 = OpAccessChain %_ptr_Uniform_v2float %_ %int_5 + %67 = OpLoad %v2float %66 + %68 = OpAccessChain %_ptr_Uniform_v2float %_ %int_9 + %69 = OpLoad %v2float %68 + %70 = OpExtInst %v2float %1 NMax %67 %69 + %71 = OpAccessChain %_ptr_Uniform_v2float %_ %int_1 + OpStore %71 %70 + %72 = OpAccessChain %_ptr_Uniform_v3float %_ %int_6 + %73 = OpLoad %v3float %72 + %74 = OpAccessChain %_ptr_Uniform_v3float %_ %int_10 + %75 = OpLoad %v3float %74 + %76 = OpExtInst %v3float %1 NMax %73 %75 + %77 = OpAccessChain %_ptr_Uniform_v3float %_ %int_2 + OpStore %77 %76 + %78 = OpAccessChain %_ptr_Uniform_v4float %_ %int_7 + %79 = OpLoad %v4float %78 + %80 = OpAccessChain %_ptr_Uniform_v4float %_ %int_11 + %81 = OpLoad %v4float %80 + %82 = OpExtInst %v4float %1 NMax %79 %81 + %83 = OpAccessChain %_ptr_Uniform_v4float %_ %int_3 + OpStore %83 %82 + %84 = OpAccessChain %_ptr_Uniform_float %_ %int_0 + %85 = OpLoad %float %84 + %86 = OpAccessChain %_ptr_Uniform_float %_ %int_4 + %87 = OpLoad %float %86 + %88 = OpAccessChain %_ptr_Uniform_float %_ %int_8 + %89 = OpLoad %float %88 + %90 = OpExtInst %float %1 NClamp %85 %87 %89 + %91 = OpAccessChain %_ptr_Uniform_float %_ %int_0 + OpStore %91 %90 + %92 = OpAccessChain %_ptr_Uniform_v2float %_ %int_1 + %93 = OpLoad %v2float %92 + %94 = OpAccessChain %_ptr_Uniform_v2float %_ %int_5 + %95 = OpLoad %v2float %94 + %96 = OpAccessChain %_ptr_Uniform_v2float %_ %int_9 + %97 = OpLoad %v2float %96 + %98 = OpExtInst %v2float %1 NClamp %93 %95 %97 + %99 = OpAccessChain %_ptr_Uniform_v2float %_ %int_1 + OpStore %99 %98 + %100 = OpAccessChain %_ptr_Uniform_v3float %_ %int_2 + %101 = OpLoad %v3float %100 + %102 = OpAccessChain %_ptr_Uniform_v3float %_ %int_6 + %103 = OpLoad %v3float %102 + %104 = OpAccessChain %_ptr_Uniform_v3float %_ %int_10 + %105 = OpLoad %v3float %104 + %106 = OpExtInst %v3float %1 NClamp %101 %103 %105 + %107 = OpAccessChain %_ptr_Uniform_v3float %_ %int_2 + OpStore %107 %106 + %108 = OpAccessChain %_ptr_Uniform_v4float %_ %int_3 + %109 = OpLoad %v4float %108 + %110 = OpAccessChain %_ptr_Uniform_v4float %_ %int_7 + %111 = OpLoad %v4float %110 + %112 = OpAccessChain %_ptr_Uniform_v4float %_ %int_11 + %113 = OpLoad %v4float %112 + %114 = OpExtInst %v4float %1 NClamp %109 %111 %113 + %115 = OpAccessChain %_ptr_Uniform_v4float %_ %int_3 + OpStore %115 %114 + OpStore %i %int_0 + OpBranch %116 + %116 = OpLabel + OpLoopMerge %117 %118 None + OpBranch %119 + %119 = OpLabel + %120 = OpLoad %int %i + %121 = OpSLessThan %bool %120 %int_2 + OpBranchConditional %121 %122 %117 + %122 = OpLabel + %123 = OpAccessChain %_ptr_Uniform_v2float %_ %int_5 + %124 = OpLoad %v2float %123 + %125 = OpAccessChain %_ptr_Uniform_v2float %_ %int_9 + %126 = OpLoad %v2float %125 + %127 = OpExtInst %v2float %1 NMin %124 %126 + %128 = OpAccessChain %_ptr_Uniform_v2float %_ %int_1 + OpStore %128 %127 + OpBranch %118 + %118 = OpLabel + %129 = OpLoad %int %i + %130 = OpIAdd %int %129 %int_1 + OpStore %i %130 + %131 = OpAccessChain %_ptr_Uniform_float %_ %int_0 + %132 = OpLoad %float %131 + %133 = OpAccessChain %_ptr_Uniform_float %_ %int_5 %uint_0 + %134 = OpLoad %float %133 + %135 = OpAccessChain %_ptr_Uniform_float %_ %int_5 %uint_1 + %136 = OpLoad %float %135 + %137 = OpExtInst %float %1 NClamp %132 %134 %136 + %138 = OpAccessChain %_ptr_Uniform_float %_ %int_0 + OpStore %138 %137 + OpBranch %116 + %117 = OpLabel + OpReturn + OpFunctionEnd diff --git a/3rdparty/spirv-cross/shaders/asm/comp/nmin-max-clamp.asm.comp b/3rdparty/spirv-cross/shaders/asm/comp/nmin-max-clamp.asm.comp new file mode 100644 index 000000000..6c060eeda --- /dev/null +++ b/3rdparty/spirv-cross/shaders/asm/comp/nmin-max-clamp.asm.comp @@ -0,0 +1,203 @@ +; SPIR-V +; Version: 1.3 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 139 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 450 + OpName %main "main" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "a1" + OpMemberName %SSBO 1 "a2" + OpMemberName %SSBO 2 "a3" + OpMemberName %SSBO 3 "a4" + OpMemberName %SSBO 4 "b1" + OpMemberName %SSBO 5 "b2" + OpMemberName %SSBO 6 "b3" + OpMemberName %SSBO 7 "b4" + OpMemberName %SSBO 8 "c1" + OpMemberName %SSBO 9 "c2" + OpMemberName %SSBO 10 "c3" + OpMemberName %SSBO 11 "c4" + OpName %_ "" + OpName %i "i" + OpMemberDecorate %SSBO 0 Offset 0 + OpMemberDecorate %SSBO 1 Offset 8 + OpMemberDecorate %SSBO 2 Offset 16 + OpMemberDecorate %SSBO 3 Offset 32 + OpMemberDecorate %SSBO 4 Offset 48 + OpMemberDecorate %SSBO 5 Offset 56 + OpMemberDecorate %SSBO 6 Offset 64 + OpMemberDecorate %SSBO 7 Offset 80 + OpMemberDecorate %SSBO 8 Offset 96 + OpMemberDecorate %SSBO 9 Offset 104 + OpMemberDecorate %SSBO 10 Offset 112 + OpMemberDecorate %SSBO 11 Offset 128 + OpDecorate %SSBO BufferBlock + OpDecorate %_ DescriptorSet 0 + OpDecorate %_ Binding 0 + %void = OpTypeVoid + %7 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v2float = OpTypeVector %float 2 + %v3float = OpTypeVector %float 3 + %v4float = OpTypeVector %float 4 + %SSBO = OpTypeStruct %float %v2float %v3float %v4float %float %v2float %v3float %v4float %float %v2float %v3float %v4float +%_ptr_Uniform_SSBO = OpTypePointer Uniform %SSBO + %_ = OpVariable %_ptr_Uniform_SSBO Uniform + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_4 = OpConstant %int 4 +%_ptr_Uniform_float = OpTypePointer Uniform %float + %int_8 = OpConstant %int 8 + %int_1 = OpConstant %int 1 + %int_5 = OpConstant %int 5 +%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float + %int_9 = OpConstant %int 9 + %int_2 = OpConstant %int 2 + %int_6 = OpConstant %int 6 +%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float + %int_10 = OpConstant %int 10 + %int_3 = OpConstant %int 3 + %int_7 = OpConstant %int 7 +%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float + %int_11 = OpConstant %int 11 +%_ptr_Function_int = OpTypePointer Function %int + %bool = OpTypeBool + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %main = OpFunction %void None %7 + %35 = OpLabel + %i = OpVariable %_ptr_Function_int Function + %36 = OpAccessChain %_ptr_Uniform_float %_ %int_4 + %37 = OpLoad %float %36 + %38 = OpAccessChain %_ptr_Uniform_float %_ %int_8 + %39 = OpLoad %float %38 + %40 = OpExtInst %float %1 NMin %37 %39 + %41 = OpAccessChain %_ptr_Uniform_float %_ %int_0 + OpStore %41 %40 + %42 = OpAccessChain %_ptr_Uniform_v2float %_ %int_5 + %43 = OpLoad %v2float %42 + %44 = OpAccessChain %_ptr_Uniform_v2float %_ %int_9 + %45 = OpLoad %v2float %44 + %46 = OpExtInst %v2float %1 NMin %43 %45 + %47 = OpAccessChain %_ptr_Uniform_v2float %_ %int_1 + OpStore %47 %46 + %48 = OpAccessChain %_ptr_Uniform_v3float %_ %int_6 + %49 = OpLoad %v3float %48 + %50 = OpAccessChain %_ptr_Uniform_v3float %_ %int_10 + %51 = OpLoad %v3float %50 + %52 = OpExtInst %v3float %1 NMin %49 %51 + %53 = OpAccessChain %_ptr_Uniform_v3float %_ %int_2 + OpStore %53 %52 + %54 = OpAccessChain %_ptr_Uniform_v4float %_ %int_7 + %55 = OpLoad %v4float %54 + %56 = OpAccessChain %_ptr_Uniform_v4float %_ %int_11 + %57 = OpLoad %v4float %56 + %58 = OpExtInst %v4float %1 NMin %55 %57 + %59 = OpAccessChain %_ptr_Uniform_v4float %_ %int_3 + OpStore %59 %58 + %60 = OpAccessChain %_ptr_Uniform_float %_ %int_4 + %61 = OpLoad %float %60 + %62 = OpAccessChain %_ptr_Uniform_float %_ %int_8 + %63 = OpLoad %float %62 + %64 = OpExtInst %float %1 NMax %61 %63 + %65 = OpAccessChain %_ptr_Uniform_float %_ %int_0 + OpStore %65 %64 + %66 = OpAccessChain %_ptr_Uniform_v2float %_ %int_5 + %67 = OpLoad %v2float %66 + %68 = OpAccessChain %_ptr_Uniform_v2float %_ %int_9 + %69 = OpLoad %v2float %68 + %70 = OpExtInst %v2float %1 NMax %67 %69 + %71 = OpAccessChain %_ptr_Uniform_v2float %_ %int_1 + OpStore %71 %70 + %72 = OpAccessChain %_ptr_Uniform_v3float %_ %int_6 + %73 = OpLoad %v3float %72 + %74 = OpAccessChain %_ptr_Uniform_v3float %_ %int_10 + %75 = OpLoad %v3float %74 + %76 = OpExtInst %v3float %1 NMax %73 %75 + %77 = OpAccessChain %_ptr_Uniform_v3float %_ %int_2 + OpStore %77 %76 + %78 = OpAccessChain %_ptr_Uniform_v4float %_ %int_7 + %79 = OpLoad %v4float %78 + %80 = OpAccessChain %_ptr_Uniform_v4float %_ %int_11 + %81 = OpLoad %v4float %80 + %82 = OpExtInst %v4float %1 NMax %79 %81 + %83 = OpAccessChain %_ptr_Uniform_v4float %_ %int_3 + OpStore %83 %82 + %84 = OpAccessChain %_ptr_Uniform_float %_ %int_0 + %85 = OpLoad %float %84 + %86 = OpAccessChain %_ptr_Uniform_float %_ %int_4 + %87 = OpLoad %float %86 + %88 = OpAccessChain %_ptr_Uniform_float %_ %int_8 + %89 = OpLoad %float %88 + %90 = OpExtInst %float %1 NClamp %85 %87 %89 + %91 = OpAccessChain %_ptr_Uniform_float %_ %int_0 + OpStore %91 %90 + %92 = OpAccessChain %_ptr_Uniform_v2float %_ %int_1 + %93 = OpLoad %v2float %92 + %94 = OpAccessChain %_ptr_Uniform_v2float %_ %int_5 + %95 = OpLoad %v2float %94 + %96 = OpAccessChain %_ptr_Uniform_v2float %_ %int_9 + %97 = OpLoad %v2float %96 + %98 = OpExtInst %v2float %1 NClamp %93 %95 %97 + %99 = OpAccessChain %_ptr_Uniform_v2float %_ %int_1 + OpStore %99 %98 + %100 = OpAccessChain %_ptr_Uniform_v3float %_ %int_2 + %101 = OpLoad %v3float %100 + %102 = OpAccessChain %_ptr_Uniform_v3float %_ %int_6 + %103 = OpLoad %v3float %102 + %104 = OpAccessChain %_ptr_Uniform_v3float %_ %int_10 + %105 = OpLoad %v3float %104 + %106 = OpExtInst %v3float %1 NClamp %101 %103 %105 + %107 = OpAccessChain %_ptr_Uniform_v3float %_ %int_2 + OpStore %107 %106 + %108 = OpAccessChain %_ptr_Uniform_v4float %_ %int_3 + %109 = OpLoad %v4float %108 + %110 = OpAccessChain %_ptr_Uniform_v4float %_ %int_7 + %111 = OpLoad %v4float %110 + %112 = OpAccessChain %_ptr_Uniform_v4float %_ %int_11 + %113 = OpLoad %v4float %112 + %114 = OpExtInst %v4float %1 NClamp %109 %111 %113 + %115 = OpAccessChain %_ptr_Uniform_v4float %_ %int_3 + OpStore %115 %114 + OpStore %i %int_0 + OpBranch %116 + %116 = OpLabel + OpLoopMerge %117 %118 None + OpBranch %119 + %119 = OpLabel + %120 = OpLoad %int %i + %121 = OpSLessThan %bool %120 %int_2 + OpBranchConditional %121 %122 %117 + %122 = OpLabel + %123 = OpAccessChain %_ptr_Uniform_v2float %_ %int_5 + %124 = OpLoad %v2float %123 + %125 = OpAccessChain %_ptr_Uniform_v2float %_ %int_9 + %126 = OpLoad %v2float %125 + %127 = OpExtInst %v2float %1 NMin %124 %126 + %128 = OpAccessChain %_ptr_Uniform_v2float %_ %int_1 + OpStore %128 %127 + OpBranch %118 + %118 = OpLabel + %129 = OpLoad %int %i + %130 = OpIAdd %int %129 %int_1 + OpStore %i %130 + %131 = OpAccessChain %_ptr_Uniform_float %_ %int_0 + %132 = OpLoad %float %131 + %133 = OpAccessChain %_ptr_Uniform_float %_ %int_5 %uint_0 + %134 = OpLoad %float %133 + %135 = OpAccessChain %_ptr_Uniform_float %_ %int_5 %uint_1 + %136 = OpLoad %float %135 + %137 = OpExtInst %float %1 NClamp %132 %134 %136 + %138 = OpAccessChain %_ptr_Uniform_float %_ %int_0 + OpStore %138 %137 + OpBranch %116 + %117 = OpLabel + OpReturn + OpFunctionEnd diff --git a/3rdparty/spirv-cross/shaders/asm/geom/unroll-glposition-load.asm.geom b/3rdparty/spirv-cross/shaders/asm/geom/unroll-glposition-load.asm.geom new file mode 100644 index 000000000..8c10de397 --- /dev/null +++ b/3rdparty/spirv-cross/shaders/asm/geom/unroll-glposition-load.asm.geom @@ -0,0 +1,102 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 7 +; Bound: 55 +; Schema: 0 + OpCapability Geometry + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Geometry %main "main" %OUT_pos %positions_1 + OpExecutionMode %main Triangles + OpExecutionMode %main Invocations 1 + OpExecutionMode %main OutputTriangleStrip + OpExecutionMode %main OutputVertices 3 + OpSource HLSL 500 + OpName %main "main" + OpName %SceneOut "SceneOut" + OpMemberName %SceneOut 0 "pos" + OpName %_main_vf4_3__struct_SceneOut_vf41_ "@main(vf4[3];struct-SceneOut-vf41;" + OpName %positions "positions" + OpName %OUT "OUT" + OpName %i "i" + OpName %o "o" + OpName %OUT_pos "OUT.pos" + OpName %positions_0 "positions" + OpName %positions_1 "positions" + OpName %OUT_0 "OUT" + OpName %param "param" + OpName %param_0 "param" + OpDecorate %OUT_pos BuiltIn Position + OpDecorate %positions_1 BuiltIn Position + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_3 = OpConstant %uint 3 +%_arr_v4float_uint_3 = OpTypeArray %v4float %uint_3 +%_ptr_Function__arr_v4float_uint_3 = OpTypePointer Function %_arr_v4float_uint_3 + %SceneOut = OpTypeStruct %v4float +%_ptr_Function_SceneOut = OpTypePointer Function %SceneOut + %14 = OpTypeFunction %void %_ptr_Function__arr_v4float_uint_3 %_ptr_Function_SceneOut + %int = OpTypeInt 32 1 +%_ptr_Function_int = OpTypePointer Function %int + %int_0 = OpConstant %int 0 + %int_3 = OpConstant %int 3 + %bool = OpTypeBool +%_ptr_Function_v4float = OpTypePointer Function %v4float +%_ptr_Output_v4float = OpTypePointer Output %v4float + %OUT_pos = OpVariable %_ptr_Output_v4float Output + %int_1 = OpConstant %int 1 +%_ptr_Input__arr_v4float_uint_3 = OpTypePointer Input %_arr_v4float_uint_3 +%positions_1 = OpVariable %_ptr_Input__arr_v4float_uint_3 Input + %main = OpFunction %void None %3 + %5 = OpLabel +%positions_0 = OpVariable %_ptr_Function__arr_v4float_uint_3 Function + %OUT_0 = OpVariable %_ptr_Function_SceneOut Function + %param = OpVariable %_ptr_Function__arr_v4float_uint_3 Function + %param_0 = OpVariable %_ptr_Function_SceneOut Function + %48 = OpLoad %_arr_v4float_uint_3 %positions_1 + OpStore %positions_0 %48 + %51 = OpLoad %_arr_v4float_uint_3 %positions_0 + OpStore %param %51 + %53 = OpFunctionCall %void %_main_vf4_3__struct_SceneOut_vf41_ %param %param_0 + %54 = OpLoad %SceneOut %param_0 + OpStore %OUT_0 %54 + OpReturn + OpFunctionEnd +%_main_vf4_3__struct_SceneOut_vf41_ = OpFunction %void None %14 + %positions = OpFunctionParameter %_ptr_Function__arr_v4float_uint_3 + %OUT = OpFunctionParameter %_ptr_Function_SceneOut + %18 = OpLabel + %i = OpVariable %_ptr_Function_int Function + %o = OpVariable %_ptr_Function_SceneOut Function + OpStore %i %int_0 + OpBranch %23 + %23 = OpLabel + OpLoopMerge %25 %26 None + OpBranch %27 + %27 = OpLabel + %28 = OpLoad %int %i + %31 = OpSLessThan %bool %28 %int_3 + OpBranchConditional %31 %24 %25 + %24 = OpLabel + %33 = OpLoad %int %i + %35 = OpAccessChain %_ptr_Function_v4float %positions %33 + %36 = OpLoad %v4float %35 + %37 = OpAccessChain %_ptr_Function_v4float %o %int_0 + OpStore %37 %36 + %40 = OpAccessChain %_ptr_Function_v4float %o %int_0 + %41 = OpLoad %v4float %40 + OpStore %OUT_pos %41 + OpEmitVertex + OpBranch %26 + %26 = OpLabel + %42 = OpLoad %int %i + %44 = OpIAdd %int %42 %int_1 + OpStore %i %44 + OpBranch %23 + %25 = OpLabel + OpEndPrimitive + OpReturn + OpFunctionEnd diff --git a/3rdparty/spirv-cross/shaders/asm/tese/unroll-input-array-load.asm.tese b/3rdparty/spirv-cross/shaders/asm/tese/unroll-input-array-load.asm.tese new file mode 100644 index 000000000..960b8fa2d --- /dev/null +++ b/3rdparty/spirv-cross/shaders/asm/tese/unroll-input-array-load.asm.tese @@ -0,0 +1,131 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 7 +; Bound: 79 +; Schema: 0 + OpCapability Tessellation + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationEvaluation %main "main" %input_foo %input_bar %uv_1 %CPData_1 %_entryPointOutput_pos + OpExecutionMode %main Quads + OpSource HLSL 500 + OpName %main "main" + OpName %HS_INPUT "HS_INPUT" + OpMemberName %HS_INPUT 0 "foo" + OpMemberName %HS_INPUT 1 "bar" + OpName %ControlPoint "ControlPoint" + OpMemberName %ControlPoint 0 "baz" + OpName %DS_OUTPUT "DS_OUTPUT" + OpMemberName %DS_OUTPUT 0 "pos" + OpName %_main_struct_HS_INPUT_vf4_vf41_vf2_struct_ControlPoint_vf41_4__ "@main(struct-HS_INPUT-vf4-vf41;vf2;struct-ControlPoint-vf41[4];" + OpName %input "input" + OpName %uv "uv" + OpName %CPData "CPData" + OpName %o "o" + OpName %input_0 "input" + OpName %input_foo "input.foo" + OpName %input_bar "input.bar" + OpName %uv_0 "uv" + OpName %uv_1 "uv" + OpName %CPData_0 "CPData" + OpName %CPData_1 "CPData" + OpName %_entryPointOutput_pos "@entryPointOutput.pos" + OpName %param "param" + OpName %param_0 "param" + OpName %param_1 "param" + OpDecorate %input_foo Patch + OpDecorate %input_foo Location 0 + OpDecorate %input_bar Patch + OpDecorate %input_bar Location 1 + OpDecorate %uv_1 Patch + OpDecorate %uv_1 BuiltIn TessCoord + OpDecorate %CPData_1 Location 2 + OpDecorate %_entryPointOutput_pos BuiltIn Position + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %HS_INPUT = OpTypeStruct %v4float %v4float +%_ptr_Function_HS_INPUT = OpTypePointer Function %HS_INPUT + %v2float = OpTypeVector %float 2 +%_ptr_Function_v2float = OpTypePointer Function %v2float +%ControlPoint = OpTypeStruct %v4float + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_ControlPoint_uint_4 = OpTypeArray %ControlPoint %uint_4 +%_ptr_Function__arr_ControlPoint_uint_4 = OpTypePointer Function %_arr_ControlPoint_uint_4 + %DS_OUTPUT = OpTypeStruct %v4float + %18 = OpTypeFunction %DS_OUTPUT %_ptr_Function_HS_INPUT %_ptr_Function_v2float %_ptr_Function__arr_ControlPoint_uint_4 +%_ptr_Function_DS_OUTPUT = OpTypePointer Function %DS_OUTPUT + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %int_1 = OpConstant %int 1 + %int_3 = OpConstant %int 3 +%_ptr_Input_v4float = OpTypePointer Input %v4float + %input_foo = OpVariable %_ptr_Input_v4float Input + %input_bar = OpVariable %_ptr_Input_v4float Input + %v3float = OpTypeVector %float 3 +%_ptr_Input_v3float = OpTypePointer Input %v3float + %uv_1 = OpVariable %_ptr_Input_v3float Input +%_ptr_Input__arr_ControlPoint_uint_4 = OpTypePointer Input %_arr_ControlPoint_uint_4 + %CPData_1 = OpVariable %_ptr_Input__arr_ControlPoint_uint_4 Input +%_ptr_Output_v4float = OpTypePointer Output %v4float +%_entryPointOutput_pos = OpVariable %_ptr_Output_v4float Output + %main = OpFunction %void None %3 + %5 = OpLabel + %input_0 = OpVariable %_ptr_Function_HS_INPUT Function + %uv_0 = OpVariable %_ptr_Function_v2float Function + %CPData_0 = OpVariable %_ptr_Function__arr_ControlPoint_uint_4 Function + %param = OpVariable %_ptr_Function_HS_INPUT Function + %param_0 = OpVariable %_ptr_Function_v2float Function + %param_1 = OpVariable %_ptr_Function__arr_ControlPoint_uint_4 Function + %52 = OpLoad %v4float %input_foo + %53 = OpAccessChain %_ptr_Function_v4float %input_0 %int_0 + OpStore %53 %52 + %55 = OpLoad %v4float %input_bar + %56 = OpAccessChain %_ptr_Function_v4float %input_0 %int_1 + OpStore %56 %55 + %61 = OpLoad %v3float %uv_1 + %62 = OpCompositeExtract %float %61 0 + %63 = OpCompositeExtract %float %61 1 + %64 = OpCompositeConstruct %v2float %62 %63 + OpStore %uv_0 %64 + %68 = OpLoad %_arr_ControlPoint_uint_4 %CPData_1 + OpStore %CPData_0 %68 + %72 = OpLoad %HS_INPUT %input_0 + OpStore %param %72 + %74 = OpLoad %v2float %uv_0 + OpStore %param_0 %74 + %76 = OpLoad %_arr_ControlPoint_uint_4 %CPData_0 + OpStore %param_1 %76 + %77 = OpFunctionCall %DS_OUTPUT %_main_struct_HS_INPUT_vf4_vf41_vf2_struct_ControlPoint_vf41_4__ %param %param_0 %param_1 + %78 = OpCompositeExtract %v4float %77 0 + OpStore %_entryPointOutput_pos %78 + OpReturn + OpFunctionEnd +%_main_struct_HS_INPUT_vf4_vf41_vf2_struct_ControlPoint_vf41_4__ = OpFunction %DS_OUTPUT None %18 + %input = OpFunctionParameter %_ptr_Function_HS_INPUT + %uv = OpFunctionParameter %_ptr_Function_v2float + %CPData = OpFunctionParameter %_ptr_Function__arr_ControlPoint_uint_4 + %23 = OpLabel + %o = OpVariable %_ptr_Function_DS_OUTPUT Function + %29 = OpAccessChain %_ptr_Function_v4float %input %int_0 + %30 = OpLoad %v4float %29 + %32 = OpAccessChain %_ptr_Function_v4float %input %int_1 + %33 = OpLoad %v4float %32 + %34 = OpFAdd %v4float %30 %33 + %35 = OpLoad %v2float %uv + %36 = OpVectorShuffle %v4float %35 %35 0 1 0 1 + %37 = OpFAdd %v4float %34 %36 + %38 = OpAccessChain %_ptr_Function_v4float %CPData %int_0 %int_0 + %39 = OpLoad %v4float %38 + %40 = OpFAdd %v4float %37 %39 + %42 = OpAccessChain %_ptr_Function_v4float %CPData %int_3 %int_0 + %43 = OpLoad %v4float %42 + %44 = OpFAdd %v4float %40 %43 + %45 = OpAccessChain %_ptr_Function_v4float %o %int_0 + OpStore %45 %44 + %46 = OpLoad %DS_OUTPUT %o + OpReturnValue %46 + OpFunctionEnd diff --git a/3rdparty/spirv-cross/shaders/vulkan/frag/push-constant-as-ubo.push-ubo.vk.frag b/3rdparty/spirv-cross/shaders/vulkan/frag/push-constant-as-ubo.push-ubo.vk.frag new file mode 100644 index 000000000..b843e266e --- /dev/null +++ b/3rdparty/spirv-cross/shaders/vulkan/frag/push-constant-as-ubo.push-ubo.vk.frag @@ -0,0 +1,13 @@ +#version 450 + +layout(push_constant, std140) uniform UBO +{ + float ubo[4]; +}; + +layout(location = 0) out float FragColor; + +void main() +{ + FragColor = ubo[1]; +} diff --git a/3rdparty/spirv-cross/spirv_cross_c.cpp b/3rdparty/spirv-cross/spirv_cross_c.cpp index b7943a2eb..4c8728fea 100644 --- a/3rdparty/spirv-cross/spirv_cross_c.cpp +++ b/3rdparty/spirv-cross/spirv_cross_c.cpp @@ -316,14 +316,19 @@ spvc_result spvc_compiler_create_compiler_options(spvc_compiler compiler, spvc_c { case SPVC_BACKEND_MSL: opt->backend_flags |= SPVC_COMPILER_OPTION_MSL_BIT | SPVC_COMPILER_OPTION_COMMON_BIT; + opt->glsl = static_cast(compiler->compiler.get())->get_common_options(); + opt->msl = static_cast(compiler->compiler.get())->get_msl_options(); break; case SPVC_BACKEND_HLSL: opt->backend_flags |= SPVC_COMPILER_OPTION_HLSL_BIT | SPVC_COMPILER_OPTION_COMMON_BIT; + opt->glsl = static_cast(compiler->compiler.get())->get_common_options(); + opt->hlsl = static_cast(compiler->compiler.get())->get_hlsl_options(); break; case SPVC_BACKEND_GLSL: opt->backend_flags |= SPVC_COMPILER_OPTION_GLSL_BIT | SPVC_COMPILER_OPTION_COMMON_BIT; + opt->glsl = static_cast(compiler->compiler.get())->get_common_options(); break; default: @@ -474,6 +479,10 @@ spvc_result spvc_compiler_options_set_uint(spvc_compiler_options options, spvc_c options->msl.argument_buffers = value != 0; break; + case SPVC_COMPILER_OPTION_GLSL_EMIT_PUSH_CONSTANT_AS_UNIFORM_BUFFER: + options->glsl.emit_push_constant_as_uniform_buffer = value != 0; + break; + default: options->context->report_error("Unknown option."); return SPVC_ERROR_INVALID_ARGUMENT; diff --git a/3rdparty/spirv-cross/spirv_cross_c.h b/3rdparty/spirv-cross/spirv_cross_c.h index 8419aa51f..6b5d5a07a 100644 --- a/3rdparty/spirv-cross/spirv_cross_c.h +++ b/3rdparty/spirv-cross/spirv_cross_c.h @@ -33,7 +33,7 @@ extern "C" { /* Bumped if ABI or API breaks backwards compatibility. */ #define SPVC_C_API_VERSION_MAJOR 0 /* Bumped if APIs or enumerations are added in a backwards compatible way. */ -#define SPVC_C_API_VERSION_MINOR 2 +#define SPVC_C_API_VERSION_MINOR 3 /* Bumped if internal implementation details change. */ #define SPVC_C_API_VERSION_PATCH 0 @@ -420,6 +420,8 @@ typedef enum spvc_compiler_option SPVC_COMPILER_OPTION_MSL_PLATFORM = 31 | SPVC_COMPILER_OPTION_MSL_BIT, SPVC_COMPILER_OPTION_MSL_ARGUMENT_BUFFERS = 32 | SPVC_COMPILER_OPTION_MSL_BIT, + SPVC_COMPILER_OPTION_GLSL_EMIT_PUSH_CONSTANT_AS_UNIFORM_BUFFER = 33 | SPVC_COMPILER_OPTION_GLSL_BIT, + SPVC_COMPILER_OPTION_INT_MAX = 0x7fffffff } spvc_compiler_option; diff --git a/3rdparty/spirv-cross/spirv_glsl.cpp b/3rdparty/spirv-cross/spirv_glsl.cpp index 8f464dcc1..9d7939c58 100644 --- a/3rdparty/spirv-cross/spirv_glsl.cpp +++ b/3rdparty/spirv-cross/spirv_glsl.cpp @@ -172,6 +172,11 @@ void CompilerGLSL::init() const struct lconv *conv = localeconv(); if (conv && conv->decimal_point) current_locale_radix_character = *conv->decimal_point; +#elif defined(__ANDROID__) && __ANDROID_API__ < 26 + // nl_langinfo is not supported on this platform, fall back to the worse alternative. + const struct lconv *conv = localeconv(); + if (conv && conv->decimal_point) + current_locale_radix_character = *conv->decimal_point; #else // localeconv, the portable function is not MT safe ... const char *decimal_point = nl_langinfo(RADIXCHAR); @@ -1258,7 +1263,7 @@ bool CompilerGLSL::can_use_io_location(StorageClass storage, bool block) return false; } - if (storage == StorageClassUniform || storage == StorageClassUniformConstant) + if (storage == StorageClassUniform || storage == StorageClassUniformConstant || storage == StorageClassPushConstant) { if (options.es && options.version < 310) return false; @@ -1360,10 +1365,12 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var) bool push_constant_block = options.vulkan_semantics && var.storage == StorageClassPushConstant; bool ssbo_block = var.storage == StorageClassStorageBuffer || (var.storage == StorageClassUniform && typeflags.get(DecorationBufferBlock)); + bool emulated_ubo = var.storage == StorageClassPushConstant && options.emit_push_constant_as_uniform_buffer; + bool ubo_block = var.storage == StorageClassUniform && typeflags.get(DecorationBlock); // Instead of adding explicit offsets for every element here, just assume we're using std140 or std430. // If SPIR-V does not comply with either layout, we cannot really work around it. - if (can_use_buffer_blocks && var.storage == StorageClassUniform && typeflags.get(DecorationBlock)) + if (can_use_buffer_blocks && (ubo_block || emulated_ubo)) { if (buffer_is_packing_standard(type, BufferPackingStd140)) attr.push_back("std140"); @@ -1374,7 +1381,7 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var) // however, we can only use layout(offset) on the block itself, not any substructs, so the substructs better be the appropriate layout. // Enhanced layouts seem to always work in Vulkan GLSL, so no need for extensions there. if (options.es && !options.vulkan_semantics) - SPIRV_CROSS_THROW("Push constant block cannot be expressed as neither std430 nor std140. ES-targets do " + SPIRV_CROSS_THROW("Uniform buffer block cannot be expressed as std140. ES-targets do " "not support GL_ARB_enhanced_layouts."); if (!options.es && !options.vulkan_semantics && options.version < 440) require_extension_internal("GL_ARB_enhanced_layouts"); @@ -1456,6 +1463,8 @@ void CompilerGLSL::emit_push_constant_block(const SPIRVariable &var) emit_buffer_block_flattened(var); else if (options.vulkan_semantics) emit_push_constant_block_vulkan(var); + else if (options.emit_push_constant_as_uniform_buffer) + emit_buffer_block_native(var); else emit_push_constant_block_glsl(var); } @@ -4926,14 +4935,27 @@ void CompilerGLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, break; case GLSLstd450NMin: - emit_binary_func_op(result_type, id, args[0], args[1], "unsupported_glsl450_nmin"); - break; case GLSLstd450NMax: - emit_binary_func_op(result_type, id, args[0], args[1], "unsupported_glsl450_nmax"); + { + emit_nminmax_op(result_type, id, args[0], args[1], op); break; + } + case GLSLstd450NClamp: - emit_binary_func_op(result_type, id, args[0], args[1], "unsupported_glsl450_nclamp"); + { + // Make sure we have a unique ID here to avoid aliasing the extra sub-expressions between clamp and NMin sub-op. + // IDs cannot exceed 24 bits, so we can make use of the higher bits for some unique flags. + uint32_t &max_id = extra_sub_expressions[id | 0x80000000u]; + if (!max_id) + max_id = ir.increase_bound_by(1); + + // Inherit precision qualifiers. + ir.meta[max_id] = ir.meta[id]; + + emit_nminmax_op(result_type, max_id, args[0], args[1], GLSLstd450NMax); + emit_nminmax_op(result_type, id, max_id, args[2], GLSLstd450NMin); break; + } default: statement("// unimplemented GLSL op ", eop); @@ -4941,6 +4963,35 @@ void CompilerGLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, } } +void CompilerGLSL::emit_nminmax_op(uint32_t result_type, uint32_t id, uint32_t op0, uint32_t op1, GLSLstd450 op) +{ + // Need to emulate this call. + uint32_t &ids = extra_sub_expressions[id]; + if (!ids) + { + ids = ir.increase_bound_by(5); + auto btype = get(result_type); + btype.basetype = SPIRType::Boolean; + set(ids, btype); + } + + uint32_t btype_id = ids + 0; + uint32_t left_nan_id = ids + 1; + uint32_t right_nan_id = ids + 2; + uint32_t tmp_id = ids + 3; + uint32_t mixed_first_id = ids + 4; + + // Inherit precision qualifiers. + ir.meta[tmp_id] = ir.meta[id]; + ir.meta[mixed_first_id] = ir.meta[id]; + + emit_unary_func_op(btype_id, left_nan_id, op0, "isnan"); + emit_unary_func_op(btype_id, right_nan_id, op1, "isnan"); + emit_binary_func_op(result_type, tmp_id, op0, op1, op == GLSLstd450NMin ? "min" : "max"); + emit_mix_op(result_type, mixed_first_id, tmp_id, op1, left_nan_id); + emit_mix_op(result_type, id, mixed_first_id, op0, right_nan_id); +} + void CompilerGLSL::emit_spv_amd_shader_ballot_op(uint32_t result_type, uint32_t id, uint32_t eop, const uint32_t *args, uint32_t) { @@ -6900,6 +6951,11 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // We might need to bitcast in order to load from a builtin. bitcast_from_builtin_load(ptr, expr, get(result_type)); + // We might be trying to load a gl_Position[N], where we should be + // doing float4[](gl_in[i].gl_Position, ...) instead. + // Similar workarounds are required for input arrays in tessellation. + unroll_array_from_complex_load(id, ptr, expr); + if (ptr_expression) ptr_expression->need_transpose = old_need_transpose; @@ -10738,6 +10794,9 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block) auto &type = expression_type(block.condition); bool unsigned_case = type.basetype == SPIRType::UInt || type.basetype == SPIRType::UShort; + if (block.merge == SPIRBlock::MergeNone) + SPIRV_CROSS_THROW("Switch statement is not structured"); + if (type.basetype == SPIRType::UInt64 || type.basetype == SPIRType::Int64) { // SPIR-V spec suggests this is allowed, but we cannot support it in higher level languages. @@ -11029,6 +11088,59 @@ void CompilerGLSL::emit_array_copy(const string &lhs, uint32_t rhs_id) statement(lhs, " = ", to_expression(rhs_id), ";"); } +void CompilerGLSL::unroll_array_from_complex_load(uint32_t target_id, uint32_t source_id, std::string &expr) +{ + if (!backend.force_gl_in_out_block) + return; + // This path is only relevant for GL backends. + + auto *var = maybe_get(source_id); + if (!var) + return; + + if (var->storage != StorageClassInput) + return; + + auto &type = get_variable_data_type(*var); + if (type.array.empty()) + return; + + auto builtin = BuiltIn(get_decoration(var->self, DecorationBuiltIn)); + bool is_builtin = is_builtin_variable(*var) && (builtin == BuiltInPointSize || builtin == BuiltInPosition); + bool is_tess = is_tessellation_shader(); + + // Tessellation input arrays are special in that they are unsized, so we cannot directly copy from it. + // We must unroll the array load. + // For builtins, we couldn't catch this case normally, + // because this is resolved in the OpAccessChain in most cases. + // If we load the entire array, we have no choice but to unroll here. + if (is_builtin || is_tess) + { + auto new_expr = join("_", target_id, "_unrolled"); + statement(variable_decl(type, new_expr, target_id), ";"); + string array_expr; + if (type.array_size_literal.front()) + { + array_expr = convert_to_string(type.array.front()); + if (type.array.front() == 0) + SPIRV_CROSS_THROW("Cannot unroll an array copy from unsized array."); + } + else + array_expr = to_expression(type.array.front()); + + // The array size might be a specialization constant, so use a for-loop instead. + statement("for (int i = 0; i < int(", array_expr, "); i++)"); + begin_scope(); + if (is_builtin) + statement(new_expr, "[i] = gl_in[i].", expr, ";"); + else + statement(new_expr, "[i] = ", expr, "[i];"); + end_scope(); + + expr = move(new_expr); + } +} + void CompilerGLSL::bitcast_from_builtin_load(uint32_t source_id, std::string &expr, const spirv_cross::SPIRType &expr_type) { diff --git a/3rdparty/spirv-cross/spirv_glsl.hpp b/3rdparty/spirv-cross/spirv_glsl.hpp index a46ebe425..5d7731954 100644 --- a/3rdparty/spirv-cross/spirv_glsl.hpp +++ b/3rdparty/spirv-cross/spirv_glsl.hpp @@ -18,6 +18,7 @@ #define SPIRV_CROSS_GLSL_HPP #include "spirv_cross.hpp" +#include "GLSL.std.450.h" #include #include #include @@ -96,6 +97,9 @@ public: // If disabled on older targets, binding decorations will be stripped. bool enable_420pack_extension = true; + // In non-Vulkan GLSL, emit push constant blocks as UBOs rather than plain uniforms. + bool emit_push_constant_as_uniform_buffer = false; + enum Precision { DontCare, @@ -418,6 +422,7 @@ protected: bool should_dereference(uint32_t id); bool should_forward(uint32_t id); void emit_mix_op(uint32_t result_type, uint32_t id, uint32_t left, uint32_t right, uint32_t lerp); + void emit_nminmax_op(uint32_t result_type, uint32_t id, uint32_t op0, uint32_t op1, GLSLstd450 op); bool to_trivial_mix_op(const SPIRType &type, std::string &op, uint32_t left, uint32_t right, uint32_t lerp); void emit_quaternary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, uint32_t op2, uint32_t op3, const char *op); @@ -549,6 +554,11 @@ protected: std::vector forced_extensions; std::vector header_lines; + // Used when expressions emit extra opcodes with their own unique IDs, + // and we need to reuse the IDs across recompilation loops. + // Currently used by NMin/Max/Clamp implementations. + std::unordered_map extra_sub_expressions; + uint32_t statement_count; inline bool is_legacy() const @@ -616,6 +626,7 @@ protected: // Sometimes we will need to automatically perform bitcasts on load and store to make this work. virtual void bitcast_to_builtin_store(uint32_t target_id, std::string &expr, const SPIRType &expr_type); virtual void bitcast_from_builtin_load(uint32_t source_id, std::string &expr, const SPIRType &expr_type); + void unroll_array_from_complex_load(uint32_t target_id, uint32_t source_id, std::string &expr); void handle_store_to_invariant_variable(uint32_t store_id, uint32_t value_id); void disallow_forwarding_in_expression_chain(const SPIRExpression &expr); diff --git a/3rdparty/spirv-cross/spirv_parser.cpp b/3rdparty/spirv-cross/spirv_parser.cpp index 1725b4ca3..ec82795f5 100644 --- a/3rdparty/spirv-cross/spirv_parser.cpp +++ b/3rdparty/spirv-cross/spirv_parser.cpp @@ -879,9 +879,6 @@ void Parser::parse(const Instruction &instruction) if (!current_block) SPIRV_CROSS_THROW("Trying to end a non-existing block."); - if (current_block->merge == SPIRBlock::MergeNone) - SPIRV_CROSS_THROW("Switch statement is not structured"); - current_block->terminator = SPIRBlock::MultiSelect; current_block->condition = ops[0]; diff --git a/3rdparty/spirv-cross/test_shaders.py b/3rdparty/spirv-cross/test_shaders.py index 51095f0ad..6806b55a8 100755 --- a/3rdparty/spirv-cross/test_shaders.py +++ b/3rdparty/spirv-cross/test_shaders.py @@ -302,7 +302,7 @@ def validate_shader(shader, vulkan, paths): else: subprocess.check_call([paths.glslang, shader]) -def cross_compile(shader, vulkan, spirv, invalid_spirv, eliminate, is_legacy, flatten_ubo, sso, flatten_dim, opt, paths): +def cross_compile(shader, vulkan, spirv, invalid_spirv, eliminate, is_legacy, flatten_ubo, sso, flatten_dim, opt, push_ubo, paths): spirv_path = create_temporary() glsl_path = create_temporary(os.path.basename(shader)) @@ -335,6 +335,8 @@ def cross_compile(shader, vulkan, spirv, invalid_spirv, eliminate, is_legacy, fl extra_args += ['--separate-shader-objects'] if flatten_dim: extra_args += ['--flatten-multidimensional-arrays'] + if push_ubo: + extra_args += ['--glsl-emit-push-constant-as-ubo'] spirv_cross_path = './spirv-cross' @@ -496,6 +498,9 @@ def shader_is_flatten_dimensions(shader): def shader_is_noopt(shader): return '.noopt.' in shader +def shader_is_push_ubo(shader): + return '.push-ubo.' in shader + def test_shader(stats, shader, update, keep, opt, paths): joined_path = os.path.join(shader[0], shader[1]) vulkan = shader_is_vulkan(shader[1]) @@ -508,9 +513,10 @@ def test_shader(stats, shader, update, keep, opt, paths): sso = shader_is_sso(shader[1]) flatten_dim = shader_is_flatten_dimensions(shader[1]) noopt = shader_is_noopt(shader[1]) + push_ubo = shader_is_push_ubo(shader[1]) print('Testing shader:', joined_path) - spirv, glsl, vulkan_glsl = cross_compile(joined_path, vulkan, is_spirv, invalid_spirv, eliminate, is_legacy, flatten_ubo, sso, flatten_dim, opt and (not noopt), paths) + spirv, glsl, vulkan_glsl = cross_compile(joined_path, vulkan, is_spirv, invalid_spirv, eliminate, is_legacy, flatten_ubo, sso, flatten_dim, opt and (not noopt), push_ubo, paths) # Only test GLSL stats if we have a shader following GL semantics. if stats and (not vulkan) and (not is_spirv) and (not desktop):