summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/3rdparty/spirv-cross/reference/shaders-msl/frag/lut-promotion.frag
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/3rdparty/spirv-cross/reference/shaders-msl/frag/lut-promotion.frag')
-rw-r--r--3rdparty/bgfx/3rdparty/spirv-cross/reference/shaders-msl/frag/lut-promotion.frag99
1 files changed, 42 insertions, 57 deletions
diff --git a/3rdparty/bgfx/3rdparty/spirv-cross/reference/shaders-msl/frag/lut-promotion.frag b/3rdparty/bgfx/3rdparty/spirv-cross/reference/shaders-msl/frag/lut-promotion.frag
index 1af7f872bdc..b1e0e7311dc 100644
--- a/3rdparty/bgfx/3rdparty/spirv-cross/reference/shaders-msl/frag/lut-promotion.frag
+++ b/3rdparty/bgfx/3rdparty/spirv-cross/reference/shaders-msl/frag/lut-promotion.frag
@@ -1,77 +1,62 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
+#pragma clang diagnostic ignored "-Wmissing-braces"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
-constant float _16[16] = { 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0 };
-constant float4 _60[4] = { float4(0.0), float4(1.0), float4(8.0), float4(5.0) };
-constant float4 _104[4] = { float4(20.0), float4(30.0), float4(50.0), float4(60.0) };
-
-struct main0_out
-{
- float FragColor [[color(0)]];
-};
-
-struct main0_in
-{
- int index [[user(locn0)]];
-};
-
-template<typename T, uint A>
-inline void spvArrayCopyFromConstantToStack1(thread T (&dst)[A], constant T (&src)[A])
+template<typename T, size_t Num>
+struct spvUnsafeArray
{
- for (uint i = 0; i < A; i++)
+ T elements[Num ? Num : 1];
+
+ thread T& operator [] (size_t pos) thread
{
- dst[i] = src[i];
+ return elements[pos];
}
-}
-
-template<typename T, uint A>
-inline void spvArrayCopyFromConstantToThreadGroup1(threadgroup T (&dst)[A], constant T (&src)[A])
-{
- for (uint i = 0; i < A; i++)
+ constexpr const thread T& operator [] (size_t pos) const thread
{
- dst[i] = src[i];
+ return elements[pos];
}
-}
-
-template<typename T, uint A>
-inline void spvArrayCopyFromStackToStack1(thread T (&dst)[A], thread const T (&src)[A])
-{
- for (uint i = 0; i < A; i++)
+
+ device T& operator [] (size_t pos) device
{
- dst[i] = src[i];
+ return elements[pos];
}
-}
-
-template<typename T, uint A>
-inline void spvArrayCopyFromStackToThreadGroup1(threadgroup T (&dst)[A], thread const T (&src)[A])
-{
- for (uint i = 0; i < A; i++)
+ constexpr const device T& operator [] (size_t pos) const device
{
- dst[i] = src[i];
+ return elements[pos];
}
-}
-
-template<typename T, uint A>
-inline void spvArrayCopyFromThreadGroupToStack1(thread T (&dst)[A], threadgroup const T (&src)[A])
-{
- for (uint i = 0; i < A; i++)
+
+ constexpr const constant T& operator [] (size_t pos) const constant
{
- dst[i] = src[i];
+ return elements[pos];
}
-}
-
-template<typename T, uint A>
-inline void spvArrayCopyFromThreadGroupToThreadGroup1(threadgroup T (&dst)[A], threadgroup const T (&src)[A])
-{
- for (uint i = 0; i < A; i++)
+
+ threadgroup T& operator [] (size_t pos) threadgroup
{
- dst[i] = src[i];
+ return elements[pos];
}
-}
+ constexpr const threadgroup T& operator [] (size_t pos) const threadgroup
+ {
+ return elements[pos];
+ }
+};
+
+constant spvUnsafeArray<float, 16> _16 = spvUnsafeArray<float, 16>({ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0 });
+constant spvUnsafeArray<float4, 4> _60 = spvUnsafeArray<float4, 4>({ float4(0.0), float4(1.0), float4(8.0), float4(5.0) });
+constant spvUnsafeArray<float4, 4> _104 = spvUnsafeArray<float4, 4>({ float4(20.0), float4(30.0), float4(50.0), float4(60.0) });
+
+struct main0_out
+{
+ float FragColor [[color(0)]];
+};
+
+struct main0_in
+{
+ int index [[user(locn0)]];
+};
fragment main0_out main0(main0_in in [[stage_in]])
{
@@ -93,14 +78,14 @@ fragment main0_out main0(main0_in in [[stage_in]])
{
out.FragColor += _60[in.index & 1].x;
}
- float4 foobar[4] = { float4(0.0), float4(1.0), float4(8.0), float4(5.0) };
+ spvUnsafeArray<float4, 4> foobar = spvUnsafeArray<float4, 4>({ float4(0.0), float4(1.0), float4(8.0), float4(5.0) });
if (in.index > 30)
{
foobar[1].z = 20.0;
}
out.FragColor += foobar[in.index & 3].z;
- float4 baz[4] = { float4(0.0), float4(1.0), float4(8.0), float4(5.0) };
- spvArrayCopyFromConstantToStack1(baz, _104);
+ spvUnsafeArray<float4, 4> baz = spvUnsafeArray<float4, 4>({ float4(0.0), float4(1.0), float4(8.0), float4(5.0) });
+ baz = _104;
out.FragColor += baz[in.index & 3].z;
return out;
}