Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Cross.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Hollings <bill.hollings@brenwill.com>2021-09-29 02:10:16 +0300
committerBill Hollings <bill.hollings@brenwill.com>2021-09-29 02:10:16 +0300
commitec054dad7fc345391ef2f7553c755f653efa1404 (patch)
treeb0c4e7723affe0adc82b41e99b9965d1a26aceba /reference/opt/shaders-msl
parentdee35bf3cef8efa9bd903582a4b564f612dfa3ba (diff)
MSL: Support synthetic functions in function constants.
Emit synthetic functions before function constants. Support use of spvQuantizeToF16() in function constants for numerical behavior consistency with the op code. Ensure subnormal results from OpQuantizeToF16 are flushed to zero per SPIR-V spec. Adjust SPIRV-Cross unit test reference shaders to accommodate these changes. Any MSL reference shader that inclues a synthetic function is affected, since the location it is emitted has changed.
Diffstat (limited to 'reference/opt/shaders-msl')
-rw-r--r--reference/opt/shaders-msl/asm/comp/atomic-decrement.asm.comp10
-rw-r--r--reference/opt/shaders-msl/asm/comp/atomic-increment.asm.comp10
-rw-r--r--reference/opt/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp10
-rw-r--r--reference/opt/shaders-msl/asm/comp/buffer-write.asm.comp10
-rw-r--r--reference/opt/shaders-msl/asm/comp/quantize.asm.comp20
-rw-r--r--reference/opt/shaders-msl/asm/frag/single-function-private-lut.asm.frag14
-rw-r--r--reference/opt/shaders-msl/comp/composite-array-initialization.force-native-array.comp44
-rw-r--r--reference/opt/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp12
-rw-r--r--reference/opt/shaders-msl/comp/global-invocation-id.comp12
-rw-r--r--reference/opt/shaders-msl/comp/image-atomic-automatic-bindings.argument.msl2.comp12
-rw-r--r--reference/opt/shaders-msl/comp/image-atomic-automatic-bindings.comp12
-rw-r--r--reference/opt/shaders-msl/comp/inverse.comp32
-rw-r--r--reference/opt/shaders-msl/comp/local-invocation-id.comp12
-rw-r--r--reference/opt/shaders-msl/comp/local-invocation-index.comp12
-rw-r--r--reference/opt/shaders-msl/comp/mod.comp14
-rw-r--r--reference/opt/shaders-msl/comp/writable-ssbo.comp12
-rw-r--r--reference/opt/shaders-msl/frag/array-of-texture-swizzle-nonconstant-uniform.msl2.argument.discrete.swizzle.frag58
-rw-r--r--reference/opt/shaders-msl/frag/array-of-texture-swizzle-nonconstant-uniform.msl2.swizzle.frag40
-rw-r--r--reference/opt/shaders-msl/frag/array-of-texture-swizzle.msl2.argument.discrete.swizzle.frag34
-rw-r--r--reference/opt/shaders-msl/frag/array-of-texture-swizzle.msl2.swizzle.frag20
-rw-r--r--reference/opt/shaders-msl/frag/buffer-read-write.frag10
-rw-r--r--reference/opt/shaders-msl/frag/mrt-array.frag14
-rw-r--r--reference/opt/shaders-msl/frag/pixel-interlock-ordered.msl2.argument.frag12
-rw-r--r--reference/opt/shaders-msl/frag/pixel-interlock-ordered.msl2.frag12
-rw-r--r--reference/opt/shaders-msl/frag/scalar-refract-reflect.frag20
-rw-r--r--reference/opt/shaders-msl/frag/subgroup-globals-extract.msl22.frag10
-rw-r--r--reference/opt/shaders-msl/frag/texture-cube-array.ios.emulate-cube-array.frag20
-rw-r--r--reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc32
-rw-r--r--reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc34
-rw-r--r--reference/opt/shaders-msl/vert/float-math.invariant-float-math.vert48
-rw-r--r--reference/opt/shaders-msl/vert/functions.vert48
-rw-r--r--reference/opt/shaders-msl/vert/no-contraction.vert24
-rw-r--r--reference/opt/shaders-msl/vert/sign-int-types.vert14
-rw-r--r--reference/opt/shaders-msl/vert/texture_buffer.vert10
34 files changed, 355 insertions, 353 deletions
diff --git a/reference/opt/shaders-msl/asm/comp/atomic-decrement.asm.comp b/reference/opt/shaders-msl/asm/comp/atomic-decrement.asm.comp
index 3dc6fffc..513f8763 100644
--- a/reference/opt/shaders-msl/asm/comp/atomic-decrement.asm.comp
+++ b/reference/opt/shaders-msl/asm/comp/atomic-decrement.asm.comp
@@ -7,11 +7,6 @@
using namespace metal;
-struct u0_counters
-{
- uint c;
-};
-
// Returns 2D texture coords corresponding to 1D texel buffer coords
static inline __attribute__((always_inline))
uint2 spvTexelBufferCoord(uint tc)
@@ -19,6 +14,11 @@ uint2 spvTexelBufferCoord(uint tc)
return uint2(tc % 4096, tc / 4096);
}
+struct u0_counters
+{
+ uint c;
+};
+
kernel void main0(device u0_counters& u0_counter [[buffer(0)]], texture2d<uint, access::write> u0 [[texture(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint _29 = atomic_fetch_sub_explicit((device atomic_uint*)&u0_counter.c, 1, memory_order_relaxed);
diff --git a/reference/opt/shaders-msl/asm/comp/atomic-increment.asm.comp b/reference/opt/shaders-msl/asm/comp/atomic-increment.asm.comp
index 6f42bb9d..55c41374 100644
--- a/reference/opt/shaders-msl/asm/comp/atomic-increment.asm.comp
+++ b/reference/opt/shaders-msl/asm/comp/atomic-increment.asm.comp
@@ -7,11 +7,6 @@
using namespace metal;
-struct u0_counters
-{
- uint c;
-};
-
// Returns 2D texture coords corresponding to 1D texel buffer coords
static inline __attribute__((always_inline))
uint2 spvTexelBufferCoord(uint tc)
@@ -19,6 +14,11 @@ uint2 spvTexelBufferCoord(uint tc)
return uint2(tc % 4096, tc / 4096);
}
+struct u0_counters
+{
+ uint c;
+};
+
kernel void main0(device u0_counters& u0_counter [[buffer(0)]], texture2d<uint, access::write> u0 [[texture(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint _29 = atomic_fetch_add_explicit((device atomic_uint*)&u0_counter.c, 1, memory_order_relaxed);
diff --git a/reference/opt/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp b/reference/opt/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp
index bb51fd7b..db0ade34 100644
--- a/reference/opt/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp
+++ b/reference/opt/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp
@@ -5,11 +5,6 @@
using namespace metal;
-struct cb5_struct
-{
- float4 _m0[5];
-};
-
// Returns 2D texture coords corresponding to 1D texel buffer coords
static inline __attribute__((always_inline))
uint2 spvTexelBufferCoord(uint tc)
@@ -17,6 +12,11 @@ uint2 spvTexelBufferCoord(uint tc)
return uint2(tc % 4096, tc / 4096);
}
+struct cb5_struct
+{
+ float4 _m0[5];
+};
+
kernel void main0(constant cb5_struct& cb0_5 [[buffer(0)]], texture2d<uint, access::write> u0 [[texture(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]])
{
uint _44 = as_type<uint>(as_type<float>(int(gl_LocalInvocationID.x) << 4)) >> 2u;
diff --git a/reference/opt/shaders-msl/asm/comp/buffer-write.asm.comp b/reference/opt/shaders-msl/asm/comp/buffer-write.asm.comp
index 8c9e23aa..89e8d83e 100644
--- a/reference/opt/shaders-msl/asm/comp/buffer-write.asm.comp
+++ b/reference/opt/shaders-msl/asm/comp/buffer-write.asm.comp
@@ -5,11 +5,6 @@
using namespace metal;
-struct cb
-{
- float value;
-};
-
// Returns 2D texture coords corresponding to 1D texel buffer coords
static inline __attribute__((always_inline))
uint2 spvTexelBufferCoord(uint tc)
@@ -17,6 +12,11 @@ uint2 spvTexelBufferCoord(uint tc)
return uint2(tc % 4096, tc / 4096);
}
+struct cb
+{
+ float value;
+};
+
kernel void main0(constant cb& _6 [[buffer(0)]], texture2d<float, access::write> _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/reference/opt/shaders-msl/asm/comp/quantize.asm.comp b/reference/opt/shaders-msl/asm/comp/quantize.asm.comp
index b7e6f919..672c2b20 100644
--- a/reference/opt/shaders-msl/asm/comp/quantize.asm.comp
+++ b/reference/opt/shaders-msl/asm/comp/quantize.asm.comp
@@ -5,6 +5,17 @@
using namespace metal;
+template <typename F> struct SpvHalfTypeSelector;
+template <> struct SpvHalfTypeSelector<float> { public: using H = half; };
+template<uint N> struct SpvHalfTypeSelector<vec<float, N>> { using H = vec<half, N>; };
+template<typename F, typename H = typename SpvHalfTypeSelector<F>::H>
+[[clang::optnone]] F spvQuantizeToF16(F fval)
+{
+ H hval = H(fval);
+ hval = select(copysign(H(0), hval), hval, isnormal(hval) || isinf(hval) || isnan(hval));
+ return F(hval);
+}
+
struct SSBO0
{
float scalar;
@@ -13,15 +24,6 @@ struct SSBO0
float4 vec4_val;
};
-template <typename F> struct SpvHalfTypeSelector;
-template <> struct SpvHalfTypeSelector<float> { public: using H = half; };
-template<uint N> struct SpvHalfTypeSelector<vec<float, N>> { using H = vec<half, N>; };
-template<typename F, typename H = typename SpvHalfTypeSelector<F>::H>
-[[clang::optnone]] F spvQuantizeToF16(F val)
-{
- return F(H(val));
-}
-
kernel void main0(device SSBO0& _4 [[buffer(0)]])
{
_4.scalar = spvQuantizeToF16(_4.scalar);
diff --git a/reference/opt/shaders-msl/asm/frag/single-function-private-lut.asm.frag b/reference/opt/shaders-msl/asm/frag/single-function-private-lut.asm.frag
index 4c0ea901..6ae5ec78 100644
--- a/reference/opt/shaders-msl/asm/frag/single-function-private-lut.asm.frag
+++ b/reference/opt/shaders-msl/asm/frag/single-function-private-lut.asm.frag
@@ -44,6 +44,13 @@ struct spvUnsafeArray
}
};
+// Implementation of the GLSL mod() function, which is slightly different than Metal fmod()
+template<typename Tx, typename Ty>
+inline Tx mod(Tx x, Ty y)
+{
+ return x - y * floor(x / y);
+}
+
struct myType
{
float data;
@@ -54,13 +61,6 @@ struct main0_out
float4 o_color [[color(0)]];
};
-// Implementation of the GLSL mod() function, which is slightly different than Metal fmod()
-template<typename Tx, typename Ty>
-inline Tx mod(Tx x, Ty y)
-{
- return x - y * floor(x / y);
-}
-
fragment main0_out main0(float4 gl_FragCoord [[position]])
{
spvUnsafeArray<myType, 5> _21 = spvUnsafeArray<myType, 5>({ myType{ 0.0 }, myType{ 1.0 }, myType{ 0.0 }, myType{ 1.0 }, myType{ 0.0 } });
diff --git a/reference/opt/shaders-msl/comp/composite-array-initialization.force-native-array.comp b/reference/opt/shaders-msl/comp/composite-array-initialization.force-native-array.comp
index aa612ecd..536a6e30 100644
--- a/reference/opt/shaders-msl/comp/composite-array-initialization.force-native-array.comp
+++ b/reference/opt/shaders-msl/comp/composite-array-initialization.force-native-array.comp
@@ -5,28 +5,6 @@
using namespace metal;
-struct Data
-{
- float a;
- float b;
-};
-
-constant float X_tmp [[function_constant(0)]];
-constant float X = is_function_constant_defined(X_tmp) ? X_tmp : 4.0;
-
-struct Data_1
-{
- float a;
- float b;
-};
-
-struct SSBO
-{
- Data_1 outdata[1];
-};
-
-constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(2u, 1u, 1u);
-
template<typename T, uint A>
inline void spvArrayCopyFromConstantToStack1(thread T (&dst)[A], constant T (&src)[A])
{
@@ -135,6 +113,28 @@ inline void spvArrayCopyFromDeviceToThreadGroup1(threadgroup T (&dst)[A], device
}
}
+struct Data
+{
+ float a;
+ float b;
+};
+
+constant float X_tmp [[function_constant(0)]];
+constant float X = is_function_constant_defined(X_tmp) ? X_tmp : 4.0;
+
+struct Data_1
+{
+ float a;
+ float b;
+};
+
+struct SSBO
+{
+ Data_1 outdata[1];
+};
+
+constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(2u, 1u, 1u);
+
kernel void main0(device SSBO& _53 [[buffer(0)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]])
{
Data _25[2] = { Data{ 1.0, 2.0 }, Data{ 3.0, 4.0 } };
diff --git a/reference/opt/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp b/reference/opt/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp
index 9900b593..333485a2 100644
--- a/reference/opt/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp
+++ b/reference/opt/shaders-msl/comp/global-invocation-id-writable-ssbo-in-function.comp
@@ -5,12 +5,6 @@
using namespace metal;
-struct myBlock
-{
- int a;
- float b[1];
-};
-
// Implementation of the GLSL mod() function, which is slightly different than Metal fmod()
template<typename Tx, typename Ty>
inline Tx mod(Tx x, Ty y)
@@ -18,6 +12,12 @@ inline Tx mod(Tx x, Ty y)
return x - y * floor(x / y);
}
+struct myBlock
+{
+ int a;
+ float b[1];
+};
+
kernel void main0(device myBlock& myStorage [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
myStorage.a = (myStorage.a + 1) % 256;
diff --git a/reference/opt/shaders-msl/comp/global-invocation-id.comp b/reference/opt/shaders-msl/comp/global-invocation-id.comp
index 9900b593..333485a2 100644
--- a/reference/opt/shaders-msl/comp/global-invocation-id.comp
+++ b/reference/opt/shaders-msl/comp/global-invocation-id.comp
@@ -5,12 +5,6 @@
using namespace metal;
-struct myBlock
-{
- int a;
- float b[1];
-};
-
// Implementation of the GLSL mod() function, which is slightly different than Metal fmod()
template<typename Tx, typename Ty>
inline Tx mod(Tx x, Ty y)
@@ -18,6 +12,12 @@ inline Tx mod(Tx x, Ty y)
return x - y * floor(x / y);
}
+struct myBlock
+{
+ int a;
+ float b[1];
+};
+
kernel void main0(device myBlock& myStorage [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
myStorage.a = (myStorage.a + 1) % 256;
diff --git a/reference/opt/shaders-msl/comp/image-atomic-automatic-bindings.argument.msl2.comp b/reference/opt/shaders-msl/comp/image-atomic-automatic-bindings.argument.msl2.comp
index 7dea8b71..05dc3874 100644
--- a/reference/opt/shaders-msl/comp/image-atomic-automatic-bindings.argument.msl2.comp
+++ b/reference/opt/shaders-msl/comp/image-atomic-automatic-bindings.argument.msl2.comp
@@ -7,6 +7,12 @@
using namespace metal;
+// The required alignment of a linear texture of R32Uint format.
+constant uint spvLinearTextureAlignmentOverride [[function_constant(65535)]];
+constant uint spvLinearTextureAlignment = is_function_constant_defined(spvLinearTextureAlignmentOverride) ? spvLinearTextureAlignmentOverride : 4;
+// Returns buffer coords corresponding to 2D texture coords for emulating 2D texture atomics
+#define spvImage2DAtomicCoord(tc, tex) (((((tex).get_width() + spvLinearTextureAlignment / 4 - 1) & ~( spvLinearTextureAlignment / 4 - 1)) * (tc).y) + (tc).x)
+
struct SSBO
{
float4 outdata;
@@ -23,12 +29,6 @@ struct spvDescriptorSetBuffer0
sampler uTextureSmplr [[id(4)]];
};
-// The required alignment of a linear texture of R32Uint format.
-constant uint spvLinearTextureAlignmentOverride [[function_constant(65535)]];
-constant uint spvLinearTextureAlignment = is_function_constant_defined(spvLinearTextureAlignmentOverride) ? spvLinearTextureAlignmentOverride : 4;
-// Returns buffer coords corresponding to 2D texture coords for emulating 2D texture atomics
-#define spvImage2DAtomicCoord(tc, tex) (((((tex).get_width() + spvLinearTextureAlignment / 4 - 1) & ~( spvLinearTextureAlignment / 4 - 1)) * (tc).y) + (tc).x)
-
kernel void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint _26 = atomic_fetch_add_explicit((device atomic_uint*)&spvDescriptorSet0.uImage_atomic[spvImage2DAtomicCoord(int2(gl_GlobalInvocationID.xy), spvDescriptorSet0.uImage)], 10u, memory_order_relaxed);
diff --git a/reference/opt/shaders-msl/comp/image-atomic-automatic-bindings.comp b/reference/opt/shaders-msl/comp/image-atomic-automatic-bindings.comp
index a2846474..7b0a129a 100644
--- a/reference/opt/shaders-msl/comp/image-atomic-automatic-bindings.comp
+++ b/reference/opt/shaders-msl/comp/image-atomic-automatic-bindings.comp
@@ -7,6 +7,12 @@
using namespace metal;
+// The required alignment of a linear texture of R32Uint format.
+constant uint spvLinearTextureAlignmentOverride [[function_constant(65535)]];
+constant uint spvLinearTextureAlignment = is_function_constant_defined(spvLinearTextureAlignmentOverride) ? spvLinearTextureAlignmentOverride : 4;
+// Returns buffer coords corresponding to 2D texture coords for emulating 2D texture atomics
+#define spvImage2DAtomicCoord(tc, tex) (((((tex).get_width() + spvLinearTextureAlignment / 4 - 1) & ~( spvLinearTextureAlignment / 4 - 1)) * (tc).y) + (tc).x)
+
struct SSBO
{
float4 outdata;
@@ -14,12 +20,6 @@ struct SSBO
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u);
-// The required alignment of a linear texture of R32Uint format.
-constant uint spvLinearTextureAlignmentOverride [[function_constant(65535)]];
-constant uint spvLinearTextureAlignment = is_function_constant_defined(spvLinearTextureAlignmentOverride) ? spvLinearTextureAlignmentOverride : 4;
-// Returns buffer coords corresponding to 2D texture coords for emulating 2D texture atomics
-#define spvImage2DAtomicCoord(tc, tex) (((((tex).get_width() + spvLinearTextureAlignment / 4 - 1) & ~( spvLinearTextureAlignment / 4 - 1)) * (tc).y) + (tc).x)
-
kernel void main0(device SSBO& _31 [[buffer(1)]], texture2d<uint> uImage [[texture(0)]], device atomic_uint* uImage_atomic [[buffer(0)]], texture2d<float> uTexture [[texture(1)]], sampler uTextureSmplr [[sampler(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint _26 = atomic_fetch_add_explicit((device atomic_uint*)&uImage_atomic[spvImage2DAtomicCoord(int2(gl_GlobalInvocationID.xy), uImage)], 10u, memory_order_relaxed);
diff --git a/reference/opt/shaders-msl/comp/inverse.comp b/reference/opt/shaders-msl/comp/inverse.comp
index 33aed468..0a1d298b 100644
--- a/reference/opt/shaders-msl/comp/inverse.comp
+++ b/reference/opt/shaders-msl/comp/inverse.comp
@@ -5,22 +5,6 @@
using namespace metal;
-struct MatrixOut
-{
- float2x2 m2out;
- float3x3 m3out;
- float4x4 m4out;
-};
-
-struct MatrixIn
-{
- float2x2 m2in;
- float3x3 m3in;
- float4x4 m4in;
-};
-
-constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u);
-
// Returns the determinant of a 2x2 matrix.
static inline __attribute__((always_inline))
float spvDet2x2(float a1, float a2, float b1, float b2)
@@ -121,6 +105,22 @@ float2x2 spvInverse2x2(float2x2 m)
return (det != 0.0f) ? (adj * (1.0f / det)) : m;
}
+struct MatrixOut
+{
+ float2x2 m2out;
+ float3x3 m3out;
+ float4x4 m4out;
+};
+
+struct MatrixIn
+{
+ float2x2 m2in;
+ float3x3 m3in;
+ float4x4 m4in;
+};
+
+constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u);
+
kernel void main0(device MatrixOut& _15 [[buffer(0)]], const device MatrixIn& _20 [[buffer(1)]])
{
_15.m2out = spvInverse2x2(_20.m2in);
diff --git a/reference/opt/shaders-msl/comp/local-invocation-id.comp b/reference/opt/shaders-msl/comp/local-invocation-id.comp
index 362aaa30..45059905 100644
--- a/reference/opt/shaders-msl/comp/local-invocation-id.comp
+++ b/reference/opt/shaders-msl/comp/local-invocation-id.comp
@@ -5,12 +5,6 @@
using namespace metal;
-struct myBlock
-{
- int a;
- float b[1];
-};
-
// Implementation of the GLSL mod() function, which is slightly different than Metal fmod()
template<typename Tx, typename Ty>
inline Tx mod(Tx x, Ty y)
@@ -18,6 +12,12 @@ inline Tx mod(Tx x, Ty y)
return x - y * floor(x / y);
}
+struct myBlock
+{
+ int a;
+ float b[1];
+};
+
kernel void main0(device myBlock& myStorage [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]])
{
myStorage.a = (myStorage.a + 1) % 256;
diff --git a/reference/opt/shaders-msl/comp/local-invocation-index.comp b/reference/opt/shaders-msl/comp/local-invocation-index.comp
index f8c1550e..67426dd3 100644
--- a/reference/opt/shaders-msl/comp/local-invocation-index.comp
+++ b/reference/opt/shaders-msl/comp/local-invocation-index.comp
@@ -5,12 +5,6 @@
using namespace metal;
-struct myBlock
-{
- int a;
- float b[1];
-};
-
// Implementation of the GLSL mod() function, which is slightly different than Metal fmod()
template<typename Tx, typename Ty>
inline Tx mod(Tx x, Ty y)
@@ -18,6 +12,12 @@ inline Tx mod(Tx x, Ty y)
return x - y * floor(x / y);
}
+struct myBlock
+{
+ int a;
+ float b[1];
+};
+
kernel void main0(device myBlock& myStorage [[buffer(0)]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]])
{
myStorage.a = (myStorage.a + 1) % 256;
diff --git a/reference/opt/shaders-msl/comp/mod.comp b/reference/opt/shaders-msl/comp/mod.comp
index e8c01f96..94d739fe 100644
--- a/reference/opt/shaders-msl/comp/mod.comp
+++ b/reference/opt/shaders-msl/comp/mod.comp
@@ -5,6 +5,13 @@
using namespace metal;
+// Implementation of the GLSL mod() function, which is slightly different than Metal fmod()
+template<typename Tx, typename Ty>
+inline Tx mod(Tx x, Ty y)
+{
+ return x - y * floor(x / y);
+}
+
struct SSBO
{
float4 in_data[1];
@@ -17,13 +24,6 @@ struct SSBO2
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u);
-// Implementation of the GLSL mod() function, which is slightly different than Metal fmod()
-template<typename Tx, typename Ty>
-inline Tx mod(Tx x, Ty y)
-{
- return x - y * floor(x / y);
-}
-
kernel void main0(const device SSBO& _23 [[buffer(0)]], device SSBO2& _33 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
_33.out_data[gl_GlobalInvocationID.x] = mod(_23.in_data[gl_GlobalInvocationID.x], _33.out_data[gl_GlobalInvocationID.x]);
diff --git a/reference/opt/shaders-msl/comp/writable-ssbo.comp b/reference/opt/shaders-msl/comp/writable-ssbo.comp
index dcec81a3..310cda7f 100644
--- a/reference/opt/shaders-msl/comp/writable-ssbo.comp
+++ b/reference/opt/shaders-msl/comp/writable-ssbo.comp
@@ -5,12 +5,6 @@
using namespace metal;
-struct myBlock
-{
- int a;
- float b;
-};
-
// Implementation of the GLSL mod() function, which is slightly different than Metal fmod()
template<typename Tx, typename Ty>
inline Tx mod(Tx x, Ty y)
@@ -18,6 +12,12 @@ inline Tx mod(Tx x, Ty y)
return x - y * floor(x / y);
}
+struct myBlock
+{
+ int a;
+ float b;
+};
+
kernel void main0(device myBlock& myStorage [[buffer(0)]])
{
myStorage.a = (myStorage.a + 1) % 256;
diff --git a/reference/opt/shaders-msl/frag/array-of-texture-swizzle-nonconstant-uniform.msl2.argument.discrete.swizzle.frag b/reference/opt/shaders-msl/frag/array-of-texture-swizzle-nonconstant-uniform.msl2.argument.discrete.swizzle.frag
index 0df12434..936b11dc 100644
--- a/reference/opt/shaders-msl/frag/array-of-texture-swizzle-nonconstant-uniform.msl2.argument.discrete.swizzle.frag
+++ b/reference/opt/shaders-msl/frag/array-of-texture-swizzle-nonconstant-uniform.msl2.argument.discrete.swizzle.frag
@@ -5,35 +5,6 @@
using namespace metal;
-struct UBO
-{
- uint index;
-};
-
-struct UBO2
-{
- uint index2;
-};
-
-struct spvDescriptorSetBuffer0
-{
- array<texture2d<float>, 4> uSampler [[id(0)]];
- array<sampler, 4> uSamplerSmplr [[id(4)]];
- constant UBO* uUBO [[id(8)]];
- constant UBO2* m_50 [[id(9)]];
- constant uint* spvSwizzleConstants [[id(10)]];
-};
-
-struct main0_out
-{
- float4 FragColor [[color(0)]];
-};
-
-struct main0_in
-{
- float2 vUV [[user(locn0)]];
-};
-
template<typename T> struct spvRemoveReference { typedef T type; };
template<typename T> struct spvRemoveReference<thread T&> { typedef T type; };
template<typename T> struct spvRemoveReference<thread T&&> { typedef T type; };
@@ -94,6 +65,35 @@ inline T spvTextureSwizzle(T x, uint s)
return spvTextureSwizzle(vec<T, 4>(x, 0, 0, 1), s).x;
}
+struct UBO
+{
+ uint index;
+};
+
+struct UBO2
+{
+ uint index2;
+};
+
+struct spvDescriptorSetBuffer0
+{
+ array<texture2d<float>, 4> uSampler [[id(0)]];
+ array<sampler, 4> uSamplerSmplr [[id(4)]];
+ constant UBO* uUBO [[id(8)]];
+ constant UBO2* m_50 [[id(9)]];
+ constant uint* spvSwizzleConstants [[id(10)]];
+};
+
+struct main0_out
+{
+ float4 FragColor [[color(0)]];
+};
+
+struct main0_in
+{
+ float2 vUV [[user(locn0)]];
+};
+
fragment main0_out main0(main0_in in [[stage_in]], constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], constant uint* spvSwizzleConstants [[buffer(30)]])
{
main0_out out = {};
diff --git a/reference/opt/shaders-msl/frag/array-of-texture-swizzle-nonconstant-uniform.msl2.swizzle.frag b/reference/opt/shaders-msl/frag/array-of-texture-swizzle-nonconstant-uniform.msl2.swizzle.frag
index c447536e..c680f04b 100644
--- a/reference/opt/shaders-msl/frag/array-of-texture-swizzle-nonconstant-uniform.msl2.swizzle.frag
+++ b/reference/opt/shaders-msl/frag/array-of-texture-swizzle-nonconstant-uniform.msl2.swizzle.frag
@@ -5,26 +5,6 @@
using namespace metal;
-struct UBO
-{
- uint index;
-};
-
-struct UBO2
-{
- uint index2;
-};
-
-struct main0_out
-{
- float4 FragColor [[color(0)]];
-};
-
-struct main0_in
-{
- float2 vUV [[user(locn0)]];
-};
-
template<typename T> struct spvRemoveReference { typedef T type; };
template<typename T> struct spvRemoveReference<thread T&> { typedef T type; };
template<typename T> struct spvRemoveReference<thread T&&> { typedef T type; };
@@ -85,6 +65,26 @@ inline T spvTextureSwizzle(T x, uint s)
return spvTextureSwizzle(vec<T, 4>(x, 0, 0, 1), s).x;
}
+struct UBO
+{
+ uint index;
+};
+
+struct UBO2
+{
+ uint index2;
+};
+
+struct main0_out
+{
+ float4 FragColor [[color(0)]];
+};
+
+struct main0_in
+{
+ float2 vUV [[user(locn0)]];
+};
+
fragment main0_out main0(main0_in in [[stage_in]], constant uint* spvSwizzleConstants [[buffer(30)]], constant UBO& uUBO [[buffer(0)]], constant UBO2& _50 [[buffer(1)]], array<texture2d<float>, 4> uSampler [[texture(0)]], array<sampler, 4> uSamplerSmplr [[sampler(0)]])
{
main0_out out = {};
diff --git a/reference/opt/shaders-msl/frag/array-of-texture-swizzle.msl2.argument.discrete.swizzle.frag b/reference/opt/shaders-msl/frag/array-of-texture-swizzle.msl2.argument.discrete.swizzle.frag
index d00acd7e..cc503e86 100644
--- a/reference/opt/shaders-msl/frag/array-of-texture-swizzle.msl2.argument.discrete.swizzle.frag
+++ b/reference/opt/shaders-msl/frag/array-of-texture-swizzle.msl2.argument.discrete.swizzle.frag
@@ -5,23 +5,6 @@
using namespace metal;
-struct spvDescriptorSetBuffer0
-{
- array<texture2d<float>, 4> uSampler0 [[id(0)]];
- array<sampler, 4> uSampler0Smplr [[id(4)]];
- constant uint* spvSwizzleConstants [[id(8)]];
-};
-
-struct main0_out
-{
- float4 FragColor [[color(0)]];
-};
-
-struct main0_in
-{
- float2 vUV [[user(locn0)]];
-};
-
template<typename T> struct spvRemoveReference { typedef T type; };
template<typename T> struct spvRemoveReference<thread T&> { typedef T type; };
template<typename T> struct spvRemoveReference<thread T&&> { typedef T type; };
@@ -82,6 +65,23 @@ inline T spvTextureSwizzle(T x, uint s)
return spvTextureSwizzle(vec<T, 4>(x, 0, 0, 1), s).x;
}
+struct spvDescriptorSetBuffer0
+{
+ array<texture2d<float>, 4> uSampler0 [[id(0)]];
+ array<sampler, 4> uSampler0Smplr [[id(4)]];
+ constant uint* spvSwizzleConstants [[id(8)]];
+};
+
+struct main0_out
+{
+ float4 FragColor [[color(0)]];
+};
+
+struct main0_in
+{
+ float2 vUV [[user(locn0)]];
+};
+
fragment main0_out main0(main0_in in [[stage_in]], constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], constant uint* spvSwizzleConstants [[buffer(30)]], texture2d<float> uSampler1 [[texture(0)]], sampler uSampler1Smplr [[sampler(0)]])
{
main0_out out = {};
diff --git a/reference/opt/shaders-msl/frag/array-of-texture-swizzle.msl2.swizzle.frag b/reference/opt/shaders-msl/frag/array-of-texture-swizzle.msl2.swizzle.frag
index 2f9aef13..5b1d17c5 100644
--- a/reference/opt/shaders-msl/frag/array-of-texture-swizzle.msl2.swizzle.frag
+++ b/reference/opt/shaders-msl/frag/array-of-texture-swizzle.msl2.swizzle.frag
@@ -5,16 +5,6 @@
using namespace metal;
-struct main0_out
-{
- float4 FragColor [[color(0)]];
-};
-
-struct main0_in
-{
- float2 vUV [[user(locn0)]];
-};
-
template<typename T> struct spvRemoveReference { typedef T type; };
template<typename T> struct spvRemoveReference<thread T&> { typedef T type; };
template<typename T> struct spvRemoveReference<thread T&&> { typedef T type; };
@@ -75,6 +65,16 @@ inline T spvTextureSwizzle(T x, uint s)
return spvTextureSwizzle(vec<T, 4>(x, 0, 0, 1), s).x;
}
+struct main0_out
+{
+ float4 FragColor [[color(0)]];
+};
+
+struct main0_in
+{
+ float2 vUV [[user(locn0)]];
+};
+
fragment main0_out main0(main0_in in [[stage_in]], constant uint* spvSwizzleConstants [[buffer(30)]], array<texture2d<float>, 4> uSampler [[texture(0)]], array<sampler, 4> uSamplerSmplr [[sampler(0)]])
{
main0_out out = {};
diff --git a/reference/opt/shaders-msl/frag/buffer-read-write.frag b/reference/opt/shaders-msl/frag/buffer-read-write.frag
index 166d4311..4f114ed7 100644
--- a/reference/opt/shaders-msl/frag/buffer-read-write.frag
+++ b/reference/opt/shaders-msl/frag/buffer-read-write.frag
@@ -5,11 +5,6 @@
using namespace metal;
-struct main0_out
-{
- float4 FragColor [[color(0)]];
-};
-
// Returns 2D texture coords corresponding to 1D texel buffer coords
static inline __attribute__((always_inline))
uint2 spvTexelBufferCoord(uint tc)
@@ -17,6 +12,11 @@ uint2 spvTexelBufferCoord(uint tc)
return uint2(tc % 4096, tc / 4096);
}
+struct main0_out
+{
+ float4 FragColor [[color(0)]];
+};
+
fragment main0_out main0(texture2d<float> buf [[texture(0)]], texture2d<float, access::write> bufOut [[texture(1)]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
diff --git a/reference/opt/shaders-msl/frag/mrt-array.frag b/reference/opt/shaders-msl/frag/mrt-array.frag
index 79fc0391..d7fccded 100644
--- a/reference/opt/shaders-msl/frag/mrt-array.frag
+++ b/reference/opt/shaders-msl/frag/mrt-array.frag
@@ -44,6 +44,13 @@ struct spvUnsafeArray
}
};
+// Implementation of the GLSL mod() function, which is slightly different than Metal fmod()
+template<typename Tx, typename Ty>
+inline Tx mod(Tx x, Ty y)
+{
+ return x - y * floor(x / y);
+}
+
struct main0_out
{
float4 FragColor_0 [[color(0)]];
@@ -58,13 +65,6 @@ struct main0_in
float4 vB [[user(locn1)]];
};
-// Implementation of the GLSL mod() function, which is slightly different than Metal fmod()
-template<typename Tx, typename Ty>
-inline Tx mod(Tx x, Ty y)
-{
- return x - y * floor(x / y);
-}
-
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
diff --git a/reference/opt/shaders-msl/frag/pixel-interlock-ordered.msl2.argument.frag b/reference/opt/shaders-msl/frag/pixel-interlock-ordered.msl2.argument.frag
index adea453d..1bfaff53 100644
--- a/reference/opt/shaders-msl/frag/pixel-interlock-ordered.msl2.argument.frag
+++ b/reference/opt/shaders-msl/frag/pixel-interlock-ordered.msl2.argument.frag
@@ -7,6 +7,12 @@
using namespace metal;
+// The required alignment of a linear texture of R32Uint format.
+constant uint spvLinearTextureAlignmentOverride [[function_constant(65535)]];
+constant uint spvLinearTextureAlignment = is_function_constant_defined(spvLinearTextureAlignmentOverride) ? spvLinearTextureAlignmentOverride : 4;
+// Returns buffer coords corresponding to 2D texture coords for emulating 2D texture atomics
+#define spvImage2DAtomicCoord(tc, tex) (((((tex).get_width() + spvLinearTextureAlignment / 4 - 1) & ~( spvLinearTextureAlignment / 4 - 1)) * (tc).y) + (tc).x)
+
struct Buffer3
{
int baz;
@@ -35,12 +41,6 @@ struct spvDescriptorSetBuffer0
device Buffer2* m_52 [[id(7), raster_order_group(0)]];
};
-// The required alignment of a linear texture of R32Uint format.
-constant uint spvLinearTextureAlignmentOverride [[function_constant(65535)]];
-constant uint spvLinearTextureAlignment = is_function_constant_defined(spvLinearTextureAlignmentOverride) ? spvLinearTextureAlignmentOverride : 4;
-// Returns buffer coords corresponding to 2D texture coords for emulating 2D texture atomics
-#define spvImage2DAtomicCoord(tc, tex) (((((tex).get_width() + spvLinearTextureAlignment / 4 - 1) & ~( spvLinearTextureAlignment / 4 - 1)) * (tc).y) + (tc).x)
-
fragment void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]])
{
(*spvDescriptorSet0.m_9).baz = 0;
diff --git a/reference/opt/shaders-msl/frag/pixel-interlock-ordered.msl2.frag b/reference/opt/shaders-msl/frag/pixel-interlock-ordered.msl2.frag
index e409ea06..6a300e8c 100644
--- a/reference/opt/shaders-msl/frag/pixel-interlock-ordered.msl2.frag
+++ b/reference/opt/shaders-msl/frag/pixel-interlock-ordered.msl2.frag
@@ -7,6 +7,12 @@
using namespace metal;
+// The required alignment of a linear texture of R32Uint format.
+constant uint spvLinearTextureAlignmentOverride [[function_constant(65535)]];
+constant uint spvLinearTextureAlignment = is_function_constant_defined(spvLinearTextureAlignmentOverride) ? spvLinearTextureAlignmentOverride : 4;
+// Returns buffer coords corresponding to 2D texture coords for emulating 2D texture atomics
+#define spvImage2DAtomicCoord(tc, tex) (((((tex).get_width() + spvLinearTextureAlignment / 4 - 1) & ~( spvLinearTextureAlignment / 4 - 1)) * (tc).y) + (tc).x)
+
struct Buffer3
{
int baz;
@@ -23,12 +29,6 @@ struct Buffer2
uint quux;
};
-// The required alignment of a linear texture of R32Uint format.
-constant uint spvLinearTextureAlignmentOverride [[function_constant(65535)]];
-constant uint spvLinearTextureAlignment = is_function_constant_defined(spvLinearTextureAlignmentOverride) ? spvLinearTextureAlignmentOverride : 4;
-// Returns buffer coords corresponding to 2D texture coords for emulating 2D texture atomics
-#define spvImage2DAtomicCoord(tc, tex) (((((tex).get_width() + spvLinearTextureAlignment / 4 - 1) & ~( spvLinearTextureAlignment / 4 - 1)) * (tc).y) + (tc).x)
-
fragment void main0(device Buffer3& _9 [[buffer(0)]], volatile device Buffer& _42 [[buffer(2), raster_order_group(0)]], device Buffer2& _52 [[buffer(3), raster_order_group(0)]], texture2d<float, access::write> img4 [[texture(0)]], texture2d<float, access::write> img [[texture(1), raster_order_group(0)]], texture2d<float> img3 [[texture(2), raster_order_group(0)]], texture2d<uint> img2 [[texture(3), raster_order_group(0)]], device atomic_uint* img2_atomic [[buffer(1), raster_order_group(0)]])
{
_9.baz = 0;
diff --git a/reference/opt/shaders-msl/frag/scalar-refract-reflect.frag b/reference/opt/shaders-msl/frag/scalar-refract-reflect.frag
index e4adc4ab..fc908cb3 100644
--- a/reference/opt/shaders-msl/frag/scalar-refract-reflect.frag
+++ b/reference/opt/shaders-msl/frag/scalar-refract-reflect.frag
@@ -5,16 +5,6 @@
using namespace metal;
-struct main0_out
-{
- float FragColor [[color(0)]];
-};
-
-struct main0_in
-{
- float3 vRefract [[user(locn0)]];
-};
-
template<typename T>
[[clang::optnone]] T spvReflect(T i, T n)
{
@@ -37,6 +27,16 @@ inline T spvRefract(T i, T n, T eta)
}
}
+struct main0_out
+{
+ float FragColor [[color(0)]];
+};
+
+struct main0_in
+{
+ float3 vRefract [[user(locn0)]];
+};
+
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
diff --git a/reference/opt/shaders-msl/frag/subgroup-globals-extract.msl22.frag b/reference/opt/shaders-msl/frag/subgroup-globals-extract.msl22.frag
index bb8fadcf..b2cfddf6 100644
--- a/reference/opt/shaders-msl/frag/subgroup-globals-extract.msl22.frag
+++ b/reference/opt/shaders-msl/frag/subgroup-globals-extract.msl22.frag
@@ -5,11 +5,6 @@
using namespace metal;
-struct main0_out
-{
- uint2 FragColor [[color(0)]];
-};
-
inline uint spvSubgroupBallotFindLSB(uint4 ballot, uint gl_SubgroupSize)
{
uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupSize, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupSize - 32, 0)), uint2(0));
@@ -47,6 +42,11 @@ inline uint spvSubgroupBallotExclusiveBitCount(uint4 ballot, uint gl_SubgroupInv
return spvPopCount4(ballot & mask);
}
+struct main0_out
+{
+ uint2 FragColor [[color(0)]];
+};
+
fragment main0_out main0(uint gl_SubgroupInvocationID [[thread_index_in_simdgroup]], uint gl_SubgroupSize [[threads_per_simdgroup]])
{
main0_out out = {};
diff --git a/reference/opt/shaders-msl/frag/texture-cube-array.ios.emulate-cube-array.frag b/reference/opt/shaders-msl/frag/texture-cube-array.ios.emulate-cube-array.frag
index 217a7a9e..c057e217 100644
--- a/reference/opt/shaders-msl/frag/texture-cube-array.ios.emulate-cube-array.frag
+++ b/reference/opt/shaders-msl/frag/texture-cube-array.ios.emulate-cube-array.frag
@@ -5,16 +5,6 @@
using namespace metal;
-struct main0_out
-{
- float4 FragColor [[color(0)]];
-};
-
-struct main0_in
-{
- float4 vUV [[user(locn0)]];
-};
-
static inline __attribute__((always_inline))
float3 spvCubemapTo2DArrayFace(float3 P)
{
@@ -49,6 +39,16 @@ float3 spvCubemapTo2DArrayFace(float3 P)
return float3(u, v, CubeFace);
}
+struct main0_out
+{
+ float4 FragColor [[color(0)]];
+};
+
+struct main0_in
+{
+ float4 vUV [[user(locn0)]];
+};
+
fragment main0_out main0(main0_in in [[stage_in]], texturecube<float> cubeSampler [[texture(0)]], texture2d_array<float> cubeArraySampler [[texture(1)]], texture2d_array<float> texArraySampler [[texture(2)]], sampler cubeSamplerSmplr [[sampler(0)]], sampler cubeArraySamplerSmplr [[sampler(1)]], sampler texArraySamplerSmplr [[sampler(2)]])
{
main0_out out = {};
diff --git a/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc b/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc
index 406feed9..24928da0 100644
--- a/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc
+++ b/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc
@@ -44,22 +44,6 @@ struct spvUnsafeArray
}
};
-struct main0_out
-{
- float4 gl_Position;
-};
-
-struct main0_patchOut
-{
- spvUnsafeArray<float4, 2> pFoo;
-};
-
-struct main0_in
-{
- spvUnsafeArray<float4, 2> iFoo;
- float4 ipFoo;
-};
-
template<typename T, uint A>
inline void spvArrayCopyFromConstantToStack1(thread T (&dst)[A], constant T (&src)[A])
{
@@ -168,6 +152,22 @@ inline void spvArrayCopyFromDeviceToThreadGroup1(threadgroup T (&dst)[A], device
}
}
+struct main0_out
+{
+ float4 gl_Position;
+};
+
+struct main0_patchOut
+{
+ spvUnsafeArray<float4, 2> pFoo;
+};
+
+struct main0_in
+{
+ spvUnsafeArray<float4, 2> iFoo;
+ float4 ipFoo;
+};
+
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]])
{
device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4];
diff --git a/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc b/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc
index e9dd68dc..a08364e2 100644
--- a/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc
+++ b/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc
@@ -44,23 +44,6 @@ struct spvUnsafeArray
}
};
-struct main0_out
-{
- float4 gl_Position;
-};
-
-struct main0_patchOut
-{
- spvUnsafeArray<float4, 2> pFoo;
-};
-
-struct main0_in
-{
- float4 iFoo_0 [[attribute(0)]];
- float4 iFoo_1 [[attribute(1)]];
- float4 ipFoo [[attribute(2)]];
-};
-
template<typename T, uint A>
inline void spvArrayCopyFromConstantToStack1(thread T (&dst)[A], constant T (&src)[A])
{
@@ -169,6 +152,23 @@ inline void spvArrayCopyFromDeviceToThreadGroup1(threadgroup T (&dst)[A], device
}
}
+struct main0_out
+{
+ float4 gl_Position;
+};
+
+struct main0_patchOut
+{
+ spvUnsafeArray<float4, 2> pFoo;
+};
+
+struct main0_in
+{
+ float4 iFoo_0 [[attribute(0)]];
+ float4 iFoo_1 [[attribute(1)]];
+ float4 ipFoo [[attribute(2)]];
+};
+
kernel void main0(main0_in in [[stage_in]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]])
{
threadgroup float4 Foo[4][2];
diff --git a/reference/opt/shaders-msl/vert/float-math.invariant-float-math.vert b/reference/opt/shaders-msl/vert/float-math.invariant-float-math.vert
index d8f44bec..0fddcdf4 100644
--- a/reference/opt/shaders-msl/vert/float-math.invariant-float-math.vert
+++ b/reference/opt/shaders-msl/vert/float-math.invariant-float-math.vert
@@ -44,30 +44,6 @@ struct spvUnsafeArray
}
};
-struct Matrices
-{
- float4x4 vpMatrix;
- float4x4 wMatrix;
- float4x3 wMatrix4x3;
- float3x4 wMatrix3x4;
-};
-
-struct main0_out
-{
- float3 OutNormal [[user(locn0)]];
- float4 OutWorldPos_0 [[user(locn1)]];
- float4 OutWorldPos_1 [[user(locn2)]];
- float4 OutWorldPos_2 [[user(locn3)]];
- float4 OutWorldPos_3 [[user(locn4)]];
- float4 gl_Position [[position]];
-};
-
-struct main0_in
-{
- float3 InPos [[attribute(0)]];
- float3 InNormal [[attribute(1)]];
-};
-
template<typename T>
[[clang::optnone]] T spvFMul(T l, T r)
{
@@ -117,6 +93,30 @@ template<typename T, int LCols, int LRows, int RCols, int RRows>
return res;
}
+struct Matrices
+{
+ float4x4 vpMatrix;
+ float4x4 wMatrix;
+ float4x3 wMatrix4x3;
+ float3x4 wMatrix3x4;
+};
+
+struct main0_out
+{
+ float3 OutNormal [[user(locn0)]];
+ float4 OutWorldPos_0 [[user(locn1)]];
+ float4 OutWorldPos_1 [[user(locn2)]];
+ float4 OutWorldPos_2 [[user(locn3)]];
+ float4 OutWorldPos_3 [[user(locn4)]];
+ float4 gl_Position [[position]];
+};
+
+struct main0_in
+{
+ float3 InPos [[attribute(0)]];
+ float3 InNormal [[attribute(1)]];
+};
+
vertex main0_out main0(main0_in in [[stage_in]], constant Matrices& _22 [[buffer(0)]])
{
main0_out out = {};
diff --git a/reference/opt/shaders-msl/vert/functions.vert b/reference/opt/shaders-msl/vert/functions.vert
index 73eaa8b7..4300aa13 100644
--- a/reference/opt/shaders-msl/vert/functions.vert
+++ b/reference/opt/shaders-msl/vert/functions.vert
@@ -5,30 +5,6 @@
using namespace metal;
-struct UBO
-{
- float4x4 uMVP;
- float3 rotDeg;
- float3 rotRad;
- int2 bits;
-};
-
-struct main0_out
-{
- float3 vNormal [[user(locn0)]];
- float3 vRotDeg [[user(locn1)]];
- float3 vRotRad [[user(locn2)]];
- int2 vLSB [[user(locn3)]];
- int2 vMSB [[user(locn4)]];
- float4 gl_Position [[position]];
-};
-
-struct main0_in
-{
- float4 aVertex [[attribute(0)]];
- float3 aNormal [[attribute(1)]];
-};
-
// Implementation of the GLSL radians() function
template<typename T>
inline T radians(T d)
@@ -108,6 +84,30 @@ float4x4 spvInverse4x4(float4x4 m)
return (det != 0.0f) ? (adj * (1.0f / det)) : m;
}
+struct UBO
+{
+ float4x4 uMVP;
+ float3 rotDeg;
+ float3 rotRad;
+ int2 bits;
+};
+
+struct main0_out
+{
+ float3 vNormal [[user(locn0)]];
+ float3 vRotDeg [[user(locn1)]];
+ float3 vRotRad [[user(locn2)]];
+ int2 vLSB [[user(locn3)]];
+ int2 vMSB [[user(locn4)]];
+ float4 gl_Position [[position]];
+};
+
+struct main0_in
+{
+ float4 aVertex [[attribute(0)]];
+ float3 aNormal [[attribute(1)]];
+};
+
vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _18 [[buffer(0)]])
{
main0_out out = {};
diff --git a/reference/opt/shaders-msl/vert/no-contraction.vert b/reference/opt/shaders-msl/vert/no-contraction.vert
index 0b75dbcb..f4df5506 100644
--- a/reference/opt/shaders-msl/vert/no-contraction.vert
+++ b/reference/opt/shaders-msl/vert/no-contraction.vert
@@ -5,18 +5,6 @@
using namespace metal;
-struct main0_out
-{
- float4 gl_Position [[position]];
-};
-
-struct main0_in
-{
- float4 vA [[attribute(0)]];
- float4 vB [[attribute(1)]];
- float4 vC [[attribute(2)]];
-};
-
template<typename T>
[[clang::optnone]] T spvFMul(T l, T r)
{
@@ -78,6 +66,18 @@ template<typename T>
return fma(T(-1), r, l);
}
+struct main0_out
+{
+ float4 gl_Position [[position]];
+};
+
+struct main0_in
+{
+ float4 vA [[attribute(0)]];
+ float4 vB [[attribute(1)]];
+ float4 vC [[attribute(2)]];
+};
+
vertex main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
diff --git a/reference/opt/shaders-msl/vert/sign-int-types.vert b/reference/opt/shaders-msl/vert/sign-int-types.vert
index a5106452..f5f647d4 100644
--- a/reference/opt/shaders-msl/vert/sign-int-types.vert
+++ b/reference/opt/shaders-msl/vert/sign-int-types.vert
@@ -5,6 +5,13 @@
using namespace metal;
+// Implementation of the GLSL sign() function for integer types
+template<typename T, typename E = typename enable_if<is_integral<T>::value>::type>
+inline T sign(T x)
+{
+ return select(select(select(x, T(0), x == T(0)), T(1), x > T(0)), T(-1), x < T(0));
+}
+
struct UBO
{
float4x4 uMVP;
@@ -36,13 +43,6 @@ struct main0_in
float4 aVertex [[attribute(0)]];
};
-// Implementation of the GLSL sign() function for integer types
-template<typename T, typename E = typename enable_if<is_integral<T>::value>::type>
-inline T sign(T x)
-{
- return select(select(select(x, T(0), x == T(0)), T(1), x > T(0)), T(-1), x < T(0));
-}
-
vertex main0_out main0(main0_in in [[stage_in]], constant UBO& _21 [[buffer(0)]])
{
main0_out out = {};
diff --git a/reference/opt/shaders-msl/vert/texture_buffer.vert b/reference/opt/shaders-msl/vert/texture_buffer.vert
index 3b3d92b5..9d8b5c49 100644
--- a/reference/opt/shaders-msl/vert/texture_buffer.vert
+++ b/reference/opt/shaders-msl/vert/texture_buffer.vert
@@ -5,11 +5,6 @@
using namespace metal;
-struct main0_out
-{
- float4 gl_Position [[position]];
-};
-
// Returns 2D texture coords corresponding to 1D texel buffer coords
static inline __attribute__((always_inline))
uint2 spvTexelBufferCoord(uint tc)
@@ -17,6 +12,11 @@ uint2 spvTexelBufferCoord(uint tc)
return uint2(tc % 4096, tc / 4096);
}
+struct main0_out
+{
+ float4 gl_Position [[position]];
+};
+
vertex main0_out main0(texture2d<float> uSamp [[texture(0)]], texture2d<float> uSampo [[texture(1)]])
{
main0_out out = {};