diff options
author | Bill Hollings <bill.hollings@brenwill.com> | 2022-04-27 03:39:18 +0300 |
---|---|---|
committer | Bill Hollings <bill.hollings@brenwill.com> | 2022-04-27 03:39:18 +0300 |
commit | 3bca246ad2d30bfa8cd7caa501bd360b09472c51 (patch) | |
tree | b3584eef1ff41ca7610a3e424db7d057d46bc150 /reference/opt | |
parent | d7cae5e7cd326ca0ebfb2a7ac4e634a63ecfe19f (diff) |
MSL: Emit interface block members of array length 1 as arrays instead of scalars.
Test for array presence using is_array() instead of element count.
Add shaders-msl/vert/interface-block-single-element-array.vert regression test.
Fixes a regression error introduced in 3d4daab.
Diffstat (limited to 'reference/opt')
-rw-r--r-- | reference/opt/shaders-msl/vert/interface-block-single-element-array.vert | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/reference/opt/shaders-msl/vert/interface-block-single-element-array.vert b/reference/opt/shaders-msl/vert/interface-block-single-element-array.vert new file mode 100644 index 00000000..6858db73 --- /dev/null +++ b/reference/opt/shaders-msl/vert/interface-block-single-element-array.vert @@ -0,0 +1,79 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include <metal_stdlib> +#include <simd/simd.h> + +using namespace metal; + +template<typename T, size_t Num> +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct TDPickVertex +{ + float4 c; + spvUnsafeArray<float3, 1> uv; +}; + +struct main0_out +{ + float4 oTDVert_c [[user(locn0)]]; + float3 oTDVert_uv_0 [[user(locn1)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float3 P [[attribute(0)]]; + float3 uv_0 [[attribute(1)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + TDPickVertex oTDVert = {}; + spvUnsafeArray<float3, 1> uv = {}; + uv[0] = in.uv_0; + out.gl_Position = float4(in.P, 1.0); + oTDVert.uv[0] = uv[0]; + oTDVert.c = float4(1.0); + out.oTDVert_c = oTDVert.c; + out.oTDVert_uv_0 = oTDVert.uv[0]; + return out; +} + |