diff --git a/3rdparty/spirv-cross/CMakeLists.txt b/3rdparty/spirv-cross/CMakeLists.txt index a6eb533ce..fc3e77839 100644 --- a/3rdparty/spirv-cross/CMakeLists.txt +++ b/3rdparty/spirv-cross/CMakeLists.txt @@ -287,7 +287,7 @@ if (SPIRV_CROSS_STATIC) endif() set(spirv-cross-abi-major 0) -set(spirv-cross-abi-minor 13) +set(spirv-cross-abi-minor 14) set(spirv-cross-abi-patch 0) if (SPIRV_CROSS_SHARED) diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/block-name-alias-global.asm.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/block-name-alias-global.asm.comp index e983acd92..2928efda2 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/block-name-alias-global.asm.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/block-name-alias-global.asm.comp @@ -35,7 +35,7 @@ struct B_1 /* FIXME: A padded struct is needed here. If you see this message, file a bug! */ A_2 Data[1024]; }; -kernel void main0(device B& C3 [[buffer(0)]], device A_1& C1 [[buffer(1)]], constant A_3& C2 [[buffer(2)]], constant B_1& C4 [[buffer(3)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +kernel void main0(device A_1& C1 [[buffer(0)]], constant A_3& C2 [[buffer(1)]], device B& C3 [[buffer(2)]], constant B_1& C4 [[buffer(3)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { C1.Data[gl_GlobalInvocationID.x].a = C2.Data[gl_GlobalInvocationID.x].a; C1.Data[gl_GlobalInvocationID.x].b = C2.Data[gl_GlobalInvocationID.x].b; diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp index ce336e97b..fa2b5fe53 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp @@ -16,7 +16,7 @@ uint2 spvTexelBufferCoord(uint tc) return uint2(tc % 4096, tc / 4096); } -kernel void main0(constant cb5_struct& cb0_5 [[buffer(1)]], texture2d u0 [[texture(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) +kernel void main0(constant cb5_struct& cb0_5 [[buffer(0)]], texture2d u0 [[texture(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) { uint _44 = as_type(as_type(int(gl_LocalInvocationID.x) << 4)) >> 2u; uint4 _51 = as_type(cb0_5._m0[uint(as_type(as_type(int(gl_LocalInvocationID.x)))) + 1u]); diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write.asm.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write.asm.comp index ab375a397..159d09b38 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write.asm.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write.asm.comp @@ -16,7 +16,7 @@ uint2 spvTexelBufferCoord(uint tc) return uint2(tc % 4096, tc / 4096); } -kernel void main0(constant cb& _6 [[buffer(7)]], texture2d _buffer [[texture(0)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]]) +kernel void main0(constant cb& _6 [[buffer(0)]], texture2d _buffer [[texture(0)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]]) { _buffer.write(float4(_6.value), spvTexelBufferCoord(((32u * gl_WorkGroupID.x) + gl_LocalInvocationIndex))); } diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/vector-builtin-type-cast-func.asm.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/vector-builtin-type-cast-func.asm.comp index c69204eda..641f108e8 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/vector-builtin-type-cast-func.asm.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/vector-builtin-type-cast-func.asm.comp @@ -10,7 +10,7 @@ struct cb1_struct constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(16u, 16u, 1u); -kernel void main0(constant cb1_struct& cb0_1 [[buffer(0)]], texture2d u0 [[texture(1)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) +kernel void main0(constant cb1_struct& cb0_1 [[buffer(0)]], texture2d u0 [[texture(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) { int2 _46 = int2(u0.get_width(), u0.get_height()) >> int2(uint2(4u)); int _97; diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/vector-builtin-type-cast.asm.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/vector-builtin-type-cast.asm.comp index 4738c3552..7f6d4bd90 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/vector-builtin-type-cast.asm.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/comp/vector-builtin-type-cast.asm.comp @@ -10,7 +10,7 @@ struct cb1_struct constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(16u, 16u, 1u); -kernel void main0(constant cb1_struct& cb0_1 [[buffer(0)]], texture2d u0 [[texture(1)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) +kernel void main0(constant cb1_struct& cb0_1 [[buffer(0)]], texture2d u0 [[texture(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) { int2 _40 = int2(u0.get_width(), u0.get_height()) >> int2(uint2(4u)); int _80; diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/combined-sampler-reuse.asm.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/combined-sampler-reuse.asm.frag index e420153bf..703dd0a95 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/combined-sampler-reuse.asm.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/combined-sampler-reuse.asm.frag @@ -13,7 +13,7 @@ struct main0_in float2 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], texture2d uTex [[texture(1)]], sampler uSampler [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d uTex [[texture(0)]], sampler uSampler [[sampler(0)]]) { main0_out out = {}; out.FragColor = uTex.sample(uSampler, in.vUV); diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/descriptor-array-unnamed.asm.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/descriptor-array-unnamed.asm.frag index 697389fa8..1870f6719 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/descriptor-array-unnamed.asm.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/descriptor-array-unnamed.asm.frag @@ -23,16 +23,8 @@ struct main0_out float4 m_3 [[color(0)]]; }; -fragment main0_out main0(constant _6& _20 [[buffer(0)]], constant _7* _8_0 [[buffer(1)]], constant _7* _8_1 [[buffer(2)]], constant _7* _8_2 [[buffer(3)]], constant _7* _8_3 [[buffer(4)]], const device _4* _5_0 [[buffer(5)]], const device _4* _5_1 [[buffer(6)]], const device _4* _5_2 [[buffer(7)]], const device _4* _5_3 [[buffer(8)]]) +fragment main0_out main0(const device _4* _5_0 [[buffer(0)]], const device _4* _5_1 [[buffer(1)]], const device _4* _5_2 [[buffer(2)]], const device _4* _5_3 [[buffer(3)]], constant _6& _20 [[buffer(4)]], constant _7* _8_0 [[buffer(5)]], constant _7* _8_1 [[buffer(6)]], constant _7* _8_2 [[buffer(7)]], constant _7* _8_3 [[buffer(8)]]) { - constant _7* _8[] = - { - _8_0, - _8_1, - _8_2, - _8_3, - }; - const device _4* _5[] = { _5_0, @@ -41,6 +33,14 @@ fragment main0_out main0(constant _6& _20 [[buffer(0)]], constant _7* _8_0 [[buf _5_3, }; + constant _7* _8[] = + { + _8_0, + _8_1, + _8_2, + _8_3, + }; + main0_out out = {}; out.m_3 = _5[_20._m0]->_m0 + (_8[_20._m0]->_m0 * float4(0.20000000298023223876953125)); return out; diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/min-lod.msl22.asm.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/min-lod.msl22.asm.frag new file mode 100644 index 000000000..5193b2cda --- /dev/null +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/min-lod.msl22.asm.frag @@ -0,0 +1,22 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 vUV [[user(locn0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]]) +{ + main0_out out = {}; + out.FragColor = uSampler.sample(uSamplerSmplr, in.vUV, min_lod_clamp(4.0)); + return out; +} + diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/op-image-sampled-image.asm.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/op-image-sampled-image.asm.frag index 590e503c5..45f0ca52f 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/op-image-sampled-image.asm.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/op-image-sampled-image.asm.frag @@ -13,7 +13,7 @@ struct main0_out float4 o0 [[color(0)]]; }; -fragment main0_out main0(constant push_cb& _19 [[buffer(0)]], texture2d t0 [[texture(2)]], sampler dummy_sampler [[sampler(4)]]) +fragment main0_out main0(constant push_cb& _19 [[buffer(0)]], texture2d t0 [[texture(0)]], sampler dummy_sampler [[sampler(0)]]) { main0_out out = {}; out.o0 = t0.read(uint2(as_type(_19.cb0[0u].zw)) + uint2(int2(-1, -2)), as_type(0.0)); diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/unknown-depth-state.asm.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/unknown-depth-state.asm.frag index e8a88623a..dc8740653 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/unknown-depth-state.asm.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/unknown-depth-state.asm.frag @@ -13,7 +13,7 @@ struct main0_in float3 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d uShadow [[texture(0)]], depth2d uTexture [[texture(1)]], sampler uShadowSmplr [[sampler(0)]], sampler uSampler [[sampler(2)]]) +fragment main0_out main0(main0_in in [[stage_in]], depth2d uShadow [[texture(0)]], depth2d uTexture [[texture(1)]], sampler uShadowSmplr [[sampler(0)]], sampler uSampler [[sampler(1)]]) { main0_out out = {}; out.FragColor = uShadow.sample_compare(uShadowSmplr, in.vUV.xy, in.vUV.z) + uTexture.sample_compare(uSampler, in.vUV.xy, in.vUV.z); diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag index 989d82682..a1a73ced2 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag @@ -95,7 +95,7 @@ struct main0_out float4 m_5 [[color(0)]]; }; -fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _18& _19 [[buffer(1)]], constant _10& _11 [[buffer(2)]], texture2d _14 [[texture(4)]], texture2d _12 [[texture(13)]], texture2d _8 [[texture(14)]], sampler _15 [[sampler(3)]], sampler _13 [[sampler(5)]], sampler _9 [[sampler(6)]], float4 gl_FragCoord [[position]]) +fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buffer(1)]], constant _18& _19 [[buffer(2)]], texture2d _8 [[texture(0)]], texture2d _12 [[texture(1)]], texture2d _14 [[texture(2)]], sampler _9 [[sampler(0)]], sampler _13 [[sampler(1)]], sampler _15 [[sampler(2)]], float4 gl_FragCoord [[position]]) { main0_out out = {}; float2 _82 = gl_FragCoord.xy * _19._m23.xy; diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-discrete.msl2.argument.discrete.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-discrete.msl2.argument.discrete.comp index 98668f505..f7757cd19 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-discrete.msl2.argument.discrete.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-discrete.msl2.argument.discrete.comp @@ -33,7 +33,7 @@ struct spvDescriptorSetBuffer1 const device SSBO1* ssbo1 [[id(0)]]; }; -kernel void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], constant spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]], const device SSBO2& ssbo2 [[buffer(5)]], device SSBO3& ssbo3 [[buffer(6)]]) +kernel void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], constant spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]], device SSBO3& ssbo3 [[buffer(2)]], const device SSBO2& ssbo2 [[buffer(3)]]) { ssbo3.v = ((*spvDescriptorSet0.ssbo0).v + (*spvDescriptorSet1.ssbo1).v) + ssbo2.v; } diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-image-load-store.msl2.argument.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-image-load-store.msl2.argument.comp index b1ebf27cf..2f8067e55 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-image-load-store.msl2.argument.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/argument-buffers-image-load-store.msl2.argument.comp @@ -5,8 +5,8 @@ using namespace metal; struct spvDescriptorSetBuffer0 { - texture2d uImage [[id(1)]]; - texture2d uImageRead [[id(2)]]; + texture2d uImage [[id(0)]]; + texture2d uImageRead [[id(1)]]; }; kernel void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/array-length.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/array-length.comp index 5e65e71d7..79358eb90 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/array-length.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/array-length.comp @@ -14,7 +14,7 @@ struct SSBO1 float bz[1]; }; -kernel void main0(constant uint* spvBufferSizeConstants [[buffer(25)]], device SSBO& _14 [[buffer(1)]], device SSBO1* ssbos_0 [[buffer(2)]], device SSBO1* ssbos_1 [[buffer(3)]]) +kernel void main0(constant uint* spvBufferSizeConstants [[buffer(25)]], device SSBO& _14 [[buffer(0)]], device SSBO1* ssbos_0 [[buffer(1)]], device SSBO1* ssbos_1 [[buffer(2)]]) { device SSBO1* ssbos[] = { @@ -22,8 +22,8 @@ kernel void main0(constant uint* spvBufferSizeConstants [[buffer(25)]], device S ssbos_1, }; - constant uint& _14BufferSize = spvBufferSizeConstants[1]; - constant uint* ssbosBufferSize = &spvBufferSizeConstants[2]; + constant uint& _14BufferSize = spvBufferSizeConstants[0]; + constant uint* ssbosBufferSize = &spvBufferSizeConstants[1]; _14.size = uint(int((_14BufferSize - 16) / 16) + int((ssbosBufferSize[1] - 0) / 4)); } diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/array-length.msl2.argument.discrete.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/array-length.msl2.argument.discrete.comp index 5cec77c66..6ec9b11bb 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/array-length.msl2.argument.discrete.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/array-length.msl2.argument.discrete.comp @@ -27,17 +27,17 @@ struct SSBO3 struct spvDescriptorSetBuffer0 { - constant uint* spvBufferSizeConstants [[id(0)]]; - device SSBO* m_16 [[id(1)]]; + device SSBO* m_16 [[id(0)]]; + constant uint* spvBufferSizeConstants [[id(1)]]; }; struct spvDescriptorSetBuffer1 { - constant uint* spvBufferSizeConstants [[id(1)]]; - device SSBO1* ssbos [[id(2)]][2]; + device SSBO1* ssbos [[id(0)]][2]; + constant uint* spvBufferSizeConstants [[id(2)]]; }; -kernel void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], constant spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]], constant uint* spvBufferSizeConstants [[buffer(25)]], device SSBO3* ssbos2_0 [[buffer(2)]], device SSBO3* ssbos2_1 [[buffer(3)]], device SSBO2& _38 [[buffer(5)]]) +kernel void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], constant spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]], constant uint* spvBufferSizeConstants [[buffer(25)]], device SSBO2& _38 [[buffer(2)]], device SSBO3* ssbos2_0 [[buffer(3)]], device SSBO3* ssbos2_1 [[buffer(4)]]) { device SSBO3* ssbos2[] = { @@ -45,10 +45,10 @@ kernel void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0 ssbos2_1, }; - constant uint& spvDescriptorSet0_m_16BufferSize = spvDescriptorSet0.spvBufferSizeConstants[1]; - constant uint* spvDescriptorSet1_ssbosBufferSize = &spvDescriptorSet1.spvBufferSizeConstants[2]; - constant uint& _38BufferSize = spvBufferSizeConstants[5]; - constant uint* ssbos2BufferSize = &spvBufferSizeConstants[2]; + constant uint& spvDescriptorSet0_m_16BufferSize = spvDescriptorSet0.spvBufferSizeConstants[0]; + constant uint* spvDescriptorSet1_ssbosBufferSize = &spvDescriptorSet1.spvBufferSizeConstants[0]; + constant uint& _38BufferSize = spvBufferSizeConstants[2]; + constant uint* ssbos2BufferSize = &spvBufferSizeConstants[3]; (*spvDescriptorSet0.m_16).size = ((uint(int((spvDescriptorSet0_m_16BufferSize - 16) / 16)) + uint(int((spvDescriptorSet1_ssbosBufferSize[1] - 0) / 4))) + uint(int((_38BufferSize - 16) / 16))) + uint(int((ssbos2BufferSize[0] - 0) / 4)); } diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/atomic.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/atomic.comp index 0315f3b12..43e6a8f03 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/atomic.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/atomic.comp @@ -12,7 +12,7 @@ struct SSBO int i32; }; -kernel void main0(device SSBO& ssbo [[buffer(2)]]) +kernel void main0(device SSBO& ssbo [[buffer(0)]]) { threadgroup uint shared_u32; threadgroup int shared_i32; diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/bitcast-16bit-2.invalid.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/bitcast-16bit-2.invalid.comp index e7c20892a..a4230b1eb 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/bitcast-16bit-2.invalid.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/bitcast-16bit-2.invalid.comp @@ -18,7 +18,7 @@ struct UBO half4 const0; }; -kernel void main0(device SSBO0& _29 [[buffer(0)]], device SSBO1& _21 [[buffer(1)]], constant UBO& _40 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +kernel void main0(device SSBO1& _21 [[buffer(0)]], device SSBO0& _29 [[buffer(1)]], constant UBO& _40 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { short2 _47 = as_type(_29.inputs[gl_GlobalInvocationID.x].x) + as_type(_40.const0.xy); _21.outputs[gl_GlobalInvocationID.x] = short4(_47.x, _47.y, _21.outputs[gl_GlobalInvocationID.x].z, _21.outputs[gl_GlobalInvocationID.x].w); diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/coherent-block.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/coherent-block.comp index 963574acd..bec9b218c 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/coherent-block.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/coherent-block.comp @@ -8,7 +8,7 @@ struct SSBO float4 value; }; -kernel void main0(device SSBO& _10 [[buffer(1)]]) +kernel void main0(device SSBO& _10 [[buffer(0)]]) { _10.value = float4(20.0); } diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/coherent-image.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/coherent-image.comp index 827a24712..0fe044fb9 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/coherent-image.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/coherent-image.comp @@ -8,7 +8,7 @@ struct SSBO int4 value; }; -kernel void main0(device SSBO& _10 [[buffer(1)]], texture2d uImage [[texture(3)]]) +kernel void main0(device SSBO& _10 [[buffer(0)]], texture2d uImage [[texture(0)]]) { _10.value = uImage.read(uint2(int2(10))); } diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/int64.invalid.msl22.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/int64.invalid.msl22.comp new file mode 100644 index 000000000..13304bd0e --- /dev/null +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/int64.invalid.msl22.comp @@ -0,0 +1,24 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + int s32; + uint u32; +}; + +constant long _162 = {}; + +kernel void main0(device SSBO& _96 [[buffer(0)]]) +{ + long4 _137; + ulong4 _141; + _137 = abs((_137 + long4(30l, 40l, 50l, 60l)) + long4(_141 + ulong4(999999999999999999ul, 8888888888888888ul, 77777777777777777ul, 6666666666666666ul))); + _141 += ulong4(long4(999999999999999999l, 8888888888888888l, 77777777777777777l, 6666666666666666l)); + ulong _109 = ulong(_162); + _96.s32 = int(uint(((ulong(_137.x) + _141.y) + _109) + _109)); + _96.u32 = uint(((ulong(_137.y) + _141.z) + ulong(_162 + 1l)) + _109); +} + diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/mat3.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/mat3.comp index adf7e9496..72f08dd85 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/mat3.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/mat3.comp @@ -8,7 +8,7 @@ struct SSBO2 float3x3 out_data[1]; }; -kernel void main0(device SSBO2& _22 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +kernel void main0(device SSBO2& _22 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { _22.out_data[gl_GlobalInvocationID.x] = float3x3(float3(10.0), float3(20.0), float3(40.0)); } diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/packing-test-1.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/packing-test-1.comp index 131017735..0649f5768 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/packing-test-1.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/packing-test-1.comp @@ -21,7 +21,7 @@ struct Buffer1 constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(32u, 1u, 1u); -kernel void main0(device Buffer0& _15 [[buffer(1)]], device Buffer1& _34 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +kernel void main0(device Buffer0& _15 [[buffer(0)]], device Buffer1& _34 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { _34.buf1[gl_GlobalInvocationID.x] = _15.buf0[0].b; } diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/packing-test-2.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/packing-test-2.comp index b3b89d766..abce48a37 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/packing-test-2.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/packing-test-2.comp @@ -21,7 +21,7 @@ struct Buffer1 constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(32u, 1u, 1u); -kernel void main0(device Buffer0& _14 [[buffer(1)]], device Buffer1& _24 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +kernel void main0(device Buffer0& _14 [[buffer(0)]], device Buffer1& _24 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { _24.buf1[gl_GlobalInvocationID.x] = _14.buf0[0].b; } diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/read-write-only.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/read-write-only.comp index 42c625092..7547b417d 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/read-write-only.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/read-write-only.comp @@ -21,7 +21,7 @@ struct SSBO1 float4 data3; }; -kernel void main0(const device SSBO0& _15 [[buffer(0)]], device SSBO1& _21 [[buffer(1)]], device SSBO2& _10 [[buffer(2)]]) +kernel void main0(device SSBO2& _10 [[buffer(0)]], const device SSBO0& _15 [[buffer(1)]], device SSBO1& _21 [[buffer(2)]]) { _10.data4 = _15.data0 + _21.data2; _10.data5 = _15.data1 + _21.data3; diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/struct-layout.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/struct-layout.comp index e7bb53ece..d44136252 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/struct-layout.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/struct-layout.comp @@ -18,7 +18,7 @@ struct SSBO Foo in_data[1]; }; -kernel void main0(const device SSBO& _30 [[buffer(0)]], device SSBO2& _23 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +kernel void main0(device SSBO2& _23 [[buffer(0)]], const device SSBO& _30 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { _23.out_data[gl_GlobalInvocationID.x].m = _30.in_data[gl_GlobalInvocationID.x].m * _30.in_data[gl_GlobalInvocationID.x].m; } diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/struct-nested.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/struct-nested.comp index 9abc498f4..6a1419cec 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/struct-nested.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/struct-nested.comp @@ -18,7 +18,7 @@ struct dstbuffer s2 test[1]; }; -kernel void main0(device dstbuffer& _19 [[buffer(1)]]) +kernel void main0(device dstbuffer& _19 [[buffer(0)]]) { _19.test[0].b.a = 0; } diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/struct-packing.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/struct-packing.comp index bfaf4dd55..dd208a00a 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/struct-packing.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/struct-packing.comp @@ -116,7 +116,7 @@ struct SSBO0 float4 array[1]; }; -kernel void main0(device SSBO0& ssbo_140 [[buffer(0)]], device SSBO1& ssbo_430 [[buffer(1)]]) +kernel void main0(device SSBO1& ssbo_430 [[buffer(0)]], device SSBO0& ssbo_140 [[buffer(1)]]) { Content_1 _60 = ssbo_140.content; ssbo_430.content.m0s[0].a[0] = _60.m0s[0].a[0].xy; diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/udiv.comp b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/udiv.comp index a298ecdb7..32874ad78 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/udiv.comp +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/comp/udiv.comp @@ -13,7 +13,7 @@ struct SSBO uint inputs[1]; }; -kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _10 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +kernel void main0(device SSBO2& _10 [[buffer(0)]], device SSBO& _23 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { _10.outputs[gl_GlobalInvocationID.x] = _23.inputs[gl_GlobalInvocationID.x] / 29u; } diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/desktop-only/frag/image-ms.desktop.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/desktop-only/frag/image-ms.desktop.frag index 3b461f0fe..4083e4ea1 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/desktop-only/frag/image-ms.desktop.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/desktop-only/frag/image-ms.desktop.frag @@ -3,7 +3,7 @@ using namespace metal; -fragment void main0(texture2d uImage [[texture(0)]], texture2d_array uImageArray [[texture(1)]], texture2d_ms uImageMS [[texture(2)]]) +fragment void main0(texture2d_ms uImageMS [[texture(0)]], texture2d_array uImageArray [[texture(1)]], texture2d uImage [[texture(2)]]) { uImage.write(uImageMS.read(uint2(int2(1, 2)), 2), uint2(int2(2, 3))); uImageArray.write(uImageArray.read(uint2(int3(1, 2, 4).xy), uint(int3(1, 2, 4).z)), uint2(int3(2, 3, 7).xy), uint(int3(2, 3, 7).z)); diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag index a6f06064a..330bc6403 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag @@ -8,7 +8,7 @@ struct main0_out float4 FragColor [[color(0)]]; }; -fragment main0_out main0(texture2d_ms uSampler [[texture(0)]], texture2d_ms uImage [[texture(2)]], sampler uSamplerSmplr [[sampler(0)]]) +fragment main0_out main0(texture2d_ms uSampler [[texture(0)]], texture2d_ms uImage [[texture(1)]], sampler uSamplerSmplr [[sampler(0)]]) { main0_out out = {}; out.FragColor = float4(float(int(uSampler.get_num_samples()) + int(uImage.get_num_samples()))); diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert b/3rdparty/spirv-cross/reference/opt/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert index 32f0d9aa0..a414c9854 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert @@ -7,7 +7,6 @@ struct main0_out { float4 gl_Position [[position]]; float gl_ClipDistance [[clip_distance]] [2]; - float gl_CullDistance[2]; }; vertex main0_out main0() @@ -16,8 +15,6 @@ vertex main0_out main0() out.gl_Position = float4(10.0); out.gl_ClipDistance[0] = 1.0; out.gl_ClipDistance[1] = 4.0; - out.gl_CullDistance[0] = 4.0; - out.gl_CullDistance[1] = 9.0; return out; } diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/flatten/types.flatten.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/flatten/types.flatten.frag index 540c5baeb..cee53d9e5 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/flatten/types.flatten.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/flatten/types.flatten.frag @@ -26,7 +26,7 @@ struct main0_out float4 FragColor [[color(0)]]; }; -fragment main0_out main0(constant UBO0& _41 [[buffer(0)]], constant UBO1& _14 [[buffer(1)]], constant UBO2& _29 [[buffer(2)]]) +fragment main0_out main0(constant UBO1& _14 [[buffer(0)]], constant UBO2& _29 [[buffer(1)]], constant UBO0& _41 [[buffer(2)]]) { main0_out out = {}; out.FragColor = ((((float4(_14.c) + float4(_14.d)) + float4(_29.e)) + float4(_29.f)) + _41.a) + _41.b; diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/argument-buffers.msl2.argument.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/argument-buffers.msl2.argument.frag index f00683898..bdf9080bd 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/argument-buffers.msl2.argument.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/argument-buffers.msl2.argument.frag @@ -30,24 +30,24 @@ struct UBOs struct spvDescriptorSetBuffer0 { - texture2d uTexture [[id(2)]]; - sampler uTextureSmplr [[id(3)]]; - constant UBO* m_90 [[id(5)]]; - array, 2> uTextures [[id(6)]]; - array uTexturesSmplr [[id(8)]]; + texture2d uTexture [[id(0)]]; + sampler uTextureSmplr [[id(1)]]; + array, 2> uTextures [[id(2)]]; + array uTexturesSmplr [[id(4)]]; + constant UBO* m_90 [[id(6)]]; }; struct spvDescriptorSetBuffer1 { - array, 4> uTexture2 [[id(3)]]; - device SSBO* m_60 [[id(7)]]; - const device SSBOs* ssbos [[id(8)]][2]; - array uSampler [[id(10)]]; + array, 4> uTexture2 [[id(0)]]; + array uSampler [[id(4)]]; + device SSBO* m_60 [[id(6)]]; + const device SSBOs* ssbos [[id(7)]][2]; }; struct spvDescriptorSetBuffer2 { - constant UBOs* ubos [[id(4)]][4]; + constant UBOs* ubos [[id(0)]][4]; }; struct main0_out diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/array-of-texture-swizzle.msl2.argument.discrete.swizzle.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/array-of-texture-swizzle.msl2.argument.discrete.swizzle.frag index 67a5c2c82..2160e0be6 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/array-of-texture-swizzle.msl2.argument.discrete.swizzle.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/array-of-texture-swizzle.msl2.argument.discrete.swizzle.frag @@ -7,9 +7,9 @@ using namespace metal; struct spvDescriptorSetBuffer0 { - constant uint* spvSwizzleConstants [[id(0)]]; - array, 4> uSampler0 [[id(1)]]; - array uSampler0Smplr [[id(5)]]; + array, 4> uSampler0 [[id(0)]]; + array uSampler0Smplr [[id(4)]]; + constant uint* spvSwizzleConstants [[id(8)]]; }; struct main0_out @@ -145,7 +145,7 @@ inline vec spvGatherCompareSwizzle(sampler s, const thread Tex& t, Ts... p fragment main0_out main0(main0_in in [[stage_in]], constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], constant uint* spvSwizzleConstants [[buffer(30)]], texture2d uSampler1 [[texture(0)]], sampler uSampler1Smplr [[sampler(0)]]) { main0_out out = {}; - constant uint* spvDescriptorSet0_uSampler0Swzl = &spvDescriptorSet0.spvSwizzleConstants[1]; + constant uint* spvDescriptorSet0_uSampler0Swzl = &spvDescriptorSet0.spvSwizzleConstants[0]; constant uint& uSampler1Swzl = spvSwizzleConstants[0]; out.FragColor = spvTextureSwizzle(spvDescriptorSet0.uSampler0[2].sample(spvDescriptorSet0.uSampler0Smplr[2], in.vUV), spvDescriptorSet0_uSampler0Swzl[2]); out.FragColor += spvTextureSwizzle(uSampler1.sample(uSampler1Smplr, in.vUV), uSampler1Swzl); diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/barycentric-nv-nopersp.msl22.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/barycentric-nv-nopersp.msl22.frag new file mode 100644 index 000000000..53b8a7438 --- /dev/null +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/barycentric-nv-nopersp.msl22.frag @@ -0,0 +1,28 @@ +#include +#include + +using namespace metal; + +struct Vertices +{ + float2 uvs[1]; +}; + +struct main0_out +{ + float2 value [[color(0)]]; +}; + +struct main0_in +{ + float3 gl_BaryCoordNoPerspNV [[barycentric_coord, center_no_perspective]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], const device Vertices& _19 [[buffer(0)]], uint gl_PrimitiveID [[primitive_id]]) +{ + main0_out out = {}; + int _23 = 3 * int(gl_PrimitiveID); + out.value = ((_19.uvs[_23] * in.gl_BaryCoordNoPerspNV.x) + (_19.uvs[_23 + 1] * in.gl_BaryCoordNoPerspNV.y)) + (_19.uvs[_23 + 2] * in.gl_BaryCoordNoPerspNV.z); + return out; +} + diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/barycentric-nv.msl22.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/barycentric-nv.msl22.frag new file mode 100644 index 000000000..ae2c704d0 --- /dev/null +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/barycentric-nv.msl22.frag @@ -0,0 +1,28 @@ +#include +#include + +using namespace metal; + +struct Vertices +{ + float2 uvs[1]; +}; + +struct main0_out +{ + float2 value [[color(0)]]; +}; + +struct main0_in +{ + float3 gl_BaryCoordNV [[barycentric_coord, center_perspective]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], const device Vertices& _19 [[buffer(0)]], uint gl_PrimitiveID [[primitive_id]]) +{ + main0_out out = {}; + int _23 = 3 * int(gl_PrimitiveID); + out.value = ((_19.uvs[_23] * in.gl_BaryCoordNV.x) + (_19.uvs[_23 + 1] * in.gl_BaryCoordNV.y)) + (_19.uvs[_23 + 2] * in.gl_BaryCoordNV.z); + return out; +} + diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/complex-expression-in-access-chain.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/complex-expression-in-access-chain.frag index be10da12f..0889469c3 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/complex-expression-in-access-chain.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/complex-expression-in-access-chain.frag @@ -19,7 +19,7 @@ struct main0_in int vIn2 [[user(locn1)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], device UBO& _34 [[buffer(0)]], texture2d Buf [[texture(1)]], sampler BufSmplr [[sampler(1)]], float4 gl_FragCoord [[position]]) +fragment main0_out main0(main0_in in [[stage_in]], device UBO& _34 [[buffer(0)]], texture2d Buf [[texture(0)]], sampler BufSmplr [[sampler(0)]], float4 gl_FragCoord [[position]]) { main0_out out = {}; int _40 = Buf.read(uint2(int2(gl_FragCoord.xy)), 0).x % 16; diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/image-query-lod.msl22.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/image-query-lod.msl22.frag new file mode 100644 index 000000000..a2b8262e2 --- /dev/null +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/image-query-lod.msl22.frag @@ -0,0 +1,70 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 FragColor [[color(0)]]; +}; + +struct main0_in +{ + float3 vUV [[user(locn0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d uSampler2D [[texture(0)]], texture3d uSampler3D [[texture(1)]], texturecube uSamplerCube [[texture(2)]], texture2d uTexture2D [[texture(3)]], texture3d uTexture3D [[texture(4)]], texturecube uTextureCube [[texture(5)]], sampler uSampler2DSmplr [[sampler(0)]], sampler uSampler3DSmplr [[sampler(1)]], sampler uSamplerCubeSmplr [[sampler(2)]], sampler uSampler [[sampler(3)]]) +{ + main0_out out = {}; + out.FragColor = float2(0.0); + float2 _79; + _79.x = uSampler2D.calculate_clamped_lod(uSampler2DSmplr, in.vUV.xy); + _79.y = uSampler2D.calculate_unclamped_lod(uSampler2DSmplr, in.vUV.xy); + out.FragColor += _79; + float2 _84; + _84.x = uSampler3D.calculate_clamped_lod(uSampler3DSmplr, in.vUV); + _84.y = uSampler3D.calculate_unclamped_lod(uSampler3DSmplr, in.vUV); + out.FragColor += _84; + float2 _89; + _89.x = uSamplerCube.calculate_clamped_lod(uSamplerCubeSmplr, in.vUV); + _89.y = uSamplerCube.calculate_unclamped_lod(uSamplerCubeSmplr, in.vUV); + out.FragColor += _89; + float2 _97; + _97.x = uTexture2D.calculate_clamped_lod(uSampler, in.vUV.xy); + _97.y = uTexture2D.calculate_unclamped_lod(uSampler, in.vUV.xy); + out.FragColor += _97; + float2 _104; + _104.x = uTexture3D.calculate_clamped_lod(uSampler, in.vUV); + _104.y = uTexture3D.calculate_unclamped_lod(uSampler, in.vUV); + out.FragColor += _104; + float2 _111; + _111.x = uTextureCube.calculate_clamped_lod(uSampler, in.vUV); + _111.y = uTextureCube.calculate_unclamped_lod(uSampler, in.vUV); + out.FragColor += _111; + float2 _118; + _118.x = uSampler2D.calculate_clamped_lod(uSampler2DSmplr, in.vUV.xy); + _118.y = uSampler2D.calculate_unclamped_lod(uSampler2DSmplr, in.vUV.xy); + out.FragColor += _118; + float2 _123; + _123.x = uSampler3D.calculate_clamped_lod(uSampler3DSmplr, in.vUV); + _123.y = uSampler3D.calculate_unclamped_lod(uSampler3DSmplr, in.vUV); + out.FragColor += _123; + float2 _128; + _128.x = uSamplerCube.calculate_clamped_lod(uSamplerCubeSmplr, in.vUV); + _128.y = uSamplerCube.calculate_unclamped_lod(uSamplerCubeSmplr, in.vUV); + out.FragColor += _128; + float2 _136; + _136.x = uTexture2D.calculate_clamped_lod(uSampler, in.vUV.xy); + _136.y = uTexture2D.calculate_unclamped_lod(uSampler, in.vUV.xy); + out.FragColor += _136; + float2 _143; + _143.x = uTexture3D.calculate_clamped_lod(uSampler, in.vUV); + _143.y = uTexture3D.calculate_unclamped_lod(uSampler, in.vUV); + out.FragColor += _143; + float2 _150; + _150.x = uTextureCube.calculate_clamped_lod(uSampler, in.vUV); + _150.y = uTextureCube.calculate_unclamped_lod(uSampler, in.vUV); + out.FragColor += _150; + return out; +} + diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/in_mat.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/in_mat.frag index b0a1b87d1..83ed9b5ea 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/in_mat.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/in_mat.frag @@ -19,7 +19,7 @@ struct main0_in float inLodBias [[user(locn6)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], texturecube samplerColor [[texture(1)]], sampler samplerColorSmplr [[sampler(1)]]) +fragment main0_out main0(main0_in in [[stage_in]], texturecube samplerColor [[texture(0)]], sampler samplerColorSmplr [[sampler(0)]]) { main0_out out = {}; float4x4 inInvModelView = {}; diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/nonuniform-qualifier.msl2.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/nonuniform-qualifier.msl2.frag index 510d1ca58..14a6999f3 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/nonuniform-qualifier.msl2.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/nonuniform-qualifier.msl2.frag @@ -24,7 +24,7 @@ struct main0_in float2 vUV [[user(locn1)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], constant UBO* ubos_0 [[buffer(0)]], constant UBO* ubos_1 [[buffer(1)]], const device SSBO* ssbos_0 [[buffer(2)]], const device SSBO* ssbos_1 [[buffer(3)]], array, 8> uSamplers [[texture(0)]], array, 8> uCombinedSamplers [[texture(8)]], array uSamps [[sampler(1)]], array uCombinedSamplersSmplr [[sampler(8)]]) +fragment main0_out main0(main0_in in [[stage_in]], constant UBO* ubos_0 [[buffer(0)]], constant UBO* ubos_1 [[buffer(1)]], const device SSBO* ssbos_0 [[buffer(2)]], const device SSBO* ssbos_1 [[buffer(3)]], array, 8> uSamplers [[texture(0)]], array, 8> uCombinedSamplers [[texture(8)]], array uSamps [[sampler(0)]], array uCombinedSamplersSmplr [[sampler(7)]]) { constant UBO* ubos[] = { diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/sample-depth-separate-image-sampler.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/sample-depth-separate-image-sampler.frag index 17e1421a3..6626946c4 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/sample-depth-separate-image-sampler.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/sample-depth-separate-image-sampler.frag @@ -8,7 +8,7 @@ struct main0_out float FragColor [[color(0)]]; }; -fragment main0_out main0(depth2d uDepth [[texture(0)]], texture2d uColor [[texture(1)]], sampler uSampler [[sampler(2)]], sampler uSamplerShadow [[sampler(3)]]) +fragment main0_out main0(depth2d uDepth [[texture(0)]], texture2d uColor [[texture(1)]], sampler uSamplerShadow [[sampler(0)]], sampler uSampler [[sampler(1)]]) { main0_out out = {}; out.FragColor = uDepth.sample_compare(uSamplerShadow, float3(0.5).xy, 0.5) + uColor.sample(uSampler, float2(0.5)).x; diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.frag index 18c2d4237..630511b34 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.frag @@ -13,7 +13,7 @@ struct main0_in float4 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d_array uTex [[texture(0)]], sampler uShadow [[sampler(1)]]) +fragment main0_out main0(main0_in in [[stage_in]], depth2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) { main0_out out = {}; out.FragColor = uTex.sample_compare(uShadow, in.vUV.xy, uint(round(in.vUV.z)), in.vUV.w, level(0)); diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.ios.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.ios.frag index f01965c9e..a29ebf08b 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.ios.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.ios.frag @@ -13,7 +13,7 @@ struct main0_in float4 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d_array uTex [[texture(0)]], sampler uShadow [[sampler(1)]]) +fragment main0_out main0(main0_in in [[stage_in]], depth2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) { main0_out out = {}; out.FragColor = uTex.sample_compare(uShadow, in.vUV.xy, uint(round(in.vUV.z)), in.vUV.w, gradient2d(float2(0.0), float2(0.0))); diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/sampler-image-arrays.msl2.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/sampler-image-arrays.msl2.frag index ae37cf9a4..f3e10fcad 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/sampler-image-arrays.msl2.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/sampler-image-arrays.msl2.frag @@ -14,7 +14,7 @@ struct main0_in int vIndex [[user(locn1)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], array, 4> uSampler [[texture(0)]], array, 4> uTextures [[texture(8)]], array uSamplerSmplr [[sampler(0)]], array uSamplers [[sampler(4)]]) +fragment main0_out main0(main0_in in [[stage_in]], array, 4> uSampler [[texture(0)]], array, 4> uTextures [[texture(4)]], array uSamplerSmplr [[sampler(0)]], array uSamplers [[sampler(4)]]) { main0_out out = {}; out.FragColor = float4(0.0); diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/separate-image-sampler-argument.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/separate-image-sampler-argument.frag index b1261f372..e576b49e7 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/separate-image-sampler-argument.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/separate-image-sampler-argument.frag @@ -8,7 +8,7 @@ struct main0_out float4 FragColor [[color(0)]]; }; -fragment main0_out main0(texture2d uDepth [[texture(1)]], sampler uSampler [[sampler(0)]]) +fragment main0_out main0(texture2d uDepth [[texture(0)]], sampler uSampler [[sampler(0)]]) { main0_out out = {}; out.FragColor = uDepth.sample(uSampler, float2(0.5)); diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/shader-arithmetic-8bit.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/shader-arithmetic-8bit.frag index 6f1330c9e..30b28d213 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/shader-arithmetic-8bit.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/shader-arithmetic-8bit.frag @@ -32,7 +32,7 @@ struct main0_in int4 vColor [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], constant Push& registers [[buffer(0)]], constant UBO& ubo [[buffer(1)]], device SSBO& ssbo [[buffer(2)]]) +fragment main0_out main0(main0_in in [[stage_in]], device SSBO& ssbo [[buffer(0)]], constant Push& registers [[buffer(1)]], constant UBO& ubo [[buffer(2)]]) { main0_out out = {}; short _196 = 10; diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/shadow-compare-global-alias.invalid.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/shadow-compare-global-alias.invalid.frag index 926172577..a58f13fc4 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/shadow-compare-global-alias.invalid.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/shadow-compare-global-alias.invalid.frag @@ -13,7 +13,7 @@ struct main0_in float3 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d uSampler [[texture(0)]], depth2d uTex [[texture(1)]], sampler uSamplerSmplr [[sampler(0)]], sampler uSamp [[sampler(2)]]) +fragment main0_out main0(main0_in in [[stage_in]], depth2d uTex [[texture(0)]], depth2d uSampler [[texture(1)]], sampler uSamp [[sampler(0)]], sampler uSamplerSmplr [[sampler(1)]]) { main0_out out = {}; out.FragColor = uSampler.sample_compare(uSamplerSmplr, in.vUV.xy, in.vUV.z); diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/texture-proj-shadow.frag b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/texture-proj-shadow.frag index 2e315ff0f..52d4a026d 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/texture-proj-shadow.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/frag/texture-proj-shadow.frag @@ -15,7 +15,7 @@ struct main0_in float2 vClip2 [[user(locn2)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d uShadow2D [[texture(1)]], texture1d uSampler1D [[texture(2)]], texture2d uSampler2D [[texture(3)]], texture3d uSampler3D [[texture(4)]], sampler uShadow2DSmplr [[sampler(1)]], sampler uSampler1DSmplr [[sampler(2)]], sampler uSampler2DSmplr [[sampler(3)]], sampler uSampler3DSmplr [[sampler(4)]]) +fragment main0_out main0(main0_in in [[stage_in]], depth2d uShadow2D [[texture(0)]], texture1d uSampler1D [[texture(1)]], texture2d uSampler2D [[texture(2)]], texture3d uSampler3D [[texture(3)]], sampler uShadow2DSmplr [[sampler(0)]], sampler uSampler1DSmplr [[sampler(1)]], sampler uSampler2DSmplr [[sampler(2)]], sampler uSampler3DSmplr [[sampler(3)]]) { main0_out out = {}; float4 _20 = in.vClip4; diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/tese/water_tess.tese b/3rdparty/spirv-cross/reference/opt/shaders-msl/tese/water_tess.tese index d660a4044..dd93e4134 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/tese/water_tess.tese +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/tese/water_tess.tese @@ -26,7 +26,7 @@ struct main0_patchIn float4 vPatchLods [[attribute(1)]]; }; -[[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], constant UBO& _31 [[buffer(1)]], texture2d uHeightmapDisplacement [[texture(0)]], sampler uHeightmapDisplacementSmplr [[sampler(0)]], float2 gl_TessCoord [[position_in_patch]]) +[[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], constant UBO& _31 [[buffer(0)]], texture2d uHeightmapDisplacement [[texture(0)]], sampler uHeightmapDisplacementSmplr [[sampler(0)]], float2 gl_TessCoord [[position_in_patch]]) { main0_out out = {}; float2 _201 = patchIn.vOutPatchPosBase + (float3(gl_TessCoord, 0).xy * _31.uPatchSize); diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/no_stage_out.write_buff.vert b/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/no_stage_out.write_buff.vert index 52af329a8..d5d31f443 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/no_stage_out.write_buff.vert +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/no_stage_out.write_buff.vert @@ -23,7 +23,7 @@ struct main0_in float4 m_17 [[attribute(0)]]; }; -vertex void main0(main0_in in [[stage_in]], constant _40& _42 [[buffer(0)]], device _35& _37 [[buffer(1)]]) +vertex void main0(main0_in in [[stage_in]], device _35& _37 [[buffer(0)]], constant _40& _42 [[buffer(1)]]) { main0_out out = {}; out.gl_Position = in.m_17; diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/no_stage_out.write_tex.vert b/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/no_stage_out.write_tex.vert index c2af1e2e6..ddad934ee 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/no_stage_out.write_tex.vert +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/no_stage_out.write_tex.vert @@ -13,7 +13,7 @@ struct main0_in float4 m_17 [[attribute(0)]]; }; -vertex void main0(main0_in in [[stage_in]], texture1d _37 [[texture(0)]], texture1d _34 [[texture(1)]]) +vertex void main0(main0_in in [[stage_in]], texture1d _34 [[texture(0)]], texture1d _37 [[texture(1)]]) { main0_out out = {}; out.gl_Position = in.m_17; diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/packed_matrix.vert b/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/packed_matrix.vert index d319839c4..64e66d702 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/packed_matrix.vert +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/packed_matrix.vert @@ -37,7 +37,7 @@ struct main0_in float4 m_25 [[attribute(0)]]; }; -vertex main0_out main0(main0_in in [[stage_in]], constant _42& _44 [[buffer(12)]], constant _15& _17 [[buffer(13)]]) +vertex main0_out main0(main0_in in [[stage_in]], constant _15& _17 [[buffer(0)]], constant _42& _44 [[buffer(1)]]) { main0_out out = {}; float4 _70 = _44._m0 * float4(float3(_44._m3) + (in.m_25.xyz * (_44._m6 + _44._m7)), 1.0); diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/resource-arrays-leaf.ios.vert b/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/resource-arrays-leaf.ios.vert index 7c454c1fc..91be3a047 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/resource-arrays-leaf.ios.vert +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/resource-arrays-leaf.ios.vert @@ -20,8 +20,14 @@ struct constant_block #endif constant int arraySize = SPIRV_CROSS_CONSTANT_ID_0; -vertex void main0(constant constant_block* constants_0 [[buffer(4)]], constant constant_block* constants_1 [[buffer(5)]], constant constant_block* constants_2 [[buffer(6)]], constant constant_block* constants_3 [[buffer(7)]], device storage_block* storage_0 [[buffer(8)]], device storage_block* storage_1 [[buffer(9)]], array, 3> images [[texture(0)]]) +vertex void main0(device storage_block* storage_0 [[buffer(0)]], device storage_block* storage_1 [[buffer(1)]], constant constant_block* constants_0 [[buffer(2)]], constant constant_block* constants_1 [[buffer(3)]], constant constant_block* constants_2 [[buffer(4)]], constant constant_block* constants_3 [[buffer(5)]], array, 3> images [[texture(0)]]) { + device storage_block* storage[] = + { + storage_0, + storage_1, + }; + constant constant_block* constants[] = { constants_0, @@ -30,12 +36,6 @@ vertex void main0(constant constant_block* constants_0 [[buffer(4)]], constant c constants_3, }; - device storage_block* storage[] = - { - storage_0, - storage_1, - }; - storage[0]->baz = uint4(constants[3]->foo); storage[1]->quux = images[2].read(uint2(int2(constants[1]->bar))).xy; } diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/resource-arrays.ios.vert b/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/resource-arrays.ios.vert index 7c454c1fc..91be3a047 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/resource-arrays.ios.vert +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/resource-arrays.ios.vert @@ -20,8 +20,14 @@ struct constant_block #endif constant int arraySize = SPIRV_CROSS_CONSTANT_ID_0; -vertex void main0(constant constant_block* constants_0 [[buffer(4)]], constant constant_block* constants_1 [[buffer(5)]], constant constant_block* constants_2 [[buffer(6)]], constant constant_block* constants_3 [[buffer(7)]], device storage_block* storage_0 [[buffer(8)]], device storage_block* storage_1 [[buffer(9)]], array, 3> images [[texture(0)]]) +vertex void main0(device storage_block* storage_0 [[buffer(0)]], device storage_block* storage_1 [[buffer(1)]], constant constant_block* constants_0 [[buffer(2)]], constant constant_block* constants_1 [[buffer(3)]], constant constant_block* constants_2 [[buffer(4)]], constant constant_block* constants_3 [[buffer(5)]], array, 3> images [[texture(0)]]) { + device storage_block* storage[] = + { + storage_0, + storage_1, + }; + constant constant_block* constants[] = { constants_0, @@ -30,12 +36,6 @@ vertex void main0(constant constant_block* constants_0 [[buffer(4)]], constant c constants_3, }; - device storage_block* storage[] = - { - storage_0, - storage_1, - }; - storage[0]->baz = uint4(constants[3]->foo); storage[1]->quux = images[2].read(uint2(int2(constants[1]->bar))).xy; } diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/texture_buffer.texture-buffer-native.msl21.vert b/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/texture_buffer.texture-buffer-native.msl21.vert index 75332f484..33c077c57 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/texture_buffer.texture-buffer-native.msl21.vert +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/texture_buffer.texture-buffer-native.msl21.vert @@ -8,7 +8,7 @@ struct main0_out float4 gl_Position [[position]]; }; -vertex main0_out main0(texture_buffer uSamp [[texture(4)]], texture_buffer uSampo [[texture(5)]]) +vertex main0_out main0(texture_buffer uSamp [[texture(0)]], texture_buffer uSampo [[texture(1)]]) { main0_out out = {}; out.gl_Position = uSamp.read(uint(10)) + uSampo.read(uint(100)); diff --git a/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/texture_buffer.vert b/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/texture_buffer.vert index c45d29813..ee3956fad 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/texture_buffer.vert +++ b/3rdparty/spirv-cross/reference/opt/shaders-msl/vert/texture_buffer.vert @@ -16,7 +16,7 @@ uint2 spvTexelBufferCoord(uint tc) return uint2(tc % 4096, tc / 4096); } -vertex main0_out main0(texture2d uSamp [[texture(4)]], texture2d uSampo [[texture(5)]]) +vertex main0_out main0(texture2d uSamp [[texture(0)]], texture2d uSampo [[texture(1)]]) { main0_out out = {}; out.gl_Position = uSamp.read(spvTexelBufferCoord(10)) + uSampo.read(spvTexelBufferCoord(100)); diff --git a/3rdparty/spirv-cross/reference/opt/shaders/asm/frag/switch-label-shared-block.asm.frag b/3rdparty/spirv-cross/reference/opt/shaders/asm/frag/switch-label-shared-block.asm.frag index ade9044e3..748f96c8b 100644 --- a/3rdparty/spirv-cross/reference/opt/shaders/asm/frag/switch-label-shared-block.asm.frag +++ b/3rdparty/spirv-cross/reference/opt/shaders/asm/frag/switch-label-shared-block.asm.frag @@ -16,7 +16,6 @@ void main() _19 = 1.0; break; } - case 1: default: { _19 = 3.0; diff --git a/3rdparty/spirv-cross/reference/opt/shaders/frag/barycentric-nv.frag b/3rdparty/spirv-cross/reference/opt/shaders/frag/barycentric-nv.frag new file mode 100644 index 000000000..cc3b4de27 --- /dev/null +++ b/3rdparty/spirv-cross/reference/opt/shaders/frag/barycentric-nv.frag @@ -0,0 +1,19 @@ +#version 450 +#extension GL_NV_fragment_shader_barycentric : require + +layout(binding = 0, std430) readonly buffer Vertices +{ + vec2 uvs[]; +} _19; + +layout(location = 0) out vec2 value; + +void main() +{ + int _23 = 3 * gl_PrimitiveID; + int _32 = _23 + 1; + int _39 = _23 + 2; + value = ((_19.uvs[_23] * gl_BaryCoordNV.x) + (_19.uvs[_32] * gl_BaryCoordNV.y)) + (_19.uvs[_39] * gl_BaryCoordNV.z); + value += (((_19.uvs[_23] * gl_BaryCoordNoPerspNV.x) + (_19.uvs[_32] * gl_BaryCoordNoPerspNV.y)) + (_19.uvs[_39] * gl_BaryCoordNoPerspNV.z)); +} + diff --git a/3rdparty/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/switch-block-case-fallthrough.asm.frag b/3rdparty/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/switch-block-case-fallthrough.asm.frag new file mode 100644 index 000000000..fa4953fdb --- /dev/null +++ b/3rdparty/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/switch-block-case-fallthrough.asm.frag @@ -0,0 +1,79 @@ +static int vIndex; +static float4 FragColor; + +struct SPIRV_Cross_Input +{ + nointerpolation int vIndex : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + int i = 0; + int j; + int _30; + int _31; + if (vIndex != 0 && vIndex != 1 && vIndex != 11 && vIndex != 2 && vIndex != 3 && vIndex != 4 && vIndex != 5) + { + _30 = 2; + } + if (vIndex == 1 || vIndex == 11) + { + _31 = 1; + } + switch (vIndex) + { + case 0: + { + _30 = 3; + } + default: + { + j = _30; + _31 = 0; + } + case 1: + case 11: + { + j = _31; + } + case 2: + { + break; + } + case 3: + { + if (vIndex > 3) + { + i = 0; + break; + } + else + { + break; + } + } + case 4: + { + } + case 5: + { + i = 0; + break; + } + } + FragColor = float(i).xxxx; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vIndex = stage_input.vIndex; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/3rdparty/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers.asm.comp b/3rdparty/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers.asm.comp index dd69ce5f4..37731c720 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers.asm.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl-no-opt/asm/comp/variable-pointers.asm.comp @@ -37,7 +37,7 @@ threadgroup int* select_tgsm(constant bar& cb, threadgroup int (&tgsm)[128]) return (cb.d != 0) ? &tgsm[0u] : nullptr; } -kernel void main0(device foo& buf [[buffer(0)]], constant bar& cb [[buffer(3)]], device baz& buf2 [[buffer(4)]]) +kernel void main0(device foo& buf [[buffer(0)]], constant bar& cb [[buffer(1)]], device baz& buf2 [[buffer(2)]]) { threadgroup int tgsm[128]; device int* sbuf = select_buffer(buf, buf2, cb); diff --git a/3rdparty/spirv-cross/reference/shaders-msl-no-opt/asm/frag/inliner-dominator-inside-loop.asm.frag b/3rdparty/spirv-cross/reference/shaders-msl-no-opt/asm/frag/inliner-dominator-inside-loop.asm.frag index d02aeb6f2..1af9edc35 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl-no-opt/asm/frag/inliner-dominator-inside-loop.asm.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl-no-opt/asm/frag/inliner-dominator-inside-loop.asm.frag @@ -101,7 +101,7 @@ struct main0_in float IN_studIndex [[user(locn8)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], constant CB0& _19 [[buffer(0)]], texture2d StudsMapTexture [[texture(0)]], texture2d ShadowMapTexture [[texture(1)]], texturecube EnvironmentMapTexture [[texture(2)]], texture2d DiffuseMapTexture [[texture(3)]], texture2d NormalMapTexture [[texture(4)]], texture2d SpecularMapTexture [[texture(5)]], texture3d LightMapTexture [[texture(6)]], texture2d NormalDetailMapTexture [[texture(8)]], sampler StudsMapSampler [[sampler(0)]], sampler ShadowMapSampler [[sampler(1)]], sampler EnvironmentMapSampler [[sampler(2)]], sampler DiffuseMapSampler [[sampler(3)]], sampler NormalMapSampler [[sampler(4)]], sampler SpecularMapSampler [[sampler(5)]], sampler LightMapSampler [[sampler(6)]], sampler NormalDetailMapSampler [[sampler(8)]], float4 gl_FragCoord [[position]]) +fragment main0_out main0(main0_in in [[stage_in]], constant CB0& _19 [[buffer(0)]], texture3d LightMapTexture [[texture(0)]], texture2d ShadowMapTexture [[texture(1)]], texturecube EnvironmentMapTexture [[texture(2)]], texture2d DiffuseMapTexture [[texture(3)]], texture2d NormalMapTexture [[texture(4)]], texture2d NormalDetailMapTexture [[texture(5)]], texture2d StudsMapTexture [[texture(6)]], texture2d SpecularMapTexture [[texture(7)]], sampler LightMapSampler [[sampler(0)]], sampler ShadowMapSampler [[sampler(1)]], sampler EnvironmentMapSampler [[sampler(2)]], sampler DiffuseMapSampler [[sampler(3)]], sampler NormalMapSampler [[sampler(4)]], sampler NormalDetailMapSampler [[sampler(5)]], sampler StudsMapSampler [[sampler(6)]], sampler SpecularMapSampler [[sampler(7)]], float4 gl_FragCoord [[position]]) { main0_out out = {}; VertexOutput _128 = _121; diff --git a/3rdparty/spirv-cross/reference/shaders-msl-no-opt/asm/frag/switch-block-case-fallthrough.asm.frag b/3rdparty/spirv-cross/reference/shaders-msl-no-opt/asm/frag/switch-block-case-fallthrough.asm.frag new file mode 100644 index 000000000..e179b7e23 --- /dev/null +++ b/3rdparty/spirv-cross/reference/shaders-msl-no-opt/asm/frag/switch-block-case-fallthrough.asm.frag @@ -0,0 +1,75 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + int vIndex [[user(locn0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + int i = 0; + main0_out out = {}; + int j; + int _30; + int _31; + if (in.vIndex != 0 && in.vIndex != 1 && in.vIndex != 11 && in.vIndex != 2 && in.vIndex != 3 && in.vIndex != 4 && in.vIndex != 5) + { + _30 = 2; + } + if (in.vIndex == 1 || in.vIndex == 11) + { + _31 = 1; + } + switch (in.vIndex) + { + case 0: + { + _30 = 3; + } + default: + { + j = _30; + _31 = 0; + } + case 1: + case 11: + { + j = _31; + } + case 2: + { + break; + } + case 3: + { + if (in.vIndex > 3) + { + i = 0; + break; + } + else + { + break; + } + } + case 4: + { + } + case 5: + { + i = 0; + break; + } + } + out.FragColor = float4(float(i)); + return out; +} + diff --git a/3rdparty/spirv-cross/reference/shaders-msl-no-opt/asm/frag/texture-access.swizzle.asm.frag b/3rdparty/spirv-cross/reference/shaders-msl-no-opt/asm/frag/texture-access.swizzle.asm.frag index 1652c8c89..fce6757b4 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl-no-opt/asm/frag/texture-access.swizzle.asm.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl-no-opt/asm/frag/texture-access.swizzle.asm.frag @@ -131,7 +131,7 @@ inline vec spvGatherCompareSwizzle(sampler s, const thread Tex& t, Ts... p return t.gather_compare(s, spvForward(params)...); } -fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d tex1d [[texture(0)]], texture2d tex2d [[texture(1)]], texture3d tex3d [[texture(2)]], texturecube texCube [[texture(3)]], texture2d_array tex2dArray [[texture(4)]], texturecube_array texCubeArray [[texture(5)]], texture2d texBuffer [[texture(6)]], depth2d depth2d [[texture(7)]], depthcube depthCube [[texture(8)]], depth2d_array depth2dArray [[texture(9)]], depthcube_array depthCubeArray [[texture(10)]], sampler tex1dSamp [[sampler(0)]], sampler tex2dSamp [[sampler(1)]], sampler tex3dSamp [[sampler(2)]], sampler texCubeSamp [[sampler(3)]], sampler tex2dArraySamp [[sampler(4)]], sampler texCubeArraySamp [[sampler(5)]], sampler depth2dSamp [[sampler(7)]], sampler depthCubeSamp [[sampler(8)]], sampler depth2dArraySamp [[sampler(9)]], sampler depthCubeArraySamp [[sampler(10)]]) +fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d tex1d [[texture(0)]], texture2d tex2d [[texture(1)]], texture3d tex3d [[texture(2)]], texturecube texCube [[texture(3)]], texture2d_array tex2dArray [[texture(4)]], texturecube_array texCubeArray [[texture(5)]], depth2d depth2d [[texture(6)]], depthcube depthCube [[texture(7)]], depth2d_array depth2dArray [[texture(8)]], depthcube_array depthCubeArray [[texture(9)]], texture2d texBuffer [[texture(10)]], sampler tex1dSamp [[sampler(0)]], sampler tex2dSamp [[sampler(1)]], sampler tex3dSamp [[sampler(2)]], sampler texCubeSamp [[sampler(3)]], sampler tex2dArraySamp [[sampler(4)]], sampler texCubeArraySamp [[sampler(5)]], sampler depth2dSamp [[sampler(6)]], sampler depthCubeSamp [[sampler(7)]], sampler depth2dArraySamp [[sampler(8)]], sampler depthCubeArraySamp [[sampler(9)]]) { constant uint& tex1dSwzl = spvSwizzleConstants[0]; constant uint& tex2dSwzl = spvSwizzleConstants[1]; @@ -139,10 +139,10 @@ fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d constant uint& texCubeSwzl = spvSwizzleConstants[3]; constant uint& tex2dArraySwzl = spvSwizzleConstants[4]; constant uint& texCubeArraySwzl = spvSwizzleConstants[5]; - constant uint& depth2dSwzl = spvSwizzleConstants[7]; - constant uint& depthCubeSwzl = spvSwizzleConstants[8]; - constant uint& depth2dArraySwzl = spvSwizzleConstants[9]; - constant uint& depthCubeArraySwzl = spvSwizzleConstants[10]; + constant uint& depth2dSwzl = spvSwizzleConstants[6]; + constant uint& depthCubeSwzl = spvSwizzleConstants[7]; + constant uint& depth2dArraySwzl = spvSwizzleConstants[8]; + constant uint& depthCubeArraySwzl = spvSwizzleConstants[9]; float4 c = spvTextureSwizzle(tex1d.sample(tex1dSamp, 0.0), tex1dSwzl); c = spvTextureSwizzle(tex2d.sample(tex2dSamp, float2(0.0)), tex2dSwzl); c = spvTextureSwizzle(tex3d.sample(tex3dSamp, float3(0.0)), tex3dSwzl); diff --git a/3rdparty/spirv-cross/reference/shaders-msl-no-opt/comp/return.comp b/3rdparty/spirv-cross/reference/shaders-msl-no-opt/comp/return.comp index 4015ddb37..71fcfbe39 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl-no-opt/comp/return.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl-no-opt/comp/return.comp @@ -8,7 +8,7 @@ struct SSBO2 float4 out_data[1]; }; -kernel void main0(device SSBO2& _27 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +kernel void main0(device SSBO2& _27 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { uint ident = gl_GlobalInvocationID.x; if (ident == 2u) diff --git a/3rdparty/spirv-cross/reference/shaders-msl-no-opt/frag/texture-access-leaf.swizzle.frag b/3rdparty/spirv-cross/reference/shaders-msl-no-opt/frag/texture-access-leaf.swizzle.frag index 2b11faa02..581f29094 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl-no-opt/frag/texture-access-leaf.swizzle.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl-no-opt/frag/texture-access-leaf.swizzle.frag @@ -178,7 +178,7 @@ float4 doSwizzle(thread texture1d tex1d, thread const sampler tex1dSmplr, return c; } -fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d tex1d [[texture(0)]], texture2d tex2d [[texture(1)]], texture3d tex3d [[texture(2)]], texturecube texCube [[texture(3)]], texture2d_array tex2dArray [[texture(4)]], texturecube_array texCubeArray [[texture(5)]], texture2d texBuffer [[texture(6)]], depth2d depth2d [[texture(7)]], depthcube depthCube [[texture(8)]], depth2d_array depth2dArray [[texture(9)]], depthcube_array depthCubeArray [[texture(10)]], sampler tex1dSmplr [[sampler(0)]], sampler tex2dSmplr [[sampler(1)]], sampler tex3dSmplr [[sampler(2)]], sampler texCubeSmplr [[sampler(3)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]], sampler depth2dSmplr [[sampler(7)]], sampler depthCubeSmplr [[sampler(8)]], sampler depth2dArraySmplr [[sampler(9)]], sampler depthCubeArraySmplr [[sampler(10)]]) +fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d tex1d [[texture(0)]], texture2d tex2d [[texture(1)]], texture3d tex3d [[texture(2)]], texturecube texCube [[texture(3)]], texture2d_array tex2dArray [[texture(4)]], texturecube_array texCubeArray [[texture(5)]], depth2d depth2d [[texture(6)]], depthcube depthCube [[texture(7)]], depth2d_array depth2dArray [[texture(8)]], depthcube_array depthCubeArray [[texture(9)]], texture2d texBuffer [[texture(10)]], sampler tex1dSmplr [[sampler(0)]], sampler tex2dSmplr [[sampler(1)]], sampler tex3dSmplr [[sampler(2)]], sampler texCubeSmplr [[sampler(3)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]], sampler depth2dSmplr [[sampler(6)]], sampler depthCubeSmplr [[sampler(7)]], sampler depth2dArraySmplr [[sampler(8)]], sampler depthCubeArraySmplr [[sampler(9)]]) { constant uint& tex1dSwzl = spvSwizzleConstants[0]; constant uint& tex2dSwzl = spvSwizzleConstants[1]; @@ -186,10 +186,10 @@ fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d constant uint& texCubeSwzl = spvSwizzleConstants[3]; constant uint& tex2dArraySwzl = spvSwizzleConstants[4]; constant uint& texCubeArraySwzl = spvSwizzleConstants[5]; - constant uint& depth2dSwzl = spvSwizzleConstants[7]; - constant uint& depthCubeSwzl = spvSwizzleConstants[8]; - constant uint& depth2dArraySwzl = spvSwizzleConstants[9]; - constant uint& depthCubeArraySwzl = spvSwizzleConstants[10]; + constant uint& depth2dSwzl = spvSwizzleConstants[6]; + constant uint& depthCubeSwzl = spvSwizzleConstants[7]; + constant uint& depth2dArraySwzl = spvSwizzleConstants[8]; + constant uint& depthCubeArraySwzl = spvSwizzleConstants[9]; float4 c = doSwizzle(tex1d, tex1dSmplr, tex1dSwzl, tex2d, tex2dSmplr, tex2dSwzl, tex3d, tex3dSmplr, tex3dSwzl, texCube, texCubeSmplr, texCubeSwzl, tex2dArray, tex2dArraySmplr, tex2dArraySwzl, texCubeArray, texCubeArraySmplr, texCubeArraySwzl, depth2d, depth2dSmplr, depth2dSwzl, depthCube, depthCubeSmplr, depthCubeSwzl, depth2dArray, depth2dArraySmplr, depth2dArraySwzl, depthCubeArray, depthCubeArraySmplr, depthCubeArraySwzl, texBuffer); } diff --git a/3rdparty/spirv-cross/reference/shaders-msl-no-opt/frag/texture-access.swizzle.frag b/3rdparty/spirv-cross/reference/shaders-msl-no-opt/frag/texture-access.swizzle.frag index a819e2d5e..fb9865bcf 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl-no-opt/frag/texture-access.swizzle.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl-no-opt/frag/texture-access.swizzle.frag @@ -131,7 +131,7 @@ inline vec spvGatherCompareSwizzle(sampler s, const thread Tex& t, Ts... p return t.gather_compare(s, spvForward(params)...); } -fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d tex1d [[texture(0)]], texture2d tex2d [[texture(1)]], texture3d tex3d [[texture(2)]], texturecube texCube [[texture(3)]], texture2d_array tex2dArray [[texture(4)]], texturecube_array texCubeArray [[texture(5)]], texture2d texBuffer [[texture(6)]], depth2d depth2d [[texture(7)]], depthcube depthCube [[texture(8)]], depth2d_array depth2dArray [[texture(9)]], depthcube_array depthCubeArray [[texture(10)]], sampler tex1dSmplr [[sampler(0)]], sampler tex2dSmplr [[sampler(1)]], sampler tex3dSmplr [[sampler(2)]], sampler texCubeSmplr [[sampler(3)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]], sampler depth2dSmplr [[sampler(7)]], sampler depthCubeSmplr [[sampler(8)]], sampler depth2dArraySmplr [[sampler(9)]], sampler depthCubeArraySmplr [[sampler(10)]]) +fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d tex1d [[texture(0)]], texture2d tex2d [[texture(1)]], texture3d tex3d [[texture(2)]], texturecube texCube [[texture(3)]], texture2d_array tex2dArray [[texture(4)]], texturecube_array texCubeArray [[texture(5)]], depth2d depth2d [[texture(6)]], depthcube depthCube [[texture(7)]], depth2d_array depth2dArray [[texture(8)]], depthcube_array depthCubeArray [[texture(9)]], texture2d texBuffer [[texture(10)]], sampler tex1dSmplr [[sampler(0)]], sampler tex2dSmplr [[sampler(1)]], sampler tex3dSmplr [[sampler(2)]], sampler texCubeSmplr [[sampler(3)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]], sampler depth2dSmplr [[sampler(6)]], sampler depthCubeSmplr [[sampler(7)]], sampler depth2dArraySmplr [[sampler(8)]], sampler depthCubeArraySmplr [[sampler(9)]]) { constant uint& tex1dSwzl = spvSwizzleConstants[0]; constant uint& tex2dSwzl = spvSwizzleConstants[1]; @@ -139,10 +139,10 @@ fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d constant uint& texCubeSwzl = spvSwizzleConstants[3]; constant uint& tex2dArraySwzl = spvSwizzleConstants[4]; constant uint& texCubeArraySwzl = spvSwizzleConstants[5]; - constant uint& depth2dSwzl = spvSwizzleConstants[7]; - constant uint& depthCubeSwzl = spvSwizzleConstants[8]; - constant uint& depth2dArraySwzl = spvSwizzleConstants[9]; - constant uint& depthCubeArraySwzl = spvSwizzleConstants[10]; + constant uint& depth2dSwzl = spvSwizzleConstants[6]; + constant uint& depthCubeSwzl = spvSwizzleConstants[7]; + constant uint& depth2dArraySwzl = spvSwizzleConstants[8]; + constant uint& depthCubeArraySwzl = spvSwizzleConstants[9]; float4 c = spvTextureSwizzle(tex1d.sample(tex1dSmplr, 0.0), tex1dSwzl); c = spvTextureSwizzle(tex2d.sample(tex2dSmplr, float2(0.0)), tex2dSwzl); c = spvTextureSwizzle(tex3d.sample(tex3dSmplr, float3(0.0)), tex3dSwzl); diff --git a/3rdparty/spirv-cross/reference/shaders-msl-no-opt/vert/functions_nested.vert b/3rdparty/spirv-cross/reference/shaders-msl-no-opt/vert/functions_nested.vert index 521109573..5d67f408b 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl-no-opt/vert/functions_nested.vert +++ b/3rdparty/spirv-cross/reference/shaders-msl-no-opt/vert/functions_nested.vert @@ -173,7 +173,7 @@ void vs_adjust(thread float4& dst_reg0, thread float4& dst_reg1, thread float4& dst_reg0.x = float4(dot(float4(tmp0.xyz, 1.0), v_309.vc[0])).x; } -vertex main0_out main0(constant VertexBuffer& v_227 [[buffer(0)]], constant VertexConstantsBuffer& v_309 [[buffer(1)]], texture2d buff_in_1 [[texture(3)]], texture2d buff_in_2 [[texture(4)]], uint gl_VertexIndex [[vertex_id]]) +vertex main0_out main0(constant VertexBuffer& v_227 [[buffer(0)]], constant VertexConstantsBuffer& v_309 [[buffer(1)]], texture2d buff_in_2 [[texture(0)]], texture2d buff_in_1 [[texture(1)]], uint gl_VertexIndex [[vertex_id]]) { main0_out out = {}; float4 dst_reg0 = float4(0.0, 0.0, 0.0, 1.0); diff --git a/3rdparty/spirv-cross/reference/shaders-msl-no-opt/vulkan/frag/texture-access-function.swizzle.vk.frag b/3rdparty/spirv-cross/reference/shaders-msl-no-opt/vulkan/frag/texture-access-function.swizzle.vk.frag index af920dbfe..9c3fff593 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl-no-opt/vulkan/frag/texture-access-function.swizzle.vk.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl-no-opt/vulkan/frag/texture-access-function.swizzle.vk.frag @@ -183,7 +183,7 @@ float4 do_samples(thread const texture1d t1, thread const sampler t1Smplr return c; } -fragment main0_out main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d tex1d [[texture(0)]], texture2d tex2d [[texture(1)]], texture3d tex3d [[texture(2)]], texturecube texCube [[texture(3)]], texture2d_array tex2dArray [[texture(4)]], texturecube_array texCubeArray [[texture(5)]], texture2d texBuffer [[texture(6)]], depth2d depth2d [[texture(7)]], depthcube depthCube [[texture(8)]], depth2d_array depth2dArray [[texture(9)]], depthcube_array depthCubeArray [[texture(10)]], sampler tex1dSmplr [[sampler(0)]], sampler tex3dSmplr [[sampler(2)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]], sampler depth2dSmplr [[sampler(7)]], sampler depthCubeSmplr [[sampler(8)]], sampler depthCubeArraySmplr [[sampler(10)]], sampler defaultSampler [[sampler(11)]], sampler shadowSampler [[sampler(12)]]) +fragment main0_out main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d tex1d [[texture(0)]], texture2d tex2d [[texture(1)]], texture3d tex3d [[texture(2)]], texturecube texCube [[texture(3)]], texture2d_array tex2dArray [[texture(4)]], texturecube_array texCubeArray [[texture(5)]], texture2d texBuffer [[texture(6)]], depth2d depth2d [[texture(7)]], depthcube depthCube [[texture(8)]], depth2d_array depth2dArray [[texture(9)]], depthcube_array depthCubeArray [[texture(10)]], sampler defaultSampler [[sampler(0)]], sampler shadowSampler [[sampler(1)]], sampler tex1dSmplr [[sampler(2)]], sampler tex3dSmplr [[sampler(3)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]], sampler depth2dSmplr [[sampler(6)]], sampler depthCubeSmplr [[sampler(7)]], sampler depthCubeArraySmplr [[sampler(8)]]) { main0_out out = {}; constant uint& tex1dSwzl = spvSwizzleConstants[0]; diff --git a/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/block-name-alias-global.asm.comp b/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/block-name-alias-global.asm.comp index e983acd92..2928efda2 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/block-name-alias-global.asm.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/block-name-alias-global.asm.comp @@ -35,7 +35,7 @@ struct B_1 /* FIXME: A padded struct is needed here. If you see this message, file a bug! */ A_2 Data[1024]; }; -kernel void main0(device B& C3 [[buffer(0)]], device A_1& C1 [[buffer(1)]], constant A_3& C2 [[buffer(2)]], constant B_1& C4 [[buffer(3)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +kernel void main0(device A_1& C1 [[buffer(0)]], constant A_3& C2 [[buffer(1)]], device B& C3 [[buffer(2)]], constant B_1& C4 [[buffer(3)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { C1.Data[gl_GlobalInvocationID.x].a = C2.Data[gl_GlobalInvocationID.x].a; C1.Data[gl_GlobalInvocationID.x].b = C2.Data[gl_GlobalInvocationID.x].b; diff --git a/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp b/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp index 4cb90e202..217782ce7 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp @@ -16,7 +16,7 @@ uint2 spvTexelBufferCoord(uint tc) return uint2(tc % 4096, tc / 4096); } -kernel void main0(constant cb5_struct& cb0_5 [[buffer(1)]], texture2d u0 [[texture(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) +kernel void main0(constant cb5_struct& cb0_5 [[buffer(0)]], texture2d u0 [[texture(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) { float4 r0; r0.x = as_type(int(gl_LocalInvocationID.x) << 4); diff --git a/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/buffer-write.asm.comp b/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/buffer-write.asm.comp index ab375a397..159d09b38 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/buffer-write.asm.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/buffer-write.asm.comp @@ -16,7 +16,7 @@ uint2 spvTexelBufferCoord(uint tc) return uint2(tc % 4096, tc / 4096); } -kernel void main0(constant cb& _6 [[buffer(7)]], texture2d _buffer [[texture(0)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]]) +kernel void main0(constant cb& _6 [[buffer(0)]], texture2d _buffer [[texture(0)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]]) { _buffer.write(float4(_6.value), spvTexelBufferCoord(((32u * gl_WorkGroupID.x) + gl_LocalInvocationIndex))); } diff --git a/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/global-parameter-name-alias.asm.comp b/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/global-parameter-name-alias.asm.comp index 23b88f7a3..967d14bfc 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/global-parameter-name-alias.asm.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/global-parameter-name-alias.asm.comp @@ -22,7 +22,7 @@ void _main(thread const uint3& id, const device ssbo& ssbo_1) Load(param, ssbo_1); } -kernel void main0(const device ssbo& ssbo_1 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +kernel void main0(const device ssbo& ssbo_1 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { uint3 id = gl_GlobalInvocationID; uint3 param = id; diff --git a/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/vector-builtin-type-cast-func.asm.comp b/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/vector-builtin-type-cast-func.asm.comp index 8a9e4450a..e4092261d 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/vector-builtin-type-cast-func.asm.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/vector-builtin-type-cast-func.asm.comp @@ -17,7 +17,7 @@ int2 get_texcoord(thread const int2& base, thread const int2& index, thread uint return (base * int3(gl_LocalInvocationID).xy) + index; } -kernel void main0(constant cb1_struct& cb0_1 [[buffer(0)]], texture2d u0 [[texture(1)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) +kernel void main0(constant cb1_struct& cb0_1 [[buffer(0)]], texture2d u0 [[texture(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) { int2 r0 = int2(int2(u0.get_width(), u0.get_height()) >> int2(uint2(4u))); for (int i = 0; i < r0.y; i++) diff --git a/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/vector-builtin-type-cast.asm.comp b/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/vector-builtin-type-cast.asm.comp index 177662501..793713d58 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/vector-builtin-type-cast.asm.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/asm/comp/vector-builtin-type-cast.asm.comp @@ -10,7 +10,7 @@ struct cb1_struct constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(16u, 16u, 1u); -kernel void main0(constant cb1_struct& cb0_1 [[buffer(0)]], texture2d u0 [[texture(1)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) +kernel void main0(constant cb1_struct& cb0_1 [[buffer(0)]], texture2d u0 [[texture(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) { int2 r0 = int2(int2(u0.get_width(), u0.get_height()) >> int2(uint2(4u))); for (int i = 0; i < r0.y; i++) diff --git a/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/combined-sampler-reuse.asm.frag b/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/combined-sampler-reuse.asm.frag index e420153bf..703dd0a95 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/combined-sampler-reuse.asm.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/combined-sampler-reuse.asm.frag @@ -13,7 +13,7 @@ struct main0_in float2 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], texture2d uTex [[texture(1)]], sampler uSampler [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d uTex [[texture(0)]], sampler uSampler [[sampler(0)]]) { main0_out out = {}; out.FragColor = uTex.sample(uSampler, in.vUV); diff --git a/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/descriptor-array-unnamed.asm.frag b/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/descriptor-array-unnamed.asm.frag index 697389fa8..1870f6719 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/descriptor-array-unnamed.asm.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/descriptor-array-unnamed.asm.frag @@ -23,16 +23,8 @@ struct main0_out float4 m_3 [[color(0)]]; }; -fragment main0_out main0(constant _6& _20 [[buffer(0)]], constant _7* _8_0 [[buffer(1)]], constant _7* _8_1 [[buffer(2)]], constant _7* _8_2 [[buffer(3)]], constant _7* _8_3 [[buffer(4)]], const device _4* _5_0 [[buffer(5)]], const device _4* _5_1 [[buffer(6)]], const device _4* _5_2 [[buffer(7)]], const device _4* _5_3 [[buffer(8)]]) +fragment main0_out main0(const device _4* _5_0 [[buffer(0)]], const device _4* _5_1 [[buffer(1)]], const device _4* _5_2 [[buffer(2)]], const device _4* _5_3 [[buffer(3)]], constant _6& _20 [[buffer(4)]], constant _7* _8_0 [[buffer(5)]], constant _7* _8_1 [[buffer(6)]], constant _7* _8_2 [[buffer(7)]], constant _7* _8_3 [[buffer(8)]]) { - constant _7* _8[] = - { - _8_0, - _8_1, - _8_2, - _8_3, - }; - const device _4* _5[] = { _5_0, @@ -41,6 +33,14 @@ fragment main0_out main0(constant _6& _20 [[buffer(0)]], constant _7* _8_0 [[buf _5_3, }; + constant _7* _8[] = + { + _8_0, + _8_1, + _8_2, + _8_3, + }; + main0_out out = {}; out.m_3 = _5[_20._m0]->_m0 + (_8[_20._m0]->_m0 * float4(0.20000000298023223876953125)); return out; diff --git a/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/min-lod.msl22.asm.frag b/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/min-lod.msl22.asm.frag new file mode 100644 index 000000000..5193b2cda --- /dev/null +++ b/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/min-lod.msl22.asm.frag @@ -0,0 +1,22 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 vUV [[user(locn0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]]) +{ + main0_out out = {}; + out.FragColor = uSampler.sample(uSamplerSmplr, in.vUV, min_lod_clamp(4.0)); + return out; +} + diff --git a/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/op-image-sampled-image.asm.frag b/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/op-image-sampled-image.asm.frag index 1fd5d15e6..972daee61 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/op-image-sampled-image.asm.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/op-image-sampled-image.asm.frag @@ -13,7 +13,7 @@ struct main0_out float4 o0 [[color(0)]]; }; -fragment main0_out main0(constant push_cb& _19 [[buffer(0)]], texture2d t0 [[texture(2)]], sampler dummy_sampler [[sampler(4)]]) +fragment main0_out main0(constant push_cb& _19 [[buffer(0)]], texture2d t0 [[texture(0)]], sampler dummy_sampler [[sampler(0)]]) { main0_out out = {}; float4 r0; diff --git a/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/unknown-depth-state.asm.frag b/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/unknown-depth-state.asm.frag index 005af22e3..ce2b95196 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/unknown-depth-state.asm.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/unknown-depth-state.asm.frag @@ -25,7 +25,7 @@ float sample_separate(thread float3& vUV, thread depth2d uTexture, thread return uTexture.sample_compare(uSampler, vUV.xy, vUV.z); } -fragment main0_out main0(main0_in in [[stage_in]], depth2d uShadow [[texture(0)]], depth2d uTexture [[texture(1)]], sampler uShadowSmplr [[sampler(0)]], sampler uSampler [[sampler(2)]]) +fragment main0_out main0(main0_in in [[stage_in]], depth2d uShadow [[texture(0)]], depth2d uTexture [[texture(1)]], sampler uShadowSmplr [[sampler(0)]], sampler uSampler [[sampler(1)]]) { main0_out out = {}; out.FragColor = sample_combined(in.vUV, uShadow, uShadowSmplr) + sample_separate(in.vUV, uTexture, uSampler); diff --git a/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag b/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag index 1738478dc..e55d9aead 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag @@ -125,7 +125,7 @@ struct main0_out float4 m_5 [[color(0)]]; }; -fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _18& _19 [[buffer(1)]], constant _10& _11 [[buffer(2)]], texture2d _14 [[texture(4)]], texture2d _12 [[texture(13)]], texture2d _8 [[texture(14)]], sampler _15 [[sampler(3)]], sampler _13 [[sampler(5)]], sampler _9 [[sampler(6)]], float4 gl_FragCoord [[position]]) +fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buffer(1)]], constant _18& _19 [[buffer(2)]], texture2d _8 [[texture(0)]], texture2d _12 [[texture(1)]], texture2d _14 [[texture(2)]], sampler _9 [[sampler(0)]], sampler _13 [[sampler(1)]], sampler _15 [[sampler(2)]], float4 gl_FragCoord [[position]]) { main0_out out = {}; _28 _77 = _74; diff --git a/3rdparty/spirv-cross/reference/shaders-msl/comp/argument-buffers-discrete.msl2.argument.discrete.comp b/3rdparty/spirv-cross/reference/shaders-msl/comp/argument-buffers-discrete.msl2.argument.discrete.comp index 98668f505..f7757cd19 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/comp/argument-buffers-discrete.msl2.argument.discrete.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/comp/argument-buffers-discrete.msl2.argument.discrete.comp @@ -33,7 +33,7 @@ struct spvDescriptorSetBuffer1 const device SSBO1* ssbo1 [[id(0)]]; }; -kernel void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], constant spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]], const device SSBO2& ssbo2 [[buffer(5)]], device SSBO3& ssbo3 [[buffer(6)]]) +kernel void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], constant spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]], device SSBO3& ssbo3 [[buffer(2)]], const device SSBO2& ssbo2 [[buffer(3)]]) { ssbo3.v = ((*spvDescriptorSet0.ssbo0).v + (*spvDescriptorSet1.ssbo1).v) + ssbo2.v; } diff --git a/3rdparty/spirv-cross/reference/shaders-msl/comp/argument-buffers-image-load-store.msl2.argument.comp b/3rdparty/spirv-cross/reference/shaders-msl/comp/argument-buffers-image-load-store.msl2.argument.comp index 58bb59eae..9bd15acf7 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/comp/argument-buffers-image-load-store.msl2.argument.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/comp/argument-buffers-image-load-store.msl2.argument.comp @@ -5,8 +5,8 @@ using namespace metal; struct spvDescriptorSetBuffer0 { - texture2d uImage [[id(1)]]; - texture2d uImageRead [[id(2)]]; + texture2d uImage [[id(0)]]; + texture2d uImageRead [[id(1)]]; }; kernel void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) diff --git a/3rdparty/spirv-cross/reference/shaders-msl/comp/array-length.comp b/3rdparty/spirv-cross/reference/shaders-msl/comp/array-length.comp index 6bba2ab4f..8406d1e50 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/comp/array-length.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/comp/array-length.comp @@ -21,7 +21,7 @@ uint get_size(device SSBO& v_14, constant uint& v_14BufferSize, device SSBO1* (& return uint(int((v_14BufferSize - 16) / 16) + int((ssbosBufferSize[1] - 0) / 4)); } -kernel void main0(constant uint* spvBufferSizeConstants [[buffer(25)]], device SSBO& v_14 [[buffer(1)]], device SSBO1* ssbos_0 [[buffer(2)]], device SSBO1* ssbos_1 [[buffer(3)]]) +kernel void main0(constant uint* spvBufferSizeConstants [[buffer(25)]], device SSBO& v_14 [[buffer(0)]], device SSBO1* ssbos_0 [[buffer(1)]], device SSBO1* ssbos_1 [[buffer(2)]]) { device SSBO1* ssbos[] = { @@ -29,8 +29,8 @@ kernel void main0(constant uint* spvBufferSizeConstants [[buffer(25)]], device S ssbos_1, }; - constant uint& v_14BufferSize = spvBufferSizeConstants[1]; - constant uint* ssbosBufferSize = &spvBufferSizeConstants[2]; + constant uint& v_14BufferSize = spvBufferSizeConstants[0]; + constant uint* ssbosBufferSize = &spvBufferSizeConstants[1]; v_14.size = get_size(v_14, v_14BufferSize, ssbos, ssbosBufferSize); } diff --git a/3rdparty/spirv-cross/reference/shaders-msl/comp/array-length.msl2.argument.discrete.comp b/3rdparty/spirv-cross/reference/shaders-msl/comp/array-length.msl2.argument.discrete.comp index 89d9809e1..73bd3f6d7 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/comp/array-length.msl2.argument.discrete.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/comp/array-length.msl2.argument.discrete.comp @@ -29,14 +29,14 @@ struct SSBO3 struct spvDescriptorSetBuffer0 { - constant uint* spvBufferSizeConstants [[id(0)]]; - device SSBO* v_16 [[id(1)]]; + device SSBO* v_16 [[id(0)]]; + constant uint* spvBufferSizeConstants [[id(1)]]; }; struct spvDescriptorSetBuffer1 { - constant uint* spvBufferSizeConstants [[id(1)]]; - device SSBO1* ssbos [[id(2)]][2]; + device SSBO1* ssbos [[id(0)]][2]; + constant uint* spvBufferSizeConstants [[id(2)]]; }; uint get_size(device SSBO& v_16, constant uint& v_16BufferSize, device SSBO1* constant (&ssbos)[2], constant uint* ssbosBufferSize, device SSBO2& v_38, constant uint& v_38BufferSize, device SSBO3* (&ssbos2)[2], constant uint* ssbos2BufferSize) @@ -48,7 +48,7 @@ uint get_size(device SSBO& v_16, constant uint& v_16BufferSize, device SSBO1* co return len; } -kernel void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], constant spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]], constant uint* spvBufferSizeConstants [[buffer(25)]], device SSBO3* ssbos2_0 [[buffer(2)]], device SSBO3* ssbos2_1 [[buffer(3)]], device SSBO2& v_38 [[buffer(5)]]) +kernel void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], constant spvDescriptorSetBuffer1& spvDescriptorSet1 [[buffer(1)]], constant uint* spvBufferSizeConstants [[buffer(25)]], device SSBO2& v_38 [[buffer(2)]], device SSBO3* ssbos2_0 [[buffer(3)]], device SSBO3* ssbos2_1 [[buffer(4)]]) { device SSBO3* ssbos2[] = { @@ -56,10 +56,10 @@ kernel void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0 ssbos2_1, }; - constant uint& spvDescriptorSet0_v_16BufferSize = spvDescriptorSet0.spvBufferSizeConstants[1]; - constant uint* spvDescriptorSet1_ssbosBufferSize = &spvDescriptorSet1.spvBufferSizeConstants[2]; - constant uint& v_38BufferSize = spvBufferSizeConstants[5]; - constant uint* ssbos2BufferSize = &spvBufferSizeConstants[2]; + constant uint& spvDescriptorSet0_v_16BufferSize = spvDescriptorSet0.spvBufferSizeConstants[0]; + constant uint* spvDescriptorSet1_ssbosBufferSize = &spvDescriptorSet1.spvBufferSizeConstants[0]; + constant uint& v_38BufferSize = spvBufferSizeConstants[2]; + constant uint* ssbos2BufferSize = &spvBufferSizeConstants[3]; (*spvDescriptorSet0.v_16).size = get_size((*spvDescriptorSet0.v_16), spvDescriptorSet0_v_16BufferSize, spvDescriptorSet1.ssbos, spvDescriptorSet1_ssbosBufferSize, v_38, v_38BufferSize, ssbos2, ssbos2BufferSize); } diff --git a/3rdparty/spirv-cross/reference/shaders-msl/comp/atomic.comp b/3rdparty/spirv-cross/reference/shaders-msl/comp/atomic.comp index 0315f3b12..43e6a8f03 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/comp/atomic.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/comp/atomic.comp @@ -12,7 +12,7 @@ struct SSBO int i32; }; -kernel void main0(device SSBO& ssbo [[buffer(2)]]) +kernel void main0(device SSBO& ssbo [[buffer(0)]]) { threadgroup uint shared_u32; threadgroup int shared_i32; diff --git a/3rdparty/spirv-cross/reference/shaders-msl/comp/bitcast-16bit-2.invalid.comp b/3rdparty/spirv-cross/reference/shaders-msl/comp/bitcast-16bit-2.invalid.comp index 1dac3969b..59eb961f1 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/comp/bitcast-16bit-2.invalid.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/comp/bitcast-16bit-2.invalid.comp @@ -18,7 +18,7 @@ struct UBO half4 const0; }; -kernel void main0(device SSBO0& _29 [[buffer(0)]], device SSBO1& _21 [[buffer(1)]], constant UBO& _40 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +kernel void main0(device SSBO1& _21 [[buffer(0)]], device SSBO0& _29 [[buffer(1)]], constant UBO& _40 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { uint ident = gl_GlobalInvocationID.x; short2 _47 = as_type(_29.inputs[ident].x) + as_type(_40.const0.xy); diff --git a/3rdparty/spirv-cross/reference/shaders-msl/comp/coherent-block.comp b/3rdparty/spirv-cross/reference/shaders-msl/comp/coherent-block.comp index 963574acd..bec9b218c 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/comp/coherent-block.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/comp/coherent-block.comp @@ -8,7 +8,7 @@ struct SSBO float4 value; }; -kernel void main0(device SSBO& _10 [[buffer(1)]]) +kernel void main0(device SSBO& _10 [[buffer(0)]]) { _10.value = float4(20.0); } diff --git a/3rdparty/spirv-cross/reference/shaders-msl/comp/coherent-image.comp b/3rdparty/spirv-cross/reference/shaders-msl/comp/coherent-image.comp index 827a24712..0fe044fb9 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/comp/coherent-image.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/comp/coherent-image.comp @@ -8,7 +8,7 @@ struct SSBO int4 value; }; -kernel void main0(device SSBO& _10 [[buffer(1)]], texture2d uImage [[texture(3)]]) +kernel void main0(device SSBO& _10 [[buffer(0)]], texture2d uImage [[texture(0)]]) { _10.value = uImage.read(uint2(int2(10))); } diff --git a/3rdparty/spirv-cross/reference/shaders-msl/comp/int64.invalid.msl22.comp b/3rdparty/spirv-cross/reference/shaders-msl/comp/int64.invalid.msl22.comp new file mode 100644 index 000000000..6eb4a8a8d --- /dev/null +++ b/3rdparty/spirv-cross/reference/shaders-msl/comp/int64.invalid.msl22.comp @@ -0,0 +1,63 @@ +#include +#include + +using namespace metal; + +struct M0 +{ + long v; + long2 b[2]; + ulong c; + ulong d[5]; +}; + +struct SSBO0_Type +{ + long4 a; + M0 m0; +}; + +struct SSBO1_Type +{ + ulong4 b; + M0 m0; +}; + +struct SSBO2_Type +{ + long a[4]; + long2 b[4]; +}; + +struct SSBO3_Type +{ + long a[4]; + long2 b[4]; +}; + +struct SSBO +{ + int s32; + uint u32; +}; + +kernel void main0(device SSBO& _96 [[buffer(0)]]) +{ + SSBO0_Type ssbo_0; + ssbo_0.a += long4(10l, 20l, 30l, 40l); + SSBO1_Type ssbo_1; + ssbo_1.b += ulong4(999999999999999999ul, 8888888888888888ul, 77777777777777777ul, 6666666666666666ul); + ssbo_0.a += long4(20l); + ssbo_0.a = abs(ssbo_0.a + long4(ssbo_1.b)); + ssbo_0.a += long4(1l); + ssbo_1.b += ulong4(long4(1l)); + ssbo_0.a -= long4(1l); + ssbo_1.b -= ulong4(long4(1l)); + SSBO2_Type ssbo_2; + ssbo_2.a[0] += 1l; + SSBO3_Type ssbo_3; + ssbo_3.a[0] += 2l; + _96.s32 = int(uint(((ulong(ssbo_0.a.x) + ssbo_1.b.y) + ulong(ssbo_2.a[1])) + ulong(ssbo_3.a[2]))); + _96.u32 = uint(((ulong(ssbo_0.a.y) + ssbo_1.b.z) + ulong(ssbo_2.a[0])) + ulong(ssbo_3.a[1])); +} + diff --git a/3rdparty/spirv-cross/reference/shaders-msl/comp/mat3.comp b/3rdparty/spirv-cross/reference/shaders-msl/comp/mat3.comp index 475d163bd..c2d9a7c83 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/comp/mat3.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/comp/mat3.comp @@ -8,7 +8,7 @@ struct SSBO2 float3x3 out_data[1]; }; -kernel void main0(device SSBO2& _22 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +kernel void main0(device SSBO2& _22 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { uint ident = gl_GlobalInvocationID.x; _22.out_data[ident] = float3x3(float3(10.0), float3(20.0), float3(40.0)); diff --git a/3rdparty/spirv-cross/reference/shaders-msl/comp/packing-test-1.comp b/3rdparty/spirv-cross/reference/shaders-msl/comp/packing-test-1.comp index eae01fff4..61297429a 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/comp/packing-test-1.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/comp/packing-test-1.comp @@ -27,7 +27,7 @@ struct Buffer1 constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(32u, 1u, 1u); -kernel void main0(device Buffer0& _15 [[buffer(1)]], device Buffer1& _34 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +kernel void main0(device Buffer0& _15 [[buffer(0)]], device Buffer1& _34 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { T1 v; v.a = float3(_15.buf0[0].a); diff --git a/3rdparty/spirv-cross/reference/shaders-msl/comp/packing-test-2.comp b/3rdparty/spirv-cross/reference/shaders-msl/comp/packing-test-2.comp index 61a4970cc..4b91f3ca9 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/comp/packing-test-2.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/comp/packing-test-2.comp @@ -21,7 +21,7 @@ struct Buffer1 constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(32u, 1u, 1u); -kernel void main0(device Buffer0& _14 [[buffer(1)]], device Buffer1& _24 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +kernel void main0(device Buffer0& _14 [[buffer(0)]], device Buffer1& _24 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { float x = _14.buf0[0].b; _24.buf1[gl_GlobalInvocationID.x] = x; diff --git a/3rdparty/spirv-cross/reference/shaders-msl/comp/read-write-only.comp b/3rdparty/spirv-cross/reference/shaders-msl/comp/read-write-only.comp index 42c625092..7547b417d 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/comp/read-write-only.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/comp/read-write-only.comp @@ -21,7 +21,7 @@ struct SSBO1 float4 data3; }; -kernel void main0(const device SSBO0& _15 [[buffer(0)]], device SSBO1& _21 [[buffer(1)]], device SSBO2& _10 [[buffer(2)]]) +kernel void main0(device SSBO2& _10 [[buffer(0)]], const device SSBO0& _15 [[buffer(1)]], device SSBO1& _21 [[buffer(2)]]) { _10.data4 = _15.data0 + _21.data2; _10.data5 = _15.data1 + _21.data3; diff --git a/3rdparty/spirv-cross/reference/shaders-msl/comp/struct-layout.comp b/3rdparty/spirv-cross/reference/shaders-msl/comp/struct-layout.comp index 3c44fe541..b6ee59f16 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/comp/struct-layout.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/comp/struct-layout.comp @@ -18,7 +18,7 @@ struct SSBO Foo in_data[1]; }; -kernel void main0(const device SSBO& _30 [[buffer(0)]], device SSBO2& _23 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +kernel void main0(device SSBO2& _23 [[buffer(0)]], const device SSBO& _30 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { uint ident = gl_GlobalInvocationID.x; _23.out_data[ident].m = _30.in_data[ident].m * _30.in_data[ident].m; diff --git a/3rdparty/spirv-cross/reference/shaders-msl/comp/struct-nested.comp b/3rdparty/spirv-cross/reference/shaders-msl/comp/struct-nested.comp index 117e492d6..86229e341 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/comp/struct-nested.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/comp/struct-nested.comp @@ -28,7 +28,7 @@ struct dstbuffer s2_1 test[1]; }; -kernel void main0(device dstbuffer& _19 [[buffer(1)]]) +kernel void main0(device dstbuffer& _19 [[buffer(0)]]) { s2 testVal; testVal.b.a = 0; diff --git a/3rdparty/spirv-cross/reference/shaders-msl/comp/struct-packing.comp b/3rdparty/spirv-cross/reference/shaders-msl/comp/struct-packing.comp index bfaf4dd55..dd208a00a 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/comp/struct-packing.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/comp/struct-packing.comp @@ -116,7 +116,7 @@ struct SSBO0 float4 array[1]; }; -kernel void main0(device SSBO0& ssbo_140 [[buffer(0)]], device SSBO1& ssbo_430 [[buffer(1)]]) +kernel void main0(device SSBO1& ssbo_430 [[buffer(0)]], device SSBO0& ssbo_140 [[buffer(1)]]) { Content_1 _60 = ssbo_140.content; ssbo_430.content.m0s[0].a[0] = _60.m0s[0].a[0].xy; diff --git a/3rdparty/spirv-cross/reference/shaders-msl/comp/udiv.comp b/3rdparty/spirv-cross/reference/shaders-msl/comp/udiv.comp index a298ecdb7..32874ad78 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/comp/udiv.comp +++ b/3rdparty/spirv-cross/reference/shaders-msl/comp/udiv.comp @@ -13,7 +13,7 @@ struct SSBO uint inputs[1]; }; -kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _10 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +kernel void main0(device SSBO2& _10 [[buffer(0)]], device SSBO& _23 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { _10.outputs[gl_GlobalInvocationID.x] = _23.inputs[gl_GlobalInvocationID.x] / 29u; } diff --git a/3rdparty/spirv-cross/reference/shaders-msl/desktop-only/frag/image-ms.desktop.frag b/3rdparty/spirv-cross/reference/shaders-msl/desktop-only/frag/image-ms.desktop.frag index b7b2cc158..7957b209d 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/desktop-only/frag/image-ms.desktop.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/desktop-only/frag/image-ms.desktop.frag @@ -3,7 +3,7 @@ using namespace metal; -fragment void main0(texture2d uImage [[texture(0)]], texture2d_array uImageArray [[texture(1)]], texture2d_ms uImageMS [[texture(2)]]) +fragment void main0(texture2d_ms uImageMS [[texture(0)]], texture2d_array uImageArray [[texture(1)]], texture2d uImage [[texture(2)]]) { float4 a = uImageMS.read(uint2(int2(1, 2)), 2); float4 b = uImageArray.read(uint2(int3(1, 2, 4).xy), uint(int3(1, 2, 4).z)); diff --git a/3rdparty/spirv-cross/reference/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag b/3rdparty/spirv-cross/reference/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag index a6f06064a..330bc6403 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/desktop-only/frag/sampler-ms-query.desktop.frag @@ -8,7 +8,7 @@ struct main0_out float4 FragColor [[color(0)]]; }; -fragment main0_out main0(texture2d_ms uSampler [[texture(0)]], texture2d_ms uImage [[texture(2)]], sampler uSamplerSmplr [[sampler(0)]]) +fragment main0_out main0(texture2d_ms uSampler [[texture(0)]], texture2d_ms uImage [[texture(1)]], sampler uSamplerSmplr [[sampler(0)]]) { main0_out out = {}; out.FragColor = float4(float(int(uSampler.get_num_samples()) + int(uImage.get_num_samples()))); diff --git a/3rdparty/spirv-cross/reference/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert b/3rdparty/spirv-cross/reference/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert index 32f0d9aa0..a414c9854 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert +++ b/3rdparty/spirv-cross/reference/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert @@ -7,7 +7,6 @@ struct main0_out { float4 gl_Position [[position]]; float gl_ClipDistance [[clip_distance]] [2]; - float gl_CullDistance[2]; }; vertex main0_out main0() @@ -16,8 +15,6 @@ vertex main0_out main0() out.gl_Position = float4(10.0); out.gl_ClipDistance[0] = 1.0; out.gl_ClipDistance[1] = 4.0; - out.gl_CullDistance[0] = 4.0; - out.gl_CullDistance[1] = 9.0; return out; } diff --git a/3rdparty/spirv-cross/reference/shaders-msl/flatten/types.flatten.frag b/3rdparty/spirv-cross/reference/shaders-msl/flatten/types.flatten.frag index 540c5baeb..cee53d9e5 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/flatten/types.flatten.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/flatten/types.flatten.frag @@ -26,7 +26,7 @@ struct main0_out float4 FragColor [[color(0)]]; }; -fragment main0_out main0(constant UBO0& _41 [[buffer(0)]], constant UBO1& _14 [[buffer(1)]], constant UBO2& _29 [[buffer(2)]]) +fragment main0_out main0(constant UBO1& _14 [[buffer(0)]], constant UBO2& _29 [[buffer(1)]], constant UBO0& _41 [[buffer(2)]]) { main0_out out = {}; out.FragColor = ((((float4(_14.c) + float4(_14.d)) + float4(_29.e)) + float4(_29.f)) + _41.a) + _41.b; diff --git a/3rdparty/spirv-cross/reference/shaders-msl/frag/argument-buffers.msl2.argument.frag b/3rdparty/spirv-cross/reference/shaders-msl/frag/argument-buffers.msl2.argument.frag index 27b77a271..1cf972771 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/frag/argument-buffers.msl2.argument.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/frag/argument-buffers.msl2.argument.frag @@ -32,24 +32,24 @@ struct UBOs struct spvDescriptorSetBuffer0 { - texture2d uTexture [[id(2)]]; - sampler uTextureSmplr [[id(3)]]; - constant UBO* v_90 [[id(5)]]; - array, 2> uTextures [[id(6)]]; - array uTexturesSmplr [[id(8)]]; + texture2d uTexture [[id(0)]]; + sampler uTextureSmplr [[id(1)]]; + array, 2> uTextures [[id(2)]]; + array uTexturesSmplr [[id(4)]]; + constant UBO* v_90 [[id(6)]]; }; struct spvDescriptorSetBuffer1 { - array, 4> uTexture2 [[id(3)]]; - device SSBO* v_60 [[id(7)]]; - const device SSBOs* ssbos [[id(8)]][2]; - array uSampler [[id(10)]]; + array, 4> uTexture2 [[id(0)]]; + array uSampler [[id(4)]]; + device SSBO* v_60 [[id(6)]]; + const device SSBOs* ssbos [[id(7)]][2]; }; struct spvDescriptorSetBuffer2 { - constant UBOs* ubos [[id(4)]][4]; + constant UBOs* ubos [[id(0)]][4]; }; struct main0_out diff --git a/3rdparty/spirv-cross/reference/shaders-msl/frag/array-of-texture-swizzle.msl2.argument.discrete.swizzle.frag b/3rdparty/spirv-cross/reference/shaders-msl/frag/array-of-texture-swizzle.msl2.argument.discrete.swizzle.frag index 2b5afe235..702409ee7 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/frag/array-of-texture-swizzle.msl2.argument.discrete.swizzle.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/frag/array-of-texture-swizzle.msl2.argument.discrete.swizzle.frag @@ -7,9 +7,9 @@ using namespace metal; struct spvDescriptorSetBuffer0 { - constant uint* spvSwizzleConstants [[id(0)]]; - array, 4> uSampler0 [[id(1)]]; - array uSampler0Smplr [[id(5)]]; + array, 4> uSampler0 [[id(0)]]; + array uSampler0Smplr [[id(4)]]; + constant uint* spvSwizzleConstants [[id(8)]]; }; struct main0_out @@ -160,7 +160,7 @@ float4 sample_single_in_func(thread const texture2d s, thread const sampl fragment main0_out main0(main0_in in [[stage_in]], constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], constant uint* spvSwizzleConstants [[buffer(30)]], texture2d uSampler1 [[texture(0)]], sampler uSampler1Smplr [[sampler(0)]]) { main0_out out = {}; - constant uint* spvDescriptorSet0_uSampler0Swzl = &spvDescriptorSet0.spvSwizzleConstants[1]; + constant uint* spvDescriptorSet0_uSampler0Swzl = &spvDescriptorSet0.spvSwizzleConstants[0]; constant uint& uSampler1Swzl = spvSwizzleConstants[0]; out.FragColor = sample_in_func_1(spvDescriptorSet0.uSampler0, spvDescriptorSet0.uSampler0Smplr, spvDescriptorSet0_uSampler0Swzl, in.vUV); out.FragColor += sample_in_func_2(in.vUV, uSampler1, uSampler1Smplr, uSampler1Swzl); diff --git a/3rdparty/spirv-cross/reference/shaders-msl/frag/barycentric-nv-nopersp.msl22.frag b/3rdparty/spirv-cross/reference/shaders-msl/frag/barycentric-nv-nopersp.msl22.frag new file mode 100644 index 000000000..ef19fbf85 --- /dev/null +++ b/3rdparty/spirv-cross/reference/shaders-msl/frag/barycentric-nv-nopersp.msl22.frag @@ -0,0 +1,31 @@ +#include +#include + +using namespace metal; + +struct Vertices +{ + float2 uvs[1]; +}; + +struct main0_out +{ + float2 value [[color(0)]]; +}; + +struct main0_in +{ + float3 gl_BaryCoordNoPerspNV [[barycentric_coord, center_no_perspective]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], const device Vertices& _19 [[buffer(0)]], uint gl_PrimitiveID [[primitive_id]]) +{ + main0_out out = {}; + int prim = int(gl_PrimitiveID); + float2 uv0 = _19.uvs[(3 * prim) + 0]; + float2 uv1 = _19.uvs[(3 * prim) + 1]; + float2 uv2 = _19.uvs[(3 * prim) + 2]; + out.value = ((uv0 * in.gl_BaryCoordNoPerspNV.x) + (uv1 * in.gl_BaryCoordNoPerspNV.y)) + (uv2 * in.gl_BaryCoordNoPerspNV.z); + return out; +} + diff --git a/3rdparty/spirv-cross/reference/shaders-msl/frag/barycentric-nv.msl22.frag b/3rdparty/spirv-cross/reference/shaders-msl/frag/barycentric-nv.msl22.frag new file mode 100644 index 000000000..1d2e4c2f2 --- /dev/null +++ b/3rdparty/spirv-cross/reference/shaders-msl/frag/barycentric-nv.msl22.frag @@ -0,0 +1,31 @@ +#include +#include + +using namespace metal; + +struct Vertices +{ + float2 uvs[1]; +}; + +struct main0_out +{ + float2 value [[color(0)]]; +}; + +struct main0_in +{ + float3 gl_BaryCoordNV [[barycentric_coord, center_perspective]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], const device Vertices& _19 [[buffer(0)]], uint gl_PrimitiveID [[primitive_id]]) +{ + main0_out out = {}; + int prim = int(gl_PrimitiveID); + float2 uv0 = _19.uvs[(3 * prim) + 0]; + float2 uv1 = _19.uvs[(3 * prim) + 1]; + float2 uv2 = _19.uvs[(3 * prim) + 2]; + out.value = ((uv0 * in.gl_BaryCoordNV.x) + (uv1 * in.gl_BaryCoordNV.y)) + (uv2 * in.gl_BaryCoordNV.z); + return out; +} + diff --git a/3rdparty/spirv-cross/reference/shaders-msl/frag/complex-expression-in-access-chain.frag b/3rdparty/spirv-cross/reference/shaders-msl/frag/complex-expression-in-access-chain.frag index 7f39a7b94..9cd8bdc21 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/frag/complex-expression-in-access-chain.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/frag/complex-expression-in-access-chain.frag @@ -19,7 +19,7 @@ struct main0_in int vIn2 [[user(locn1)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], device UBO& _34 [[buffer(0)]], texture2d Buf [[texture(1)]], sampler BufSmplr [[sampler(1)]], float4 gl_FragCoord [[position]]) +fragment main0_out main0(main0_in in [[stage_in]], device UBO& _34 [[buffer(0)]], texture2d Buf [[texture(0)]], sampler BufSmplr [[sampler(0)]], float4 gl_FragCoord [[position]]) { main0_out out = {}; int4 coords = Buf.read(uint2(int2(gl_FragCoord.xy)), 0); diff --git a/3rdparty/spirv-cross/reference/shaders-msl/frag/image-query-lod.msl22.frag b/3rdparty/spirv-cross/reference/shaders-msl/frag/image-query-lod.msl22.frag new file mode 100644 index 000000000..4ec61c24d --- /dev/null +++ b/3rdparty/spirv-cross/reference/shaders-msl/frag/image-query-lod.msl22.frag @@ -0,0 +1,77 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float2 FragColor [[color(0)]]; +}; + +struct main0_in +{ + float3 vUV [[user(locn0)]]; +}; + +void from_function(thread float2& FragColor, thread texture2d uSampler2D, thread const sampler uSampler2DSmplr, thread float3& vUV, thread texture3d uSampler3D, thread const sampler uSampler3DSmplr, thread texturecube uSamplerCube, thread const sampler uSamplerCubeSmplr, thread texture2d uTexture2D, thread sampler uSampler, thread texture3d uTexture3D, thread texturecube uTextureCube) +{ + float2 _22; + _22.x = uSampler2D.calculate_clamped_lod(uSampler2DSmplr, vUV.xy); + _22.y = uSampler2D.calculate_unclamped_lod(uSampler2DSmplr, vUV.xy); + FragColor += _22; + float2 _31; + _31.x = uSampler3D.calculate_clamped_lod(uSampler3DSmplr, vUV); + _31.y = uSampler3D.calculate_unclamped_lod(uSampler3DSmplr, vUV); + FragColor += _31; + float2 _40; + _40.x = uSamplerCube.calculate_clamped_lod(uSamplerCubeSmplr, vUV); + _40.y = uSamplerCube.calculate_unclamped_lod(uSamplerCubeSmplr, vUV); + FragColor += _40; + float2 _53; + _53.x = uTexture2D.calculate_clamped_lod(uSampler, vUV.xy); + _53.y = uTexture2D.calculate_unclamped_lod(uSampler, vUV.xy); + FragColor += _53; + float2 _62; + _62.x = uTexture3D.calculate_clamped_lod(uSampler, vUV); + _62.y = uTexture3D.calculate_unclamped_lod(uSampler, vUV); + FragColor += _62; + float2 _71; + _71.x = uTextureCube.calculate_clamped_lod(uSampler, vUV); + _71.y = uTextureCube.calculate_unclamped_lod(uSampler, vUV); + FragColor += _71; +} + +fragment main0_out main0(main0_in in [[stage_in]], texture2d uSampler2D [[texture(0)]], texture3d uSampler3D [[texture(1)]], texturecube uSamplerCube [[texture(2)]], texture2d uTexture2D [[texture(3)]], texture3d uTexture3D [[texture(4)]], texturecube uTextureCube [[texture(5)]], sampler uSampler2DSmplr [[sampler(0)]], sampler uSampler3DSmplr [[sampler(1)]], sampler uSamplerCubeSmplr [[sampler(2)]], sampler uSampler [[sampler(3)]]) +{ + main0_out out = {}; + out.FragColor = float2(0.0); + float2 _79; + _79.x = uSampler2D.calculate_clamped_lod(uSampler2DSmplr, in.vUV.xy); + _79.y = uSampler2D.calculate_unclamped_lod(uSampler2DSmplr, in.vUV.xy); + out.FragColor += _79; + float2 _84; + _84.x = uSampler3D.calculate_clamped_lod(uSampler3DSmplr, in.vUV); + _84.y = uSampler3D.calculate_unclamped_lod(uSampler3DSmplr, in.vUV); + out.FragColor += _84; + float2 _89; + _89.x = uSamplerCube.calculate_clamped_lod(uSamplerCubeSmplr, in.vUV); + _89.y = uSamplerCube.calculate_unclamped_lod(uSamplerCubeSmplr, in.vUV); + out.FragColor += _89; + float2 _97; + _97.x = uTexture2D.calculate_clamped_lod(uSampler, in.vUV.xy); + _97.y = uTexture2D.calculate_unclamped_lod(uSampler, in.vUV.xy); + out.FragColor += _97; + float2 _104; + _104.x = uTexture3D.calculate_clamped_lod(uSampler, in.vUV); + _104.y = uTexture3D.calculate_unclamped_lod(uSampler, in.vUV); + out.FragColor += _104; + float2 _111; + _111.x = uTextureCube.calculate_clamped_lod(uSampler, in.vUV); + _111.y = uTextureCube.calculate_unclamped_lod(uSampler, in.vUV); + out.FragColor += _111; + from_function(out.FragColor, uSampler2D, uSampler2DSmplr, in.vUV, uSampler3D, uSampler3DSmplr, uSamplerCube, uSamplerCubeSmplr, uTexture2D, uSampler, uTexture3D, uTextureCube); + return out; +} + diff --git a/3rdparty/spirv-cross/reference/shaders-msl/frag/in_mat.frag b/3rdparty/spirv-cross/reference/shaders-msl/frag/in_mat.frag index f0f4c4eee..70ff4860b 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/frag/in_mat.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/frag/in_mat.frag @@ -19,7 +19,7 @@ struct main0_in float inLodBias [[user(locn6)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], texturecube samplerColor [[texture(1)]], sampler samplerColorSmplr [[sampler(1)]]) +fragment main0_out main0(main0_in in [[stage_in]], texturecube samplerColor [[texture(0)]], sampler samplerColorSmplr [[sampler(0)]]) { main0_out out = {}; float4x4 inInvModelView = {}; diff --git a/3rdparty/spirv-cross/reference/shaders-msl/frag/nonuniform-qualifier.msl2.frag b/3rdparty/spirv-cross/reference/shaders-msl/frag/nonuniform-qualifier.msl2.frag index 377a27d30..34f2bde10 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/frag/nonuniform-qualifier.msl2.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/frag/nonuniform-qualifier.msl2.frag @@ -24,7 +24,7 @@ struct main0_in float2 vUV [[user(locn1)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], constant UBO* ubos_0 [[buffer(0)]], constant UBO* ubos_1 [[buffer(1)]], const device SSBO* ssbos_0 [[buffer(2)]], const device SSBO* ssbos_1 [[buffer(3)]], array, 8> uSamplers [[texture(0)]], array, 8> uCombinedSamplers [[texture(8)]], array uSamps [[sampler(1)]], array uCombinedSamplersSmplr [[sampler(8)]]) +fragment main0_out main0(main0_in in [[stage_in]], constant UBO* ubos_0 [[buffer(0)]], constant UBO* ubos_1 [[buffer(1)]], const device SSBO* ssbos_0 [[buffer(2)]], const device SSBO* ssbos_1 [[buffer(3)]], array, 8> uSamplers [[texture(0)]], array, 8> uCombinedSamplers [[texture(8)]], array uSamps [[sampler(0)]], array uCombinedSamplersSmplr [[sampler(7)]]) { constant UBO* ubos[] = { diff --git a/3rdparty/spirv-cross/reference/shaders-msl/frag/sample-depth-separate-image-sampler.frag b/3rdparty/spirv-cross/reference/shaders-msl/frag/sample-depth-separate-image-sampler.frag index ae8434474..a9c0f8b41 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/frag/sample-depth-separate-image-sampler.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/frag/sample-depth-separate-image-sampler.frag @@ -20,7 +20,7 @@ float sample_color_from_function(thread const texture2d uT, thread const return uT.sample(uS, float2(0.5)).x; } -fragment main0_out main0(depth2d uDepth [[texture(0)]], texture2d uColor [[texture(1)]], sampler uSampler [[sampler(2)]], sampler uSamplerShadow [[sampler(3)]]) +fragment main0_out main0(depth2d uDepth [[texture(0)]], texture2d uColor [[texture(1)]], sampler uSamplerShadow [[sampler(0)]], sampler uSampler [[sampler(1)]]) { main0_out out = {}; out.FragColor = sample_depth_from_function(uDepth, uSamplerShadow) + sample_color_from_function(uColor, uSampler); diff --git a/3rdparty/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.frag b/3rdparty/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.frag index 18c2d4237..630511b34 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.frag @@ -13,7 +13,7 @@ struct main0_in float4 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d_array uTex [[texture(0)]], sampler uShadow [[sampler(1)]]) +fragment main0_out main0(main0_in in [[stage_in]], depth2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) { main0_out out = {}; out.FragColor = uTex.sample_compare(uShadow, in.vUV.xy, uint(round(in.vUV.z)), in.vUV.w, level(0)); diff --git a/3rdparty/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.ios.frag b/3rdparty/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.ios.frag index f01965c9e..a29ebf08b 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.ios.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.ios.frag @@ -13,7 +13,7 @@ struct main0_in float4 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d_array uTex [[texture(0)]], sampler uShadow [[sampler(1)]]) +fragment main0_out main0(main0_in in [[stage_in]], depth2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) { main0_out out = {}; out.FragColor = uTex.sample_compare(uShadow, in.vUV.xy, uint(round(in.vUV.z)), in.vUV.w, gradient2d(float2(0.0), float2(0.0))); diff --git a/3rdparty/spirv-cross/reference/shaders-msl/frag/sampler-image-arrays.msl2.frag b/3rdparty/spirv-cross/reference/shaders-msl/frag/sampler-image-arrays.msl2.frag index af5112c19..10a771626 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/frag/sampler-image-arrays.msl2.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/frag/sampler-image-arrays.msl2.frag @@ -31,7 +31,7 @@ float4 sample_single_from_argument(thread const texture2d samp, thread co return samp.sample(sampSmplr, (vTex + float2(0.300000011920928955078125))); } -fragment main0_out main0(main0_in in [[stage_in]], array, 4> uSampler [[texture(0)]], array, 4> uTextures [[texture(8)]], array uSamplerSmplr [[sampler(0)]], array uSamplers [[sampler(4)]]) +fragment main0_out main0(main0_in in [[stage_in]], array, 4> uSampler [[texture(0)]], array, 4> uTextures [[texture(4)]], array uSamplerSmplr [[sampler(0)]], array uSamplers [[sampler(4)]]) { main0_out out = {}; out.FragColor = float4(0.0); diff --git a/3rdparty/spirv-cross/reference/shaders-msl/frag/separate-image-sampler-argument.frag b/3rdparty/spirv-cross/reference/shaders-msl/frag/separate-image-sampler-argument.frag index c0c2ea11e..46c0524ab 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/frag/separate-image-sampler-argument.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/frag/separate-image-sampler-argument.frag @@ -15,7 +15,7 @@ float4 samp(thread const texture2d t, thread const sampler s) return t.sample(s, float2(0.5)); } -fragment main0_out main0(texture2d uDepth [[texture(1)]], sampler uSampler [[sampler(0)]]) +fragment main0_out main0(texture2d uDepth [[texture(0)]], sampler uSampler [[sampler(0)]]) { main0_out out = {}; out.FragColor = samp(uDepth, uSampler); diff --git a/3rdparty/spirv-cross/reference/shaders-msl/frag/shader-arithmetic-8bit.frag b/3rdparty/spirv-cross/reference/shaders-msl/frag/shader-arithmetic-8bit.frag index e480f0bf9..28ef04372 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/frag/shader-arithmetic-8bit.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/frag/shader-arithmetic-8bit.frag @@ -86,7 +86,7 @@ void compute_uint8(device SSBO& ssbo, thread int4& vColor, constant Push& regist FragColorUint = uint4(tmp); } -fragment main0_out main0(main0_in in [[stage_in]], constant Push& registers [[buffer(0)]], constant UBO& ubo [[buffer(1)]], device SSBO& ssbo [[buffer(2)]]) +fragment main0_out main0(main0_in in [[stage_in]], device SSBO& ssbo [[buffer(0)]], constant Push& registers [[buffer(1)]], constant UBO& ubo [[buffer(2)]]) { main0_out out = {}; packing_int8(ssbo); diff --git a/3rdparty/spirv-cross/reference/shaders-msl/frag/shadow-compare-global-alias.invalid.frag b/3rdparty/spirv-cross/reference/shaders-msl/frag/shadow-compare-global-alias.invalid.frag index 2dd2d32df..4bd5d3209 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/frag/shadow-compare-global-alias.invalid.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/frag/shadow-compare-global-alias.invalid.frag @@ -35,7 +35,7 @@ float Samp4(thread const depth2d uS, thread const sampler uSSmplr, thread return uS.sample_compare(uSSmplr, vUV.xy, vUV.z); } -fragment main0_out main0(main0_in in [[stage_in]], depth2d uSampler [[texture(0)]], depth2d uTex [[texture(1)]], sampler uSamplerSmplr [[sampler(0)]], sampler uSamp [[sampler(2)]]) +fragment main0_out main0(main0_in in [[stage_in]], depth2d uTex [[texture(0)]], depth2d uSampler [[texture(1)]], sampler uSamp [[sampler(0)]], sampler uSamplerSmplr [[sampler(1)]]) { main0_out out = {}; out.FragColor = uSampler.sample_compare(uSamplerSmplr, in.vUV.xy, in.vUV.z); diff --git a/3rdparty/spirv-cross/reference/shaders-msl/frag/texture-proj-shadow.frag b/3rdparty/spirv-cross/reference/shaders-msl/frag/texture-proj-shadow.frag index 2e315ff0f..52d4a026d 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/frag/texture-proj-shadow.frag +++ b/3rdparty/spirv-cross/reference/shaders-msl/frag/texture-proj-shadow.frag @@ -15,7 +15,7 @@ struct main0_in float2 vClip2 [[user(locn2)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d uShadow2D [[texture(1)]], texture1d uSampler1D [[texture(2)]], texture2d uSampler2D [[texture(3)]], texture3d uSampler3D [[texture(4)]], sampler uShadow2DSmplr [[sampler(1)]], sampler uSampler1DSmplr [[sampler(2)]], sampler uSampler2DSmplr [[sampler(3)]], sampler uSampler3DSmplr [[sampler(4)]]) +fragment main0_out main0(main0_in in [[stage_in]], depth2d uShadow2D [[texture(0)]], texture1d uSampler1D [[texture(1)]], texture2d uSampler2D [[texture(2)]], texture3d uSampler3D [[texture(3)]], sampler uShadow2DSmplr [[sampler(0)]], sampler uSampler1DSmplr [[sampler(1)]], sampler uSampler2DSmplr [[sampler(2)]], sampler uSampler3DSmplr [[sampler(3)]]) { main0_out out = {}; float4 _20 = in.vClip4; diff --git a/3rdparty/spirv-cross/reference/shaders-msl/tese/water_tess.tese b/3rdparty/spirv-cross/reference/shaders-msl/tese/water_tess.tese index 1465d2bc1..9b6c0aca8 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/tese/water_tess.tese +++ b/3rdparty/spirv-cross/reference/shaders-msl/tese/water_tess.tese @@ -47,7 +47,7 @@ float3 sample_height_displacement(thread const float2& uv, thread const float2& return mix(uHeightmapDisplacement.sample(uHeightmapDisplacementSmplr, (uv + (off * 0.5)), level(lod.x)).xyz, uHeightmapDisplacement.sample(uHeightmapDisplacementSmplr, (uv + (off * 1.0)), level(lod.x + 1.0)).xyz, float3(lod.y)); } -[[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], constant UBO& v_31 [[buffer(1)]], texture2d uHeightmapDisplacement [[texture(0)]], sampler uHeightmapDisplacementSmplr [[sampler(0)]], float2 gl_TessCoord [[position_in_patch]]) +[[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], constant UBO& v_31 [[buffer(0)]], texture2d uHeightmapDisplacement [[texture(0)]], sampler uHeightmapDisplacementSmplr [[sampler(0)]], float2 gl_TessCoord [[position_in_patch]]) { main0_out out = {}; float2 tess_coord = float3(gl_TessCoord, 0).xy; diff --git a/3rdparty/spirv-cross/reference/shaders-msl/vert/no_stage_out.write_buff.vert b/3rdparty/spirv-cross/reference/shaders-msl/vert/no_stage_out.write_buff.vert index 2ac15cfa6..23fa0817c 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/vert/no_stage_out.write_buff.vert +++ b/3rdparty/spirv-cross/reference/shaders-msl/vert/no_stage_out.write_buff.vert @@ -23,7 +23,7 @@ struct main0_in float4 m_17 [[attribute(0)]]; }; -vertex void main0(main0_in in [[stage_in]], constant _40& _42 [[buffer(0)]], device _35& _37 [[buffer(1)]]) +vertex void main0(main0_in in [[stage_in]], device _35& _37 [[buffer(0)]], constant _40& _42 [[buffer(1)]]) { main0_out out = {}; out.gl_Position = in.m_17; diff --git a/3rdparty/spirv-cross/reference/shaders-msl/vert/no_stage_out.write_tex.vert b/3rdparty/spirv-cross/reference/shaders-msl/vert/no_stage_out.write_tex.vert index 533986b95..76eb6f24f 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/vert/no_stage_out.write_tex.vert +++ b/3rdparty/spirv-cross/reference/shaders-msl/vert/no_stage_out.write_tex.vert @@ -13,7 +13,7 @@ struct main0_in float4 m_17 [[attribute(0)]]; }; -vertex void main0(main0_in in [[stage_in]], texture1d _37 [[texture(0)]], texture1d _34 [[texture(1)]]) +vertex void main0(main0_in in [[stage_in]], texture1d _34 [[texture(0)]], texture1d _37 [[texture(1)]]) { main0_out out = {}; out.gl_Position = in.m_17; diff --git a/3rdparty/spirv-cross/reference/shaders-msl/vert/packed_matrix.vert b/3rdparty/spirv-cross/reference/shaders-msl/vert/packed_matrix.vert index 98d4de532..5c1b9bf16 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/vert/packed_matrix.vert +++ b/3rdparty/spirv-cross/reference/shaders-msl/vert/packed_matrix.vert @@ -37,7 +37,7 @@ struct main0_in float4 m_25 [[attribute(0)]]; }; -vertex main0_out main0(main0_in in [[stage_in]], constant _42& _44 [[buffer(12)]], constant _15& _17 [[buffer(13)]]) +vertex main0_out main0(main0_in in [[stage_in]], constant _15& _17 [[buffer(0)]], constant _42& _44 [[buffer(1)]]) { main0_out out = {}; float3 _91; diff --git a/3rdparty/spirv-cross/reference/shaders-msl/vert/resource-arrays-leaf.ios.vert b/3rdparty/spirv-cross/reference/shaders-msl/vert/resource-arrays-leaf.ios.vert index 5c2676306..97e97e6fd 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/vert/resource-arrays-leaf.ios.vert +++ b/3rdparty/spirv-cross/reference/shaders-msl/vert/resource-arrays-leaf.ios.vert @@ -28,8 +28,14 @@ void doWork(device storage_block* (&storage)[2], constant constant_block* (&cons storage[1]->quux = images[2].read(uint2(int2(constants[1]->bar))).xy; } -vertex void main0(constant constant_block* constants_0 [[buffer(4)]], constant constant_block* constants_1 [[buffer(5)]], constant constant_block* constants_2 [[buffer(6)]], constant constant_block* constants_3 [[buffer(7)]], device storage_block* storage_0 [[buffer(8)]], device storage_block* storage_1 [[buffer(9)]], array, 3> images [[texture(0)]]) +vertex void main0(device storage_block* storage_0 [[buffer(0)]], device storage_block* storage_1 [[buffer(1)]], constant constant_block* constants_0 [[buffer(2)]], constant constant_block* constants_1 [[buffer(3)]], constant constant_block* constants_2 [[buffer(4)]], constant constant_block* constants_3 [[buffer(5)]], array, 3> images [[texture(0)]]) { + device storage_block* storage[] = + { + storage_0, + storage_1, + }; + constant constant_block* constants[] = { constants_0, @@ -38,12 +44,6 @@ vertex void main0(constant constant_block* constants_0 [[buffer(4)]], constant c constants_3, }; - device storage_block* storage[] = - { - storage_0, - storage_1, - }; - doWork(storage, constants, images); } diff --git a/3rdparty/spirv-cross/reference/shaders-msl/vert/resource-arrays.ios.vert b/3rdparty/spirv-cross/reference/shaders-msl/vert/resource-arrays.ios.vert index 7c454c1fc..91be3a047 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/vert/resource-arrays.ios.vert +++ b/3rdparty/spirv-cross/reference/shaders-msl/vert/resource-arrays.ios.vert @@ -20,8 +20,14 @@ struct constant_block #endif constant int arraySize = SPIRV_CROSS_CONSTANT_ID_0; -vertex void main0(constant constant_block* constants_0 [[buffer(4)]], constant constant_block* constants_1 [[buffer(5)]], constant constant_block* constants_2 [[buffer(6)]], constant constant_block* constants_3 [[buffer(7)]], device storage_block* storage_0 [[buffer(8)]], device storage_block* storage_1 [[buffer(9)]], array, 3> images [[texture(0)]]) +vertex void main0(device storage_block* storage_0 [[buffer(0)]], device storage_block* storage_1 [[buffer(1)]], constant constant_block* constants_0 [[buffer(2)]], constant constant_block* constants_1 [[buffer(3)]], constant constant_block* constants_2 [[buffer(4)]], constant constant_block* constants_3 [[buffer(5)]], array, 3> images [[texture(0)]]) { + device storage_block* storage[] = + { + storage_0, + storage_1, + }; + constant constant_block* constants[] = { constants_0, @@ -30,12 +36,6 @@ vertex void main0(constant constant_block* constants_0 [[buffer(4)]], constant c constants_3, }; - device storage_block* storage[] = - { - storage_0, - storage_1, - }; - storage[0]->baz = uint4(constants[3]->foo); storage[1]->quux = images[2].read(uint2(int2(constants[1]->bar))).xy; } diff --git a/3rdparty/spirv-cross/reference/shaders-msl/vert/texture_buffer.texture-buffer-native.msl21.vert b/3rdparty/spirv-cross/reference/shaders-msl/vert/texture_buffer.texture-buffer-native.msl21.vert index 75332f484..33c077c57 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/vert/texture_buffer.texture-buffer-native.msl21.vert +++ b/3rdparty/spirv-cross/reference/shaders-msl/vert/texture_buffer.texture-buffer-native.msl21.vert @@ -8,7 +8,7 @@ struct main0_out float4 gl_Position [[position]]; }; -vertex main0_out main0(texture_buffer uSamp [[texture(4)]], texture_buffer uSampo [[texture(5)]]) +vertex main0_out main0(texture_buffer uSamp [[texture(0)]], texture_buffer uSampo [[texture(1)]]) { main0_out out = {}; out.gl_Position = uSamp.read(uint(10)) + uSampo.read(uint(100)); diff --git a/3rdparty/spirv-cross/reference/shaders-msl/vert/texture_buffer.vert b/3rdparty/spirv-cross/reference/shaders-msl/vert/texture_buffer.vert index c45d29813..ee3956fad 100644 --- a/3rdparty/spirv-cross/reference/shaders-msl/vert/texture_buffer.vert +++ b/3rdparty/spirv-cross/reference/shaders-msl/vert/texture_buffer.vert @@ -16,7 +16,7 @@ uint2 spvTexelBufferCoord(uint tc) return uint2(tc % 4096, tc / 4096); } -vertex main0_out main0(texture2d uSamp [[texture(4)]], texture2d uSampo [[texture(5)]]) +vertex main0_out main0(texture2d uSamp [[texture(0)]], texture2d uSampo [[texture(1)]]) { main0_out out = {}; out.gl_Position = uSamp.read(spvTexelBufferCoord(10)) + uSampo.read(spvTexelBufferCoord(100)); diff --git a/3rdparty/spirv-cross/reference/shaders-no-opt/asm/frag/switch-block-case-fallthrough.asm.frag b/3rdparty/spirv-cross/reference/shaders-no-opt/asm/frag/switch-block-case-fallthrough.asm.frag new file mode 100644 index 000000000..de8090e31 --- /dev/null +++ b/3rdparty/spirv-cross/reference/shaders-no-opt/asm/frag/switch-block-case-fallthrough.asm.frag @@ -0,0 +1,63 @@ +#version 450 + +layout(location = 0) flat in int vIndex; +layout(location = 0) out vec4 FragColor; + +void main() +{ + int i; + int j; + int _30; + int _31; + if (vIndex != 0 && vIndex != 1 && vIndex != 11 && vIndex != 2 && vIndex != 3 && vIndex != 4 && vIndex != 5) + { + _30 = 2; + } + if (vIndex == 1 || vIndex == 11) + { + _31 = 1; + } + switch (vIndex) + { + case 0: + { + _30 = 3; + } + default: + { + j = _30; + _31 = 0; + } + case 1: + case 11: + { + j = _31; + } + case 2: + { + break; + } + case 3: + { + if (vIndex > 3) + { + i = 0; + break; + } + else + { + break; + } + } + case 4: + { + } + case 5: + { + i = 0; + break; + } + } + FragColor = vec4(float(i)); +} + diff --git a/3rdparty/spirv-cross/reference/shaders/asm/frag/switch-label-shared-block.asm.frag b/3rdparty/spirv-cross/reference/shaders/asm/frag/switch-label-shared-block.asm.frag index ade9044e3..748f96c8b 100644 --- a/3rdparty/spirv-cross/reference/shaders/asm/frag/switch-label-shared-block.asm.frag +++ b/3rdparty/spirv-cross/reference/shaders/asm/frag/switch-label-shared-block.asm.frag @@ -16,7 +16,6 @@ void main() _19 = 1.0; break; } - case 1: default: { _19 = 3.0; diff --git a/3rdparty/spirv-cross/reference/shaders/frag/barycentric-nv.frag b/3rdparty/spirv-cross/reference/shaders/frag/barycentric-nv.frag new file mode 100644 index 000000000..12d24bb73 --- /dev/null +++ b/3rdparty/spirv-cross/reference/shaders/frag/barycentric-nv.frag @@ -0,0 +1,20 @@ +#version 450 +#extension GL_NV_fragment_shader_barycentric : require + +layout(binding = 0, std430) readonly buffer Vertices +{ + vec2 uvs[]; +} _19; + +layout(location = 0) out vec2 value; + +void main() +{ + int prim = gl_PrimitiveID; + vec2 uv0 = _19.uvs[(3 * prim) + 0]; + vec2 uv1 = _19.uvs[(3 * prim) + 1]; + vec2 uv2 = _19.uvs[(3 * prim) + 2]; + value = ((uv0 * gl_BaryCoordNV.x) + (uv1 * gl_BaryCoordNV.y)) + (uv2 * gl_BaryCoordNV.z); + value += (((uv0 * gl_BaryCoordNoPerspNV.x) + (uv1 * gl_BaryCoordNoPerspNV.y)) + (uv2 * gl_BaryCoordNoPerspNV.z)); +} + diff --git a/3rdparty/spirv-cross/shaders-hlsl-no-opt/asm/frag/switch-block-case-fallthrough.asm.frag b/3rdparty/spirv-cross/shaders-hlsl-no-opt/asm/frag/switch-block-case-fallthrough.asm.frag new file mode 100644 index 000000000..6556c3c8c --- /dev/null +++ b/3rdparty/spirv-cross/shaders-hlsl-no-opt/asm/frag/switch-block-case-fallthrough.asm.frag @@ -0,0 +1,80 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 7 +; Bound: 29 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %vIndex %FragColor + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpName %main "main" + OpName %vIndex "vIndex" + OpName %FragColor "FragColor" + OpName %i "i" + OpName %j "j" + OpDecorate %vIndex Flat + OpDecorate %vIndex Location 0 + OpDecorate %FragColor Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %bool = OpTypeBool + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %int 1 + %int_2 = OpConstant %int 2 + %int_3 = OpConstant %int 3 +%_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 +%_ptr_Function_int = OpTypePointer Function %int + %main = OpFunction %void None %3 + %header = OpLabel + %i = OpVariable %_ptr_Function_int Function %int_0 + %j = OpVariable %_ptr_Function_int Function + %9 = OpLoad %int %vIndex + OpSelectionMerge %switch_merge None + OpSwitch %9 %default_case 100 %default_case 0 %case_0 1 %case_1 11 %case_1 2 %case_2 3 %case_3 4 %case_4 5 %case_5 + + %case_0 = OpLabel + OpBranch %default_case + + %default_case = OpLabel + %default_case_phi = OpPhi %int %int_2 %header %int_3 %case_0 + ; Test what happens when a case block dominates access to a variable. + OpStore %j %default_case_phi + OpBranch %case_1 + + %case_1 = OpLabel + ; Test phi nodes between case labels. + %case_1_phi = OpPhi %int %int_0 %default_case %int_1 %header + OpStore %j %case_1_phi + OpBranch %case_2 + + %case_2 = OpLabel + OpBranch %switch_merge + + %case_3 = OpLabel + ; Conditionally branch to another case block. This is really dumb, but it is apparently legal. + %case_3_cond = OpSGreaterThan %bool %9 %int_3 + OpBranchConditional %case_3_cond %case_4 %switch_merge + + %case_4 = OpLabel + ; When emitted from case 3, we should *not* see fallthrough behavior. + OpBranch %case_5 + + %case_5 = OpLabel + OpStore %i %int_0 + OpBranch %switch_merge + + %switch_merge = OpLabel + %26 = OpLoad %int %i + %27 = OpConvertSToF %float %26 + %28 = OpCompositeConstruct %v4float %27 %27 %27 %27 + OpStore %FragColor %28 + OpReturn + OpFunctionEnd diff --git a/3rdparty/spirv-cross/shaders-msl-no-opt/asm/frag/switch-block-case-fallthrough.asm.frag b/3rdparty/spirv-cross/shaders-msl-no-opt/asm/frag/switch-block-case-fallthrough.asm.frag new file mode 100644 index 000000000..6556c3c8c --- /dev/null +++ b/3rdparty/spirv-cross/shaders-msl-no-opt/asm/frag/switch-block-case-fallthrough.asm.frag @@ -0,0 +1,80 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 7 +; Bound: 29 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %vIndex %FragColor + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpName %main "main" + OpName %vIndex "vIndex" + OpName %FragColor "FragColor" + OpName %i "i" + OpName %j "j" + OpDecorate %vIndex Flat + OpDecorate %vIndex Location 0 + OpDecorate %FragColor Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %bool = OpTypeBool + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %int 1 + %int_2 = OpConstant %int 2 + %int_3 = OpConstant %int 3 +%_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 +%_ptr_Function_int = OpTypePointer Function %int + %main = OpFunction %void None %3 + %header = OpLabel + %i = OpVariable %_ptr_Function_int Function %int_0 + %j = OpVariable %_ptr_Function_int Function + %9 = OpLoad %int %vIndex + OpSelectionMerge %switch_merge None + OpSwitch %9 %default_case 100 %default_case 0 %case_0 1 %case_1 11 %case_1 2 %case_2 3 %case_3 4 %case_4 5 %case_5 + + %case_0 = OpLabel + OpBranch %default_case + + %default_case = OpLabel + %default_case_phi = OpPhi %int %int_2 %header %int_3 %case_0 + ; Test what happens when a case block dominates access to a variable. + OpStore %j %default_case_phi + OpBranch %case_1 + + %case_1 = OpLabel + ; Test phi nodes between case labels. + %case_1_phi = OpPhi %int %int_0 %default_case %int_1 %header + OpStore %j %case_1_phi + OpBranch %case_2 + + %case_2 = OpLabel + OpBranch %switch_merge + + %case_3 = OpLabel + ; Conditionally branch to another case block. This is really dumb, but it is apparently legal. + %case_3_cond = OpSGreaterThan %bool %9 %int_3 + OpBranchConditional %case_3_cond %case_4 %switch_merge + + %case_4 = OpLabel + ; When emitted from case 3, we should *not* see fallthrough behavior. + OpBranch %case_5 + + %case_5 = OpLabel + OpStore %i %int_0 + OpBranch %switch_merge + + %switch_merge = OpLabel + %26 = OpLoad %int %i + %27 = OpConvertSToF %float %26 + %28 = OpCompositeConstruct %v4float %27 %27 %27 %27 + OpStore %FragColor %28 + OpReturn + OpFunctionEnd diff --git a/3rdparty/spirv-cross/shaders-msl/asm/frag/min-lod.msl22.asm.frag b/3rdparty/spirv-cross/shaders-msl/asm/frag/min-lod.msl22.asm.frag new file mode 100644 index 000000000..0d30e1694 --- /dev/null +++ b/3rdparty/spirv-cross/shaders-msl/asm/frag/min-lod.msl22.asm.frag @@ -0,0 +1,42 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 7 +; Bound: 21 +; Schema: 0 + OpCapability Shader + OpCapability MinLod + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor %vUV + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpName %main "main" + OpName %FragColor "FragColor" + OpName %uSampler "uSampler" + OpName %vUV "vUV" + OpDecorate %FragColor Location 0 + OpDecorate %uSampler DescriptorSet 0 + OpDecorate %uSampler Binding 0 + OpDecorate %vUV Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %FragColor = OpVariable %_ptr_Output_v4float Output + %10 = OpTypeImage %float 2D 0 0 0 1 Unknown + %11 = OpTypeSampledImage %10 +%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11 + %uSampler = OpVariable %_ptr_UniformConstant_11 UniformConstant + %v2float = OpTypeVector %float 2 +%_ptr_Input_v2float = OpTypePointer Input %v2float + %vUV = OpVariable %_ptr_Input_v2float Input + %float_4 = OpConstant %float 4 + %main = OpFunction %void None %3 + %5 = OpLabel + %14 = OpLoad %11 %uSampler + %18 = OpLoad %v2float %vUV + %20 = OpImageSampleImplicitLod %v4float %14 %18 MinLod %float_4 + OpStore %FragColor %20 + OpReturn + OpFunctionEnd diff --git a/3rdparty/spirv-cross/shaders-msl/comp/int64.invalid.msl22.comp b/3rdparty/spirv-cross/shaders-msl/comp/int64.invalid.msl22.comp new file mode 100644 index 000000000..965bed4ae --- /dev/null +++ b/3rdparty/spirv-cross/shaders-msl/comp/int64.invalid.msl22.comp @@ -0,0 +1,65 @@ +#version 450 +#extension GL_ARB_gpu_shader_int64 : require +layout(local_size_x = 1) in; + +struct M0 +{ + int64_t v; + i64vec2 b[2]; + uint64_t c; + uint64_t d[5]; +}; + +struct SSBO0_Type +{ + i64vec4 a; + M0 m0; +}; + +struct SSBO1_Type +{ + u64vec4 b; + M0 m0; +}; + +struct SSBO2_Type +{ + int64_t a[4]; + i64vec2 b[4]; +}; + +struct SSBO3_Type +{ + int64_t a[4]; + i64vec2 b[4]; +}; + +layout(set = 0, binding = 0, std430) buffer SSBO +{ + int s32; + uint u32; +}; + +void main() +{ + SSBO0_Type ssbo_0; + SSBO1_Type ssbo_1; + SSBO2_Type ssbo_2; + SSBO3_Type ssbo_3; + + ssbo_0.a += i64vec4(10, 20, 30, 40); + ssbo_1.b += u64vec4(999999999999999999ul, 8888888888888888ul, 77777777777777777ul, 6666666666666666ul); + ssbo_0.a += 20; + ssbo_0.a = abs(ssbo_0.a + i64vec4(ssbo_1.b)); + + ssbo_0.a++; + ssbo_1.b++; + ssbo_0.a--; + ssbo_1.b--; + + ssbo_2.a[0] += 1l; + ssbo_3.a[0] += 2l; + + s32 = int(ssbo_0.a.x + ssbo_1.b.y + ssbo_2.a[1] + ssbo_3.a[2]); + u32 = uint(ssbo_0.a.y + ssbo_1.b.z + ssbo_2.a[0] + ssbo_3.a[1]); +} diff --git a/3rdparty/spirv-cross/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert b/3rdparty/spirv-cross/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert index 9e4a0b7ac..9c0f1d5f3 100644 --- a/3rdparty/spirv-cross/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert +++ b/3rdparty/spirv-cross/shaders-msl/desktop-only/vert/clip-cull-distance.desktop.vert @@ -5,6 +5,6 @@ void main() gl_Position = vec4(10.0); gl_ClipDistance[0] = 1.0; gl_ClipDistance[1] = 4.0; - gl_CullDistance[0] = 4.0; - gl_CullDistance[1] = 9.0; + //gl_CullDistance[0] = 4.0; + //gl_CullDistance[1] = 9.0; } diff --git a/3rdparty/spirv-cross/shaders-msl/frag/barycentric-nv-nopersp.msl22.frag b/3rdparty/spirv-cross/shaders-msl/frag/barycentric-nv-nopersp.msl22.frag new file mode 100644 index 000000000..24edb1a29 --- /dev/null +++ b/3rdparty/spirv-cross/shaders-msl/frag/barycentric-nv-nopersp.msl22.frag @@ -0,0 +1,17 @@ +#version 450 +#extension GL_NV_fragment_shader_barycentric : require + +layout(location = 0) out vec2 value; + +layout(set = 0, binding = 0) readonly buffer Vertices +{ + vec2 uvs[]; +}; + +void main () { + int prim = gl_PrimitiveID; + vec2 uv0 = uvs[3 * prim + 0]; + vec2 uv1 = uvs[3 * prim + 1]; + vec2 uv2 = uvs[3 * prim + 2]; + value = gl_BaryCoordNoPerspNV.x * uv0 + gl_BaryCoordNoPerspNV.y * uv1 + gl_BaryCoordNoPerspNV.z * uv2; +} diff --git a/3rdparty/spirv-cross/shaders-msl/frag/barycentric-nv.msl22.frag b/3rdparty/spirv-cross/shaders-msl/frag/barycentric-nv.msl22.frag new file mode 100644 index 000000000..7aec19fba --- /dev/null +++ b/3rdparty/spirv-cross/shaders-msl/frag/barycentric-nv.msl22.frag @@ -0,0 +1,17 @@ +#version 450 +#extension GL_NV_fragment_shader_barycentric : require + +layout(location = 0) out vec2 value; + +layout(set = 0, binding = 0) readonly buffer Vertices +{ + vec2 uvs[]; +}; + +void main () { + int prim = gl_PrimitiveID; + vec2 uv0 = uvs[3 * prim + 0]; + vec2 uv1 = uvs[3 * prim + 1]; + vec2 uv2 = uvs[3 * prim + 2]; + value = gl_BaryCoordNV.x * uv0 + gl_BaryCoordNV.y * uv1 + gl_BaryCoordNV.z * uv2; +} diff --git a/3rdparty/spirv-cross/shaders-msl/frag/image-query-lod.msl22.frag b/3rdparty/spirv-cross/shaders-msl/frag/image-query-lod.msl22.frag new file mode 100644 index 000000000..33d5630e6 --- /dev/null +++ b/3rdparty/spirv-cross/shaders-msl/frag/image-query-lod.msl22.frag @@ -0,0 +1,33 @@ +#version 450 + +layout(location = 0) out vec2 FragColor; +layout(set = 0, binding = 0) uniform sampler2D uSampler2D; +layout(set = 0, binding = 1) uniform sampler3D uSampler3D; +layout(set = 0, binding = 2) uniform samplerCube uSamplerCube; +layout(set = 0, binding = 3) uniform sampler uSampler; +layout(set = 0, binding = 4) uniform texture2D uTexture2D; +layout(set = 0, binding = 5) uniform texture3D uTexture3D; +layout(set = 0, binding = 6) uniform textureCube uTextureCube; +layout(location = 0) in vec3 vUV; + +void from_function() +{ + FragColor += textureQueryLod(uSampler2D, vUV.xy); + FragColor += textureQueryLod(uSampler3D, vUV); + FragColor += textureQueryLod(uSamplerCube, vUV); + FragColor += textureQueryLod(sampler2D(uTexture2D, uSampler), vUV.xy); + FragColor += textureQueryLod(sampler3D(uTexture3D, uSampler), vUV); + FragColor += textureQueryLod(samplerCube(uTextureCube, uSampler), vUV); +} + +void main() +{ + FragColor = vec2(0.0); + FragColor += textureQueryLod(uSampler2D, vUV.xy); + FragColor += textureQueryLod(uSampler3D, vUV); + FragColor += textureQueryLod(uSamplerCube, vUV); + FragColor += textureQueryLod(sampler2D(uTexture2D, uSampler), vUV.xy); + FragColor += textureQueryLod(sampler3D(uTexture3D, uSampler), vUV); + FragColor += textureQueryLod(samplerCube(uTextureCube, uSampler), vUV); + from_function(); +} diff --git a/3rdparty/spirv-cross/shaders-no-opt/asm/frag/switch-block-case-fallthrough.asm.frag b/3rdparty/spirv-cross/shaders-no-opt/asm/frag/switch-block-case-fallthrough.asm.frag new file mode 100644 index 000000000..b15467951 --- /dev/null +++ b/3rdparty/spirv-cross/shaders-no-opt/asm/frag/switch-block-case-fallthrough.asm.frag @@ -0,0 +1,80 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 7 +; Bound: 29 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %vIndex %FragColor + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpName %main "main" + OpName %vIndex "vIndex" + OpName %FragColor "FragColor" + OpName %i "i" + OpName %j "j" + OpDecorate %vIndex Flat + OpDecorate %vIndex Location 0 + OpDecorate %FragColor Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %bool = OpTypeBool + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %int 1 + %int_2 = OpConstant %int 2 + %int_3 = OpConstant %int 3 +%_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 +%_ptr_Function_int = OpTypePointer Function %int + %main = OpFunction %void None %3 + %header = OpLabel + %i = OpVariable %_ptr_Function_int Function + %j = OpVariable %_ptr_Function_int Function + %9 = OpLoad %int %vIndex + OpSelectionMerge %switch_merge None + OpSwitch %9 %default_case 100 %default_case 0 %case_0 1 %case_1 11 %case_1 2 %case_2 3 %case_3 4 %case_4 5 %case_5 + + %case_0 = OpLabel + OpBranch %default_case + + %default_case = OpLabel + %default_case_phi = OpPhi %int %int_2 %header %int_3 %case_0 + ; Test what happens when a case block dominates access to a variable. + OpStore %j %default_case_phi + OpBranch %case_1 + + %case_1 = OpLabel + ; Test phi nodes between case labels. + %case_1_phi = OpPhi %int %int_0 %default_case %int_1 %header + OpStore %j %case_1_phi + OpBranch %case_2 + + %case_2 = OpLabel + OpBranch %switch_merge + + %case_3 = OpLabel + ; Conditionally branch to another case block. This is really dumb, but it is apparently legal. + %case_3_cond = OpSGreaterThan %bool %9 %int_3 + OpBranchConditional %case_3_cond %case_4 %switch_merge + + %case_4 = OpLabel + ; When emitted from case 3, we should *not* see fallthrough behavior. + OpBranch %case_5 + + %case_5 = OpLabel + OpStore %i %int_0 + OpBranch %switch_merge + + %switch_merge = OpLabel + %26 = OpLoad %int %i + %27 = OpConvertSToF %float %26 + %28 = OpCompositeConstruct %v4float %27 %27 %27 %27 + OpStore %FragColor %28 + OpReturn + OpFunctionEnd diff --git a/3rdparty/spirv-cross/shaders/frag/barycentric-nv.frag b/3rdparty/spirv-cross/shaders/frag/barycentric-nv.frag new file mode 100644 index 000000000..340408370 --- /dev/null +++ b/3rdparty/spirv-cross/shaders/frag/barycentric-nv.frag @@ -0,0 +1,18 @@ +#version 450 +#extension GL_NV_fragment_shader_barycentric : require + +layout(location = 0) out vec2 value; + +layout(set = 0, binding = 0) readonly buffer Vertices +{ + vec2 uvs[]; +}; + +void main () { + int prim = gl_PrimitiveID; + vec2 uv0 = uvs[3 * prim + 0]; + vec2 uv1 = uvs[3 * prim + 1]; + vec2 uv2 = uvs[3 * prim + 2]; + value = gl_BaryCoordNV.x * uv0 + gl_BaryCoordNV.y * uv1 + gl_BaryCoordNV.z * uv2; + value += gl_BaryCoordNoPerspNV.x * uv0 + gl_BaryCoordNoPerspNV.y * uv1 + gl_BaryCoordNoPerspNV.z * uv2; +} diff --git a/3rdparty/spirv-cross/spirv_common.hpp b/3rdparty/spirv-cross/spirv_common.hpp index 82e305a51..1f9bce681 100644 --- a/3rdparty/spirv-cross/spirv_common.hpp +++ b/3rdparty/spirv-cross/spirv_common.hpp @@ -183,14 +183,14 @@ std::string join(Ts &&... ts) return stream.str(); } -inline std::string merge(const SmallVector &list) +inline std::string merge(const SmallVector &list, const char *between = ", ") { StringStream<> stream; for (auto &elem : list) { stream << elem; if (&elem != &list.back()) - stream << ", "; + stream << between; } return stream.str(); } @@ -704,6 +704,10 @@ struct SPIRBlock : IVariant // Do we need a ladder variable to defer breaking out of a loop construct after a switch block? bool need_ladder_break = false; + // If marked, we have explicitly handled Phi from this block, so skip any flushes related to that on a branch. + // Used to handle an edge case with switch and case-label fallthrough where fall-through writes to Phi. + uint32_t ignore_phi_from_block = 0; + // The dominating block which this block might be within. // Used in continue; blocks to determine if we really need to write continue. uint32_t loop_dominator = 0; @@ -1427,7 +1431,8 @@ struct Meta bool packed = false; uint32_t ib_member_index = ~(0u); uint32_t ib_orig_id = 0; - uint32_t argument_buffer_id = ~(0u); + uint32_t resource_index_primary = ~(0u); + uint32_t resource_index_secondary = ~(0u); } extended; }; diff --git a/3rdparty/spirv-cross/spirv_cross.cpp b/3rdparty/spirv-cross/spirv_cross.cpp index 784eca536..4011c849b 100644 --- a/3rdparty/spirv-cross/spirv_cross.cpp +++ b/3rdparty/spirv-cross/spirv_cross.cpp @@ -17,6 +17,7 @@ #include "spirv_cross.hpp" #include "GLSL.std.450.h" #include "spirv_cfg.hpp" +#include "spirv_common.hpp" #include "spirv_parser.hpp" #include #include @@ -1141,8 +1142,12 @@ void Compiler::set_extended_decoration(uint32_t id, ExtendedDecorations decorati dec.extended.ib_orig_id = value; break; - case SPIRVCrossDecorationArgumentBufferID: - dec.extended.argument_buffer_id = value; + case SPIRVCrossDecorationResourceIndexPrimary: + dec.extended.resource_index_primary = value; + break; + + case SPIRVCrossDecorationResourceIndexSecondary: + dec.extended.resource_index_secondary = value; break; } } @@ -1171,8 +1176,12 @@ void Compiler::set_extended_member_decoration(uint32_t type, uint32_t index, Ext dec.extended.ib_orig_id = value; break; - case SPIRVCrossDecorationArgumentBufferID: - dec.extended.argument_buffer_id = value; + case SPIRVCrossDecorationResourceIndexPrimary: + dec.extended.resource_index_primary = value; + break; + + case SPIRVCrossDecorationResourceIndexSecondary: + dec.extended.resource_index_secondary = value; break; } } @@ -1198,8 +1207,11 @@ uint32_t Compiler::get_extended_decoration(uint32_t id, ExtendedDecorations deco case SPIRVCrossDecorationInterfaceOrigID: return dec.extended.ib_orig_id; - case SPIRVCrossDecorationArgumentBufferID: - return dec.extended.argument_buffer_id; + case SPIRVCrossDecorationResourceIndexPrimary: + return dec.extended.resource_index_primary; + + case SPIRVCrossDecorationResourceIndexSecondary: + return dec.extended.resource_index_secondary; } return 0; @@ -1229,8 +1241,11 @@ uint32_t Compiler::get_extended_member_decoration(uint32_t type, uint32_t index, case SPIRVCrossDecorationInterfaceOrigID: return dec.extended.ib_orig_id; - case SPIRVCrossDecorationArgumentBufferID: - return dec.extended.argument_buffer_id; + case SPIRVCrossDecorationResourceIndexPrimary: + return dec.extended.resource_index_primary; + + case SPIRVCrossDecorationResourceIndexSecondary: + return dec.extended.resource_index_secondary; } return 0; @@ -1257,8 +1272,11 @@ bool Compiler::has_extended_decoration(uint32_t id, ExtendedDecorations decorati case SPIRVCrossDecorationInterfaceOrigID: return dec.extended.ib_orig_id != 0; - case SPIRVCrossDecorationArgumentBufferID: - return dec.extended.argument_buffer_id != 0; + case SPIRVCrossDecorationResourceIndexPrimary: + return dec.extended.resource_index_primary != uint32_t(-1); + + case SPIRVCrossDecorationResourceIndexSecondary: + return dec.extended.resource_index_secondary != uint32_t(-1); } return false; @@ -1288,8 +1306,11 @@ bool Compiler::has_extended_member_decoration(uint32_t type, uint32_t index, Ext case SPIRVCrossDecorationInterfaceOrigID: return dec.extended.ib_orig_id != 0; - case SPIRVCrossDecorationArgumentBufferID: - return dec.extended.argument_buffer_id != uint32_t(-1); + case SPIRVCrossDecorationResourceIndexPrimary: + return dec.extended.resource_index_primary != uint32_t(-1); + + case SPIRVCrossDecorationResourceIndexSecondary: + return dec.extended.resource_index_secondary != uint32_t(-1); } return false; @@ -1309,15 +1330,19 @@ void Compiler::unset_extended_decoration(uint32_t id, ExtendedDecorations decora break; case SPIRVCrossDecorationInterfaceMemberIndex: - dec.extended.ib_member_index = ~(0u); + dec.extended.ib_member_index = uint32_t(-1); break; case SPIRVCrossDecorationInterfaceOrigID: dec.extended.ib_orig_id = 0; break; - case SPIRVCrossDecorationArgumentBufferID: - dec.extended.argument_buffer_id = 0; + case SPIRVCrossDecorationResourceIndexPrimary: + dec.extended.resource_index_primary = uint32_t(-1); + break; + + case SPIRVCrossDecorationResourceIndexSecondary: + dec.extended.resource_index_secondary = uint32_t(-1); break; } } @@ -1338,15 +1363,19 @@ void Compiler::unset_extended_member_decoration(uint32_t type, uint32_t index, E break; case SPIRVCrossDecorationInterfaceMemberIndex: - dec.extended.ib_member_index = ~(0u); + dec.extended.ib_member_index = uint32_t(-1); break; case SPIRVCrossDecorationInterfaceOrigID: dec.extended.ib_orig_id = 0; break; - case SPIRVCrossDecorationArgumentBufferID: - dec.extended.argument_buffer_id = 0; + case SPIRVCrossDecorationResourceIndexPrimary: + dec.extended.resource_index_primary = uint32_t(-1); + break; + + case SPIRVCrossDecorationResourceIndexSecondary: + dec.extended.resource_index_secondary = uint32_t(-1); break; } } @@ -1600,6 +1629,11 @@ bool Compiler::execution_is_branchless(const SPIRBlock &from, const SPIRBlock &t } } +bool Compiler::execution_is_direct_branch(const SPIRBlock &from, const SPIRBlock &to) const +{ + return from.terminator == SPIRBlock::Direct && from.merge == SPIRBlock::MergeNone && from.next_block == to.self; +} + SPIRBlock::ContinueBlockType Compiler::continue_block_type(const SPIRBlock &block) const { // The block was deemed too complex during code emit, pick conservative fallback paths. diff --git a/3rdparty/spirv-cross/spirv_cross.hpp b/3rdparty/spirv-cross/spirv_cross.hpp index 3f75627ea..ccd7c04a3 100644 --- a/3rdparty/spirv-cross/spirv_cross.hpp +++ b/3rdparty/spirv-cross/spirv_cross.hpp @@ -123,7 +123,10 @@ enum ExtendedDecorations SPIRVCrossDecorationPackedType, SPIRVCrossDecorationInterfaceMemberIndex, SPIRVCrossDecorationInterfaceOrigID, - SPIRVCrossDecorationArgumentBufferID + SPIRVCrossDecorationResourceIndexPrimary, + // Used for decorations like resource indices for samplers when part of combined image samplers. + // A variable might need to hold two resource indices in this case. + SPIRVCrossDecorationResourceIndexSecondary, }; class Compiler @@ -669,6 +672,7 @@ protected: bool block_is_outside_flow_control_from_block(const SPIRBlock &from, const SPIRBlock &to); bool execution_is_branchless(const SPIRBlock &from, const SPIRBlock &to) const; + bool execution_is_direct_branch(const SPIRBlock &from, const SPIRBlock &to) const; bool execution_is_noop(const SPIRBlock &from, const SPIRBlock &to) const; SPIRBlock::ContinueBlockType continue_block_type(const SPIRBlock &continue_block) const; diff --git a/3rdparty/spirv-cross/spirv_cross_c.cpp b/3rdparty/spirv-cross/spirv_cross_c.cpp index c5dae3b52..8f68a5388 100644 --- a/3rdparty/spirv-cross/spirv_cross_c.cpp +++ b/3rdparty/spirv-cross/spirv_cross_c.cpp @@ -1031,6 +1031,42 @@ spvc_result spvc_compiler_msl_set_fragment_output_components(spvc_compiler compi #endif } +unsigned spvc_compiler_msl_get_automatic_resource_binding(spvc_compiler compiler, spvc_variable_id id) +{ +#if SPIRV_CROSS_C_API_MSL + if (compiler->backend != SPVC_BACKEND_MSL) + { + compiler->context->report_error("MSL function used on a non-MSL backend."); + return uint32_t(-1); + } + + auto &msl = *static_cast(compiler->compiler.get()); + return msl.get_automatic_msl_resource_binding(id); +#else + (void)id; + compiler->context->report_error("MSL function used on a non-MSL backend."); + return uint32_t(-1); +#endif +} + +unsigned spvc_compiler_msl_get_automatic_resource_binding_secondary(spvc_compiler compiler, spvc_variable_id id) +{ +#if SPIRV_CROSS_C_API_MSL + if (compiler->backend != SPVC_BACKEND_MSL) + { + compiler->context->report_error("MSL function used on a non-MSL backend."); + return uint32_t(-1); + } + + auto &msl = *static_cast(compiler->compiler.get()); + return msl.get_automatic_msl_resource_binding_secondary(id); +#else + (void)id; + compiler->context->report_error("MSL function used on a non-MSL backend."); + return uint32_t(-1); +#endif +} + spvc_result spvc_compiler_compile(spvc_compiler compiler, const char **source) { SPVC_BEGIN_SAFE_SCOPE diff --git a/3rdparty/spirv-cross/spirv_cross_c.h b/3rdparty/spirv-cross/spirv_cross_c.h index 717fe5ca2..afa5a832d 100644 --- a/3rdparty/spirv-cross/spirv_cross_c.h +++ b/3rdparty/spirv-cross/spirv_cross_c.h @@ -33,7 +33,7 @@ extern "C" { /* Bumped if ABI or API breaks backwards compatibility. */ #define SPVC_C_API_VERSION_MAJOR 0 /* Bumped if APIs or enumerations are added in a backwards compatible way. */ -#define SPVC_C_API_VERSION_MINOR 13 +#define SPVC_C_API_VERSION_MINOR 14 /* Bumped if internal implementation details change. */ #define SPVC_C_API_VERSION_PATCH 0 @@ -551,6 +551,9 @@ SPVC_PUBLIC_API spvc_result spvc_compiler_msl_remap_constexpr_sampler(spvc_compi SPVC_PUBLIC_API spvc_result spvc_compiler_msl_remap_constexpr_sampler_by_binding(spvc_compiler compiler, unsigned desc_set, unsigned binding, const spvc_msl_constexpr_sampler *sampler); SPVC_PUBLIC_API spvc_result spvc_compiler_msl_set_fragment_output_components(spvc_compiler compiler, unsigned location, unsigned components); +SPVC_PUBLIC_API unsigned spvc_compiler_msl_get_automatic_resource_binding(spvc_compiler compiler, spvc_variable_id id); +SPVC_PUBLIC_API unsigned spvc_compiler_msl_get_automatic_resource_binding_secondary(spvc_compiler compiler, spvc_variable_id id); + /* * Reflect resources. * Maps almost 1:1 to C++ API. diff --git a/3rdparty/spirv-cross/spirv_cross_containers.hpp b/3rdparty/spirv-cross/spirv_cross_containers.hpp index 393f4614b..31a8abbd0 100644 --- a/3rdparty/spirv-cross/spirv_cross_containers.hpp +++ b/3rdparty/spirv-cross/spirv_cross_containers.hpp @@ -447,6 +447,11 @@ public: } } + void insert(T *itr, const T &value) + { + insert(itr, &value, &value + 1); + } + T *erase(T *itr) { std::move(itr + 1, this->end(), itr); diff --git a/3rdparty/spirv-cross/spirv_glsl.cpp b/3rdparty/spirv-cross/spirv_glsl.cpp index b4d888ad5..abc05e1ad 100644 --- a/3rdparty/spirv-cross/spirv_glsl.cpp +++ b/3rdparty/spirv-cross/spirv_glsl.cpp @@ -288,8 +288,11 @@ static uint32_t pls_format_to_components(PlsFormat format) static const char *vector_swizzle(int vecsize, int index) { - static const char *swizzle[4][4] = { - { ".x", ".y", ".z", ".w" }, { ".xy", ".yz", ".zw" }, { ".xyz", ".yzw" }, { "" } + static const char *const swizzle[4][4] = { + { ".x", ".y", ".z", ".w" }, + { ".xy", ".yz", ".zw", nullptr }, + { ".xyz", ".yzw", nullptr, nullptr }, + { "", nullptr, nullptr, nullptr }, }; assert(vecsize >= 1 && vecsize <= 4); @@ -4700,6 +4703,7 @@ void CompilerGLSL::emit_texture_op(const Instruction &i) uint32_t offset = 0; uint32_t coffsets = 0; uint32_t sample = 0; + uint32_t minlod = 0; uint32_t flags = 0; if (length) @@ -4725,14 +4729,15 @@ void CompilerGLSL::emit_texture_op(const Instruction &i) test(offset, ImageOperandsOffsetMask); test(coffsets, ImageOperandsConstOffsetsMask); test(sample, ImageOperandsSampleMask); + test(minlod, ImageOperandsMinLodMask); string expr; bool forward = false; expr += to_function_name(img, imgtype, !!fetch, !!gather, !!proj, !!coffsets, (!!coffset || !!offset), - (!!grad_x || !!grad_y), !!dref, lod); + (!!grad_x || !!grad_y), !!dref, lod, minlod); expr += "("; expr += to_function_args(img, imgtype, fetch, gather, proj, coord, coord_components, dref, grad_x, grad_y, lod, - coffset, offset, bias, comp, sample, &forward); + coffset, offset, bias, comp, sample, minlod, &forward); expr += ")"; // texture(samplerXShadow) returns float. shadowX() returns vec4. Swizzle here. @@ -4797,8 +4802,11 @@ bool CompilerGLSL::expression_is_constant_null(uint32_t id) const // For some subclasses, the function is a method on the specified image. string CompilerGLSL::to_function_name(uint32_t tex, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool is_proj, bool has_array_offsets, bool has_offset, bool has_grad, bool, - uint32_t lod) + uint32_t lod, uint32_t minlod) { + if (minlod != 0) + SPIRV_CROSS_THROW("Sparse texturing not yet supported."); + string fname; // textureLod on sampler2DArrayShadow and samplerCubeShadow does not exist in GLSL for some reason. @@ -4877,7 +4885,8 @@ std::string CompilerGLSL::convert_separate_image_to_expression(uint32_t id) string CompilerGLSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool is_proj, uint32_t coord, uint32_t coord_components, uint32_t dref, uint32_t grad_x, uint32_t grad_y, uint32_t lod, uint32_t coffset, uint32_t offset, - uint32_t bias, uint32_t comp, uint32_t sample, bool *p_forward) + uint32_t bias, uint32_t comp, uint32_t sample, uint32_t /*minlod*/, + bool *p_forward) { string farg_str; if (is_fetch) @@ -6156,6 +6165,26 @@ string CompilerGLSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage) case BuiltInIncomingRayFlagsNV: return "gl_IncomingRayFlagsNV"; + case BuiltInBaryCoordNV: + { + if (options.es && options.version < 320) + SPIRV_CROSS_THROW("gl_BaryCoordNV requires ESSL 320."); + else if (!options.es && options.version < 450) + SPIRV_CROSS_THROW("gl_BaryCoordNV requires GLSL 450."); + require_extension_internal("GL_NV_fragment_shader_barycentric"); + return "gl_BaryCoordNV"; + } + + case BuiltInBaryCoordNoPerspNV: + { + if (options.es && options.version < 320) + SPIRV_CROSS_THROW("gl_BaryCoordNoPerspNV requires ESSL 320."); + else if (!options.es && options.version < 450) + SPIRV_CROSS_THROW("gl_BaryCoordNoPerspNV requires GLSL 450."); + require_extension_internal("GL_NV_fragment_shader_barycentric"); + return "gl_BaryCoordNoPerspNV"; + } + case BuiltInFragStencilRefEXT: { if (!options.es) @@ -10698,6 +10727,8 @@ bool CompilerGLSL::flush_phi_required(uint32_t from, uint32_t to) void CompilerGLSL::flush_phi(uint32_t from, uint32_t to) { auto &child = get(to); + if (child.ignore_phi_from_block == from) + return; unordered_set temporary_phi_variables; @@ -11458,7 +11489,8 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block) case SPIRBlock::MultiSelect: { auto &type = expression_type(block.condition); - bool unsigned_case = type.basetype == SPIRType::UInt || type.basetype == SPIRType::UShort; + bool unsigned_case = + type.basetype == SPIRType::UInt || type.basetype == SPIRType::UShort || type.basetype == SPIRType::UByte; if (block.merge == SPIRBlock::MergeNone) SPIRV_CROSS_THROW("Switch statement is not structured"); @@ -11483,61 +11515,182 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block) if (block.need_ladder_break) statement("bool _", block.self, "_ladder_break = false;"); + // Find all unique case constructs. + unordered_map> case_constructs; + SmallVector block_declaration_order; + SmallVector literals_to_merge; + + // If a switch case branches to the default block for some reason, we can just remove that literal from consideration + // and let the default: block handle it. + // 2.11 in SPIR-V spec states that for fall-through cases, there is a very strict declaration order which we can take advantage of here. + // We only need to consider possible fallthrough if order[i] branches to order[i + 1]. + for (auto &c : block.cases) + { + if (c.block != block.next_block && c.block != block.default_block) + { + if (!case_constructs.count(c.block)) + block_declaration_order.push_back(c.block); + case_constructs[c.block].push_back(c.value); + } + else if (c.block == block.next_block && block.default_block != block.next_block) + { + // We might have to flush phi inside specific case labels. + // If we can piggyback on default:, do so instead. + literals_to_merge.push_back(c.value); + } + } + + // Empty literal array -> default. + if (block.default_block != block.next_block) + { + auto &default_block = get(block.default_block); + + // We need to slide in the default block somewhere in this chain + // if there are fall-through scenarios since the default is declared separately in OpSwitch. + // Only consider trivial fall-through cases here. + size_t num_blocks = block_declaration_order.size(); + bool injected_block = false; + + for (size_t i = 0; i < num_blocks; i++) + { + auto &case_block = get(block_declaration_order[i]); + if (execution_is_direct_branch(case_block, default_block)) + { + // Fallthrough to default block, we must inject the default block here. + block_declaration_order.insert(begin(block_declaration_order) + i + 1, block.default_block); + injected_block = true; + break; + } + else if (execution_is_direct_branch(default_block, case_block)) + { + // Default case is falling through to another case label, we must inject the default block here. + block_declaration_order.insert(begin(block_declaration_order) + i, block.default_block); + injected_block = true; + break; + } + } + + // Order does not matter. + if (!injected_block) + block_declaration_order.push_back(block.default_block); + + case_constructs[block.default_block] = {}; + } + + size_t num_blocks = block_declaration_order.size(); + + const auto to_case_label = [](uint32_t literal, bool is_unsigned_case) -> string { + return is_unsigned_case ? convert_to_string(literal) : convert_to_string(int32_t(literal)); + }; + + // We need to deal with a complex scenario for OpPhi. If we have case-fallthrough and Phi in the picture, + // we need to flush phi nodes outside the switch block in a branch, + // and skip any Phi handling inside the case label to make fall-through work as expected. + // This kind of code-gen is super awkward and it's a last resort. Normally we would want to handle this + // inside the case label if at all possible. + for (size_t i = 1; i < num_blocks; i++) + { + if (flush_phi_required(block.self, block_declaration_order[i]) && + flush_phi_required(block_declaration_order[i - 1], block_declaration_order[i])) + { + uint32_t target_block = block_declaration_order[i]; + + // Make sure we flush Phi, it might have been marked to be ignored earlier. + get(target_block).ignore_phi_from_block = 0; + + auto &literals = case_constructs[target_block]; + + if (literals.empty()) + { + // Oh boy, gotta make a complete negative test instead! o.o + // Find all possible literals that would *not* make us enter the default block. + // If none of those literals match, we flush Phi ... + SmallVector conditions; + for (size_t j = 0; j < num_blocks; j++) + { + auto &negative_literals = case_constructs[block_declaration_order[j]]; + for (auto &case_label : negative_literals) + conditions.push_back(join(to_enclosed_expression(block.condition), + " != ", to_case_label(case_label, unsigned_case))); + } + + statement("if (", merge(conditions, " && "), ")"); + begin_scope(); + flush_phi(block.self, target_block); + end_scope(); + } + else + { + SmallVector conditions; + conditions.reserve(literals.size()); + for (auto &case_label : literals) + conditions.push_back(join(to_enclosed_expression(block.condition), + " == ", to_case_label(case_label, unsigned_case))); + statement("if (", merge(conditions, " || "), ")"); + begin_scope(); + flush_phi(block.self, target_block); + end_scope(); + } + + // Mark the block so that we don't flush Phi from header to case label. + get(target_block).ignore_phi_from_block = block.self; + } + } + emit_block_hints(block); statement("switch (", to_expression(block.condition), ")"); begin_scope(); - // Multiple case labels can branch to same block, so find all unique blocks. - bool emitted_default = false; - unordered_set emitted_blocks; - - for (auto &c : block.cases) + for (size_t i = 0; i < num_blocks; i++) { - if (emitted_blocks.count(c.block) != 0) - continue; + uint32_t target_block = block_declaration_order[i]; + auto &literals = case_constructs[target_block]; - // Emit all case labels which branch to our target. - // FIXME: O(n^2), revisit if we hit shaders with 100++ case labels ... - for (auto &other_case : block.cases) + if (literals.empty()) { - if (other_case.block == c.block) + // Default case. + statement("default:"); + } + else + { + for (auto &case_literal : literals) { // The case label value must be sign-extended properly in SPIR-V, so we can assume 32-bit values here. - auto case_value = unsigned_case ? convert_to_string(uint32_t(other_case.value)) : - convert_to_string(int32_t(other_case.value)); - statement("case ", case_value, label_suffix, ":"); + statement("case ", to_case_label(case_literal, unsigned_case), label_suffix, ":"); } } - // Maybe we share with default block? - if (block.default_block == c.block) + auto &case_block = get(target_block); + if (i + 1 < num_blocks && + execution_is_direct_branch(case_block, get(block_declaration_order[i + 1]))) { - statement("default:"); - emitted_default = true; + // We will fall through here, so just terminate the block chain early. + // We still need to deal with Phi potentially. + // No need for a stack-like thing here since we only do fall-through when there is a + // single trivial branch to fall-through target.. + current_emitting_switch_fallthrough = true; } - - // Complete the target. - emitted_blocks.insert(c.block); + else + current_emitting_switch_fallthrough = false; begin_scope(); - branch(block.self, c.block); + branch(block.self, target_block); end_scope(); + + current_emitting_switch_fallthrough = false; } - if (!emitted_default) + // Might still have to flush phi variables if we branch from loop header directly to merge target. + if (flush_phi_required(block.self, block.next_block)) { - if (block.default_block != block.next_block) + if (block.default_block == block.next_block || !literals_to_merge.empty()) { - statement("default:"); - begin_scope(); - if (is_break(block.default_block)) - SPIRV_CROSS_THROW("Cannot break; out of a switch statement and out of a loop at the same time ..."); - branch(block.self, block.default_block); - end_scope(); - } - else if (flush_phi_required(block.self, block.next_block)) - { - statement("default:"); + for (auto &case_literal : literals_to_merge) + statement("case ", to_case_label(case_literal, unsigned_case), label_suffix, ":"); + + if (block.default_block == block.next_block) + statement("default:"); + begin_scope(); flush_phi(block.self, block.next_block); statement("break;"); @@ -11619,22 +11772,26 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block) if (block.merge != SPIRBlock::MergeSelection) flush_phi(block.self, block.next_block); - // For merge selects we might have ignored the fact that a merge target - // could have been a break; or continue; - // We will need to deal with it here. - if (is_loop_break(block.next_block)) + // For switch fallthrough cases, we terminate the chain here, but we still need to handle Phi. + if (!current_emitting_switch_fallthrough) { - // Cannot check for just break, because switch statements will also use break. - assert(block.merge == SPIRBlock::MergeSelection); - statement("break;"); + // For merge selects we might have ignored the fact that a merge target + // could have been a break; or continue; + // We will need to deal with it here. + if (is_loop_break(block.next_block)) + { + // Cannot check for just break, because switch statements will also use break. + assert(block.merge == SPIRBlock::MergeSelection); + statement("break;"); + } + else if (is_continue(block.next_block)) + { + assert(block.merge == SPIRBlock::MergeSelection); + branch_to_continue(block.self, block.next_block); + } + else if (block.self != block.next_block) + emit_block_chain(get(block.next_block)); } - else if (is_continue(block.next_block)) - { - assert(block.merge == SPIRBlock::MergeSelection); - branch_to_continue(block.self, block.next_block); - } - else if (block.self != block.next_block) - emit_block_chain(get(block.next_block)); } if (block.merge == SPIRBlock::MergeLoop) diff --git a/3rdparty/spirv-cross/spirv_glsl.hpp b/3rdparty/spirv-cross/spirv_glsl.hpp index 6ca281fd0..45a8654c5 100644 --- a/3rdparty/spirv-cross/spirv_glsl.hpp +++ b/3rdparty/spirv-cross/spirv_glsl.hpp @@ -223,6 +223,7 @@ protected: SPIRBlock *current_emitting_block = nullptr; SPIRBlock *current_emitting_switch = nullptr; + bool current_emitting_switch_fallthrough = false; virtual void emit_instruction(const Instruction &instr); void emit_block_instructions(SPIRBlock &block); @@ -257,12 +258,12 @@ protected: virtual std::string to_func_call_arg(uint32_t id); virtual std::string to_function_name(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool is_proj, bool has_array_offsets, bool has_offset, bool has_grad, - bool has_dref, uint32_t lod); + bool has_dref, uint32_t lod, uint32_t minlod); virtual std::string to_function_args(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool is_proj, uint32_t coord, uint32_t coord_components, uint32_t dref, uint32_t grad_x, uint32_t grad_y, uint32_t lod, uint32_t coffset, uint32_t offset, uint32_t bias, uint32_t comp, uint32_t sample, - bool *p_forward); + uint32_t minlod, bool *p_forward); virtual void emit_buffer_block(const SPIRVariable &type); virtual void emit_push_constant_block(const SPIRVariable &var); virtual void emit_uniform(const SPIRVariable &var); diff --git a/3rdparty/spirv-cross/spirv_hlsl.cpp b/3rdparty/spirv-cross/spirv_hlsl.cpp index d2dcdfb8a..c129966fe 100644 --- a/3rdparty/spirv-cross/spirv_hlsl.cpp +++ b/3rdparty/spirv-cross/spirv_hlsl.cpp @@ -2536,6 +2536,7 @@ void CompilerHLSL::emit_texture_op(const Instruction &i) uint32_t offset = 0; uint32_t coffsets = 0; uint32_t sample = 0; + uint32_t minlod = 0; uint32_t flags = 0; if (length) @@ -2562,10 +2563,14 @@ void CompilerHLSL::emit_texture_op(const Instruction &i) test(offset, ImageOperandsOffsetMask); test(coffsets, ImageOperandsConstOffsetsMask); test(sample, ImageOperandsSampleMask); + test(minlod, ImageOperandsMinLodMask); string expr; string texop; + if (minlod != 0) + SPIRV_CROSS_THROW("MinLod texture operand not supported in HLSL."); + if (op == OpImageFetch) { if (hlsl_options.shader_model < 40) diff --git a/3rdparty/spirv-cross/spirv_msl.cpp b/3rdparty/spirv-cross/spirv_msl.cpp index 3a827c65e..b3097ab82 100644 --- a/3rdparty/spirv-cross/spirv_msl.cpp +++ b/3rdparty/spirv-cross/spirv_msl.cpp @@ -79,6 +79,16 @@ bool CompilerMSL::is_msl_resource_binding_used(ExecutionModel model, uint32_t de return itr != end(resource_bindings) && itr->second.second; } +uint32_t CompilerMSL::get_automatic_msl_resource_binding(uint32_t id) const +{ + return get_extended_decoration(id, SPIRVCrossDecorationResourceIndexPrimary); +} + +uint32_t CompilerMSL::get_automatic_msl_resource_binding_secondary(uint32_t id) const +{ + return get_extended_decoration(id, SPIRVCrossDecorationResourceIndexSecondary); +} + void CompilerMSL::set_fragment_output_components(uint32_t location, uint32_t components) { fragment_output_components[location] = components; @@ -404,6 +414,7 @@ void CompilerMSL::build_implicit_builtins() // This should never match anything. set_decoration(var_id, DecorationDescriptorSet, kSwizzleBufferBinding); set_decoration(var_id, DecorationBinding, msl_options.swizzle_buffer_index); + set_extended_decoration(var_id, SPIRVCrossDecorationResourceIndexPrimary, msl_options.swizzle_buffer_index); swizzle_buffer_id = var_id; } @@ -414,6 +425,7 @@ void CompilerMSL::build_implicit_builtins() // This should never match anything. set_decoration(var_id, DecorationDescriptorSet, kBufferSizeBufferBinding); set_decoration(var_id, DecorationBinding, msl_options.buffer_size_buffer_index); + set_extended_decoration(var_id, SPIRVCrossDecorationResourceIndexPrimary, msl_options.buffer_size_buffer_index); buffer_size_buffer_id = var_id; } } @@ -771,6 +783,8 @@ string CompilerMSL::compile() next_metal_resource_index_buffer = 0; next_metal_resource_index_texture = 0; next_metal_resource_index_sampler = 0; + for (auto &id : next_metal_resource_ids) + id = 0; // Move constructor for this type is broken on GCC 4.9 ... buffer.reset(); @@ -1942,6 +1956,7 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch) // Accumulate the variables that should appear in the interface struct. SmallVector vars; bool incl_builtins = storage == StorageClassOutput || is_tessellation_shader(); + bool has_seen_barycentric = false; ir.for_each_typed_id([&](uint32_t var_id, SPIRVariable &var) { if (var.storage != storage) @@ -1956,7 +1971,8 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch) bool is_interface_block_builtin = (bi_type == BuiltInPosition || bi_type == BuiltInPointSize || bi_type == BuiltInClipDistance || bi_type == BuiltInCullDistance || bi_type == BuiltInLayer || bi_type == BuiltInViewportIndex || - bi_type == BuiltInFragDepth || bi_type == BuiltInFragStencilRefEXT || bi_type == BuiltInSampleMask) || + bi_type == BuiltInBaryCoordNV || bi_type == BuiltInBaryCoordNoPerspNV || bi_type == BuiltInFragDepth || + bi_type == BuiltInFragStencilRefEXT || bi_type == BuiltInSampleMask) || (get_execution_model() == ExecutionModelTessellationEvaluation && (bi_type == BuiltInTessLevelOuter || bi_type == BuiltInTessLevelInner)); @@ -1969,7 +1985,17 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch) bool filter_patch_decoration = (has_decoration(var_id, DecorationPatch) || is_patch_block(type)) == patch; - if (is_active && !is_hidden_variable(var, incl_builtins) && type.pointer && filter_patch_decoration && + bool hidden = is_hidden_variable(var, incl_builtins); + // Barycentric inputs must be emitted in stage-in, because they can have interpolation arguments. + if (is_active && (bi_type == BuiltInBaryCoordNV || bi_type == BuiltInBaryCoordNoPerspNV)) + { + if (has_seen_barycentric) + SPIRV_CROSS_THROW("Cannot declare both BaryCoordNV and BaryCoordNoPerspNV in same shader in MSL."); + has_seen_barycentric = true; + hidden = false; + } + + if (is_active && !hidden && type.pointer && filter_patch_decoration && (!is_builtin || is_interface_block_builtin)) { vars.push_back(&var); @@ -3846,11 +3872,11 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) auto store_type = texel_type; store_type.vecsize = 4; - statement(join( - to_expression(img_id), ".write(", remap_swizzle(store_type, texel_type.vecsize, to_expression(texel_id)), - ", ", - to_function_args(img_id, img_type, true, false, false, coord_id, 0, 0, 0, 0, lod, 0, 0, 0, 0, 0, &forward), - ");")); + statement(join(to_expression(img_id), ".write(", + remap_swizzle(store_type, texel_type.vecsize, to_expression(texel_id)), ", ", + to_function_args(img_id, img_type, true, false, false, coord_id, 0, 0, 0, 0, lod, 0, 0, 0, 0, 0, + 0, &forward), + ");")); if (p_var && variable_storage_is_aliased(*p_var)) flush_all_aliased_variables(); @@ -3904,7 +3930,30 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) } case OpImageQueryLod: - SPIRV_CROSS_THROW("MSL does not support textureQueryLod()."); + { + if (!msl_options.supports_msl_version(2, 2)) + SPIRV_CROSS_THROW("ImageQueryLod is only supported on MSL 2.2 and up."); + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t image_id = ops[2]; + uint32_t coord_id = ops[3]; + emit_uninitialized_temporary_expression(result_type, id); + + auto sampler_expr = to_sampler_expression(image_id); + auto *combined = maybe_get(image_id); + auto image_expr = combined ? to_expression(combined->image) : to_expression(image_id); + + // TODO: It is unclear if calculcate_clamped_lod also conditionally rounds + // the reported LOD based on the sampler. NEAREST miplevel should + // round the LOD, but LINEAR miplevel should not round. + // Let's hope this does not become an issue ... + statement(to_expression(id), ".x = ", image_expr, ".calculate_clamped_lod(", sampler_expr, ", ", + to_expression(coord_id), ");"); + statement(to_expression(id), ".y = ", image_expr, ".calculate_unclamped_lod(", sampler_expr, ", ", + to_expression(coord_id), ");"); + register_control_dependent_expression(id); + break; + } #define MSL_ImgQry(qrytype) \ do \ @@ -4661,7 +4710,7 @@ void CompilerMSL::emit_function_prototype(SPIRFunction &func, const Bitset &) // Returns the texture sampling function string for the specified image and sampling characteristics. string CompilerMSL::to_function_name(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool, bool, - bool has_offset, bool, bool has_dref, uint32_t) + bool has_offset, bool, bool has_dref, uint32_t, uint32_t) { // Special-case gather. We have to alter the component being looked up // in the swizzle case. @@ -4721,7 +4770,7 @@ string CompilerMSL::to_function_name(uint32_t img, const SPIRType &imgtype, bool string CompilerMSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool is_proj, uint32_t coord, uint32_t, uint32_t dref, uint32_t grad_x, uint32_t grad_y, uint32_t lod, uint32_t coffset, uint32_t offset, uint32_t bias, uint32_t comp, - uint32_t sample, bool *p_forward) + uint32_t sample, uint32_t minlod, bool *p_forward) { string farg_str; if (!is_fetch) @@ -4978,6 +5027,20 @@ string CompilerMSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool farg_str += ", gradient" + grad_opt + "(" + to_expression(grad_x) + ", " + to_expression(grad_y) + ")"; } + if (minlod) + { + if (msl_options.is_macos()) + { + if (!msl_options.supports_msl_version(2, 2)) + SPIRV_CROSS_THROW("min_lod_clamp() is only supported in MSL 2.2+ and up on macOS."); + } + else if (msl_options.is_ios()) + SPIRV_CROSS_THROW("min_lod_clamp() is not supported on iOS."); + + forward = forward && should_forward(minlod); + farg_str += ", min_lod_clamp(" + to_expression(minlod) + ")"; + } + // Add offsets string offset_expr; if (coffset && !is_fetch) @@ -5026,6 +5089,7 @@ string CompilerMSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool if (sample) { + forward = forward && should_forward(sample); farg_str += ", "; farg_str += to_expression(sample); } @@ -5425,9 +5489,9 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in BuiltIn builtin = BuiltInMax; bool is_builtin = is_member_builtin(type, index, &builtin); - if (has_extended_member_decoration(type.self, index, SPIRVCrossDecorationArgumentBufferID)) - return join(" [[id(", get_extended_member_decoration(type.self, index, SPIRVCrossDecorationArgumentBufferID), - ")]]"); + if (has_extended_member_decoration(type.self, index, SPIRVCrossDecorationResourceIndexPrimary)) + return join(" [[id(", + get_extended_member_decoration(type.self, index, SPIRVCrossDecorationResourceIndexPrimary), ")]]"); // Vertex function inputs if (execution.model == ExecutionModelVertex && type.storage == StorageClassInput) @@ -5557,7 +5621,7 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in // Fragment function inputs if (execution.model == ExecutionModelFragment && type.storage == StorageClassInput) { - string quals = ""; + string quals; if (is_builtin) { switch (builtin) @@ -5568,7 +5632,10 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in case BuiltInSampleId: case BuiltInSampleMask: case BuiltInLayer: + case BuiltInBaryCoordNV: + case BuiltInBaryCoordNoPerspNV: quals = builtin_qualifier(builtin); + break; default: break; @@ -5586,6 +5653,20 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in quals = string("user(locn") + convert_to_string(locn) + ")"; } } + + if (builtin == BuiltInBaryCoordNV || builtin == BuiltInBaryCoordNoPerspNV) + { + if (has_member_decoration(type.self, index, DecorationFlat) || + has_member_decoration(type.self, index, DecorationCentroid) || + has_member_decoration(type.self, index, DecorationSample) || + has_member_decoration(type.self, index, DecorationNoPerspective)) + { + // NoPerspective is baked into the builtin type. + SPIRV_CROSS_THROW( + "Flat, Centroid, Sample, NoPerspective decorations are not supported for BaryCoord inputs."); + } + } + // Don't bother decorating integers with the 'flat' attribute; it's // the default (in fact, the only option). Also don't bother with the // FragCoord builtin; it's always noperspective on Metal. @@ -5622,6 +5703,7 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in quals += "center_no_perspective"; } } + if (!quals.empty()) return " [[" + quals + "]]"; } @@ -5929,13 +6011,14 @@ void CompilerMSL::entry_point_args_builtin(string &ep_args) bi_type != BuiltInPatchVertices && bi_type != BuiltInTessLevelInner && bi_type != BuiltInTessLevelOuter && bi_type != BuiltInPosition && bi_type != BuiltInPointSize && bi_type != BuiltInClipDistance && bi_type != BuiltInCullDistance && bi_type != BuiltInSubgroupEqMask && + bi_type != BuiltInBaryCoordNV && bi_type != BuiltInBaryCoordNoPerspNV && bi_type != BuiltInSubgroupGeMask && bi_type != BuiltInSubgroupGtMask && bi_type != BuiltInSubgroupLeMask && bi_type != BuiltInSubgroupLtMask) { if (!ep_args.empty()) ep_args += ", "; - ep_args += builtin_type_decl(bi_type) + " " + to_expression(var_id); + ep_args += builtin_type_decl(bi_type, var_id) + " " + to_expression(var_id); ep_args += " [[" + builtin_qualifier(bi_type) + "]]"; } } @@ -6418,12 +6501,17 @@ uint32_t CompilerMSL::get_metal_resource_index(SPIRVariable &var, SPIRType::Base { auto &execution = get_entry_point(); auto &var_dec = ir.meta[var.self].decoration; + auto &var_type = get(var.basetype); uint32_t var_desc_set = (var.storage == StorageClassPushConstant) ? kPushConstDescSet : var_dec.set; uint32_t var_binding = (var.storage == StorageClassPushConstant) ? kPushConstBinding : var_dec.binding; // If a matching binding has been specified, find and use it. auto itr = resource_bindings.find({ execution.model, var_desc_set, var_binding }); + auto resource_decoration = var_type.basetype == SPIRType::SampledImage && basetype == SPIRType::Sampler ? + SPIRVCrossDecorationResourceIndexSecondary : + SPIRVCrossDecorationResourceIndexPrimary; + if (itr != end(resource_bindings)) { auto &remap = itr->second; @@ -6431,45 +6519,70 @@ uint32_t CompilerMSL::get_metal_resource_index(SPIRVariable &var, SPIRType::Base switch (basetype) { case SPIRType::Image: + set_extended_decoration(var.self, resource_decoration, remap.first.msl_texture); return remap.first.msl_texture; case SPIRType::Sampler: + set_extended_decoration(var.self, resource_decoration, remap.first.msl_sampler); return remap.first.msl_sampler; default: + set_extended_decoration(var.self, resource_decoration, remap.first.msl_buffer); return remap.first.msl_buffer; } } - // If there is no explicit mapping of bindings to MSL, use the declared binding. - if (has_decoration(var.self, DecorationBinding)) - { - var_binding = get_decoration(var.self, DecorationBinding); - // Avoid emitting sentinel bindings. - if (var_binding < 0x80000000u) - return var_binding; - } + // If we have already allocated an index, keep using it. + if (has_extended_decoration(var.self, resource_decoration)) + return get_extended_decoration(var.self, resource_decoration); + + // If we did not explicitly remap, allocate bindings on demand. + // We cannot reliably use Binding decorations since SPIR-V and MSL's binding models are very different. uint32_t binding_stride = 1; auto &type = get(var.basetype); for (uint32_t i = 0; i < uint32_t(type.array.size()); i++) binding_stride *= type.array_size_literal[i] ? type.array[i] : get(type.array[i]).scalar(); - // If a binding has not been specified, revert to incrementing resource indices + assert(binding_stride != 0); + + // If a binding has not been specified, revert to incrementing resource indices. uint32_t resource_index; - switch (basetype) + + bool allocate_argument_buffer_ids = false; + uint32_t desc_set = 0; + + if (var.storage != StorageClassPushConstant) { - case SPIRType::Image: - resource_index = next_metal_resource_index_texture; - next_metal_resource_index_texture += binding_stride; - break; - case SPIRType::Sampler: - resource_index = next_metal_resource_index_sampler; - next_metal_resource_index_sampler += binding_stride; - break; - default: - resource_index = next_metal_resource_index_buffer; - next_metal_resource_index_buffer += binding_stride; - break; + desc_set = get_decoration(var.self, DecorationDescriptorSet); + allocate_argument_buffer_ids = descriptor_set_is_argument_buffer(desc_set); } + + if (allocate_argument_buffer_ids) + { + // Allocate from a flat ID binding space. + resource_index = next_metal_resource_ids[desc_set]; + next_metal_resource_ids[desc_set] += binding_stride; + } + else + { + // Allocate from plain bindings which are allocated per resource type. + switch (basetype) + { + case SPIRType::Image: + resource_index = next_metal_resource_index_texture; + next_metal_resource_index_texture += binding_stride; + break; + case SPIRType::Sampler: + resource_index = next_metal_resource_index_sampler; + next_metal_resource_index_sampler += binding_stride; + break; + default: + resource_index = next_metal_resource_index_buffer; + next_metal_resource_index_buffer += binding_stride; + break; + } + } + + set_extended_decoration(var.self, resource_decoration, resource_index); return resource_index; } @@ -6504,7 +6617,7 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) if (var.basevariable == stage_in_ptr_var_id || var.basevariable == stage_out_ptr_var_id) decl += type_to_glsl(type, arg.id); else if (builtin) - decl += builtin_type_decl(static_cast(get_decoration(arg.id, DecorationBuiltIn))); + decl += builtin_type_decl(static_cast(get_decoration(arg.id, DecorationBuiltIn)), arg.id); else if ((storage == StorageClassUniform || storage == StorageClassStorageBuffer) && is_array(type)) decl += join(type_to_glsl(type, arg.id), "*"); else @@ -7024,10 +7137,14 @@ string CompilerMSL::type_to_glsl(const SPIRType &type, uint32_t id) type_name = "uint"; break; case SPIRType::Int64: - type_name = "long"; // Currently unsupported + if (!msl_options.supports_msl_version(2, 2)) + SPIRV_CROSS_THROW("64-bit integers are only supported in MSL 2.2 and above."); + type_name = "long"; break; case SPIRType::UInt64: - type_name = "size_t"; + if (!msl_options.supports_msl_version(2, 2)) + SPIRV_CROSS_THROW("64-bit integers are only supported in MSL 2.2 and above."); + type_name = "ulong"; break; case SPIRType::Half: type_name = "half"; @@ -7541,6 +7658,12 @@ string CompilerMSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage) break; + case BuiltInBaryCoordNV: + case BuiltInBaryCoordNoPerspNV: + if (storage == StorageClassInput && current_function && (current_function->self == ir.default_entry_point)) + return stage_in_var_name + "." + CompilerGLSL::builtin_to_glsl(builtin, storage); + break; + case BuiltInTessLevelOuter: if (get_execution_model() == ExecutionModelTessellationEvaluation) { @@ -7633,6 +7756,12 @@ string CompilerMSL::builtin_qualifier(BuiltIn builtin) return "threadgroup_position_in_grid"; case ExecutionModelTessellationEvaluation: return "patch_id"; + case ExecutionModelFragment: + if (msl_options.is_ios()) + SPIRV_CROSS_THROW("PrimitiveId is not supported in fragment on iOS."); + else if (msl_options.is_macos() && !msl_options.supports_msl_version(2, 2)) + SPIRV_CROSS_THROW("PrimitiveId on macOS requires MSL 2.2."); + return "primitive_id"; default: SPIRV_CROSS_THROW("PrimitiveId is not supported in this execution model."); } @@ -7716,13 +7845,29 @@ string CompilerMSL::builtin_qualifier(BuiltIn builtin) // Shouldn't be reached. SPIRV_CROSS_THROW("Subgroup ballot masks are handled specially in MSL."); + case BuiltInBaryCoordNV: + // TODO: AMD barycentrics as well? Seem to have different swizzle and 2 components rather than 3. + if (msl_options.is_ios()) + SPIRV_CROSS_THROW("Barycentrics not supported on iOS."); + else if (!msl_options.supports_msl_version(2, 2)) + SPIRV_CROSS_THROW("Barycentrics are only supported in MSL 2.2 and above on macOS."); + return "barycentric_coord, center_perspective"; + + case BuiltInBaryCoordNoPerspNV: + // TODO: AMD barycentrics as well? Seem to have different swizzle and 2 components rather than 3. + if (msl_options.is_ios()) + SPIRV_CROSS_THROW("Barycentrics not supported on iOS."); + else if (!msl_options.supports_msl_version(2, 2)) + SPIRV_CROSS_THROW("Barycentrics are only supported in MSL 2.2 and above on macOS."); + return "barycentric_coord, center_no_perspective"; + default: return "unsupported-built-in"; } } // Returns an MSL string type declaration for a SPIR-V builtin -string CompilerMSL::builtin_type_decl(BuiltIn builtin) +string CompilerMSL::builtin_type_decl(BuiltIn builtin, uint32_t id) { const SPIREntryPoint &execution = get_entry_point(); switch (builtin) @@ -7822,6 +7967,11 @@ string CompilerMSL::builtin_type_decl(BuiltIn builtin) case BuiltInHelperInvocation: return "bool"; + case BuiltInBaryCoordNV: + case BuiltInBaryCoordNoPerspNV: + // Use the type as declared, can be 1, 2 or 3 components. + return type_to_glsl(get_variable_data_type(get(id))); + default: return "unsupported-built-in-type"; } @@ -7902,6 +8052,13 @@ size_t CompilerMSL::get_declared_struct_member_alignment(const SPIRType &struct_ case SPIRType::Sampler: SPIRV_CROSS_THROW("Querying alignment of opaque object."); + case SPIRType::Int64: + SPIRV_CROSS_THROW("long types are not supported in buffers in MSL."); + case SPIRType::UInt64: + SPIRV_CROSS_THROW("ulong types are not supported in buffers in MSL."); + case SPIRType::Double: + SPIRV_CROSS_THROW("double types are not supported in buffers in MSL."); + case SPIRType::Struct: { // In MSL, a struct's alignment is equal to the maximum alignment of any of its members. @@ -8332,7 +8489,8 @@ void CompilerMSL::remap_constexpr_sampler(uint32_t id, const MSLConstexprSampler constexpr_samplers_by_id[id] = sampler; } -void CompilerMSL::remap_constexpr_sampler_by_binding(uint32_t desc_set, uint32_t binding, const MSLConstexprSampler &sampler) +void CompilerMSL::remap_constexpr_sampler_by_binding(uint32_t desc_set, uint32_t binding, + const MSLConstexprSampler &sampler) { constexpr_samplers_by_binding[{ desc_set, binding }] = sampler; } @@ -8360,6 +8518,7 @@ void CompilerMSL::bitcast_from_builtin_load(uint32_t source_id, std::string &exp case BuiltInLayer: case BuiltInViewportIndex: case BuiltInFragStencilRefEXT: + case BuiltInPrimitiveId: expected_type = SPIRType::UInt; break; @@ -8401,6 +8560,7 @@ void CompilerMSL::bitcast_to_builtin_store(uint32_t target_id, std::string &expr case BuiltInLayer: case BuiltInViewportIndex: case BuiltInFragStencilRefEXT: + case BuiltInPrimitiveId: expected_type = SPIRType::UInt; break; @@ -8512,11 +8672,6 @@ void CompilerMSL::analyze_argument_buffers() uint32_t image_resource_index = get_metal_resource_index(var, SPIRType::Image); uint32_t sampler_resource_index = get_metal_resource_index(var, SPIRType::Sampler); - // Avoid trivial conflicts where we didn't remap. - // This will let us at least compile test cases without having to instrument remaps. - if (sampler_resource_index == image_resource_index) - sampler_resource_index += type.array.empty() ? 1 : to_array_size_literal(type); - resources_in_set[desc_set].push_back({ &var, to_name(var_id), SPIRType::Image, image_resource_index }); if (type.image.dim != DimBuffer && !constexpr_sampler) @@ -8683,7 +8838,7 @@ void CompilerMSL::analyze_argument_buffers() } } - set_extended_member_decoration(buffer_type.self, member_index, SPIRVCrossDecorationArgumentBufferID, + set_extended_member_decoration(buffer_type.self, member_index, SPIRVCrossDecorationResourceIndexPrimary, resource.index); set_extended_member_decoration(buffer_type.self, member_index, SPIRVCrossDecorationInterfaceOrigID, var.self); @@ -8718,4 +8873,3 @@ size_t CompilerMSL::InternalHasher::operator()(const StageSetBinding &value) con auto tmp_hash = (hash_model * 0x10001b31) ^ hash_set; return (tmp_hash * 0x10001b31) ^ value.binding; } - diff --git a/3rdparty/spirv-cross/spirv_msl.hpp b/3rdparty/spirv-cross/spirv_msl.hpp index 097826107..5a059235d 100644 --- a/3rdparty/spirv-cross/spirv_msl.hpp +++ b/3rdparty/spirv-cross/spirv_msl.hpp @@ -20,9 +20,9 @@ #include "spirv_glsl.hpp" #include #include +#include #include #include -#include namespace SPIRV_CROSS_NAMESPACE { @@ -314,6 +314,19 @@ public: // by remap_constexpr_sampler(_by_binding). bool is_msl_resource_binding_used(spv::ExecutionModel model, uint32_t set, uint32_t binding); + // This must only be called after a successful call to CompilerMSL::compile(). + // For a variable resource ID obtained through reflection API, report the automatically assigned resource index. + // If the descriptor set was part of an argument buffer, report the [[id(N)]], + // or [[buffer/texture/sampler]] binding for other resources. + // If the resource was a combined image sampler, report the image binding here, + // use the _secondary version of this call to query the sampler half of the resource. + // If no binding exists, uint32_t(-1) is returned. + uint32_t get_automatic_msl_resource_binding(uint32_t id) const; + + // Same as get_automatic_msl_resource_binding, but should only be used for combined image samplers, in which case the + // sampler's binding is returned instead. For any other resource type, -1 is returned. + uint32_t get_automatic_msl_resource_binding_secondary(uint32_t id) const; + // Compiles the SPIR-V code into Metal Shading Language. std::string compile() override; @@ -397,12 +410,12 @@ protected: std::string to_func_call_arg(uint32_t id) override; std::string to_name(uint32_t id, bool allow_alias = true) const override; std::string to_function_name(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool is_proj, - bool has_array_offsets, bool has_offset, bool has_grad, bool has_dref, - uint32_t lod) override; + bool has_array_offsets, bool has_offset, bool has_grad, bool has_dref, uint32_t lod, + uint32_t minlod) override; std::string to_function_args(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool is_proj, uint32_t coord, uint32_t coord_components, uint32_t dref, uint32_t grad_x, uint32_t grad_y, uint32_t lod, uint32_t coffset, uint32_t offset, uint32_t bias, - uint32_t comp, uint32_t sample, bool *p_forward) override; + uint32_t comp, uint32_t sample, uint32_t minlod, bool *p_forward) override; std::string to_initializer_expression(const SPIRVariable &var) override; std::string unpack_expression_type(std::string expr_str, const SPIRType &type, uint32_t packed_type_id) override; std::string bitcast_glsl_op(const SPIRType &result_type, const SPIRType &argument_type) override; @@ -471,7 +484,7 @@ protected: std::string to_swizzle_expression(uint32_t id); std::string to_buffer_size_expression(uint32_t id); std::string builtin_qualifier(spv::BuiltIn builtin); - std::string builtin_type_decl(spv::BuiltIn builtin); + std::string builtin_type_decl(spv::BuiltIn builtin, uint32_t id = 0); std::string built_in_func_arg(spv::BuiltIn builtin, bool prefix_comma); std::string member_attribute_qualifier(const SPIRType &type, uint32_t index); std::string argument_decl(const SPIRFunction::Parameter &arg); @@ -561,6 +574,7 @@ protected: uint32_t next_metal_resource_index_buffer = 0; uint32_t next_metal_resource_index_texture = 0; uint32_t next_metal_resource_index_sampler = 0; + uint32_t next_metal_resource_ids[kMaxArgumentBuffers] = {}; uint32_t stage_in_var_id = 0; uint32_t stage_out_var_id = 0; diff --git a/3rdparty/spirv-cross/test_shaders.py b/3rdparty/spirv-cross/test_shaders.py index cd1fac69d..2df8e5937 100755 --- a/3rdparty/spirv-cross/test_shaders.py +++ b/3rdparty/spirv-cross/test_shaders.py @@ -90,6 +90,21 @@ def print_msl_compiler_version(): except OSError as e: if (e.errno != errno.ENOENT): # Ignore xcrun not found error raise + except subprocess.CalledProcessError: + pass + +def msl_compiler_supports_22(): + try: + subprocess.check_call(['xcrun', '--sdk', 'macosx', 'metal', '-x', 'metal', '-std=macos-metal2.2', '-'], + stdin = subprocess.DEVNULL, stdout = subprocess.DEVNULL, stderr = subprocess.DEVNULL) + print('Current SDK supports MSL 2.2. Enabling validation for MSL 2.2 shaders.') + return True + except OSError as e: + print('Failed to check if MSL 2.2 is not supported. It probably is not.') + return False + except subprocess.CalledProcessError: + print('Current SDK does NOT support MSL 2.2. Disabling validation for MSL 2.2 shaders.') + return False def path_to_msl_standard(shader): if '.ios.' in shader: @@ -578,7 +593,12 @@ def test_shader_msl(stats, shader, args, paths): # executable from Xcode using args: `--msl --entry main --output msl_path spirv_path`. # print('SPRIV shader: ' + spirv) - if not args.force_no_external_validation: + shader_is_msl22 = 'msl22' in joined_path + skip_validation = shader_is_msl22 and (not args.msl22) + if '.invalid.' in joined_path: + skip_validation = True + + if (not args.force_no_external_validation) and (not skip_validation): validate_shader_msl(shader, args.opt) remove_file(spirv) @@ -720,8 +740,10 @@ def main(): sys.stderr.write('Parallel execution is disabled when using the flags --update, --malisc or --force-no-external-validation\n') args.parallel = False + args.msl22 = False if args.msl: print_msl_compiler_version() + args.msl22 = msl_compiler_supports_22() backend = 'glsl' if (args.msl or args.metal):