diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.frag new file mode 100644 index 0000000000..322c86bed3 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.frag @@ -0,0 +1,29 @@ +Texture2D uTexture : register(t0); +SamplerState _uTexture_sampler : register(s0); + +static min16float4 FragColor; +static min16float2 UV; + +struct SPIRV_Cross_Input +{ + min16float2 UV : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + min16float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = min16float4(uTexture.Sample(_uTexture_sampler, UV)); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + UV = stage_input.UV; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/outer-product.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/outer-product.comp new file mode 100644 index 0000000000..71613d4f15 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/outer-product.comp @@ -0,0 +1,48 @@ +RWByteAddressBuffer _21 : register(u0); +ByteAddressBuffer _26 : register(t1); + +void comp_main() +{ + float2x2 _32 = float2x2(asfloat(_26.Load2(0)) * asfloat(_26.Load2(0)).x, asfloat(_26.Load2(0)) * asfloat(_26.Load2(0)).y); + _21.Store2(0, asuint(_32[0])); + _21.Store2(8, asuint(_32[1])); + float2x3 _41 = float2x3(asfloat(_26.Load3(16)) * asfloat(_26.Load2(0)).x, asfloat(_26.Load3(16)) * asfloat(_26.Load2(0)).y); + _21.Store3(16, asuint(_41[0])); + _21.Store3(32, asuint(_41[1])); + float2x4 _50 = float2x4(asfloat(_26.Load4(32)) * asfloat(_26.Load2(0)).x, asfloat(_26.Load4(32)) * asfloat(_26.Load2(0)).y); + _21.Store4(48, asuint(_50[0])); + _21.Store4(64, asuint(_50[1])); + float3x2 _58 = float3x2(asfloat(_26.Load2(0)) * asfloat(_26.Load3(16)).x, asfloat(_26.Load2(0)) * asfloat(_26.Load3(16)).y, asfloat(_26.Load2(0)) * asfloat(_26.Load3(16)).z); + _21.Store2(80, asuint(_58[0])); + _21.Store2(88, asuint(_58[1])); + _21.Store2(96, asuint(_58[2])); + float3x3 _66 = float3x3(asfloat(_26.Load3(16)) * asfloat(_26.Load3(16)).x, asfloat(_26.Load3(16)) * asfloat(_26.Load3(16)).y, asfloat(_26.Load3(16)) * asfloat(_26.Load3(16)).z); + _21.Store3(112, asuint(_66[0])); + _21.Store3(128, asuint(_66[1])); + _21.Store3(144, asuint(_66[2])); + float3x4 _74 = float3x4(asfloat(_26.Load4(32)) * asfloat(_26.Load3(16)).x, asfloat(_26.Load4(32)) * asfloat(_26.Load3(16)).y, asfloat(_26.Load4(32)) * asfloat(_26.Load3(16)).z); + _21.Store4(160, asuint(_74[0])); + _21.Store4(176, asuint(_74[1])); + _21.Store4(192, asuint(_74[2])); + float4x2 _82 = float4x2(asfloat(_26.Load2(0)) * asfloat(_26.Load4(32)).x, asfloat(_26.Load2(0)) * asfloat(_26.Load4(32)).y, asfloat(_26.Load2(0)) * asfloat(_26.Load4(32)).z, asfloat(_26.Load2(0)) * asfloat(_26.Load4(32)).w); + _21.Store2(208, asuint(_82[0])); + _21.Store2(216, asuint(_82[1])); + _21.Store2(224, asuint(_82[2])); + _21.Store2(232, asuint(_82[3])); + float4x3 _90 = float4x3(asfloat(_26.Load3(16)) * asfloat(_26.Load4(32)).x, asfloat(_26.Load3(16)) * asfloat(_26.Load4(32)).y, asfloat(_26.Load3(16)) * asfloat(_26.Load4(32)).z, asfloat(_26.Load3(16)) * asfloat(_26.Load4(32)).w); + _21.Store3(240, asuint(_90[0])); + _21.Store3(256, asuint(_90[1])); + _21.Store3(272, asuint(_90[2])); + _21.Store3(288, asuint(_90[3])); + float4x4 _98 = float4x4(asfloat(_26.Load4(32)) * asfloat(_26.Load4(32)).x, asfloat(_26.Load4(32)) * asfloat(_26.Load4(32)).y, asfloat(_26.Load4(32)) * asfloat(_26.Load4(32)).z, asfloat(_26.Load4(32)) * asfloat(_26.Load4(32)).w); + _21.Store4(304, asuint(_98[0])); + _21.Store4(320, asuint(_98[1])); + _21.Store4(336, asuint(_98[2])); + _21.Store4(352, asuint(_98[3])); +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/scalar-std450-distance-length-normalize.comp b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/scalar-std450-distance-length-normalize.comp new file mode 100644 index 0000000000..47f2fe4107 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/comp/scalar-std450-distance-length-normalize.comp @@ -0,0 +1,14 @@ +RWByteAddressBuffer _9 : register(u0); + +void comp_main() +{ + _9.Store(8, asuint(distance(asfloat(_9.Load(0)), asfloat(_9.Load(4))))); + _9.Store(12, asuint(length(asfloat(_9.Load(0))))); + _9.Store(16, asuint(sign(asfloat(_9.Load(0))))); +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/for-loop-continue-control-flow.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/for-loop-continue-control-flow.frag new file mode 100644 index 0000000000..f37c1fcc4b --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/for-loop-continue-control-flow.frag @@ -0,0 +1,25 @@ +static float4 FragColor; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = 0.0f.xxxx; + for (int _43 = 0; _43 < 3; ) + { + FragColor[_43] += float(_43); + _43++; + continue; + } +} + +SPIRV_Cross_Output main() +{ + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/scalar-refract-reflect.frag b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/scalar-refract-reflect.frag new file mode 100644 index 0000000000..0fb694c543 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-hlsl/frag/scalar-refract-reflect.frag @@ -0,0 +1,49 @@ +static float FragColor; +static float3 vRefract; + +struct SPIRV_Cross_Input +{ + float3 vRefract : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float FragColor : SV_Target0; +}; + +float SPIRV_Cross_Reflect(float i, float n) +{ + return i - 2.0 * dot(n, i) * n; +} + +float SPIRV_Cross_Refract(float i, float n, float eta) +{ + float NoI = n * i; + float NoI2 = NoI * NoI; + float k = 1.0 - eta * eta * (1.0 - NoI2); + if (k < 0.0) + { + return 0.0; + } + else + { + return eta * i - (eta * NoI + sqrt(k)) * n; + } +} + +void frag_main() +{ + FragColor = SPIRV_Cross_Refract(vRefract.x, vRefract.y, vRefract.z); + FragColor += SPIRV_Cross_Reflect(vRefract.x, vRefract.y); + FragColor += refract(vRefract.xy, vRefract.yz, vRefract.z).y; + FragColor += reflect(vRefract.xy, vRefract.zy).y; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vRefract = stage_input.vRefract; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/texture-sampling-fp16.asm.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/texture-sampling-fp16.asm.frag new file mode 100644 index 0000000000..97345820b6 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-msl/asm/frag/texture-sampling-fp16.asm.frag @@ -0,0 +1,22 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + half4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + half2 UV [[user(locn0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d uTexture [[texture(0)]], sampler uTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + out.FragColor = half4(uTexture.sample(uTextureSmplr, float2(in.UV))); + return out; +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/outer-product.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/outer-product.comp new file mode 100644 index 0000000000..8e32db392e --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/outer-product.comp @@ -0,0 +1,38 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float2x2 m22; + float2x3 m23; + float2x4 m24; + float3x2 m32; + float3x3 m33; + float3x4 m34; + float4x2 m42; + float4x3 m43; + float4x4 m44; +}; + +struct ReadSSBO +{ + float2 v2; + float3 v3; + float4 v4; +}; + +kernel void main0(device SSBO& _21 [[buffer(0)]], const device ReadSSBO& _26 [[buffer(1)]]) +{ + _21.m22 = float2x2(_26.v2 * _26.v2.x, _26.v2 * _26.v2.y); + _21.m23 = float2x3(_26.v3 * _26.v2.x, _26.v3 * _26.v2.y); + _21.m24 = float2x4(_26.v4 * _26.v2.x, _26.v4 * _26.v2.y); + _21.m32 = float3x2(_26.v2 * _26.v3.x, _26.v2 * _26.v3.y, _26.v2 * _26.v3.z); + _21.m33 = float3x3(_26.v3 * _26.v3.x, _26.v3 * _26.v3.y, _26.v3 * _26.v3.z); + _21.m34 = float3x4(_26.v4 * _26.v3.x, _26.v4 * _26.v3.y, _26.v4 * _26.v3.z); + _21.m42 = float4x2(_26.v2 * _26.v4.x, _26.v2 * _26.v4.y, _26.v2 * _26.v4.z, _26.v2 * _26.v4.w); + _21.m43 = float4x3(_26.v3 * _26.v4.x, _26.v3 * _26.v4.y, _26.v3 * _26.v4.z, _26.v3 * _26.v4.w); + _21.m44 = float4x4(_26.v4 * _26.v4.x, _26.v4 * _26.v4.y, _26.v4 * _26.v4.z, _26.v4 * _26.v4.w); +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/scalar-std450-distance-length-normalize.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/scalar-std450-distance-length-normalize.comp new file mode 100644 index 0000000000..312a6f9453 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/scalar-std450-distance-length-normalize.comp @@ -0,0 +1,21 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float a; + float b; + float c; + float d; + float e; +}; + +kernel void main0(device SSBO& _9 [[buffer(0)]]) +{ + _9.c = abs(_9.a - _9.b); + _9.d = abs(_9.a); + _9.e = sign(_9.a); +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/struct-packing.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/struct-packing.comp index dd208a00a1..35cf1b22cb 100644 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/struct-packing.comp +++ b/deps/SPIRV-Cross/reference/opt/shaders-msl/comp/struct-packing.comp @@ -3,7 +3,7 @@ using namespace metal; -typedef float3x2 packed_float2x3; +typedef packed_float2 packed_rm_float2x3[3]; struct S0 { @@ -58,7 +58,7 @@ struct SSBO1 float3x2 m3; float2x2 m4; float2x2 m5[9]; - packed_float2x3 m6[4][2]; + packed_rm_float2x3 m6[4][2]; char _m10_pad[8]; float3x2 m7; char _m11_pad[8]; @@ -142,6 +142,6 @@ kernel void main0(device SSBO1& ssbo_430 [[buffer(0)]], device SSBO0& ssbo_140 [ ssbo_430.content.m3s[5].c = _60.m3s[5].c; ssbo_430.content.m3s[6].c = _60.m3s[6].c; ssbo_430.content.m3s[7].c = _60.m3s[7].c; - ssbo_430.content.m1.a = ssbo_430.content.m3.a * ssbo_430.m6[1][1]; + ssbo_430.content.m1.a = ssbo_430.content.m3.a * float3x2(float2(ssbo_430.m6[1][1][0]), float2(ssbo_430.m6[1][1][1]), float2(ssbo_430.m6[1][1][2])); } diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/for-loop-continue-control-flow.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/for-loop-continue-control-flow.frag new file mode 100644 index 0000000000..b4cd2085e3 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/for-loop-continue-control-flow.frag @@ -0,0 +1,23 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0() +{ + main0_out out = {}; + out.FragColor = float4(0.0); + for (int _43 = 0; _43 < 3; ) + { + out.FragColor[_43] += float(_43); + _43++; + continue; + } + return out; +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/scalar-refract-reflect.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/scalar-refract-reflect.frag new file mode 100644 index 0000000000..592d445810 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/scalar-refract-reflect.frag @@ -0,0 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float FragColor [[color(0)]]; +}; + +struct main0_in +{ + float3 vRefract [[user(locn0)]]; +}; + +template +inline T spvReflect(T i, T n) +{ + return i - T(2) * i * n * n; +} + +template +inline T spvRefract(T i, T n, T eta) +{ + T NoI = n * i; + T NoI2 = NoI * NoI; + T k = T(1) - eta * eta * (T(1) - NoI2); + if (k < T(0)) + { + return T(0); + } + else + { + return eta * i - (eta * NoI + sqrt(k)) * n; + } +} + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.FragColor = spvRefract(in.vRefract.x, in.vRefract.y, in.vRefract.z); + out.FragColor += spvReflect(in.vRefract.x, in.vRefract.y); + out.FragColor += refract(in.vRefract.xy, in.vRefract.yz, in.vRefract.z).y; + out.FragColor += reflect(in.vRefract.xy, in.vRefract.zy).y; + return out; +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/subgroup-builtins.msl22.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/subgroup-builtins.msl22.frag new file mode 100644 index 0000000000..03a536f0c6 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-msl/frag/subgroup-builtins.msl22.frag @@ -0,0 +1,18 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + uint2 FragColor [[color(0)]]; +}; + +fragment main0_out main0(uint gl_SubgroupSize [[threads_per_simdgroup]], uint gl_SubgroupInvocationID [[thread_index_in_simdgroup]]) +{ + main0_out out = {}; + out.FragColor.x = gl_SubgroupSize; + out.FragColor.y = gl_SubgroupInvocationID; + return out; +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/packed_matrix.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/packed_matrix.vert index 64e66d7024..44db8203c7 100644 --- a/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/packed_matrix.vert +++ b/deps/SPIRV-Cross/reference/opt/shaders-msl/vert/packed_matrix.vert @@ -3,12 +3,12 @@ using namespace metal; -typedef float3x4 packed_float4x3; +typedef packed_float4 packed_rm_float4x3[3]; struct _15 { - packed_float4x3 _m0; - packed_float4x3 _m1; + packed_rm_float4x3 _m0; + packed_rm_float4x3 _m1; }; struct _42 @@ -41,7 +41,7 @@ vertex main0_out main0(main0_in in [[stage_in]], constant _15& _17 [[buffer(0)]] { main0_out out = {}; float4 _70 = _44._m0 * float4(float3(_44._m3) + (in.m_25.xyz * (_44._m6 + _44._m7)), 1.0); - out.m_72 = normalize(float4(in.m_25.xyz, 0.0) * _17._m1); + out.m_72 = normalize(float4(in.m_25.xyz, 0.0) * float3x4(float4(_17._m1[0]), float4(_17._m1[1]), float4(_17._m1[2]))); float4 _94 = _70; _94.y = -_70.y; out.gl_Position = _94; diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/comp/struct-packing-scalar.nocompat.invalid.vk.comp b/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/comp/struct-packing-scalar.nocompat.invalid.vk.comp new file mode 100644 index 0000000000..278a8bb2ee --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/comp/struct-packing-scalar.nocompat.invalid.vk.comp @@ -0,0 +1,171 @@ +#include +#include + +using namespace metal; + +typedef packed_float2 packed_float2x2[2]; +typedef packed_float2 packed_rm_float2x3[3]; +typedef packed_float3 packed_float2x3[2]; +typedef packed_float3 packed_rm_float3x2[2]; + +struct S0 +{ + packed_float2 a[1]; + float b; +}; + +struct S1 +{ + packed_float3 a; + float b; +}; + +struct S2 +{ + packed_float3 a[1]; + float b; +}; + +struct S3 +{ + packed_float2 a; + float b; +}; + +struct S4 +{ + float2 c; +}; + +struct Content +{ + S0 m0s[1]; + S1 m1s[1]; + S2 m2s[1]; + S0 m0; + S1 m1; + S2 m2; + S3 m3; + float m4; + S4 m3s[8]; +}; + +struct SSBO1 +{ + Content content; + Content content1[2]; + Content content2; + float2x2 m0; + float2x2 m1; + packed_float2x3 m2[4]; + float3x2 m3; + float2x2 m4; + float2x2 m5[9]; + packed_rm_float2x3 m6[4][2]; + float3x2 m7; + float array[1]; +}; + +struct S0_1 +{ + float4 a[1]; + float b; +}; + +struct S1_1 +{ + packed_float3 a; + float b; +}; + +struct S2_1 +{ + float3 a[1]; + float b; +}; + +struct S3_1 +{ + float2 a; + float b; +}; + +struct S4_1 +{ + float2 c; +}; + +struct Content_1 +{ + S0_1 m0s[1]; + S1_1 m1s[1]; + S2_1 m2s[1]; + S0_1 m0; + S1_1 m1; + S2_1 m2; + S3_1 m3; + float m4; + char _m8_pad[12]; + /* FIXME: A padded struct is needed here. If you see this message, file a bug! */ S4_1 m3s[8]; +}; + +struct SSBO0 +{ + Content_1 content; + Content_1 content1[2]; + Content_1 content2; + float2x2 m0; + char _m4_pad[16]; + float2x2 m1; + char _m5_pad[16]; + float2x3 m2[4]; + float3x2 m3; + char _m7_pad[24]; + float2x2 m4; + char _m8_pad[16]; + float2x2 m5[9]; + float2x3 m6[4][2]; + float3x2 m7; + float4 array[1]; +}; + +struct SSBO2 +{ + float m0; + packed_float2x2 m1; + packed_rm_float3x2 m2; +}; + +kernel void main0(device SSBO1& ssbo_scalar [[buffer(0)]], device SSBO0& ssbo_140 [[buffer(1)]], device SSBO2& ssbo_scalar2 [[buffer(2)]]) +{ + ssbo_scalar.content.m0s[0].a[0] = ssbo_140.content.m0s[0].a[0].xy; + ssbo_scalar.content.m0s[0].b = ssbo_140.content.m0s[0].b; + ssbo_scalar.content.m1s[0].a = float3(ssbo_140.content.m1s[0].a); + ssbo_scalar.content.m1s[0].b = ssbo_140.content.m1s[0].b; + ssbo_scalar.content.m2s[0].a[0] = ssbo_140.content.m2s[0].a[0]; + ssbo_scalar.content.m2s[0].b = ssbo_140.content.m2s[0].b; + ssbo_scalar.content.m0.a[0] = ssbo_140.content.m0.a[0].xy; + ssbo_scalar.content.m0.b = ssbo_140.content.m0.b; + ssbo_scalar.content.m1.a = float3(ssbo_140.content.m1.a); + ssbo_scalar.content.m1.b = ssbo_140.content.m1.b; + ssbo_scalar.content.m2.a[0] = ssbo_140.content.m2.a[0]; + ssbo_scalar.content.m2.b = ssbo_140.content.m2.b; + ssbo_scalar.content.m3.a = ssbo_140.content.m3.a; + ssbo_scalar.content.m3.b = ssbo_140.content.m3.b; + ssbo_scalar.content.m4 = ssbo_140.content.m4; + ssbo_scalar.content.m3s[0].c = ssbo_140.content.m3s[0].c; + ssbo_scalar.content.m3s[1].c = ssbo_140.content.m3s[1].c; + ssbo_scalar.content.m3s[2].c = ssbo_140.content.m3s[2].c; + ssbo_scalar.content.m3s[3].c = ssbo_140.content.m3s[3].c; + ssbo_scalar.content.m3s[4].c = ssbo_140.content.m3s[4].c; + ssbo_scalar.content.m3s[5].c = ssbo_140.content.m3s[5].c; + ssbo_scalar.content.m3s[6].c = ssbo_140.content.m3s[6].c; + ssbo_scalar.content.m3s[7].c = ssbo_140.content.m3s[7].c; + ssbo_scalar.content.m1.a = float2x3(float3(ssbo_scalar.m2[1][0]), float3(ssbo_scalar.m2[1][1])) * float2(ssbo_scalar.content.m0.a[0]); + ssbo_scalar.m0 = float2x2(float2(ssbo_scalar2.m1[0]), float2(ssbo_scalar2.m1[1])); + ssbo_scalar2.m1[0] = transpose(ssbo_scalar.m4)[0]; + ssbo_scalar2.m1[1] = transpose(ssbo_scalar.m4)[1]; + ssbo_scalar2.m2[0] = spvConvertFromRowMajor3x2(ssbo_scalar.m3)[0]; + ssbo_scalar2.m2[1] = spvConvertFromRowMajor3x2(ssbo_scalar.m3)[1]; +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/frag/basic.multiview.nocompat.vk.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/frag/basic.multiview.nocompat.vk.frag new file mode 100644 index 0000000000..23c554940b --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/frag/basic.multiview.nocompat.vk.frag @@ -0,0 +1,32 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + float4 vColor [[user(locn0)]]; + float2 vTex_0 [[user(locn1)]]; + float2 vTex_1 [[user(locn2)]]; + float2 vTex_2 [[user(locn3)]]; + float2 vTex_3 [[user(locn4)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], constant uint* spvViewMask [[buffer(24)]], texture2d uTex [[texture(0)]], sampler uTexSmplr [[sampler(0)]], uint gl_ViewIndex [[render_target_array_index]]) +{ + main0_out out = {}; + float2 vTex[4] = {}; + vTex[0] = in.vTex_0; + vTex[1] = in.vTex_1; + vTex[2] = in.vTex_2; + vTex[3] = in.vTex_3; + gl_ViewIndex += spvViewMask[0]; + out.FragColor = in.vColor * uTex.sample(uTexSmplr, vTex[int(gl_ViewIndex)]); + return out; +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/frag/scalar-block-layout-ubo-std430.vk.nocompat.invalid.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/frag/scalar-block-layout-ubo-std430.vk.nocompat.invalid.frag new file mode 100644 index 0000000000..ec25d06787 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/frag/scalar-block-layout-ubo-std430.vk.nocompat.invalid.frag @@ -0,0 +1,36 @@ +#include +#include + +using namespace metal; + +struct UBO +{ + float a[1]; + float2 b[2]; +}; + +struct UBOEnhancedLayout +{ + float c[1]; + float2 d[2]; + char _m2_pad[9976]; + float e; +}; + +struct main0_out +{ + float FragColor [[color(0)]]; +}; + +struct main0_in +{ + int vIndex [[user(locn0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], constant UBO& _17 [[buffer(0)]], constant UBOEnhancedLayout& _30 [[buffer(1)]]) +{ + main0_out out = {}; + out.FragColor = (_17.a[in.vIndex] + _30.c[in.vIndex]) + _30.e; + return out; +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/frag/subgroups.nocompat.invalid.vk.msl21.frag b/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/frag/subgroups.nocompat.invalid.vk.msl21.frag new file mode 100644 index 0000000000..fc9c4fcdd1 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/frag/subgroups.nocompat.invalid.vk.msl21.frag @@ -0,0 +1,89 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float FragColor [[color(0)]]; +}; + +inline uint4 spvSubgroupBallot(bool value) +{ + simd_vote vote = simd_ballot(value); + // simd_ballot() returns a 64-bit integer-like object, but + // SPIR-V callers expect a uint4. We must convert. + // FIXME: This won't include higher bits if Apple ever supports + // 128 lanes in an SIMD-group. + return uint4((uint)((simd_vote::vote_t)vote & 0xFFFFFFFF), (uint)(((simd_vote::vote_t)vote >> 32) & 0xFFFFFFFF), 0, 0); +} + +inline bool spvSubgroupBallotBitExtract(uint4 ballot, uint bit) +{ + return !!extract_bits(ballot[bit / 32], bit % 32, 1); +} + +inline uint spvSubgroupBallotFindLSB(uint4 ballot) +{ + return select(ctz(ballot.x), select(32 + ctz(ballot.y), select(64 + ctz(ballot.z), select(96 + ctz(ballot.w), uint(-1), ballot.w == 0), ballot.z == 0), ballot.y == 0), ballot.x == 0); +} + +inline uint spvSubgroupBallotFindMSB(uint4 ballot) +{ + return select(128 - (clz(ballot.w) + 1), select(96 - (clz(ballot.z) + 1), select(64 - (clz(ballot.y) + 1), select(32 - (clz(ballot.x) + 1), uint(-1), ballot.x == 0), ballot.y == 0), ballot.z == 0), ballot.w == 0); +} + +inline uint spvSubgroupBallotBitCount(uint4 ballot) +{ + return popcount(ballot.x) + popcount(ballot.y) + popcount(ballot.z) + popcount(ballot.w); +} + +inline uint spvSubgroupBallotInclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID + 1, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0)), uint2(0)); + return spvSubgroupBallotBitCount(ballot & mask); +} + +inline uint spvSubgroupBallotExclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID - 32, 0)), uint2(0)); + return spvSubgroupBallotBitCount(ballot & mask); +} + +template +inline bool spvSubgroupAllEqual(T value) +{ + return simd_all(value == simd_broadcast_first(value)); +} + +template<> +inline bool spvSubgroupAllEqual(bool value) +{ + return simd_all(value) || !simd_any(value); +} + +fragment main0_out main0() +{ + main0_out out = {}; + uint gl_SubgroupSize = simd_sum(1); + uint gl_SubgroupInvocationID = simd_prefix_exclusive_sum(1); + uint4 gl_SubgroupEqMask = gl_SubgroupInvocationID > 32 ? uint4(0, (1 << (gl_SubgroupInvocationID - 32)), uint2(0)) : uint4(1 << gl_SubgroupInvocationID, uint3(0)); + uint4 gl_SubgroupGeMask = uint4(extract_bits(0xFFFFFFFF, min(gl_SubgroupInvocationID, 32u), (uint)max(min((int)gl_SubgroupSize, 32) - (int)gl_SubgroupInvocationID, 0)), extract_bits(0xFFFFFFFF, (uint)max((int)gl_SubgroupInvocationID - 32, 0), (uint)max((int)gl_SubgroupSize - (int)max(gl_SubgroupInvocationID, 32u), 0)), uint2(0)); + uint4 gl_SubgroupGtMask = uint4(extract_bits(0xFFFFFFFF, min(gl_SubgroupInvocationID + 1, 32u), (uint)max(min((int)gl_SubgroupSize, 32) - (int)gl_SubgroupInvocationID - 1, 0)), extract_bits(0xFFFFFFFF, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0), (uint)max((int)gl_SubgroupSize - (int)max(gl_SubgroupInvocationID + 1, 32u), 0)), uint2(0)); + uint4 gl_SubgroupLeMask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID + 1, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0)), uint2(0)); + uint4 gl_SubgroupLtMask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID - 32, 0)), uint2(0)); + out.FragColor = float(gl_SubgroupSize); + out.FragColor = float(gl_SubgroupInvocationID); + out.FragColor = float4(gl_SubgroupEqMask).x; + out.FragColor = float4(gl_SubgroupGeMask).x; + out.FragColor = float4(gl_SubgroupGtMask).x; + out.FragColor = float4(gl_SubgroupLeMask).x; + out.FragColor = float4(gl_SubgroupLtMask).x; + uint4 _63 = spvSubgroupBallot(true); + float4 _147 = simd_prefix_inclusive_product(simd_product(float4(20.0))); + int4 _149 = simd_prefix_inclusive_product(simd_product(int4(20))); + return out; +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/vert/multiview.multiview.nocompat.vk.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/vert/multiview.multiview.nocompat.vk.vert new file mode 100644 index 0000000000..c42e67211e --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/vert/multiview.multiview.nocompat.vk.vert @@ -0,0 +1,31 @@ +#include +#include + +using namespace metal; + +struct MVPs +{ + float4x4 MVP[2]; +}; + +struct main0_out +{ + float4 gl_Position [[position]]; + uint gl_Layer [[render_target_array_index]]; +}; + +struct main0_in +{ + float4 Position [[attribute(0)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant uint* spvViewMask [[buffer(24)]], constant MVPs& _19 [[buffer(0)]], uint gl_InstanceIndex [[instance_id]]) +{ + main0_out out = {}; + uint gl_ViewIndex = spvViewMask[0] + gl_InstanceIndex % spvViewMask[1]; + gl_InstanceIndex /= spvViewMask[1]; + out.gl_Position = _19.MVP[int(gl_ViewIndex)] * in.Position; + out.gl_Layer = gl_ViewIndex - spvViewMask[0]; + return out; +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/vert/multiview.nocompat.vk.vert b/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/vert/multiview.nocompat.vk.vert new file mode 100644 index 0000000000..f87d2a11ad --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders-msl/vulkan/vert/multiview.nocompat.vk.vert @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct MVPs +{ + float4x4 MVP[2]; +}; + +struct main0_out +{ + float4 gl_Position [[position]]; + uint gl_Layer [[render_target_array_index]]; +}; + +struct main0_in +{ + float4 Position [[attribute(0)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant MVPs& _19 [[buffer(0)]], uint gl_InstanceIndex [[instance_id]]) +{ + main0_out out = {}; + const uint gl_ViewIndex = 0; + out.gl_Position = _19.MVP[int(gl_ViewIndex)] * in.Position; + return out; +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/phi-temporary-copy-loop-variable.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/phi-temporary-copy-loop-variable.asm.comp new file mode 100644 index 0000000000..9ae8d6fd7f --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders/asm/comp/phi-temporary-copy-loop-variable.asm.comp @@ -0,0 +1,25 @@ +#version 450 +layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; + +layout(binding = 1, rgba32f) uniform writeonly image2D outImageTexture; + +void main() +{ + int _30; + _30 = 7; + int _27_copy; + for (int _27 = 7; _27 >= 0; _27_copy = _27, _27--, _30 = _27_copy) + { + if (5.0 > float(_27)) + { + break; + } + else + { + continue; + } + continue; + } + imageStore(outImageTexture, ivec2(gl_GlobalInvocationID.xy), vec4(float(_30 - 1), float(_30), 1.0, 1.0)); +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/extended-debug-extinst.invalid.asm.comp b/deps/SPIRV-Cross/reference/opt/shaders/asm/extended-debug-extinst.invalid.asm.comp new file mode 100644 index 0000000000..7755593f57 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders/asm/extended-debug-extinst.invalid.asm.comp @@ -0,0 +1,18 @@ +#version 430 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer _8_9 +{ + float _m0[]; +} _9; + +layout(binding = 1, std430) buffer _8_10 +{ + float _m0[]; +} _10; + +void main() +{ + _10._m0[gl_GlobalInvocationID.x] = -_9._m0[gl_GlobalInvocationID.x]; +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag new file mode 100644 index 0000000000..e0feb49327 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag @@ -0,0 +1,19 @@ +#version 450 +#if defined(GL_AMD_gpu_shader_half_float) +#extension GL_AMD_gpu_shader_half_float : require +#elif defined(GL_NV_gpu_shader5) +#extension GL_NV_gpu_shader5 : require +#else +#error No extension available for FP16. +#endif + +layout(binding = 0) uniform sampler2D uTexture; + +layout(location = 0) out f16vec4 FragColor; +layout(location = 0) in f16vec2 UV; + +void main() +{ + FragColor = f16vec4(texture(uTexture, UV)); +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag.vk b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag.vk new file mode 100644 index 0000000000..e13e4254ea --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag.vk @@ -0,0 +1,20 @@ +#version 450 +#if defined(GL_AMD_gpu_shader_half_float) +#extension GL_AMD_gpu_shader_half_float : require +#elif defined(GL_EXT_shader_explicit_arithmetic_types_float16) +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require +#else +#error No extension available for FP16. +#endif +#extension GL_EXT_shader_16bit_storage : require + +layout(set = 0, binding = 0) uniform sampler2D uTexture; + +layout(location = 0) out f16vec4 FragColor; +layout(location = 0) in f16vec2 UV; + +void main() +{ + FragColor = f16vec4(texture(uTexture, UV)); +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/outer-product.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/outer-product.comp new file mode 100644 index 0000000000..d31dad3b2c --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders/comp/outer-product.comp @@ -0,0 +1,36 @@ +#version 450 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) writeonly buffer SSBO +{ + mat2 m22; + mat2x3 m23; + mat2x4 m24; + mat3x2 m32; + mat3 m33; + mat3x4 m34; + mat4x2 m42; + mat4x3 m43; + mat4 m44; +} _21; + +layout(binding = 1, std430) readonly buffer ReadSSBO +{ + vec2 v2; + vec3 v3; + vec4 v4; +} _26; + +void main() +{ + _21.m22 = outerProduct(_26.v2, _26.v2); + _21.m23 = outerProduct(_26.v3, _26.v2); + _21.m24 = outerProduct(_26.v4, _26.v2); + _21.m32 = outerProduct(_26.v2, _26.v3); + _21.m33 = outerProduct(_26.v3, _26.v3); + _21.m34 = outerProduct(_26.v4, _26.v3); + _21.m42 = outerProduct(_26.v2, _26.v4); + _21.m43 = outerProduct(_26.v3, _26.v4); + _21.m44 = outerProduct(_26.v4, _26.v4); +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders/comp/scalar-std450-distance-length-normalize.comp b/deps/SPIRV-Cross/reference/opt/shaders/comp/scalar-std450-distance-length-normalize.comp new file mode 100644 index 0000000000..c28face28a --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders/comp/scalar-std450-distance-length-normalize.comp @@ -0,0 +1,19 @@ +#version 450 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer SSBO +{ + float a; + float b; + float c; + float d; + float e; +} _9; + +void main() +{ + _9.c = distance(_9.a, _9.b); + _9.d = length(_9.a); + _9.e = normalize(_9.a); +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/for-loop-continue-control-flow.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/for-loop-continue-control-flow.frag new file mode 100644 index 0000000000..f49b906099 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders/frag/for-loop-continue-control-flow.frag @@ -0,0 +1,15 @@ +#version 450 + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vec4(0.0); + for (int _43 = 0; _43 < 3; ) + { + FragColor[_43] += float(_43); + _43++; + continue; + } +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/scalar-refract-reflect.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/scalar-refract-reflect.frag new file mode 100644 index 0000000000..94d671b5a9 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders/frag/scalar-refract-reflect.frag @@ -0,0 +1,13 @@ +#version 450 + +layout(location = 0) out float FragColor; +layout(location = 0) in vec3 vRefract; + +void main() +{ + FragColor = refract(vRefract.x, vRefract.y, vRefract.z); + FragColor += reflect(vRefract.x, vRefract.y); + FragColor += refract(vRefract.xy, vRefract.yz, vRefract.z).y; + FragColor += reflect(vRefract.xy, vRefract.zy).y; +} + diff --git a/deps/SPIRV-Cross/reference/opt/shaders/frag/selection-block-dominator.frag b/deps/SPIRV-Cross/reference/opt/shaders/frag/selection-block-dominator.frag new file mode 100644 index 0000000000..f737f48917 --- /dev/null +++ b/deps/SPIRV-Cross/reference/opt/shaders/frag/selection-block-dominator.frag @@ -0,0 +1,19 @@ +#version 450 + +layout(location = 0) flat in int vIndex; +layout(location = 0) out vec4 FragColor; + +void main() +{ + for (;;) + { + if (vIndex != 1) + { + FragColor = vec4(1.0); + break; + } + FragColor = vec4(10.0); + break; + } +} + diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-qualifier-propagation.nonuniformresource.sm51.asm.frag b/deps/SPIRV-Cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-qualifier-propagation.nonuniformresource.sm51.asm.frag new file mode 100644 index 0000000000..44cc8ab221 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-qualifier-propagation.nonuniformresource.sm51.asm.frag @@ -0,0 +1,52 @@ +struct UBO_1_1 +{ + float4 v[64]; +}; + +ConstantBuffer ubos[] : register(b0, space2); +ByteAddressBuffer ssbos[] : register(t0, space3); +Texture2D uSamplers[] : register(t0, space0); +SamplerState uSamps[] : register(s0, space1); +Texture2D uCombinedSamplers[] : register(t4, space0); +SamplerState _uCombinedSamplers_sampler[] : register(s4, space0); + +static int vIndex; +static float4 FragColor; +static float2 vUV; + +struct SPIRV_Cross_Input +{ + nointerpolation int vIndex : TEXCOORD0; + float2 vUV : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + int i = vIndex; + int _59 = i + 10; + int _64 = i + 40; + FragColor = uSamplers[NonUniformResourceIndex(_59)].Sample(uSamps[NonUniformResourceIndex(_64)], vUV); + int _71 = i + 10; + FragColor = uCombinedSamplers[NonUniformResourceIndex(_71)].Sample(_uCombinedSamplers_sampler[NonUniformResourceIndex(_71)], vUV); + int _77 = i + 20; + int _80 = i + 40; + FragColor += ubos[NonUniformResourceIndex(_77)].v[_80]; + int _87 = i + 50; + int _90 = i + 60; + FragColor += asfloat(ssbos[NonUniformResourceIndex(_87)].Load4(_90 * 16 + 0)); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vIndex = stage_input.vIndex; + vUV = stage_input.vUV; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.frag new file mode 100644 index 0000000000..322c86bed3 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.frag @@ -0,0 +1,29 @@ +Texture2D uTexture : register(t0); +SamplerState _uTexture_sampler : register(s0); + +static min16float4 FragColor; +static min16float2 UV; + +struct SPIRV_Cross_Input +{ + min16float2 UV : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + min16float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = min16float4(uTexture.Sample(_uTexture_sampler, UV)); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + UV = stage_input.UV; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/outer-product.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/outer-product.comp new file mode 100644 index 0000000000..71613d4f15 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/outer-product.comp @@ -0,0 +1,48 @@ +RWByteAddressBuffer _21 : register(u0); +ByteAddressBuffer _26 : register(t1); + +void comp_main() +{ + float2x2 _32 = float2x2(asfloat(_26.Load2(0)) * asfloat(_26.Load2(0)).x, asfloat(_26.Load2(0)) * asfloat(_26.Load2(0)).y); + _21.Store2(0, asuint(_32[0])); + _21.Store2(8, asuint(_32[1])); + float2x3 _41 = float2x3(asfloat(_26.Load3(16)) * asfloat(_26.Load2(0)).x, asfloat(_26.Load3(16)) * asfloat(_26.Load2(0)).y); + _21.Store3(16, asuint(_41[0])); + _21.Store3(32, asuint(_41[1])); + float2x4 _50 = float2x4(asfloat(_26.Load4(32)) * asfloat(_26.Load2(0)).x, asfloat(_26.Load4(32)) * asfloat(_26.Load2(0)).y); + _21.Store4(48, asuint(_50[0])); + _21.Store4(64, asuint(_50[1])); + float3x2 _58 = float3x2(asfloat(_26.Load2(0)) * asfloat(_26.Load3(16)).x, asfloat(_26.Load2(0)) * asfloat(_26.Load3(16)).y, asfloat(_26.Load2(0)) * asfloat(_26.Load3(16)).z); + _21.Store2(80, asuint(_58[0])); + _21.Store2(88, asuint(_58[1])); + _21.Store2(96, asuint(_58[2])); + float3x3 _66 = float3x3(asfloat(_26.Load3(16)) * asfloat(_26.Load3(16)).x, asfloat(_26.Load3(16)) * asfloat(_26.Load3(16)).y, asfloat(_26.Load3(16)) * asfloat(_26.Load3(16)).z); + _21.Store3(112, asuint(_66[0])); + _21.Store3(128, asuint(_66[1])); + _21.Store3(144, asuint(_66[2])); + float3x4 _74 = float3x4(asfloat(_26.Load4(32)) * asfloat(_26.Load3(16)).x, asfloat(_26.Load4(32)) * asfloat(_26.Load3(16)).y, asfloat(_26.Load4(32)) * asfloat(_26.Load3(16)).z); + _21.Store4(160, asuint(_74[0])); + _21.Store4(176, asuint(_74[1])); + _21.Store4(192, asuint(_74[2])); + float4x2 _82 = float4x2(asfloat(_26.Load2(0)) * asfloat(_26.Load4(32)).x, asfloat(_26.Load2(0)) * asfloat(_26.Load4(32)).y, asfloat(_26.Load2(0)) * asfloat(_26.Load4(32)).z, asfloat(_26.Load2(0)) * asfloat(_26.Load4(32)).w); + _21.Store2(208, asuint(_82[0])); + _21.Store2(216, asuint(_82[1])); + _21.Store2(224, asuint(_82[2])); + _21.Store2(232, asuint(_82[3])); + float4x3 _90 = float4x3(asfloat(_26.Load3(16)) * asfloat(_26.Load4(32)).x, asfloat(_26.Load3(16)) * asfloat(_26.Load4(32)).y, asfloat(_26.Load3(16)) * asfloat(_26.Load4(32)).z, asfloat(_26.Load3(16)) * asfloat(_26.Load4(32)).w); + _21.Store3(240, asuint(_90[0])); + _21.Store3(256, asuint(_90[1])); + _21.Store3(272, asuint(_90[2])); + _21.Store3(288, asuint(_90[3])); + float4x4 _98 = float4x4(asfloat(_26.Load4(32)) * asfloat(_26.Load4(32)).x, asfloat(_26.Load4(32)) * asfloat(_26.Load4(32)).y, asfloat(_26.Load4(32)) * asfloat(_26.Load4(32)).z, asfloat(_26.Load4(32)) * asfloat(_26.Load4(32)).w); + _21.Store4(304, asuint(_98[0])); + _21.Store4(320, asuint(_98[1])); + _21.Store4(336, asuint(_98[2])); + _21.Store4(352, asuint(_98[3])); +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/comp/scalar-std450-distance-length-normalize.comp b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/scalar-std450-distance-length-normalize.comp new file mode 100644 index 0000000000..47f2fe4107 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-hlsl/comp/scalar-std450-distance-length-normalize.comp @@ -0,0 +1,14 @@ +RWByteAddressBuffer _9 : register(u0); + +void comp_main() +{ + _9.Store(8, asuint(distance(asfloat(_9.Load(0)), asfloat(_9.Load(4))))); + _9.Store(12, asuint(length(asfloat(_9.Load(0))))); + _9.Store(16, asuint(sign(asfloat(_9.Load(0))))); +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/for-loop-continue-control-flow.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/for-loop-continue-control-flow.frag new file mode 100644 index 0000000000..12e1e7f5fd --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/for-loop-continue-control-flow.frag @@ -0,0 +1,44 @@ +static float4 FragColor; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = 0.0f.xxxx; + int i = 0; + int _36; + for (;;) + { + if (i < 3) + { + int a = i; + FragColor[a] += float(i); + if (false) + { + _36 = 1; + } + else + { + int _41 = i; + i = _41 + 1; + _36 = _41; + } + continue; + } + else + { + break; + } + } +} + +SPIRV_Cross_Output main() +{ + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/deps/SPIRV-Cross/reference/shaders-hlsl/frag/scalar-refract-reflect.frag b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/scalar-refract-reflect.frag new file mode 100644 index 0000000000..0fb694c543 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-hlsl/frag/scalar-refract-reflect.frag @@ -0,0 +1,49 @@ +static float FragColor; +static float3 vRefract; + +struct SPIRV_Cross_Input +{ + float3 vRefract : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float FragColor : SV_Target0; +}; + +float SPIRV_Cross_Reflect(float i, float n) +{ + return i - 2.0 * dot(n, i) * n; +} + +float SPIRV_Cross_Refract(float i, float n, float eta) +{ + float NoI = n * i; + float NoI2 = NoI * NoI; + float k = 1.0 - eta * eta * (1.0 - NoI2); + if (k < 0.0) + { + return 0.0; + } + else + { + return eta * i - (eta * NoI + sqrt(k)) * n; + } +} + +void frag_main() +{ + FragColor = SPIRV_Cross_Refract(vRefract.x, vRefract.y, vRefract.z); + FragColor += SPIRV_Cross_Reflect(vRefract.x, vRefract.y); + FragColor += refract(vRefract.xy, vRefract.yz, vRefract.z).y; + FragColor += reflect(vRefract.xy, vRefract.zy).y; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vRefract = stage_input.vRefract; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/texture-sampling-fp16.asm.frag b/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/texture-sampling-fp16.asm.frag new file mode 100644 index 0000000000..97345820b6 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-msl/asm/frag/texture-sampling-fp16.asm.frag @@ -0,0 +1,22 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + half4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + half2 UV [[user(locn0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d uTexture [[texture(0)]], sampler uTextureSmplr [[sampler(0)]]) +{ + main0_out out = {}; + out.FragColor = half4(uTexture.sample(uTextureSmplr, float2(in.UV))); + return out; +} + diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/copy-array-of-arrays.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/copy-array-of-arrays.comp index cb6c328aea..0fa6c6bfd3 100644 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/copy-array-of-arrays.comp +++ b/deps/SPIRV-Cross/reference/shaders-msl/comp/copy-array-of-arrays.comp @@ -73,17 +73,11 @@ kernel void main0(device BUF& o [[buffer(0)]]) o.a = int(c[1][1][1]); float _43[2] = { o.b, o.c }; float _48[2] = { o.b, o.b }; - float _49[2][2]; - spvArrayCopyFromStack1(_49[0], _43); - spvArrayCopyFromStack1(_49[1], _48); + float _49[2][2] = { { _43[0], _43[1] }, { _48[0], _48[1] } }; float _54[2] = { o.c, o.c }; float _59[2] = { o.c, o.b }; - float _60[2][2]; - spvArrayCopyFromStack1(_60[0], _54); - spvArrayCopyFromStack1(_60[1], _59); - float _61[2][2][2]; - spvArrayCopyFromStack2(_61[0], _49); - spvArrayCopyFromStack2(_61[1], _60); + float _60[2][2] = { { _54[0], _54[1] }, { _59[0], _59[1] } }; + float _61[2][2][2] = { { { _49[0][0], _49[0][1] }, { _49[1][0], _49[1][1] } }, { { _60[0][0], _60[0][1] }, { _60[1][0], _60[1][1] } } }; float d[2][2][2]; spvArrayCopyFromStack3(d, _61); float e[2][2][2]; diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/outer-product.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/outer-product.comp new file mode 100644 index 0000000000..8e32db392e --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-msl/comp/outer-product.comp @@ -0,0 +1,38 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float2x2 m22; + float2x3 m23; + float2x4 m24; + float3x2 m32; + float3x3 m33; + float3x4 m34; + float4x2 m42; + float4x3 m43; + float4x4 m44; +}; + +struct ReadSSBO +{ + float2 v2; + float3 v3; + float4 v4; +}; + +kernel void main0(device SSBO& _21 [[buffer(0)]], const device ReadSSBO& _26 [[buffer(1)]]) +{ + _21.m22 = float2x2(_26.v2 * _26.v2.x, _26.v2 * _26.v2.y); + _21.m23 = float2x3(_26.v3 * _26.v2.x, _26.v3 * _26.v2.y); + _21.m24 = float2x4(_26.v4 * _26.v2.x, _26.v4 * _26.v2.y); + _21.m32 = float3x2(_26.v2 * _26.v3.x, _26.v2 * _26.v3.y, _26.v2 * _26.v3.z); + _21.m33 = float3x3(_26.v3 * _26.v3.x, _26.v3 * _26.v3.y, _26.v3 * _26.v3.z); + _21.m34 = float3x4(_26.v4 * _26.v3.x, _26.v4 * _26.v3.y, _26.v4 * _26.v3.z); + _21.m42 = float4x2(_26.v2 * _26.v4.x, _26.v2 * _26.v4.y, _26.v2 * _26.v4.z, _26.v2 * _26.v4.w); + _21.m43 = float4x3(_26.v3 * _26.v4.x, _26.v3 * _26.v4.y, _26.v3 * _26.v4.z, _26.v3 * _26.v4.w); + _21.m44 = float4x4(_26.v4 * _26.v4.x, _26.v4 * _26.v4.y, _26.v4 * _26.v4.z, _26.v4 * _26.v4.w); +} + diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/scalar-std450-distance-length-normalize.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/scalar-std450-distance-length-normalize.comp new file mode 100644 index 0000000000..312a6f9453 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-msl/comp/scalar-std450-distance-length-normalize.comp @@ -0,0 +1,21 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float a; + float b; + float c; + float d; + float e; +}; + +kernel void main0(device SSBO& _9 [[buffer(0)]]) +{ + _9.c = abs(_9.a - _9.b); + _9.d = abs(_9.a); + _9.e = sign(_9.a); +} + diff --git a/deps/SPIRV-Cross/reference/shaders-msl/comp/struct-packing.comp b/deps/SPIRV-Cross/reference/shaders-msl/comp/struct-packing.comp index dd208a00a1..35cf1b22cb 100644 --- a/deps/SPIRV-Cross/reference/shaders-msl/comp/struct-packing.comp +++ b/deps/SPIRV-Cross/reference/shaders-msl/comp/struct-packing.comp @@ -3,7 +3,7 @@ using namespace metal; -typedef float3x2 packed_float2x3; +typedef packed_float2 packed_rm_float2x3[3]; struct S0 { @@ -58,7 +58,7 @@ struct SSBO1 float3x2 m3; float2x2 m4; float2x2 m5[9]; - packed_float2x3 m6[4][2]; + packed_rm_float2x3 m6[4][2]; char _m10_pad[8]; float3x2 m7; char _m11_pad[8]; @@ -142,6 +142,6 @@ kernel void main0(device SSBO1& ssbo_430 [[buffer(0)]], device SSBO0& ssbo_140 [ ssbo_430.content.m3s[5].c = _60.m3s[5].c; ssbo_430.content.m3s[6].c = _60.m3s[6].c; ssbo_430.content.m3s[7].c = _60.m3s[7].c; - ssbo_430.content.m1.a = ssbo_430.content.m3.a * ssbo_430.m6[1][1]; + ssbo_430.content.m1.a = ssbo_430.content.m3.a * float3x2(float2(ssbo_430.m6[1][1][0]), float2(ssbo_430.m6[1][1][1]), float2(ssbo_430.m6[1][1][2])); } diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/for-loop-continue-control-flow.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/for-loop-continue-control-flow.frag new file mode 100644 index 0000000000..847ec6532f --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-msl/frag/for-loop-continue-control-flow.frag @@ -0,0 +1,42 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0() +{ + main0_out out = {}; + out.FragColor = float4(0.0); + int i = 0; + int _36; + for (;;) + { + if (i < 3) + { + int a = i; + out.FragColor[a] += float(i); + if (false) + { + _36 = 1; + } + else + { + int _41 = i; + i = _41 + 1; + _36 = _41; + } + continue; + } + else + { + break; + } + } + return out; +} + diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/scalar-refract-reflect.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/scalar-refract-reflect.frag new file mode 100644 index 0000000000..592d445810 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-msl/frag/scalar-refract-reflect.frag @@ -0,0 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float FragColor [[color(0)]]; +}; + +struct main0_in +{ + float3 vRefract [[user(locn0)]]; +}; + +template +inline T spvReflect(T i, T n) +{ + return i - T(2) * i * n * n; +} + +template +inline T spvRefract(T i, T n, T eta) +{ + T NoI = n * i; + T NoI2 = NoI * NoI; + T k = T(1) - eta * eta * (T(1) - NoI2); + if (k < T(0)) + { + return T(0); + } + else + { + return eta * i - (eta * NoI + sqrt(k)) * n; + } +} + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + out.FragColor = spvRefract(in.vRefract.x, in.vRefract.y, in.vRefract.z); + out.FragColor += spvReflect(in.vRefract.x, in.vRefract.y); + out.FragColor += refract(in.vRefract.xy, in.vRefract.yz, in.vRefract.z).y; + out.FragColor += reflect(in.vRefract.xy, in.vRefract.zy).y; + return out; +} + diff --git a/deps/SPIRV-Cross/reference/shaders-msl/frag/subgroup-builtins.msl22.frag b/deps/SPIRV-Cross/reference/shaders-msl/frag/subgroup-builtins.msl22.frag new file mode 100644 index 0000000000..03a536f0c6 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-msl/frag/subgroup-builtins.msl22.frag @@ -0,0 +1,18 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + uint2 FragColor [[color(0)]]; +}; + +fragment main0_out main0(uint gl_SubgroupSize [[threads_per_simdgroup]], uint gl_SubgroupInvocationID [[thread_index_in_simdgroup]]) +{ + main0_out out = {}; + out.FragColor.x = gl_SubgroupSize; + out.FragColor.y = gl_SubgroupInvocationID; + return out; +} + diff --git a/deps/SPIRV-Cross/reference/shaders-msl/vert/packed_matrix.vert b/deps/SPIRV-Cross/reference/shaders-msl/vert/packed_matrix.vert index 5c1b9bf16b..db68811581 100644 --- a/deps/SPIRV-Cross/reference/shaders-msl/vert/packed_matrix.vert +++ b/deps/SPIRV-Cross/reference/shaders-msl/vert/packed_matrix.vert @@ -3,12 +3,12 @@ using namespace metal; -typedef float3x4 packed_float4x3; +typedef packed_float4 packed_rm_float4x3[3]; struct _15 { - packed_float4x3 _m0; - packed_float4x3 _m1; + packed_rm_float4x3 _m0; + packed_rm_float4x3 _m1; }; struct _42 @@ -44,7 +44,7 @@ vertex main0_out main0(main0_in in [[stage_in]], constant _15& _17 [[buffer(0)]] float3 _13; do { - _13 = normalize(float4(in.m_25.xyz, 0.0) * _17._m1); + _13 = normalize(float4(in.m_25.xyz, 0.0) * float3x4(float4(_17._m1[0]), float4(_17._m1[1]), float4(_17._m1[2]))); break; } while (false); float4 _39 = _44._m0 * float4(float3(_44._m3) + (in.m_25.xyz * (_44._m6 + _44._m7)), 1.0); diff --git a/deps/SPIRV-Cross/reference/shaders-msl/vulkan/comp/struct-packing-scalar.nocompat.invalid.vk.comp b/deps/SPIRV-Cross/reference/shaders-msl/vulkan/comp/struct-packing-scalar.nocompat.invalid.vk.comp new file mode 100644 index 0000000000..278a8bb2ee --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-msl/vulkan/comp/struct-packing-scalar.nocompat.invalid.vk.comp @@ -0,0 +1,171 @@ +#include +#include + +using namespace metal; + +typedef packed_float2 packed_float2x2[2]; +typedef packed_float2 packed_rm_float2x3[3]; +typedef packed_float3 packed_float2x3[2]; +typedef packed_float3 packed_rm_float3x2[2]; + +struct S0 +{ + packed_float2 a[1]; + float b; +}; + +struct S1 +{ + packed_float3 a; + float b; +}; + +struct S2 +{ + packed_float3 a[1]; + float b; +}; + +struct S3 +{ + packed_float2 a; + float b; +}; + +struct S4 +{ + float2 c; +}; + +struct Content +{ + S0 m0s[1]; + S1 m1s[1]; + S2 m2s[1]; + S0 m0; + S1 m1; + S2 m2; + S3 m3; + float m4; + S4 m3s[8]; +}; + +struct SSBO1 +{ + Content content; + Content content1[2]; + Content content2; + float2x2 m0; + float2x2 m1; + packed_float2x3 m2[4]; + float3x2 m3; + float2x2 m4; + float2x2 m5[9]; + packed_rm_float2x3 m6[4][2]; + float3x2 m7; + float array[1]; +}; + +struct S0_1 +{ + float4 a[1]; + float b; +}; + +struct S1_1 +{ + packed_float3 a; + float b; +}; + +struct S2_1 +{ + float3 a[1]; + float b; +}; + +struct S3_1 +{ + float2 a; + float b; +}; + +struct S4_1 +{ + float2 c; +}; + +struct Content_1 +{ + S0_1 m0s[1]; + S1_1 m1s[1]; + S2_1 m2s[1]; + S0_1 m0; + S1_1 m1; + S2_1 m2; + S3_1 m3; + float m4; + char _m8_pad[12]; + /* FIXME: A padded struct is needed here. If you see this message, file a bug! */ S4_1 m3s[8]; +}; + +struct SSBO0 +{ + Content_1 content; + Content_1 content1[2]; + Content_1 content2; + float2x2 m0; + char _m4_pad[16]; + float2x2 m1; + char _m5_pad[16]; + float2x3 m2[4]; + float3x2 m3; + char _m7_pad[24]; + float2x2 m4; + char _m8_pad[16]; + float2x2 m5[9]; + float2x3 m6[4][2]; + float3x2 m7; + float4 array[1]; +}; + +struct SSBO2 +{ + float m0; + packed_float2x2 m1; + packed_rm_float3x2 m2; +}; + +kernel void main0(device SSBO1& ssbo_scalar [[buffer(0)]], device SSBO0& ssbo_140 [[buffer(1)]], device SSBO2& ssbo_scalar2 [[buffer(2)]]) +{ + ssbo_scalar.content.m0s[0].a[0] = ssbo_140.content.m0s[0].a[0].xy; + ssbo_scalar.content.m0s[0].b = ssbo_140.content.m0s[0].b; + ssbo_scalar.content.m1s[0].a = float3(ssbo_140.content.m1s[0].a); + ssbo_scalar.content.m1s[0].b = ssbo_140.content.m1s[0].b; + ssbo_scalar.content.m2s[0].a[0] = ssbo_140.content.m2s[0].a[0]; + ssbo_scalar.content.m2s[0].b = ssbo_140.content.m2s[0].b; + ssbo_scalar.content.m0.a[0] = ssbo_140.content.m0.a[0].xy; + ssbo_scalar.content.m0.b = ssbo_140.content.m0.b; + ssbo_scalar.content.m1.a = float3(ssbo_140.content.m1.a); + ssbo_scalar.content.m1.b = ssbo_140.content.m1.b; + ssbo_scalar.content.m2.a[0] = ssbo_140.content.m2.a[0]; + ssbo_scalar.content.m2.b = ssbo_140.content.m2.b; + ssbo_scalar.content.m3.a = ssbo_140.content.m3.a; + ssbo_scalar.content.m3.b = ssbo_140.content.m3.b; + ssbo_scalar.content.m4 = ssbo_140.content.m4; + ssbo_scalar.content.m3s[0].c = ssbo_140.content.m3s[0].c; + ssbo_scalar.content.m3s[1].c = ssbo_140.content.m3s[1].c; + ssbo_scalar.content.m3s[2].c = ssbo_140.content.m3s[2].c; + ssbo_scalar.content.m3s[3].c = ssbo_140.content.m3s[3].c; + ssbo_scalar.content.m3s[4].c = ssbo_140.content.m3s[4].c; + ssbo_scalar.content.m3s[5].c = ssbo_140.content.m3s[5].c; + ssbo_scalar.content.m3s[6].c = ssbo_140.content.m3s[6].c; + ssbo_scalar.content.m3s[7].c = ssbo_140.content.m3s[7].c; + ssbo_scalar.content.m1.a = float2x3(float3(ssbo_scalar.m2[1][0]), float3(ssbo_scalar.m2[1][1])) * float2(ssbo_scalar.content.m0.a[0]); + ssbo_scalar.m0 = float2x2(float2(ssbo_scalar2.m1[0]), float2(ssbo_scalar2.m1[1])); + ssbo_scalar2.m1[0] = transpose(ssbo_scalar.m4)[0]; + ssbo_scalar2.m1[1] = transpose(ssbo_scalar.m4)[1]; + ssbo_scalar2.m2[0] = spvConvertFromRowMajor3x2(ssbo_scalar.m3)[0]; + ssbo_scalar2.m2[1] = spvConvertFromRowMajor3x2(ssbo_scalar.m3)[1]; +} + diff --git a/deps/SPIRV-Cross/reference/shaders-msl/vulkan/frag/basic.multiview.nocompat.vk.frag b/deps/SPIRV-Cross/reference/shaders-msl/vulkan/frag/basic.multiview.nocompat.vk.frag new file mode 100644 index 0000000000..23c554940b --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-msl/vulkan/frag/basic.multiview.nocompat.vk.frag @@ -0,0 +1,32 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + float4 vColor [[user(locn0)]]; + float2 vTex_0 [[user(locn1)]]; + float2 vTex_1 [[user(locn2)]]; + float2 vTex_2 [[user(locn3)]]; + float2 vTex_3 [[user(locn4)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], constant uint* spvViewMask [[buffer(24)]], texture2d uTex [[texture(0)]], sampler uTexSmplr [[sampler(0)]], uint gl_ViewIndex [[render_target_array_index]]) +{ + main0_out out = {}; + float2 vTex[4] = {}; + vTex[0] = in.vTex_0; + vTex[1] = in.vTex_1; + vTex[2] = in.vTex_2; + vTex[3] = in.vTex_3; + gl_ViewIndex += spvViewMask[0]; + out.FragColor = in.vColor * uTex.sample(uTexSmplr, vTex[int(gl_ViewIndex)]); + return out; +} + diff --git a/deps/SPIRV-Cross/reference/shaders-msl/vulkan/frag/scalar-block-layout-ubo-std430.vk.nocompat.invalid.frag b/deps/SPIRV-Cross/reference/shaders-msl/vulkan/frag/scalar-block-layout-ubo-std430.vk.nocompat.invalid.frag new file mode 100644 index 0000000000..ec25d06787 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-msl/vulkan/frag/scalar-block-layout-ubo-std430.vk.nocompat.invalid.frag @@ -0,0 +1,36 @@ +#include +#include + +using namespace metal; + +struct UBO +{ + float a[1]; + float2 b[2]; +}; + +struct UBOEnhancedLayout +{ + float c[1]; + float2 d[2]; + char _m2_pad[9976]; + float e; +}; + +struct main0_out +{ + float FragColor [[color(0)]]; +}; + +struct main0_in +{ + int vIndex [[user(locn0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], constant UBO& _17 [[buffer(0)]], constant UBOEnhancedLayout& _30 [[buffer(1)]]) +{ + main0_out out = {}; + out.FragColor = (_17.a[in.vIndex] + _30.c[in.vIndex]) + _30.e; + return out; +} + diff --git a/deps/SPIRV-Cross/reference/shaders-msl/vulkan/frag/subgroups.nocompat.invalid.vk.msl21.frag b/deps/SPIRV-Cross/reference/shaders-msl/vulkan/frag/subgroups.nocompat.invalid.vk.msl21.frag new file mode 100644 index 0000000000..affaf86d54 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-msl/vulkan/frag/subgroups.nocompat.invalid.vk.msl21.frag @@ -0,0 +1,143 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float FragColor [[color(0)]]; +}; + +inline uint4 spvSubgroupBallot(bool value) +{ + simd_vote vote = simd_ballot(value); + // simd_ballot() returns a 64-bit integer-like object, but + // SPIR-V callers expect a uint4. We must convert. + // FIXME: This won't include higher bits if Apple ever supports + // 128 lanes in an SIMD-group. + return uint4((uint)((simd_vote::vote_t)vote & 0xFFFFFFFF), (uint)(((simd_vote::vote_t)vote >> 32) & 0xFFFFFFFF), 0, 0); +} + +inline bool spvSubgroupBallotBitExtract(uint4 ballot, uint bit) +{ + return !!extract_bits(ballot[bit / 32], bit % 32, 1); +} + +inline uint spvSubgroupBallotFindLSB(uint4 ballot) +{ + return select(ctz(ballot.x), select(32 + ctz(ballot.y), select(64 + ctz(ballot.z), select(96 + ctz(ballot.w), uint(-1), ballot.w == 0), ballot.z == 0), ballot.y == 0), ballot.x == 0); +} + +inline uint spvSubgroupBallotFindMSB(uint4 ballot) +{ + return select(128 - (clz(ballot.w) + 1), select(96 - (clz(ballot.z) + 1), select(64 - (clz(ballot.y) + 1), select(32 - (clz(ballot.x) + 1), uint(-1), ballot.x == 0), ballot.y == 0), ballot.z == 0), ballot.w == 0); +} + +inline uint spvSubgroupBallotBitCount(uint4 ballot) +{ + return popcount(ballot.x) + popcount(ballot.y) + popcount(ballot.z) + popcount(ballot.w); +} + +inline uint spvSubgroupBallotInclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID + 1, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0)), uint2(0)); + return spvSubgroupBallotBitCount(ballot & mask); +} + +inline uint spvSubgroupBallotExclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID - 32, 0)), uint2(0)); + return spvSubgroupBallotBitCount(ballot & mask); +} + +template +inline bool spvSubgroupAllEqual(T value) +{ + return simd_all(value == simd_broadcast_first(value)); +} + +template<> +inline bool spvSubgroupAllEqual(bool value) +{ + return simd_all(value) || !simd_any(value); +} + +fragment main0_out main0() +{ + main0_out out = {}; + uint gl_SubgroupSize = simd_sum(1); + uint gl_SubgroupInvocationID = simd_prefix_exclusive_sum(1); + uint4 gl_SubgroupEqMask = gl_SubgroupInvocationID > 32 ? uint4(0, (1 << (gl_SubgroupInvocationID - 32)), uint2(0)) : uint4(1 << gl_SubgroupInvocationID, uint3(0)); + uint4 gl_SubgroupGeMask = uint4(extract_bits(0xFFFFFFFF, min(gl_SubgroupInvocationID, 32u), (uint)max(min((int)gl_SubgroupSize, 32) - (int)gl_SubgroupInvocationID, 0)), extract_bits(0xFFFFFFFF, (uint)max((int)gl_SubgroupInvocationID - 32, 0), (uint)max((int)gl_SubgroupSize - (int)max(gl_SubgroupInvocationID, 32u), 0)), uint2(0)); + uint4 gl_SubgroupGtMask = uint4(extract_bits(0xFFFFFFFF, min(gl_SubgroupInvocationID + 1, 32u), (uint)max(min((int)gl_SubgroupSize, 32) - (int)gl_SubgroupInvocationID - 1, 0)), extract_bits(0xFFFFFFFF, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0), (uint)max((int)gl_SubgroupSize - (int)max(gl_SubgroupInvocationID + 1, 32u), 0)), uint2(0)); + uint4 gl_SubgroupLeMask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID + 1, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0)), uint2(0)); + uint4 gl_SubgroupLtMask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID - 32, 0)), uint2(0)); + out.FragColor = float(gl_SubgroupSize); + out.FragColor = float(gl_SubgroupInvocationID); + bool elected = simd_is_first(); + out.FragColor = float4(gl_SubgroupEqMask).x; + out.FragColor = float4(gl_SubgroupGeMask).x; + out.FragColor = float4(gl_SubgroupGtMask).x; + out.FragColor = float4(gl_SubgroupLeMask).x; + out.FragColor = float4(gl_SubgroupLtMask).x; + float4 broadcasted = simd_broadcast(float4(10.0), 8u); + float3 first = simd_broadcast_first(float3(20.0)); + uint4 ballot_value = spvSubgroupBallot(true); + bool inverse_ballot_value = spvSubgroupBallotBitExtract(ballot_value, gl_SubgroupInvocationID); + bool bit_extracted = spvSubgroupBallotBitExtract(uint4(10u), 8u); + uint bit_count = spvSubgroupBallotBitCount(ballot_value); + uint inclusive_bit_count = spvSubgroupBallotInclusiveBitCount(ballot_value, gl_SubgroupInvocationID); + uint exclusive_bit_count = spvSubgroupBallotExclusiveBitCount(ballot_value, gl_SubgroupInvocationID); + uint lsb = spvSubgroupBallotFindLSB(ballot_value); + uint msb = spvSubgroupBallotFindMSB(ballot_value); + uint shuffled = simd_shuffle(10u, 8u); + uint shuffled_xor = simd_shuffle_xor(30u, 8u); + uint shuffled_up = simd_shuffle_up(20u, 4u); + uint shuffled_down = simd_shuffle_down(20u, 4u); + bool has_all = simd_all(true); + bool has_any = simd_any(true); + bool has_equal = spvSubgroupAllEqual(0); + has_equal = spvSubgroupAllEqual(true); + float4 added = simd_sum(float4(20.0)); + int4 iadded = simd_sum(int4(20)); + float4 multiplied = simd_product(float4(20.0)); + int4 imultiplied = simd_product(int4(20)); + float4 lo = simd_min(float4(20.0)); + float4 hi = simd_max(float4(20.0)); + int4 slo = simd_min(int4(20)); + int4 shi = simd_max(int4(20)); + uint4 ulo = simd_min(uint4(20u)); + uint4 uhi = simd_max(uint4(20u)); + uint4 anded = simd_and(ballot_value); + uint4 ored = simd_or(ballot_value); + uint4 xored = simd_xor(ballot_value); + added = simd_prefix_inclusive_sum(added); + iadded = simd_prefix_inclusive_sum(iadded); + multiplied = simd_prefix_inclusive_product(multiplied); + imultiplied = simd_prefix_inclusive_product(imultiplied); + added = simd_prefix_exclusive_sum(multiplied); + multiplied = simd_prefix_exclusive_product(multiplied); + iadded = simd_prefix_exclusive_sum(imultiplied); + imultiplied = simd_prefix_exclusive_product(imultiplied); + added = quad_sum(added); + multiplied = quad_product(multiplied); + iadded = quad_sum(iadded); + imultiplied = quad_product(imultiplied); + lo = quad_min(lo); + hi = quad_max(hi); + ulo = quad_min(ulo); + uhi = quad_max(uhi); + slo = quad_min(slo); + shi = quad_max(shi); + anded = quad_and(anded); + ored = quad_or(ored); + xored = quad_xor(xored); + float4 swap_horiz = quad_shuffle_xor(float4(20.0), 1u); + float4 swap_vertical = quad_shuffle_xor(float4(20.0), 2u); + float4 swap_diagonal = quad_shuffle_xor(float4(20.0), 3u); + float4 quad_broadcast0 = quad_broadcast(float4(20.0), 3u); + return out; +} + diff --git a/deps/SPIRV-Cross/reference/shaders-msl/vulkan/vert/multiview.multiview.nocompat.vk.vert b/deps/SPIRV-Cross/reference/shaders-msl/vulkan/vert/multiview.multiview.nocompat.vk.vert new file mode 100644 index 0000000000..c42e67211e --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-msl/vulkan/vert/multiview.multiview.nocompat.vk.vert @@ -0,0 +1,31 @@ +#include +#include + +using namespace metal; + +struct MVPs +{ + float4x4 MVP[2]; +}; + +struct main0_out +{ + float4 gl_Position [[position]]; + uint gl_Layer [[render_target_array_index]]; +}; + +struct main0_in +{ + float4 Position [[attribute(0)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant uint* spvViewMask [[buffer(24)]], constant MVPs& _19 [[buffer(0)]], uint gl_InstanceIndex [[instance_id]]) +{ + main0_out out = {}; + uint gl_ViewIndex = spvViewMask[0] + gl_InstanceIndex % spvViewMask[1]; + gl_InstanceIndex /= spvViewMask[1]; + out.gl_Position = _19.MVP[int(gl_ViewIndex)] * in.Position; + out.gl_Layer = gl_ViewIndex - spvViewMask[0]; + return out; +} + diff --git a/deps/SPIRV-Cross/reference/shaders-msl/vulkan/vert/multiview.nocompat.vk.vert b/deps/SPIRV-Cross/reference/shaders-msl/vulkan/vert/multiview.nocompat.vk.vert new file mode 100644 index 0000000000..f87d2a11ad --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-msl/vulkan/vert/multiview.nocompat.vk.vert @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct MVPs +{ + float4x4 MVP[2]; +}; + +struct main0_out +{ + float4 gl_Position [[position]]; + uint gl_Layer [[render_target_array_index]]; +}; + +struct main0_in +{ + float4 Position [[attribute(0)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant MVPs& _19 [[buffer(0)]], uint gl_InstanceIndex [[instance_id]]) +{ + main0_out out = {}; + const uint gl_ViewIndex = 0; + out.gl_Position = _19.MVP[int(gl_ViewIndex)] * in.Position; + return out; +} + diff --git a/deps/SPIRV-Cross/reference/shaders-no-opt/asm/frag/nonuniform-qualifier-propagation.vk.nocompat.asm.frag.vk b/deps/SPIRV-Cross/reference/shaders-no-opt/asm/frag/nonuniform-qualifier-propagation.vk.nocompat.asm.frag.vk new file mode 100644 index 0000000000..5f7ddeee17 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders-no-opt/asm/frag/nonuniform-qualifier-propagation.vk.nocompat.asm.frag.vk @@ -0,0 +1,37 @@ +#version 450 +#extension GL_EXT_nonuniform_qualifier : require + +layout(set = 0, binding = 2, std140) uniform UBO +{ + vec4 v[64]; +} ubos[]; + +layout(set = 0, binding = 3, std430) readonly buffer SSBO +{ + vec4 v[]; +} ssbos[]; + +layout(set = 0, binding = 0) uniform texture2D uSamplers[]; +layout(set = 0, binding = 1) uniform sampler uSamps[]; +layout(set = 0, binding = 4) uniform sampler2D uCombinedSamplers[]; + +layout(location = 0) flat in int vIndex; +layout(location = 0) out vec4 FragColor; +layout(location = 1) in vec2 vUV; + +void main() +{ + int i = vIndex; + int _59 = i + 10; + int _64 = i + 40; + FragColor = texture(sampler2D(uSamplers[nonuniformEXT(_59)], uSamps[nonuniformEXT(_64)]), vUV); + int _71 = i + 10; + FragColor = texture(uCombinedSamplers[nonuniformEXT(_71)], vUV); + int _77 = i + 20; + int _80 = i + 40; + FragColor += ubos[nonuniformEXT(_77)].v[_80]; + int _87 = i + 50; + int _90 = i + 60; + FragColor += ssbos[nonuniformEXT(_87)].v[_90]; +} + diff --git a/deps/SPIRV-Cross/reference/shaders/asm/comp/phi-temporary-copy-loop-variable.asm.comp b/deps/SPIRV-Cross/reference/shaders/asm/comp/phi-temporary-copy-loop-variable.asm.comp new file mode 100644 index 0000000000..9ae8d6fd7f --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders/asm/comp/phi-temporary-copy-loop-variable.asm.comp @@ -0,0 +1,25 @@ +#version 450 +layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; + +layout(binding = 1, rgba32f) uniform writeonly image2D outImageTexture; + +void main() +{ + int _30; + _30 = 7; + int _27_copy; + for (int _27 = 7; _27 >= 0; _27_copy = _27, _27--, _30 = _27_copy) + { + if (5.0 > float(_27)) + { + break; + } + else + { + continue; + } + continue; + } + imageStore(outImageTexture, ivec2(gl_GlobalInvocationID.xy), vec4(float(_30 - 1), float(_30), 1.0, 1.0)); +} + diff --git a/deps/SPIRV-Cross/reference/shaders/asm/extended-debug-extinst.invalid.asm.comp b/deps/SPIRV-Cross/reference/shaders/asm/extended-debug-extinst.invalid.asm.comp new file mode 100644 index 0000000000..7755593f57 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders/asm/extended-debug-extinst.invalid.asm.comp @@ -0,0 +1,18 @@ +#version 430 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer _8_9 +{ + float _m0[]; +} _9; + +layout(binding = 1, std430) buffer _8_10 +{ + float _m0[]; +} _10; + +void main() +{ + _10._m0[gl_GlobalInvocationID.x] = -_9._m0[gl_GlobalInvocationID.x]; +} + diff --git a/deps/SPIRV-Cross/reference/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag b/deps/SPIRV-Cross/reference/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag new file mode 100644 index 0000000000..e0feb49327 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag @@ -0,0 +1,19 @@ +#version 450 +#if defined(GL_AMD_gpu_shader_half_float) +#extension GL_AMD_gpu_shader_half_float : require +#elif defined(GL_NV_gpu_shader5) +#extension GL_NV_gpu_shader5 : require +#else +#error No extension available for FP16. +#endif + +layout(binding = 0) uniform sampler2D uTexture; + +layout(location = 0) out f16vec4 FragColor; +layout(location = 0) in f16vec2 UV; + +void main() +{ + FragColor = f16vec4(texture(uTexture, UV)); +} + diff --git a/deps/SPIRV-Cross/reference/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag.vk b/deps/SPIRV-Cross/reference/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag.vk new file mode 100644 index 0000000000..e13e4254ea --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag.vk @@ -0,0 +1,20 @@ +#version 450 +#if defined(GL_AMD_gpu_shader_half_float) +#extension GL_AMD_gpu_shader_half_float : require +#elif defined(GL_EXT_shader_explicit_arithmetic_types_float16) +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require +#else +#error No extension available for FP16. +#endif +#extension GL_EXT_shader_16bit_storage : require + +layout(set = 0, binding = 0) uniform sampler2D uTexture; + +layout(location = 0) out f16vec4 FragColor; +layout(location = 0) in f16vec2 UV; + +void main() +{ + FragColor = f16vec4(texture(uTexture, UV)); +} + diff --git a/deps/SPIRV-Cross/reference/shaders/comp/outer-product.comp b/deps/SPIRV-Cross/reference/shaders/comp/outer-product.comp new file mode 100644 index 0000000000..d31dad3b2c --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders/comp/outer-product.comp @@ -0,0 +1,36 @@ +#version 450 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) writeonly buffer SSBO +{ + mat2 m22; + mat2x3 m23; + mat2x4 m24; + mat3x2 m32; + mat3 m33; + mat3x4 m34; + mat4x2 m42; + mat4x3 m43; + mat4 m44; +} _21; + +layout(binding = 1, std430) readonly buffer ReadSSBO +{ + vec2 v2; + vec3 v3; + vec4 v4; +} _26; + +void main() +{ + _21.m22 = outerProduct(_26.v2, _26.v2); + _21.m23 = outerProduct(_26.v3, _26.v2); + _21.m24 = outerProduct(_26.v4, _26.v2); + _21.m32 = outerProduct(_26.v2, _26.v3); + _21.m33 = outerProduct(_26.v3, _26.v3); + _21.m34 = outerProduct(_26.v4, _26.v3); + _21.m42 = outerProduct(_26.v2, _26.v4); + _21.m43 = outerProduct(_26.v3, _26.v4); + _21.m44 = outerProduct(_26.v4, _26.v4); +} + diff --git a/deps/SPIRV-Cross/reference/shaders/comp/scalar-std450-distance-length-normalize.comp b/deps/SPIRV-Cross/reference/shaders/comp/scalar-std450-distance-length-normalize.comp new file mode 100644 index 0000000000..c28face28a --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders/comp/scalar-std450-distance-length-normalize.comp @@ -0,0 +1,19 @@ +#version 450 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 0, std430) buffer SSBO +{ + float a; + float b; + float c; + float d; + float e; +} _9; + +void main() +{ + _9.c = distance(_9.a, _9.b); + _9.d = length(_9.a); + _9.e = normalize(_9.a); +} + diff --git a/deps/SPIRV-Cross/reference/shaders/frag/for-loop-continue-control-flow.frag b/deps/SPIRV-Cross/reference/shaders/frag/for-loop-continue-control-flow.frag new file mode 100644 index 0000000000..638d89be6b --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders/frag/for-loop-continue-control-flow.frag @@ -0,0 +1,34 @@ +#version 450 + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vec4(0.0); + int i = 0; + int _36; + for (;;) + { + if (i < 3) + { + int a = i; + FragColor[a] += float(i); + if (false) + { + _36 = 1; + } + else + { + int _41 = i; + i = _41 + 1; + _36 = _41; + } + continue; + } + else + { + break; + } + } +} + diff --git a/deps/SPIRV-Cross/reference/shaders/frag/scalar-refract-reflect.frag b/deps/SPIRV-Cross/reference/shaders/frag/scalar-refract-reflect.frag new file mode 100644 index 0000000000..94d671b5a9 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders/frag/scalar-refract-reflect.frag @@ -0,0 +1,13 @@ +#version 450 + +layout(location = 0) out float FragColor; +layout(location = 0) in vec3 vRefract; + +void main() +{ + FragColor = refract(vRefract.x, vRefract.y, vRefract.z); + FragColor += reflect(vRefract.x, vRefract.y); + FragColor += refract(vRefract.xy, vRefract.yz, vRefract.z).y; + FragColor += reflect(vRefract.xy, vRefract.zy).y; +} + diff --git a/deps/SPIRV-Cross/reference/shaders/frag/selection-block-dominator.frag b/deps/SPIRV-Cross/reference/shaders/frag/selection-block-dominator.frag new file mode 100644 index 0000000000..a0242a00b5 --- /dev/null +++ b/deps/SPIRV-Cross/reference/shaders/frag/selection-block-dominator.frag @@ -0,0 +1,20 @@ +#version 450 + +layout(location = 0) flat in int vIndex; +layout(location = 0) out vec4 FragColor; + +void main() +{ + int v; + if (vIndex != 1) + { + FragColor = vec4(1.0); + return; + } + else + { + v = 10; + } + FragColor = vec4(float(v)); +} + diff --git a/deps/SPIRV-Cross/shaders-hlsl-no-opt/asm/frag/nonuniform-qualifier-propagation.nonuniformresource.sm51.asm.frag b/deps/SPIRV-Cross/shaders-hlsl-no-opt/asm/frag/nonuniform-qualifier-propagation.nonuniformresource.sm51.asm.frag new file mode 100644 index 0000000000..5aa68849b1 --- /dev/null +++ b/deps/SPIRV-Cross/shaders-hlsl-no-opt/asm/frag/nonuniform-qualifier-propagation.nonuniformresource.sm51.asm.frag @@ -0,0 +1,159 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 7 +; Bound: 93 +; Schema: 0 + OpCapability Shader + OpCapability ShaderNonUniformEXT + OpCapability RuntimeDescriptorArrayEXT + OpCapability UniformBufferArrayNonUniformIndexingEXT + OpCapability SampledImageArrayNonUniformIndexingEXT + OpCapability StorageBufferArrayNonUniformIndexingEXT + OpExtension "SPV_EXT_descriptor_indexing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %vIndex %FragColor %vUV + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpSourceExtension "GL_EXT_nonuniform_qualifier" + OpName %main "main" + OpName %i "i" + OpName %vIndex "vIndex" + OpName %FragColor "FragColor" + OpName %uSamplers "uSamplers" + OpName %uSamps "uSamps" + OpName %vUV "vUV" + OpName %uCombinedSamplers "uCombinedSamplers" + OpName %UBO "UBO" + OpMemberName %UBO 0 "v" + OpName %ubos "ubos" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "v" + OpName %ssbos "ssbos" + OpDecorate %vIndex Flat + OpDecorate %vIndex Location 0 + OpDecorate %FragColor Location 0 + OpDecorate %uSamplers DescriptorSet 0 + OpDecorate %uSamplers Binding 0 + + OpDecorate %sampled_image NonUniformEXT + OpDecorate %combined_sampler NonUniformEXT + OpDecorate %ubo_ptr_copy NonUniformEXT + OpDecorate %ssbo_ptr_copy NonUniformEXT + + OpDecorate %uSamps DescriptorSet 1 + OpDecorate %uSamps Binding 0 + OpDecorate %vUV Location 1 + OpDecorate %uCombinedSamplers DescriptorSet 0 + OpDecorate %uCombinedSamplers Binding 4 + OpDecorate %_arr_v4float_uint_64 ArrayStride 16 + OpMemberDecorate %UBO 0 Offset 0 + OpDecorate %UBO Block + OpDecorate %ubos DescriptorSet 2 + OpDecorate %ubos Binding 0 + OpDecorate %_runtimearr_v4float ArrayStride 16 + OpMemberDecorate %SSBO 0 NonWritable + OpMemberDecorate %SSBO 0 Offset 0 + OpDecorate %SSBO BufferBlock + OpDecorate %ssbos DescriptorSet 3 + OpDecorate %ssbos Binding 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %int = OpTypeInt 32 1 +%_ptr_Function_int = OpTypePointer Function %int +%_ptr_Input_int = OpTypePointer Input %int + %vIndex = OpVariable %_ptr_Input_int Input + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %FragColor = OpVariable %_ptr_Output_v4float Output + %16 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_runtimearr_16 = OpTypeRuntimeArray %16 +%_ptr_UniformConstant__runtimearr_16 = OpTypePointer UniformConstant %_runtimearr_16 + %uSamplers = OpVariable %_ptr_UniformConstant__runtimearr_16 UniformConstant + %int_10 = OpConstant %int 10 +%_ptr_UniformConstant_16 = OpTypePointer UniformConstant %16 + %27 = OpTypeSampler +%_runtimearr_27 = OpTypeRuntimeArray %27 +%_ptr_UniformConstant__runtimearr_27 = OpTypePointer UniformConstant %_runtimearr_27 + %uSamps = OpVariable %_ptr_UniformConstant__runtimearr_27 UniformConstant + %int_40 = OpConstant %int 40 +%_ptr_UniformConstant_27 = OpTypePointer UniformConstant %27 + %38 = OpTypeSampledImage %16 + %v2float = OpTypeVector %float 2 +%_ptr_Input_v2float = OpTypePointer Input %v2float + %vUV = OpVariable %_ptr_Input_v2float Input +%_runtimearr_38 = OpTypeRuntimeArray %38 +%_ptr_UniformConstant__runtimearr_38 = OpTypePointer UniformConstant %_runtimearr_38 +%uCombinedSamplers = OpVariable %_ptr_UniformConstant__runtimearr_38 UniformConstant +%_ptr_UniformConstant_38 = OpTypePointer UniformConstant %38 + %uint = OpTypeInt 32 0 + %uint_64 = OpConstant %uint 64 +%_arr_v4float_uint_64 = OpTypeArray %v4float %uint_64 + %UBO = OpTypeStruct %_arr_v4float_uint_64 +%_runtimearr_UBO = OpTypeRuntimeArray %UBO +%_ptr_Uniform__runtimearr_UBO = OpTypePointer Uniform %_runtimearr_UBO + %ubos = OpVariable %_ptr_Uniform__runtimearr_UBO Uniform + %int_20 = OpConstant %int 20 + %int_0 = OpConstant %int 0 +%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float +%_runtimearr_v4float = OpTypeRuntimeArray %v4float + %SSBO = OpTypeStruct %_runtimearr_v4float +%_runtimearr_SSBO = OpTypeRuntimeArray %SSBO +%_ptr_Uniform__runtimearr_SSBO = OpTypePointer Uniform %_runtimearr_SSBO + %ssbos = OpVariable %_ptr_Uniform__runtimearr_SSBO Uniform + %int_50 = OpConstant %int 50 + %int_60 = OpConstant %int 60 + %main = OpFunction %void None %3 + %5 = OpLabel + %i = OpVariable %_ptr_Function_int Function + %11 = OpLoad %int %vIndex + OpStore %i %11 + %20 = OpLoad %int %i + %22 = OpIAdd %int %20 %int_10 + %23 = OpCopyObject %int %22 + %25 = OpAccessChain %_ptr_UniformConstant_16 %uSamplers %23 + %26 = OpLoad %16 %25 + %31 = OpLoad %int %i + %33 = OpIAdd %int %31 %int_40 + %34 = OpCopyObject %int %33 + %36 = OpAccessChain %_ptr_UniformConstant_27 %uSamps %34 + %37 = OpLoad %27 %36 + %sampled_image = OpSampledImage %38 %26 %37 + %43 = OpLoad %v2float %vUV + %44 = OpImageSampleImplicitLod %v4float %sampled_image %43 + OpStore %FragColor %44 + %48 = OpLoad %int %i + %49 = OpIAdd %int %48 %int_10 + %50 = OpCopyObject %int %49 + %52 = OpAccessChain %_ptr_UniformConstant_38 %uCombinedSamplers %50 + %combined_sampler = OpLoad %38 %52 + %54 = OpLoad %v2float %vUV + %55 = OpImageSampleImplicitLod %v4float %combined_sampler %54 + OpStore %FragColor %55 + %63 = OpLoad %int %i + %65 = OpIAdd %int %63 %int_20 + %66 = OpCopyObject %int %65 + %68 = OpLoad %int %i + %69 = OpIAdd %int %68 %int_40 + %70 = OpCopyObject %int %69 + %ubo_ptr = OpAccessChain %_ptr_Uniform_v4float %ubos %66 %int_0 %70 + %ubo_ptr_copy = OpCopyObject %_ptr_Uniform_v4float %ubo_ptr + %73 = OpLoad %v4float %ubo_ptr_copy + %74 = OpLoad %v4float %FragColor + %75 = OpFAdd %v4float %74 %73 + OpStore %FragColor %75 + %81 = OpLoad %int %i + %83 = OpIAdd %int %81 %int_50 + %84 = OpCopyObject %int %83 + %85 = OpLoad %int %i + %87 = OpIAdd %int %85 %int_60 + %88 = OpCopyObject %int %87 + %ssbo_ptr = OpAccessChain %_ptr_Uniform_v4float %ssbos %84 %int_0 %88 + %ssbo_ptr_copy = OpCopyObject %_ptr_Uniform_v4float %ssbo_ptr + %90 = OpLoad %v4float %ssbo_ptr_copy + %91 = OpLoad %v4float %FragColor + %92 = OpFAdd %v4float %91 %90 + OpStore %FragColor %92 + OpReturn + OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.frag b/deps/SPIRV-Cross/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.frag new file mode 100644 index 0000000000..ae7a972d7b --- /dev/null +++ b/deps/SPIRV-Cross/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.frag @@ -0,0 +1,46 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 7 +; Bound: 25 +; Schema: 0 + OpCapability Shader + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor %UV + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpSourceExtension "GL_EXT_shader_explicit_arithmetic_types_float16" + OpName %main "main" + OpName %FragColor "FragColor" + OpName %uTexture "uTexture" + OpName %UV "UV" + OpDecorate %FragColor Location 0 + OpDecorate %uTexture DescriptorSet 0 + OpDecorate %uTexture Binding 0 + OpDecorate %UV Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %half = OpTypeFloat 16 + %float = OpTypeFloat 32 + %v4half = OpTypeVector %half 4 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4half = OpTypePointer Output %v4half + %FragColor = OpVariable %_ptr_Output_v4half Output + %11 = OpTypeImage %float 2D 0 0 0 1 Unknown + %12 = OpTypeSampledImage %11 +%_ptr_UniformConstant_12 = OpTypePointer UniformConstant %12 + %uTexture = OpVariable %_ptr_UniformConstant_12 UniformConstant + %v2half = OpTypeVector %half 2 +%_ptr_Input_v2half = OpTypePointer Input %v2half + %UV = OpVariable %_ptr_Input_v2half Input + %main = OpFunction %void None %3 + %5 = OpLabel + %15 = OpLoad %12 %uTexture + %19 = OpLoad %v2half %UV + %23 = OpImageSampleImplicitLod %v4float %15 %19 + %24 = OpFConvert %v4half %23 + OpStore %FragColor %24 + OpReturn + OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-hlsl/comp/outer-product.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/outer-product.comp new file mode 100644 index 0000000000..9aba2a54b7 --- /dev/null +++ b/deps/SPIRV-Cross/shaders-hlsl/comp/outer-product.comp @@ -0,0 +1,37 @@ +#version 450 +layout(local_size_x = 1) in; + +layout(set = 0, binding = 0, std430) writeonly buffer SSBO +{ + mat2 m22; + mat2x3 m23; + mat2x4 m24; + mat3x2 m32; + mat3 m33; + mat3x4 m34; + mat4x2 m42; + mat4x3 m43; + mat4 m44; +}; + +layout(set = 0, binding = 1, std430) readonly buffer ReadSSBO +{ + vec2 v2; + vec3 v3; + vec4 v4; +}; + +void main() +{ + m22 = outerProduct(v2, v2); + m23 = outerProduct(v3, v2); + m24 = outerProduct(v4, v2); + + m32 = outerProduct(v2, v3); + m33 = outerProduct(v3, v3); + m34 = outerProduct(v4, v3); + + m42 = outerProduct(v2, v4); + m43 = outerProduct(v3, v4); + m44 = outerProduct(v4, v4); +} diff --git a/deps/SPIRV-Cross/shaders-hlsl/comp/scalar-std450-distance-length-normalize.comp b/deps/SPIRV-Cross/shaders-hlsl/comp/scalar-std450-distance-length-normalize.comp new file mode 100644 index 0000000000..37414737fd --- /dev/null +++ b/deps/SPIRV-Cross/shaders-hlsl/comp/scalar-std450-distance-length-normalize.comp @@ -0,0 +1,18 @@ +#version 450 +layout(local_size_x = 1) in; + +layout(std430, set = 0, binding = 0) buffer SSBO +{ + float a; + float b; + float c; + float d; + float e; +}; + +void main() +{ + c = distance(a, b); + d = length(a); + e = normalize(a); +} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/for-loop-continue-control-flow.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/for-loop-continue-control-flow.frag new file mode 100644 index 0000000000..1f91cca2a4 --- /dev/null +++ b/deps/SPIRV-Cross/shaders-hlsl/frag/for-loop-continue-control-flow.frag @@ -0,0 +1,11 @@ +#version 450 +layout(location = 0) out vec4 FragColor; +void main() +{ + FragColor = vec4(0.0); + for (int i = 0; i < 3; (0 > 1) ? 1 : i ++) + { + int a = i; + FragColor[a] += float(i); + } +} diff --git a/deps/SPIRV-Cross/shaders-hlsl/frag/scalar-refract-reflect.frag b/deps/SPIRV-Cross/shaders-hlsl/frag/scalar-refract-reflect.frag new file mode 100644 index 0000000000..486ed90bd5 --- /dev/null +++ b/deps/SPIRV-Cross/shaders-hlsl/frag/scalar-refract-reflect.frag @@ -0,0 +1,11 @@ +#version 450 +layout(location = 0) out float FragColor; +layout(location = 0) in vec3 vRefract; + +void main() +{ + FragColor = refract(vRefract.x, vRefract.y, vRefract.z); + FragColor += reflect(vRefract.x, vRefract.y); + FragColor += refract(vRefract.xy, vRefract.yz, vRefract.z).y; + FragColor += reflect(vRefract.xy, vRefract.zy).y; +} diff --git a/deps/SPIRV-Cross/shaders-msl/asm/frag/texture-sampling-fp16.asm.frag b/deps/SPIRV-Cross/shaders-msl/asm/frag/texture-sampling-fp16.asm.frag new file mode 100644 index 0000000000..ae7a972d7b --- /dev/null +++ b/deps/SPIRV-Cross/shaders-msl/asm/frag/texture-sampling-fp16.asm.frag @@ -0,0 +1,46 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 7 +; Bound: 25 +; Schema: 0 + OpCapability Shader + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor %UV + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpSourceExtension "GL_EXT_shader_explicit_arithmetic_types_float16" + OpName %main "main" + OpName %FragColor "FragColor" + OpName %uTexture "uTexture" + OpName %UV "UV" + OpDecorate %FragColor Location 0 + OpDecorate %uTexture DescriptorSet 0 + OpDecorate %uTexture Binding 0 + OpDecorate %UV Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %half = OpTypeFloat 16 + %float = OpTypeFloat 32 + %v4half = OpTypeVector %half 4 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4half = OpTypePointer Output %v4half + %FragColor = OpVariable %_ptr_Output_v4half Output + %11 = OpTypeImage %float 2D 0 0 0 1 Unknown + %12 = OpTypeSampledImage %11 +%_ptr_UniformConstant_12 = OpTypePointer UniformConstant %12 + %uTexture = OpVariable %_ptr_UniformConstant_12 UniformConstant + %v2half = OpTypeVector %half 2 +%_ptr_Input_v2half = OpTypePointer Input %v2half + %UV = OpVariable %_ptr_Input_v2half Input + %main = OpFunction %void None %3 + %5 = OpLabel + %15 = OpLoad %12 %uTexture + %19 = OpLoad %v2half %UV + %23 = OpImageSampleImplicitLod %v4float %15 %19 + %24 = OpFConvert %v4half %23 + OpStore %FragColor %24 + OpReturn + OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders-msl/comp/outer-product.comp b/deps/SPIRV-Cross/shaders-msl/comp/outer-product.comp new file mode 100644 index 0000000000..9aba2a54b7 --- /dev/null +++ b/deps/SPIRV-Cross/shaders-msl/comp/outer-product.comp @@ -0,0 +1,37 @@ +#version 450 +layout(local_size_x = 1) in; + +layout(set = 0, binding = 0, std430) writeonly buffer SSBO +{ + mat2 m22; + mat2x3 m23; + mat2x4 m24; + mat3x2 m32; + mat3 m33; + mat3x4 m34; + mat4x2 m42; + mat4x3 m43; + mat4 m44; +}; + +layout(set = 0, binding = 1, std430) readonly buffer ReadSSBO +{ + vec2 v2; + vec3 v3; + vec4 v4; +}; + +void main() +{ + m22 = outerProduct(v2, v2); + m23 = outerProduct(v3, v2); + m24 = outerProduct(v4, v2); + + m32 = outerProduct(v2, v3); + m33 = outerProduct(v3, v3); + m34 = outerProduct(v4, v3); + + m42 = outerProduct(v2, v4); + m43 = outerProduct(v3, v4); + m44 = outerProduct(v4, v4); +} diff --git a/deps/SPIRV-Cross/shaders-msl/comp/scalar-std450-distance-length-normalize.comp b/deps/SPIRV-Cross/shaders-msl/comp/scalar-std450-distance-length-normalize.comp new file mode 100644 index 0000000000..37414737fd --- /dev/null +++ b/deps/SPIRV-Cross/shaders-msl/comp/scalar-std450-distance-length-normalize.comp @@ -0,0 +1,18 @@ +#version 450 +layout(local_size_x = 1) in; + +layout(std430, set = 0, binding = 0) buffer SSBO +{ + float a; + float b; + float c; + float d; + float e; +}; + +void main() +{ + c = distance(a, b); + d = length(a); + e = normalize(a); +} diff --git a/deps/SPIRV-Cross/shaders-msl/frag/for-loop-continue-control-flow.frag b/deps/SPIRV-Cross/shaders-msl/frag/for-loop-continue-control-flow.frag new file mode 100644 index 0000000000..1f91cca2a4 --- /dev/null +++ b/deps/SPIRV-Cross/shaders-msl/frag/for-loop-continue-control-flow.frag @@ -0,0 +1,11 @@ +#version 450 +layout(location = 0) out vec4 FragColor; +void main() +{ + FragColor = vec4(0.0); + for (int i = 0; i < 3; (0 > 1) ? 1 : i ++) + { + int a = i; + FragColor[a] += float(i); + } +} diff --git a/deps/SPIRV-Cross/shaders-msl/frag/scalar-refract-reflect.frag b/deps/SPIRV-Cross/shaders-msl/frag/scalar-refract-reflect.frag new file mode 100644 index 0000000000..486ed90bd5 --- /dev/null +++ b/deps/SPIRV-Cross/shaders-msl/frag/scalar-refract-reflect.frag @@ -0,0 +1,11 @@ +#version 450 +layout(location = 0) out float FragColor; +layout(location = 0) in vec3 vRefract; + +void main() +{ + FragColor = refract(vRefract.x, vRefract.y, vRefract.z); + FragColor += reflect(vRefract.x, vRefract.y); + FragColor += refract(vRefract.xy, vRefract.yz, vRefract.z).y; + FragColor += reflect(vRefract.xy, vRefract.zy).y; +} diff --git a/deps/SPIRV-Cross/shaders-msl/frag/subgroup-builtins.msl22.frag b/deps/SPIRV-Cross/shaders-msl/frag/subgroup-builtins.msl22.frag new file mode 100644 index 0000000000..746438f00f --- /dev/null +++ b/deps/SPIRV-Cross/shaders-msl/frag/subgroup-builtins.msl22.frag @@ -0,0 +1,10 @@ +#version 450 +#extension GL_KHR_shader_subgroup_basic : require + +layout(location = 0) out uvec2 FragColor; + +void main() +{ + FragColor.x = gl_SubgroupSize; + FragColor.y = gl_SubgroupInvocationID; +} diff --git a/deps/SPIRV-Cross/shaders-msl/vulkan/comp/struct-packing-scalar.nocompat.invalid.vk.comp b/deps/SPIRV-Cross/shaders-msl/vulkan/comp/struct-packing-scalar.nocompat.invalid.vk.comp new file mode 100644 index 0000000000..a0898cfc54 --- /dev/null +++ b/deps/SPIRV-Cross/shaders-msl/vulkan/comp/struct-packing-scalar.nocompat.invalid.vk.comp @@ -0,0 +1,99 @@ +#version 310 es +#extension GL_EXT_scalar_block_layout : require + +layout(local_size_x = 1) in; + +struct S0 +{ + vec2 a[1]; + float b; +}; + +struct S1 +{ + vec3 a; + float b; +}; + +struct S2 +{ + vec3 a[1]; + float b; +}; + +struct S3 +{ + vec2 a; + float b; +}; + +struct S4 +{ + vec2 c; +}; + +struct Content +{ + S0 m0s[1]; + S1 m1s[1]; + S2 m2s[1]; + S0 m0; + S1 m1; + S2 m2; + S3 m3; + float m4; + + S4 m3s[8]; +}; + +layout(binding = 2, scalar) restrict buffer SSBO2 +{ + float m0; + mat2 m1; + layout(row_major) mat3x2 m2; +} ssbo_scalar2; + +layout(binding = 1, scalar) restrict buffer SSBO1 +{ + Content content; + Content content1[2]; + Content content2; + + layout(column_major) mat2 m0; + layout(column_major) mat2 m1; + layout(column_major) mat2x3 m2[4]; + layout(column_major) mat3x2 m3; + layout(row_major) mat2 m4; + layout(row_major) mat2 m5[9]; + layout(row_major) mat2x3 m6[4][2]; + layout(row_major) mat3x2 m7; + float array[]; +} ssbo_scalar; + +layout(binding = 0, std140) restrict buffer SSBO0 +{ + Content content; + Content content1[2]; + Content content2; + + layout(column_major) mat2 m0; + layout(column_major) mat2 m1; + layout(column_major) mat2x3 m2[4]; + layout(column_major) mat3x2 m3; + layout(row_major) mat2 m4; + layout(row_major) mat2 m5[9]; + layout(row_major) mat2x3 m6[4][2]; + layout(row_major) mat3x2 m7; + + float array[]; +} ssbo_140; + +void main() +{ + ssbo_scalar.content = ssbo_140.content; + ssbo_scalar.content.m1.a = ssbo_scalar.m2[1] * ssbo_scalar.content.m0.a[0]; // test packed matrix access + ssbo_scalar.m0 = ssbo_scalar2.m1; + ssbo_scalar2.m1 = ssbo_scalar.m4; + ssbo_scalar2.m2 = ssbo_scalar.m3; +} + diff --git a/deps/SPIRV-Cross/shaders-msl/vulkan/frag/basic.multiview.nocompat.vk.frag b/deps/SPIRV-Cross/shaders-msl/vulkan/frag/basic.multiview.nocompat.vk.frag new file mode 100644 index 0000000000..963493b871 --- /dev/null +++ b/deps/SPIRV-Cross/shaders-msl/vulkan/frag/basic.multiview.nocompat.vk.frag @@ -0,0 +1,14 @@ +#version 310 es +#extension GL_EXT_multiview : require +precision mediump float; + +layout(location = 0) in vec4 vColor; +layout(location = 1) in vec2 vTex[4]; +layout(binding = 0) uniform sampler2D uTex; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vColor * texture(uTex, vTex[gl_ViewIndex]); +} + diff --git a/deps/SPIRV-Cross/shaders-msl/vulkan/frag/scalar-block-layout-ubo-std430.vk.nocompat.invalid.frag b/deps/SPIRV-Cross/shaders-msl/vulkan/frag/scalar-block-layout-ubo-std430.vk.nocompat.invalid.frag new file mode 100644 index 0000000000..56e809c0b3 --- /dev/null +++ b/deps/SPIRV-Cross/shaders-msl/vulkan/frag/scalar-block-layout-ubo-std430.vk.nocompat.invalid.frag @@ -0,0 +1,23 @@ +#version 450 +#extension GL_EXT_scalar_block_layout : require + +layout(std430, binding = 0) uniform UBO +{ + float a[1]; + vec2 b[2]; +}; + +layout(std430, binding = 1) uniform UBOEnhancedLayout +{ + float c[1]; + vec2 d[2]; + layout(offset = 10000) float e; +}; + +layout(location = 0) flat in int vIndex; +layout(location = 0) out float FragColor; + +void main() +{ + FragColor = a[vIndex] + c[vIndex] + e; +} diff --git a/deps/SPIRV-Cross/shaders-msl/vulkan/frag/subgroups.nocompat.invalid.vk.msl21.frag b/deps/SPIRV-Cross/shaders-msl/vulkan/frag/subgroups.nocompat.invalid.vk.msl21.frag new file mode 100644 index 0000000000..3a2cf0234c --- /dev/null +++ b/deps/SPIRV-Cross/shaders-msl/vulkan/frag/subgroups.nocompat.invalid.vk.msl21.frag @@ -0,0 +1,119 @@ +#version 450 +#extension GL_KHR_shader_subgroup_basic : require +#extension GL_KHR_shader_subgroup_ballot : require +#extension GL_KHR_shader_subgroup_vote : require +#extension GL_KHR_shader_subgroup_shuffle : require +#extension GL_KHR_shader_subgroup_shuffle_relative : require +#extension GL_KHR_shader_subgroup_arithmetic : require +#extension GL_KHR_shader_subgroup_clustered : require +#extension GL_KHR_shader_subgroup_quad : require + +layout(location = 0) out float FragColor; + +void main() +{ + // basic + FragColor = float(gl_SubgroupSize); + FragColor = float(gl_SubgroupInvocationID); + subgroupBarrier(); + subgroupMemoryBarrier(); + subgroupMemoryBarrierBuffer(); + subgroupMemoryBarrierImage(); + bool elected = subgroupElect(); + + // ballot + FragColor = float(gl_SubgroupEqMask); + FragColor = float(gl_SubgroupGeMask); + FragColor = float(gl_SubgroupGtMask); + FragColor = float(gl_SubgroupLeMask); + FragColor = float(gl_SubgroupLtMask); + vec4 broadcasted = subgroupBroadcast(vec4(10.0), 8u); + vec3 first = subgroupBroadcastFirst(vec3(20.0)); + uvec4 ballot_value = subgroupBallot(true); + bool inverse_ballot_value = subgroupInverseBallot(ballot_value); + bool bit_extracted = subgroupBallotBitExtract(uvec4(10u), 8u); + uint bit_count = subgroupBallotBitCount(ballot_value); + uint inclusive_bit_count = subgroupBallotInclusiveBitCount(ballot_value); + uint exclusive_bit_count = subgroupBallotExclusiveBitCount(ballot_value); + uint lsb = subgroupBallotFindLSB(ballot_value); + uint msb = subgroupBallotFindMSB(ballot_value); + + // shuffle + uint shuffled = subgroupShuffle(10u, 8u); + uint shuffled_xor = subgroupShuffleXor(30u, 8u); + + // shuffle relative + uint shuffled_up = subgroupShuffleUp(20u, 4u); + uint shuffled_down = subgroupShuffleDown(20u, 4u); + + // vote + bool has_all = subgroupAll(true); + bool has_any = subgroupAny(true); + bool has_equal = subgroupAllEqual(0); + has_equal = subgroupAllEqual(true); + + // arithmetic + vec4 added = subgroupAdd(vec4(20.0)); + ivec4 iadded = subgroupAdd(ivec4(20)); + vec4 multiplied = subgroupMul(vec4(20.0)); + ivec4 imultiplied = subgroupMul(ivec4(20)); + vec4 lo = subgroupMin(vec4(20.0)); + vec4 hi = subgroupMax(vec4(20.0)); + ivec4 slo = subgroupMin(ivec4(20)); + ivec4 shi = subgroupMax(ivec4(20)); + uvec4 ulo = subgroupMin(uvec4(20)); + uvec4 uhi = subgroupMax(uvec4(20)); + uvec4 anded = subgroupAnd(ballot_value); + uvec4 ored = subgroupOr(ballot_value); + uvec4 xored = subgroupXor(ballot_value); + + added = subgroupInclusiveAdd(added); + iadded = subgroupInclusiveAdd(iadded); + multiplied = subgroupInclusiveMul(multiplied); + imultiplied = subgroupInclusiveMul(imultiplied); + //lo = subgroupInclusiveMin(lo); // FIXME: Unsupported by Metal + //hi = subgroupInclusiveMax(hi); + //slo = subgroupInclusiveMin(slo); + //shi = subgroupInclusiveMax(shi); + //ulo = subgroupInclusiveMin(ulo); + //uhi = subgroupInclusiveMax(uhi); + //anded = subgroupInclusiveAnd(anded); + //ored = subgroupInclusiveOr(ored); + //xored = subgroupInclusiveXor(ored); + //added = subgroupExclusiveAdd(lo); + + added = subgroupExclusiveAdd(multiplied); + multiplied = subgroupExclusiveMul(multiplied); + iadded = subgroupExclusiveAdd(imultiplied); + imultiplied = subgroupExclusiveMul(imultiplied); + //lo = subgroupExclusiveMin(lo); // FIXME: Unsupported by Metal + //hi = subgroupExclusiveMax(hi); + //ulo = subgroupExclusiveMin(ulo); + //uhi = subgroupExclusiveMax(uhi); + //slo = subgroupExclusiveMin(slo); + //shi = subgroupExclusiveMax(shi); + //anded = subgroupExclusiveAnd(anded); + //ored = subgroupExclusiveOr(ored); + //xored = subgroupExclusiveXor(ored); + + // clustered + added = subgroupClusteredAdd(added, 4u); + multiplied = subgroupClusteredMul(multiplied, 4u); + iadded = subgroupClusteredAdd(iadded, 4u); + imultiplied = subgroupClusteredMul(imultiplied, 4u); + lo = subgroupClusteredMin(lo, 4u); + hi = subgroupClusteredMax(hi, 4u); + ulo = subgroupClusteredMin(ulo, 4u); + uhi = subgroupClusteredMax(uhi, 4u); + slo = subgroupClusteredMin(slo, 4u); + shi = subgroupClusteredMax(shi, 4u); + anded = subgroupClusteredAnd(anded, 4u); + ored = subgroupClusteredOr(ored, 4u); + xored = subgroupClusteredXor(xored, 4u); + + // quad + vec4 swap_horiz = subgroupQuadSwapHorizontal(vec4(20.0)); + vec4 swap_vertical = subgroupQuadSwapVertical(vec4(20.0)); + vec4 swap_diagonal = subgroupQuadSwapDiagonal(vec4(20.0)); + vec4 quad_broadcast = subgroupQuadBroadcast(vec4(20.0), 3u); +} diff --git a/deps/SPIRV-Cross/shaders-msl/vulkan/vert/multiview.multiview.nocompat.vk.vert b/deps/SPIRV-Cross/shaders-msl/vulkan/vert/multiview.multiview.nocompat.vk.vert new file mode 100644 index 0000000000..eb1bc766f2 --- /dev/null +++ b/deps/SPIRV-Cross/shaders-msl/vulkan/vert/multiview.multiview.nocompat.vk.vert @@ -0,0 +1,14 @@ +#version 310 es +#extension GL_EXT_multiview : require + +layout(std140, binding = 0) uniform MVPs +{ + mat4 MVP[2]; +}; + +layout(location = 0) in vec4 Position; + +void main() +{ + gl_Position = MVP[gl_ViewIndex] * Position; +} diff --git a/deps/SPIRV-Cross/shaders-msl/vulkan/vert/multiview.nocompat.vk.vert b/deps/SPIRV-Cross/shaders-msl/vulkan/vert/multiview.nocompat.vk.vert new file mode 100644 index 0000000000..eb1bc766f2 --- /dev/null +++ b/deps/SPIRV-Cross/shaders-msl/vulkan/vert/multiview.nocompat.vk.vert @@ -0,0 +1,14 @@ +#version 310 es +#extension GL_EXT_multiview : require + +layout(std140, binding = 0) uniform MVPs +{ + mat4 MVP[2]; +}; + +layout(location = 0) in vec4 Position; + +void main() +{ + gl_Position = MVP[gl_ViewIndex] * Position; +} diff --git a/deps/SPIRV-Cross/shaders-no-opt/asm/frag/nonuniform-qualifier-propagation.vk.nocompat.asm.frag b/deps/SPIRV-Cross/shaders-no-opt/asm/frag/nonuniform-qualifier-propagation.vk.nocompat.asm.frag new file mode 100644 index 0000000000..e2d4562a8a --- /dev/null +++ b/deps/SPIRV-Cross/shaders-no-opt/asm/frag/nonuniform-qualifier-propagation.vk.nocompat.asm.frag @@ -0,0 +1,159 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 7 +; Bound: 93 +; Schema: 0 + OpCapability Shader + OpCapability ShaderNonUniformEXT + OpCapability RuntimeDescriptorArrayEXT + OpCapability UniformBufferArrayNonUniformIndexingEXT + OpCapability SampledImageArrayNonUniformIndexingEXT + OpCapability StorageBufferArrayNonUniformIndexingEXT + OpExtension "SPV_EXT_descriptor_indexing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %vIndex %FragColor %vUV + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpSourceExtension "GL_EXT_nonuniform_qualifier" + OpName %main "main" + OpName %i "i" + OpName %vIndex "vIndex" + OpName %FragColor "FragColor" + OpName %uSamplers "uSamplers" + OpName %uSamps "uSamps" + OpName %vUV "vUV" + OpName %uCombinedSamplers "uCombinedSamplers" + OpName %UBO "UBO" + OpMemberName %UBO 0 "v" + OpName %ubos "ubos" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "v" + OpName %ssbos "ssbos" + OpDecorate %vIndex Flat + OpDecorate %vIndex Location 0 + OpDecorate %FragColor Location 0 + OpDecorate %uSamplers DescriptorSet 0 + OpDecorate %uSamplers Binding 0 + + OpDecorate %sampled_image NonUniformEXT + OpDecorate %combined_sampler NonUniformEXT + OpDecorate %ubo_ptr_copy NonUniformEXT + OpDecorate %ssbo_ptr_copy NonUniformEXT + + OpDecorate %uSamps DescriptorSet 0 + OpDecorate %uSamps Binding 1 + OpDecorate %vUV Location 1 + OpDecorate %uCombinedSamplers DescriptorSet 0 + OpDecorate %uCombinedSamplers Binding 4 + OpDecorate %_arr_v4float_uint_64 ArrayStride 16 + OpMemberDecorate %UBO 0 Offset 0 + OpDecorate %UBO Block + OpDecorate %ubos DescriptorSet 0 + OpDecorate %ubos Binding 2 + OpDecorate %_runtimearr_v4float ArrayStride 16 + OpMemberDecorate %SSBO 0 NonWritable + OpMemberDecorate %SSBO 0 Offset 0 + OpDecorate %SSBO BufferBlock + OpDecorate %ssbos DescriptorSet 0 + OpDecorate %ssbos Binding 3 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %int = OpTypeInt 32 1 +%_ptr_Function_int = OpTypePointer Function %int +%_ptr_Input_int = OpTypePointer Input %int + %vIndex = OpVariable %_ptr_Input_int Input + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %FragColor = OpVariable %_ptr_Output_v4float Output + %16 = OpTypeImage %float 2D 0 0 0 1 Unknown +%_runtimearr_16 = OpTypeRuntimeArray %16 +%_ptr_UniformConstant__runtimearr_16 = OpTypePointer UniformConstant %_runtimearr_16 + %uSamplers = OpVariable %_ptr_UniformConstant__runtimearr_16 UniformConstant + %int_10 = OpConstant %int 10 +%_ptr_UniformConstant_16 = OpTypePointer UniformConstant %16 + %27 = OpTypeSampler +%_runtimearr_27 = OpTypeRuntimeArray %27 +%_ptr_UniformConstant__runtimearr_27 = OpTypePointer UniformConstant %_runtimearr_27 + %uSamps = OpVariable %_ptr_UniformConstant__runtimearr_27 UniformConstant + %int_40 = OpConstant %int 40 +%_ptr_UniformConstant_27 = OpTypePointer UniformConstant %27 + %38 = OpTypeSampledImage %16 + %v2float = OpTypeVector %float 2 +%_ptr_Input_v2float = OpTypePointer Input %v2float + %vUV = OpVariable %_ptr_Input_v2float Input +%_runtimearr_38 = OpTypeRuntimeArray %38 +%_ptr_UniformConstant__runtimearr_38 = OpTypePointer UniformConstant %_runtimearr_38 +%uCombinedSamplers = OpVariable %_ptr_UniformConstant__runtimearr_38 UniformConstant +%_ptr_UniformConstant_38 = OpTypePointer UniformConstant %38 + %uint = OpTypeInt 32 0 + %uint_64 = OpConstant %uint 64 +%_arr_v4float_uint_64 = OpTypeArray %v4float %uint_64 + %UBO = OpTypeStruct %_arr_v4float_uint_64 +%_runtimearr_UBO = OpTypeRuntimeArray %UBO +%_ptr_Uniform__runtimearr_UBO = OpTypePointer Uniform %_runtimearr_UBO + %ubos = OpVariable %_ptr_Uniform__runtimearr_UBO Uniform + %int_20 = OpConstant %int 20 + %int_0 = OpConstant %int 0 +%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float +%_runtimearr_v4float = OpTypeRuntimeArray %v4float + %SSBO = OpTypeStruct %_runtimearr_v4float +%_runtimearr_SSBO = OpTypeRuntimeArray %SSBO +%_ptr_Uniform__runtimearr_SSBO = OpTypePointer Uniform %_runtimearr_SSBO + %ssbos = OpVariable %_ptr_Uniform__runtimearr_SSBO Uniform + %int_50 = OpConstant %int 50 + %int_60 = OpConstant %int 60 + %main = OpFunction %void None %3 + %5 = OpLabel + %i = OpVariable %_ptr_Function_int Function + %11 = OpLoad %int %vIndex + OpStore %i %11 + %20 = OpLoad %int %i + %22 = OpIAdd %int %20 %int_10 + %23 = OpCopyObject %int %22 + %25 = OpAccessChain %_ptr_UniformConstant_16 %uSamplers %23 + %26 = OpLoad %16 %25 + %31 = OpLoad %int %i + %33 = OpIAdd %int %31 %int_40 + %34 = OpCopyObject %int %33 + %36 = OpAccessChain %_ptr_UniformConstant_27 %uSamps %34 + %37 = OpLoad %27 %36 + %sampled_image = OpSampledImage %38 %26 %37 + %43 = OpLoad %v2float %vUV + %44 = OpImageSampleImplicitLod %v4float %sampled_image %43 + OpStore %FragColor %44 + %48 = OpLoad %int %i + %49 = OpIAdd %int %48 %int_10 + %50 = OpCopyObject %int %49 + %52 = OpAccessChain %_ptr_UniformConstant_38 %uCombinedSamplers %50 + %combined_sampler = OpLoad %38 %52 + %54 = OpLoad %v2float %vUV + %55 = OpImageSampleImplicitLod %v4float %combined_sampler %54 + OpStore %FragColor %55 + %63 = OpLoad %int %i + %65 = OpIAdd %int %63 %int_20 + %66 = OpCopyObject %int %65 + %68 = OpLoad %int %i + %69 = OpIAdd %int %68 %int_40 + %70 = OpCopyObject %int %69 + %ubo_ptr = OpAccessChain %_ptr_Uniform_v4float %ubos %66 %int_0 %70 + %ubo_ptr_copy = OpCopyObject %_ptr_Uniform_v4float %ubo_ptr + %73 = OpLoad %v4float %ubo_ptr_copy + %74 = OpLoad %v4float %FragColor + %75 = OpFAdd %v4float %74 %73 + OpStore %FragColor %75 + %81 = OpLoad %int %i + %83 = OpIAdd %int %81 %int_50 + %84 = OpCopyObject %int %83 + %85 = OpLoad %int %i + %87 = OpIAdd %int %85 %int_60 + %88 = OpCopyObject %int %87 + %ssbo_ptr = OpAccessChain %_ptr_Uniform_v4float %ssbos %84 %int_0 %88 + %ssbo_ptr_copy = OpCopyObject %_ptr_Uniform_v4float %ssbo_ptr + %90 = OpLoad %v4float %ssbo_ptr_copy + %91 = OpLoad %v4float %FragColor + %92 = OpFAdd %v4float %91 %90 + OpStore %FragColor %92 + OpReturn + OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/comp/phi-temporary-copy-loop-variable.asm.comp b/deps/SPIRV-Cross/shaders/asm/comp/phi-temporary-copy-loop-variable.asm.comp new file mode 100644 index 0000000000..611591246c --- /dev/null +++ b/deps/SPIRV-Cross/shaders/asm/comp/phi-temporary-copy-loop-variable.asm.comp @@ -0,0 +1,68 @@ +; SPIR-V +; Version: 1.0 +; Generator: Google spiregg; 0 +; Bound: 42 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %cs_test "main" %gl_GlobalInvocationID %gl_LocalInvocationIndex + OpExecutionMode %cs_test LocalSize 8 8 1 + OpSource HLSL 600 + OpName %type_2d_image "type.2d.image" + OpName %outImageTexture "outImageTexture" + OpName %cs_test "cs_test" + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex + OpDecorate %outImageTexture DescriptorSet 0 + OpDecorate %outImageTexture Binding 1 + %float = OpTypeFloat 32 + %float_5 = OpConstant %float 5 + %float_1 = OpConstant %float 1 + %int = OpTypeInt 32 1 + %int_7 = OpConstant %int 7 + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %int 1 +%type_2d_image = OpTypeImage %float 2D 2 0 0 2 Rgba32f +%_ptr_UniformConstant_type_2d_image = OpTypePointer UniformConstant %type_2d_image + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint +%_ptr_Input_uint = OpTypePointer Input %uint + %void = OpTypeVoid + %19 = OpTypeFunction %void + %v2uint = OpTypeVector %uint 2 + %v4float = OpTypeVector %float 4 + %bool = OpTypeBool +%outImageTexture = OpVariable %_ptr_UniformConstant_type_2d_image UniformConstant +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input +%gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input + %cs_test = OpFunction %void None %19 + %23 = OpLabel + %24 = OpLoad %v3uint %gl_GlobalInvocationID + %25 = OpVectorShuffle %v2uint %24 %24 0 1 + OpBranch %26 + %26 = OpLabel + %27 = OpPhi %int %int_7 %23 %28 %29 + %30 = OpPhi %int %int_7 %23 %27 %29 + %31 = OpSGreaterThanEqual %bool %27 %int_0 + OpLoopMerge %32 %29 None + OpBranchConditional %31 %33 %32 + %33 = OpLabel + %34 = OpConvertSToF %float %27 + %35 = OpFOrdGreaterThan %bool %float_5 %34 + OpSelectionMerge %29 None + OpBranchConditional %35 %36 %29 + %36 = OpLabel + OpBranch %32 + %29 = OpLabel + %28 = OpISub %int %27 %int_1 + OpBranch %26 + %32 = OpLabel + %37 = OpISub %int %30 %int_1 + %38 = OpConvertSToF %float %37 + %39 = OpConvertSToF %float %30 + %40 = OpCompositeConstruct %v4float %38 %39 %float_1 %float_1 + %41 = OpLoad %type_2d_image %outImageTexture + OpImageWrite %41 %25 %40 None + OpReturn + OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/extended-debug-extinst.invalid.asm.comp b/deps/SPIRV-Cross/shaders/asm/extended-debug-extinst.invalid.asm.comp new file mode 100644 index 0000000000..5b6a189a71 --- /dev/null +++ b/deps/SPIRV-Cross/shaders/asm/extended-debug-extinst.invalid.asm.comp @@ -0,0 +1,67 @@ +; SPIR-V +; Version: 1.3 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 37 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "DebugInfo" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" %3 + OpExecutionMode %2 LocalSize 1 1 1 + %4 = OpString "negateInputs.comp" + %5 = OpString "negateInputs" + %6 = OpString "main" + %7 = OpString "" + OpSource GLSL 430 + OpName %2 "main" + OpName %3 "gl_GlobalInvocationID" + OpDecorate %3 BuiltIn GlobalInvocationId + OpDecorate %8 BufferBlock + OpDecorate %9 DescriptorSet 0 + OpDecorate %9 Binding 0 + OpDecorate %10 DescriptorSet 0 + OpDecorate %10 Binding 1 + OpDecorate %11 ArrayStride 4 + OpMemberDecorate %8 0 Offset 0 + OpLine %4 0 0 + %12 = OpTypeBool + %13 = OpTypeVoid + %14 = OpTypeFunction %13 + %15 = OpTypeInt 32 0 + %16 = OpTypeInt 32 1 + %17 = OpTypeFloat 32 + %18 = OpTypeVector %15 3 + %19 = OpTypeVector %17 3 + %20 = OpTypePointer Input %18 + %21 = OpTypePointer Uniform %16 + %22 = OpTypePointer Uniform %17 + %23 = OpTypeRuntimeArray %16 + %11 = OpTypeRuntimeArray %17 + %8 = OpTypeStruct %11 + %24 = OpTypePointer Uniform %8 + %9 = OpVariable %24 Uniform + %10 = OpVariable %24 Uniform + OpLine %4 0 1 + OpLine %5 1 0 + OpLine %4 1000 100000 + %3 = OpVariable %20 Input + %25 = OpConstant %16 0 + OpNoLine + OpLine %4 1 1 + %26 = OpExtInst %13 %1 DebugInfoNone + %27 = OpExtInst %13 %1 DebugTypeFunction %13 + %28 = OpExtInst %13 %1 DebugFunction %6 %27 %4 1 1 %4 %7 FlagIsDefinition|FlagPrototyped|FlagIsOptimized 1 %26 %26 + %2 = OpFunction %13 None %14 + %29 = OpLabel + %30 = OpExtInst %13 %1 DebugScope %28 + OpLine %4 1 1 + %31 = OpLoad %18 %3 + %32 = OpCompositeExtract %15 %31 0 + %33 = OpAccessChain %22 %9 %25 %32 + %34 = OpLoad %17 %33 + %35 = OpFNegate %17 %34 + %36 = OpAccessChain %22 %10 %25 %32 + OpStore %36 %35 + OpNoLine + OpReturn + OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag b/deps/SPIRV-Cross/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag new file mode 100644 index 0000000000..ae7a972d7b --- /dev/null +++ b/deps/SPIRV-Cross/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag @@ -0,0 +1,46 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 7 +; Bound: 25 +; Schema: 0 + OpCapability Shader + OpCapability StorageInputOutput16 + OpExtension "SPV_KHR_16bit_storage" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor %UV + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpSourceExtension "GL_EXT_shader_explicit_arithmetic_types_float16" + OpName %main "main" + OpName %FragColor "FragColor" + OpName %uTexture "uTexture" + OpName %UV "UV" + OpDecorate %FragColor Location 0 + OpDecorate %uTexture DescriptorSet 0 + OpDecorate %uTexture Binding 0 + OpDecorate %UV Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %half = OpTypeFloat 16 + %float = OpTypeFloat 32 + %v4half = OpTypeVector %half 4 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4half = OpTypePointer Output %v4half + %FragColor = OpVariable %_ptr_Output_v4half Output + %11 = OpTypeImage %float 2D 0 0 0 1 Unknown + %12 = OpTypeSampledImage %11 +%_ptr_UniformConstant_12 = OpTypePointer UniformConstant %12 + %uTexture = OpVariable %_ptr_UniformConstant_12 UniformConstant + %v2half = OpTypeVector %half 2 +%_ptr_Input_v2half = OpTypePointer Input %v2half + %UV = OpVariable %_ptr_Input_v2half Input + %main = OpFunction %void None %3 + %5 = OpLabel + %15 = OpLoad %12 %uTexture + %19 = OpLoad %v2half %UV + %23 = OpImageSampleImplicitLod %v4float %15 %19 + %24 = OpFConvert %v4half %23 + OpStore %FragColor %24 + OpReturn + OpFunctionEnd diff --git a/deps/SPIRV-Cross/shaders/comp/outer-product.comp b/deps/SPIRV-Cross/shaders/comp/outer-product.comp new file mode 100644 index 0000000000..9aba2a54b7 --- /dev/null +++ b/deps/SPIRV-Cross/shaders/comp/outer-product.comp @@ -0,0 +1,37 @@ +#version 450 +layout(local_size_x = 1) in; + +layout(set = 0, binding = 0, std430) writeonly buffer SSBO +{ + mat2 m22; + mat2x3 m23; + mat2x4 m24; + mat3x2 m32; + mat3 m33; + mat3x4 m34; + mat4x2 m42; + mat4x3 m43; + mat4 m44; +}; + +layout(set = 0, binding = 1, std430) readonly buffer ReadSSBO +{ + vec2 v2; + vec3 v3; + vec4 v4; +}; + +void main() +{ + m22 = outerProduct(v2, v2); + m23 = outerProduct(v3, v2); + m24 = outerProduct(v4, v2); + + m32 = outerProduct(v2, v3); + m33 = outerProduct(v3, v3); + m34 = outerProduct(v4, v3); + + m42 = outerProduct(v2, v4); + m43 = outerProduct(v3, v4); + m44 = outerProduct(v4, v4); +} diff --git a/deps/SPIRV-Cross/shaders/comp/scalar-std450-distance-length-normalize.comp b/deps/SPIRV-Cross/shaders/comp/scalar-std450-distance-length-normalize.comp new file mode 100644 index 0000000000..37414737fd --- /dev/null +++ b/deps/SPIRV-Cross/shaders/comp/scalar-std450-distance-length-normalize.comp @@ -0,0 +1,18 @@ +#version 450 +layout(local_size_x = 1) in; + +layout(std430, set = 0, binding = 0) buffer SSBO +{ + float a; + float b; + float c; + float d; + float e; +}; + +void main() +{ + c = distance(a, b); + d = length(a); + e = normalize(a); +} diff --git a/deps/SPIRV-Cross/shaders/frag/for-loop-continue-control-flow.frag b/deps/SPIRV-Cross/shaders/frag/for-loop-continue-control-flow.frag new file mode 100644 index 0000000000..1f91cca2a4 --- /dev/null +++ b/deps/SPIRV-Cross/shaders/frag/for-loop-continue-control-flow.frag @@ -0,0 +1,11 @@ +#version 450 +layout(location = 0) out vec4 FragColor; +void main() +{ + FragColor = vec4(0.0); + for (int i = 0; i < 3; (0 > 1) ? 1 : i ++) + { + int a = i; + FragColor[a] += float(i); + } +} diff --git a/deps/SPIRV-Cross/shaders/frag/scalar-refract-reflect.frag b/deps/SPIRV-Cross/shaders/frag/scalar-refract-reflect.frag new file mode 100644 index 0000000000..486ed90bd5 --- /dev/null +++ b/deps/SPIRV-Cross/shaders/frag/scalar-refract-reflect.frag @@ -0,0 +1,11 @@ +#version 450 +layout(location = 0) out float FragColor; +layout(location = 0) in vec3 vRefract; + +void main() +{ + FragColor = refract(vRefract.x, vRefract.y, vRefract.z); + FragColor += reflect(vRefract.x, vRefract.y); + FragColor += refract(vRefract.xy, vRefract.yz, vRefract.z).y; + FragColor += reflect(vRefract.xy, vRefract.zy).y; +} diff --git a/deps/SPIRV-Cross/shaders/frag/selection-block-dominator.frag b/deps/SPIRV-Cross/shaders/frag/selection-block-dominator.frag new file mode 100644 index 0000000000..257f4e6934 --- /dev/null +++ b/deps/SPIRV-Cross/shaders/frag/selection-block-dominator.frag @@ -0,0 +1,18 @@ +#version 450 +layout(location = 0) out vec4 FragColor; +layout(location = 0) flat in int vIndex; + +void main() +{ + int v; + if (vIndex != 1) + { + FragColor = vec4(1.0); + return; + } + else + { + v = 10; + } + FragColor = vec4(v); +} diff --git a/deps/SPIRV-Cross/spirv_glsl.cpp b/deps/SPIRV-Cross/spirv_glsl.cpp index c207eebf4f..837135cb87 100644 --- a/deps/SPIRV-Cross/spirv_glsl.cpp +++ b/deps/SPIRV-Cross/spirv_glsl.cpp @@ -2886,6 +2886,49 @@ string CompilerGLSL::to_extract_component_expression(uint32_t id, uint32_t index return join(expr, ".", index_to_swizzle(index)); } +string CompilerGLSL::to_rerolled_array_expression(const string &base_expr, const SPIRType &type) +{ + uint32_t size = to_array_size_literal(type); + auto &parent = get(type.parent_type); + string expr = "{ "; + + for (uint32_t i = 0; i < size; i++) + { + auto subexpr = join(base_expr, "[", convert_to_string(i), "]"); + if (parent.array.empty()) + expr += subexpr; + else + expr += to_rerolled_array_expression(subexpr, parent); + + if (i + 1 < size) + expr += ", "; + } + + expr += " }"; + return expr; +} + +string CompilerGLSL::to_composite_constructor_expression(uint32_t id) +{ + auto &type = expression_type(id); + if (!backend.array_is_value_type && !type.array.empty()) + { + // For this case, we need to "re-roll" an array initializer from a temporary. + // We cannot simply pass the array directly, since it decays to a pointer and it cannot + // participate in a struct initializer. E.g. + // float arr[2] = { 1.0, 2.0 }; + // Foo foo = { arr }; must be transformed to + // Foo foo = { { arr[0], arr[1] } }; + // The array sizes cannot be deduced from specialization constants since we cannot use any loops. + + // We're only triggering one read of the array expression, but this is fine since arrays have to be declared + // as temporaries anyways. + return to_rerolled_array_expression(to_enclosed_expression(id), type); + } + else + return to_expression(id); +} + string CompilerGLSL::to_expression(uint32_t id, bool register_expression_read) { auto itr = invalid_expressions.find(id); @@ -5876,13 +5919,38 @@ string CompilerGLSL::bitcast_glsl_op(const SPIRType &out_type, const SPIRType &i // Floating <-> Integer special casts. Just have to enumerate all cases. :( // 16-bit, 32-bit and 64-bit floats. if (out_type.basetype == SPIRType::UInt && in_type.basetype == SPIRType::Float) + { + if (is_legacy_es()) + SPIRV_CROSS_THROW("Float -> Uint bitcast not supported on legacy ESSL."); + else if (!options.es && options.version < 330) + require_extension_internal("GL_ARB_shader_bit_encoding"); return "floatBitsToUint"; + } else if (out_type.basetype == SPIRType::Int && in_type.basetype == SPIRType::Float) + { + if (is_legacy_es()) + SPIRV_CROSS_THROW("Float -> Int bitcast not supported on legacy ESSL."); + else if (!options.es && options.version < 330) + require_extension_internal("GL_ARB_shader_bit_encoding"); return "floatBitsToInt"; + } else if (out_type.basetype == SPIRType::Float && in_type.basetype == SPIRType::UInt) + { + if (is_legacy_es()) + SPIRV_CROSS_THROW("Uint -> Float bitcast not supported on legacy ESSL."); + else if (!options.es && options.version < 330) + require_extension_internal("GL_ARB_shader_bit_encoding"); return "uintBitsToFloat"; + } else if (out_type.basetype == SPIRType::Float && in_type.basetype == SPIRType::Int) + { + if (is_legacy_es()) + SPIRV_CROSS_THROW("Int -> Float bitcast not supported on legacy ESSL."); + else if (!options.es && options.version < 330) + require_extension_internal("GL_ARB_shader_bit_encoding"); return "intBitsToFloat"; + } + else if (out_type.basetype == SPIRType::Int64 && in_type.basetype == SPIRType::Double) return "doubleBitsToInt64"; else if (out_type.basetype == SPIRType::UInt64 && in_type.basetype == SPIRType::Double) @@ -7302,7 +7370,7 @@ string CompilerGLSL::build_composite_combiner(uint32_t return_type, const uint32 if (i) op += ", "; - subop = to_expression(elems[i]); + subop = to_composite_constructor_expression(elems[i]); } base = e ? e->base_expression : 0; @@ -7858,15 +7926,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) forward = false; string constructor_op; - if (!backend.array_is_value_type && out_type.array.size() > 1) - { - // We cannot construct array of arrays because we cannot treat the inputs - // as value types. Need to declare the array-of-arrays, and copy in elements one by one. - emit_uninitialized_temporary_expression(result_type, id); - for (uint32_t i = 0; i < length; i++) - emit_array_copy(join(to_expression(id), "[", i, "]"), elems[i]); - } - else if (backend.use_initializer_list && composite) + if (backend.use_initializer_list && composite) { // Only use this path if we are building composites. // This path cannot be used for arithmetic. @@ -11922,6 +11982,11 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block) uint32_t var = block.dominated_variables[i]; get(var).deferred_declaration = rearm_dominated_variables[i]; } + + // Just like for deferred declaration, we need to forget about loop variable enable + // if our block chain is reinstantiated later. + for (auto &var_id : block.loop_variables) + get(var_id).loop_variable_enable = false; } void CompilerGLSL::begin_scope() diff --git a/deps/SPIRV-Cross/spirv_glsl.hpp b/deps/SPIRV-Cross/spirv_glsl.hpp index a6fac92662..e1eb39bf7a 100644 --- a/deps/SPIRV-Cross/spirv_glsl.hpp +++ b/deps/SPIRV-Cross/spirv_glsl.hpp @@ -502,6 +502,8 @@ protected: SPIRExpression &emit_uninitialized_temporary_expression(uint32_t type, uint32_t id); void append_global_func_args(const SPIRFunction &func, uint32_t index, SmallVector &arglist); std::string to_expression(uint32_t id, bool register_expression_read = true); + std::string to_composite_constructor_expression(uint32_t id); + std::string to_rerolled_array_expression(const std::string &expr, const SPIRType &type); std::string to_enclosed_expression(uint32_t id, bool register_expression_read = true); std::string to_unpacked_expression(uint32_t id, bool register_expression_read = true); std::string to_enclosed_unpacked_expression(uint32_t id, bool register_expression_read = true); diff --git a/deps/SPIRV-Cross/spirv_msl.cpp b/deps/SPIRV-Cross/spirv_msl.cpp index e73d7cc47d..eaee10a049 100644 --- a/deps/SPIRV-Cross/spirv_msl.cpp +++ b/deps/SPIRV-Cross/spirv_msl.cpp @@ -2420,7 +2420,7 @@ void CompilerMSL::align_struct(SPIRType &ib_type) { set_extended_member_decoration(ib_type_id, mbr_idx, SPIRVCrossDecorationPacked); set_extended_member_decoration(ib_type_id, mbr_idx, SPIRVCrossDecorationPackedType, - ib_type.member_types[mbr_idx]); + get_member_packed_type(ib_type, mbr_idx)); } // Align current offset to the current member's default alignment. @@ -2447,7 +2447,7 @@ void CompilerMSL::align_struct(SPIRType &ib_type) // Returns whether the specified struct member supports a packable type // variation that is smaller than the unpacked variation of that type. -bool CompilerMSL::is_member_packable(SPIRType &ib_type, uint32_t index) +bool CompilerMSL::is_member_packable(SPIRType &ib_type, uint32_t index, uint32_t base_offset) { // We've already marked it as packable if (has_extended_member_decoration(ib_type.self, index, SPIRVCrossDecorationPacked)) @@ -2470,30 +2470,81 @@ bool CompilerMSL::is_member_packable(SPIRType &ib_type, uint32_t index) return true; } - // Check for array of struct, where the SPIR-V declares an array stride which is larger than the struct itself. - // This can happen for struct A { float a }; A a[]; in std140 layout. - // TODO: Emit a padded struct which can be used for this purpose. - if (is_array(mbr_type) && mbr_type.basetype == SPIRType::Struct) + uint32_t mbr_offset_curr = base_offset + get_member_decoration(ib_type.self, index, DecorationOffset); + if (mbr_type.basetype == SPIRType::Struct) { + // If this is a struct type, check if any of its members need packing. + for (uint32_t i = 0; i < mbr_type.member_types.size(); i++) + { + if (is_member_packable(mbr_type, i, mbr_offset_curr)) + { + set_extended_member_decoration(mbr_type.self, i, SPIRVCrossDecorationPacked); + set_extended_member_decoration(mbr_type.self, i, SPIRVCrossDecorationPackedType, + get_member_packed_type(mbr_type, i)); + } + } size_t declared_struct_size = get_declared_struct_size(mbr_type); size_t alignment = get_declared_struct_member_alignment(ib_type, index); declared_struct_size = (declared_struct_size + alignment - 1) & ~(alignment - 1); - if (type_struct_member_array_stride(ib_type, index) > declared_struct_size) - return true; + // Check for array of struct, where the SPIR-V declares an array stride which is larger than the struct itself. + // This can happen for struct A { float a }; A a[]; in std140 layout. + // TODO: Emit a padded struct which can be used for this purpose. + if (is_array(mbr_type)) + { + size_t array_stride = type_struct_member_array_stride(ib_type, index); + if (array_stride > declared_struct_size) + return true; + if (array_stride < declared_struct_size) + { + // If the stride is *less* (i.e. more tightly packed), then + // we need to pack the members of the struct itself. + for (uint32_t i = 0; i < mbr_type.member_types.size(); i++) + { + if (is_member_packable(mbr_type, i, mbr_offset_curr + array_stride)) + { + set_extended_member_decoration(mbr_type.self, i, SPIRVCrossDecorationPacked); + set_extended_member_decoration(mbr_type.self, i, SPIRVCrossDecorationPackedType, + get_member_packed_type(mbr_type, i)); + } + } + } + } + else + { + // Pack if there is not enough space between this member and next. + if (index < ib_type.member_types.size() - 1) + { + uint32_t mbr_offset_next = + base_offset + get_member_decoration(ib_type.self, index + 1, DecorationOffset); + if (declared_struct_size > mbr_offset_next - mbr_offset_curr) + { + for (uint32_t i = 0; i < mbr_type.member_types.size(); i++) + { + if (is_member_packable(mbr_type, i, mbr_offset_next)) + { + set_extended_member_decoration(mbr_type.self, i, SPIRVCrossDecorationPacked); + set_extended_member_decoration(mbr_type.self, i, SPIRVCrossDecorationPackedType, + get_member_packed_type(mbr_type, i)); + } + } + } + } + } } // TODO: Another sanity check for matrices. We currently do not support std140 matrices which need to be padded out per column. //if (is_matrix(mbr_type) && mbr_type.vecsize <= 2 && type_struct_member_matrix_stride(ib_type, index) == 16) // SPIRV_CROSS_THROW("Currently cannot support matrices with small vector size in std140 layout."); + // Pack if the member's offset doesn't conform to the type's usual + // alignment. For example, a float3 at offset 4. + if (mbr_offset_curr % get_declared_struct_member_alignment(ib_type, index)) + return true; + // Only vectors or 3-row matrices need to be packed. if (mbr_type.vecsize == 1 || (is_matrix(mbr_type) && mbr_type.vecsize != 3)) return false; - // Only row-major matrices need to be packed. - if (is_matrix(mbr_type) && !has_member_decoration(ib_type.self, index, DecorationRowMajor)) - return false; - if (is_array(mbr_type)) { // If member is an array, and the array stride is larger than the type needs, don't pack it. @@ -2509,16 +2560,11 @@ bool CompilerMSL::is_member_packable(SPIRType &ib_type, uint32_t index) } else { - uint32_t mbr_offset_curr = get_member_decoration(ib_type.self, index, DecorationOffset); - // For vectors, pack if the member's offset doesn't conform to the - // type's usual alignment. For example, a float3 at offset 4. - if (!is_matrix(mbr_type) && (mbr_offset_curr % unpacked_mbr_size)) - return true; // Pack if there is not enough space between this member and next. // If last member, only pack if it's a row-major matrix. if (index < ib_type.member_types.size() - 1) { - uint32_t mbr_offset_next = get_member_decoration(ib_type.self, index + 1, DecorationOffset); + uint32_t mbr_offset_next = base_offset + get_member_decoration(ib_type.self, index + 1, DecorationOffset); return unpacked_mbr_size > mbr_offset_next - mbr_offset_curr; } else @@ -2526,6 +2572,25 @@ bool CompilerMSL::is_member_packable(SPIRType &ib_type, uint32_t index) } } +uint32_t CompilerMSL::get_member_packed_type(SPIRType &type, uint32_t index) +{ + auto &mbr_type = get(type.member_types[index]); + if (is_matrix(mbr_type) && has_member_decoration(type.self, index, DecorationRowMajor)) + { + // Packed row-major matrices are stored transposed. But, we don't know if + // we're dealing with a row-major matrix at the time we need to load it. + // So, we'll set a packed type with the columns and rows transposed, so we'll + // know to use the correct constructor. + uint32_t new_type_id = ir.increase_bound_by(1); + auto &transpose_type = set(new_type_id); + transpose_type = mbr_type; + transpose_type.vecsize = mbr_type.columns; + transpose_type.columns = mbr_type.vecsize; + return new_type_id; + } + return type.member_types[index]; +} + // Returns a combination of type ID and member index for use as hash key MSLStructMemberKey CompilerMSL::get_struct_member_key(uint32_t type_id, uint32_t index) { @@ -2546,19 +2611,51 @@ void CompilerMSL::emit_store_statement(uint32_t lhs_expression, uint32_t rhs_exp { // Special handling when storing to a float[] or float2[] in std140 layout. - auto &type = get(get_extended_decoration(lhs_expression, SPIRVCrossDecorationPackedType)); + uint32_t type_id = get_extended_decoration(lhs_expression, SPIRVCrossDecorationPackedType); + auto &type = get(type_id); string lhs = to_dereferenced_expression(lhs_expression); string rhs = to_pointer_expression(rhs_expression); + uint32_t stride = get_decoration(type_id, DecorationArrayStride); - // Unpack the expression so we can store to it with a float or float2. - // It's still an l-value, so it's fine. Most other unpacking of expressions turn them into r-values instead. - if (is_scalar(type) && is_array(type)) - lhs = enclose_expression(lhs) + ".x"; - else if (is_vector(type) && type.vecsize == 2 && is_array(type)) - lhs = enclose_expression(lhs) + ".xy"; + if (is_matrix(type)) + { + // Packed matrices are stored as arrays of packed vectors, so we need + // to assign the vectors one at a time. + // For row-major matrices, we need to transpose the *right-hand* side, + // not the left-hand side. Otherwise, the changes will be lost. + auto *lhs_e = maybe_get(lhs_expression); + auto *rhs_e = maybe_get(rhs_expression); + bool transpose = lhs_e && lhs_e->need_transpose; + if (transpose) + { + lhs_e->need_transpose = false; + if (rhs_e) rhs_e->need_transpose = !rhs_e->need_transpose; + lhs = to_dereferenced_expression(lhs_expression); + rhs = to_pointer_expression(rhs_expression); + } + for (uint32_t i = 0; i < type.columns; i++) + statement(enclose_expression(lhs), "[", i, "] = ", enclose_expression(rhs), "[", i, "];"); + if (transpose) + { + lhs_e->need_transpose = true; + if (rhs_e) rhs_e->need_transpose = !rhs_e->need_transpose; + } + } + else if (is_array(type) && stride == 4 * type.width / 8) + { + // Unpack the expression so we can store to it with a float or float2. + // It's still an l-value, so it's fine. Most other unpacking of expressions turn them into r-values instead. + if (is_scalar(type)) + lhs = enclose_expression(lhs) + ".x"; + else if (is_vector(type) && type.vecsize == 2) + lhs = enclose_expression(lhs) + ".xy"; + } - if (!optimize_read_modify_write(expression_type(rhs_expression), lhs, rhs)) - statement(lhs, " = ", rhs, ";"); + if (!is_matrix(type)) + { + if (!optimize_read_modify_write(expression_type(rhs_expression), lhs, rhs)) + statement(lhs, " = ", rhs, ";"); + } register_write(lhs_expression); } } @@ -2568,14 +2665,37 @@ void CompilerMSL::emit_store_statement(uint32_t lhs_expression, uint32_t rhs_exp string CompilerMSL::unpack_expression_type(string expr_str, const SPIRType &type, uint32_t packed_type_id) { const SPIRType *packed_type = nullptr; + uint32_t stride = 0; if (packed_type_id) + { packed_type = &get(packed_type_id); + stride = get_decoration(packed_type_id, DecorationArrayStride); + } // float[] and float2[] cases are really just padding, so directly swizzle from the backing float4 instead. - if (packed_type && is_array(*packed_type) && is_scalar(*packed_type)) + if (packed_type && is_array(*packed_type) && is_scalar(*packed_type) && stride == 4 * packed_type->width / 8) return enclose_expression(expr_str) + ".x"; - else if (packed_type && is_array(*packed_type) && is_vector(*packed_type) && packed_type->vecsize == 2) + else if (packed_type && is_array(*packed_type) && is_vector(*packed_type) && packed_type->vecsize == 2 && + stride == 4 * packed_type->width / 8) return enclose_expression(expr_str) + ".xy"; + else if (is_matrix(type)) + { + // Packed matrices are stored as arrays of packed vectors. Unfortunately, + // we can't just pass the array straight to the matrix constructor. We have to + // pass each vector individually, so that they can be unpacked to normal vectors. + if (!packed_type) + packed_type = &type; + const char *base_type = packed_type->width == 16 ? "half" : "float"; + string unpack_expr = join(type_to_glsl(*packed_type), "("); + for (uint32_t i = 0; i < packed_type->columns; i++) + { + if (i > 0) + unpack_expr += ", "; + unpack_expr += join(base_type, packed_type->vecsize, "(", expr_str, "[", i, "])"); + } + unpack_expr += ")"; + return unpack_expr; + } else return join(type_to_glsl(type), "(", expr_str, ")"); } @@ -4180,16 +4300,7 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) if (e && e->need_transpose && (t.columns == t.vecsize || is_packed)) { e->need_transpose = false; - - // This is important for matrices. Packed matrices - // are generally transposed, so unpacking using a constructor argument - // will result in an error. - // The simplest solution for now is to just avoid unpacking the matrix in this operation. - unset_extended_decoration(mtx_id, SPIRVCrossDecorationPacked); - emit_binary_op(ops[0], ops[1], ops[3], ops[2], "*"); - if (is_packed) - set_extended_decoration(mtx_id, SPIRVCrossDecorationPacked); e->need_transpose = true; } else @@ -5644,16 +5755,28 @@ string CompilerMSL::to_struct_member(const SPIRType &type, uint32_t member_type_ } else if (membertype.vecsize > 1 && membertype.columns > 1) { + uint32_t rows = membertype.vecsize; + uint32_t cols = membertype.columns; pack_pfx = "packed_"; + if (has_member_decoration(type.self, index, DecorationRowMajor)) + { + // These are stored transposed. + rows = membertype.columns; + cols = membertype.vecsize; + pack_pfx = "packed_rm_"; + } string base_type = membertype.width == 16 ? "half" : "float"; string td_line = "typedef "; - td_line += base_type + to_string(membertype.vecsize) + "x" + to_string(membertype.columns); + td_line += "packed_" + base_type + to_string(rows); td_line += " " + pack_pfx; + // Use the actual matrix size here. td_line += base_type + to_string(membertype.columns) + "x" + to_string(membertype.vecsize); + td_line += "[" + to_string(cols) + "]"; td_line += ";"; add_typedef_line(td_line); } - else if (is_array(membertype) && membertype.vecsize <= 2 && membertype.basetype != SPIRType::Struct) + else if (is_array(membertype) && membertype.vecsize <= 2 && membertype.basetype != SPIRType::Struct && + type_struct_member_array_stride(type, index) == 4 * membertype.width / 8) { // A "packed" float array, but we pad here instead to 4-vector. override_type = membertype; @@ -8432,9 +8555,15 @@ size_t CompilerMSL::get_declared_struct_member_alignment(const SPIRType &struct_ const SPIRType *packed_type = packed_type_id != 0 ? &get(packed_type_id) : nullptr; if (packed_type && is_array(*packed_type) && !is_matrix(*packed_type) && packed_type->basetype != SPIRType::Struct) - return (packed_type->width / 8) * 4; + { + uint32_t stride = type_struct_member_array_stride(struct_type, index); + if (stride == (packed_type->width / 8) * 4) + return stride; + else + return packed_type->width / 8; + } else - return (type.width / 8) * (type.columns == 3 ? 4 : type.columns); + return type.width / 8; } else return (type.width / 8) * (type.vecsize == 3 ? 4 : type.vecsize); @@ -8695,14 +8824,6 @@ CompilerMSL::SPVFuncImpl CompilerMSL::OpCodePreprocessor::get_spv_func_impl(Op o return SPVFuncImplTextureSwizzle; break; - case OpCompositeConstruct: - { - auto &type = compiler.get(args[0]); - if (type.array.size() > 1) // We need to use copies to build the composite. - return static_cast(SPVFuncImplArrayCopyMultidimBase + type.array.size() - 1); - break; - } - case OpExtInst: { uint32_t extension_set = args[2]; diff --git a/deps/SPIRV-Cross/spirv_msl.hpp b/deps/SPIRV-Cross/spirv_msl.hpp index 13ed36ef9a..9f2bab49d4 100644 --- a/deps/SPIRV-Cross/spirv_msl.hpp +++ b/deps/SPIRV-Cross/spirv_msl.hpp @@ -511,7 +511,8 @@ protected: size_t get_declared_struct_member_alignment(const SPIRType &struct_type, uint32_t index) const; std::string to_component_argument(uint32_t id); void align_struct(SPIRType &ib_type); - bool is_member_packable(SPIRType &ib_type, uint32_t index); + bool is_member_packable(SPIRType &ib_type, uint32_t index, uint32_t base_offset = 0); + uint32_t get_member_packed_type(SPIRType &ib_type, uint32_t index); MSLStructMemberKey get_struct_member_key(uint32_t type_id, uint32_t index); std::string get_argument_address_space(const SPIRVariable &argument); std::string get_type_address_space(const SPIRType &type, uint32_t id); diff --git a/deps/SPIRV-Cross/spirv_parser.cpp b/deps/SPIRV-Cross/spirv_parser.cpp index a271eadff3..d5a16337d1 100644 --- a/deps/SPIRV-Cross/spirv_parser.cpp +++ b/deps/SPIRV-Cross/spirv_parser.cpp @@ -569,10 +569,6 @@ void Parser::parse(const Instruction &instruction) type.image.sampled = ops[6]; type.image.format = static_cast(ops[7]); type.image.access = (length >= 9) ? static_cast(ops[8]) : AccessQualifierMax; - - if (type.image.sampled == 0) - SPIRV_CROSS_THROW("OpTypeImage Sampled parameter must not be zero."); - break; } diff --git a/deps/SPIRV-Cross/tests-other/msl_resource_binding.spv b/deps/SPIRV-Cross/tests-other/msl_resource_binding.spv new file mode 100644 index 0000000000..1798902467 Binary files /dev/null and b/deps/SPIRV-Cross/tests-other/msl_resource_binding.spv differ diff --git a/deps/SPIRV-Cross/tests-other/msl_resource_bindings.cpp b/deps/SPIRV-Cross/tests-other/msl_resource_bindings.cpp new file mode 100644 index 0000000000..fcb3213e1d --- /dev/null +++ b/deps/SPIRV-Cross/tests-other/msl_resource_bindings.cpp @@ -0,0 +1,86 @@ +// Testbench for MSL resource binding APIs. +// It does not validate output at the moment, but it's useful for ad-hoc testing. + +#include +#include +#include +#include + +#define SPVC_CHECKED_CALL(x) do { \ + if ((x) != SPVC_SUCCESS) { \ + fprintf(stderr, "Failed at line %d.\n", __LINE__); \ + exit(1); \ + } \ +} while(0) + +static std::vector read_file(const char *path) +{ + long len; + FILE *file = fopen(path, "rb"); + + if (!file) + return {}; + + fseek(file, 0, SEEK_END); + len = ftell(file); + rewind(file); + + std::vector buffer(len / sizeof(SpvId)); + if (fread(buffer.data(), 1, len, file) != (size_t)len) + { + fclose(file); + return {}; + } + + fclose(file); + return buffer; +} + +int main(int argc, char **argv) +{ + if (argc != 2) + return EXIT_FAILURE; + + auto buffer = read_file(argv[1]); + if (buffer.empty()) + return EXIT_FAILURE; + + spvc_context ctx; + spvc_parsed_ir parsed_ir; + spvc_compiler compiler; + + SPVC_CHECKED_CALL(spvc_context_create(&ctx)); + SPVC_CHECKED_CALL(spvc_context_parse_spirv(ctx, buffer.data(), buffer.size(), &parsed_ir)); + SPVC_CHECKED_CALL(spvc_context_create_compiler(ctx, SPVC_BACKEND_MSL, parsed_ir, SPVC_CAPTURE_MODE_TAKE_OWNERSHIP, &compiler)); + SPVC_CHECKED_CALL(spvc_compiler_msl_add_discrete_descriptor_set(compiler, 3)); + + spvc_compiler_options opts; + SPVC_CHECKED_CALL(spvc_compiler_create_compiler_options(compiler, &opts)); + SPVC_CHECKED_CALL(spvc_compiler_options_set_bool(opts, SPVC_COMPILER_OPTION_MSL_ARGUMENT_BUFFERS, SPVC_TRUE)); + SPVC_CHECKED_CALL(spvc_compiler_options_set_uint(opts, SPVC_COMPILER_OPTION_MSL_VERSION, 20000)); + SPVC_CHECKED_CALL(spvc_compiler_install_compiler_options(compiler, opts)); + + spvc_msl_resource_binding binding; + spvc_msl_resource_binding_init(&binding); + binding.binding = SPVC_MSL_ARGUMENT_BUFFER_BINDING; + binding.stage = SpvExecutionModelFragment; + binding.desc_set = 0; + binding.msl_buffer = 2; + SPVC_CHECKED_CALL(spvc_compiler_msl_add_resource_binding(compiler, &binding)); + + binding.desc_set = 1; + binding.msl_buffer = 3; + SPVC_CHECKED_CALL(spvc_compiler_msl_add_resource_binding(compiler, &binding)); + + const char *str; + SPVC_CHECKED_CALL(spvc_compiler_compile(compiler, &str)); + + fprintf(stderr, "Output:\n%s\n", str); + + if (!spvc_compiler_msl_is_resource_used(compiler, SpvExecutionModelFragment, 0, SPVC_MSL_ARGUMENT_BUFFER_BINDING)) + return EXIT_FAILURE; + + if (!spvc_compiler_msl_is_resource_used(compiler, SpvExecutionModelFragment, 1, SPVC_MSL_ARGUMENT_BUFFER_BINDING)) + return EXIT_FAILURE; +} +