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:
authorHans-Kristian Arntzen <post@arntzen-software.no>2022-03-22 14:10:13 +0300
committerHans-Kristian Arntzen <post@arntzen-software.no>2022-03-22 14:25:09 +0300
commit7b9eaf0b5e9b91ca4998518ea5b9c8ee940c21fc (patch)
tree97f72b5ce78f0f0050d510e57b2870d7006006e6 /reference
parent565db34cba00171ded142e873b08fa9a24f0cec3 (diff)
MSL: Handle awkward mix and match of Offset / ArrayStride in constants.
In normal buffer blocks, every member must be declared, but for constants, you can technically mix and match, causing much pain and suffering ...
Diffstat (limited to 'reference')
-rw-r--r--reference/shaders-msl-no-opt/asm/frag/constant-composite-block-no-array-stride-2.asm.frag70
-rw-r--r--reference/shaders-msl-no-opt/asm/vert/constant-composite-block-no-array-stride.asm.vert89
2 files changed, 159 insertions, 0 deletions
diff --git a/reference/shaders-msl-no-opt/asm/frag/constant-composite-block-no-array-stride-2.asm.frag b/reference/shaders-msl-no-opt/asm/frag/constant-composite-block-no-array-stride-2.asm.frag
new file mode 100644
index 00000000..eb78db53
--- /dev/null
+++ b/reference/shaders-msl-no-opt/asm/frag/constant-composite-block-no-array-stride-2.asm.frag
@@ -0,0 +1,70 @@
+#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 _3
+{
+ spvUnsafeArray<float, 2> _m0;
+ float _m1[2];
+ spvUnsafeArray<float, 2> _m2;
+};
+
+constant spvUnsafeArray<float, 2> _15 = spvUnsafeArray<float, 2>({ 1.0, 2.0 });
+constant spvUnsafeArray<float, 2> _16 = spvUnsafeArray<float, 2>({ 3.0, 4.0 });
+constant spvUnsafeArray<float, 2> _17 = spvUnsafeArray<float, 2>({ 5.0, 6.0 });
+
+struct main0_out
+{
+ float m_2 [[color(0)]];
+};
+
+fragment main0_out main0()
+{
+ main0_out out = {};
+ _3 _23 = _3{ spvUnsafeArray<float, 2>({ 1.0, 2.0 }), { 3.0, 4.0 }, spvUnsafeArray<float, 2>({ 5.0, 6.0 }) };
+ out.m_2 = 1.0;
+ return out;
+}
+
diff --git a/reference/shaders-msl-no-opt/asm/vert/constant-composite-block-no-array-stride.asm.vert b/reference/shaders-msl-no-opt/asm/vert/constant-composite-block-no-array-stride.asm.vert
new file mode 100644
index 00000000..07bcb9f1
--- /dev/null
+++ b/reference/shaders-msl-no-opt/asm/vert/constant-composite-block-no-array-stride.asm.vert
@@ -0,0 +1,89 @@
+#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 _14
+{
+ float _m0[3];
+};
+
+struct _15
+{
+ float _m0[3];
+};
+
+constant spvUnsafeArray<float, 3> _93 = spvUnsafeArray<float, 3>({ 1.0, 2.0, 1.0 });
+constant spvUnsafeArray<float, 3> _94 = spvUnsafeArray<float, 3>({ -1.0, -2.0, -1.0 });
+
+struct main0_out
+{
+ float4 m_4 [[user(locn1)]];
+ float4 gl_Position [[position]];
+};
+
+struct main0_in
+{
+ float4 m_3 [[attribute(0)]];
+ float4 m_5 [[attribute(1)]];
+};
+
+static inline __attribute__((always_inline))
+float4 _102(float4 _107)
+{
+ float4 _109 = _107;
+ _14 _110 = _14{ { 1.0, 2.0, 1.0 } };
+ _15 _111 = _15{ { -1.0, -2.0, -1.0 } };
+ _109.y = (_110._m0[2] + _111._m0[2]) + _109.y;
+ return _109;
+}
+
+vertex main0_out main0(main0_in in [[stage_in]])
+{
+ main0_out out = {};
+ out.gl_Position = in.m_3;
+ out.m_4 = _102(in.m_5);
+ return out;
+}
+