MSL: Fix initialization of masked threadgroup variables.

This commit is contained in:
Hans-Kristian Arntzen 2021-04-14 11:27:05 +02:00
parent ee85bb345e
commit c9946296dd
18 changed files with 1392 additions and 2 deletions

View File

@ -0,0 +1,82 @@
#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 C
{
float4 v;
};
struct P
{
float4 v;
};
struct main0_out
{
float4 gl_Position;
float gl_PointSize;
};
struct main0_patchOut
{
float4 P_v;
};
kernel void main0(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)]])
{
spvUnsafeArray<C, 4> _18 = spvUnsafeArray<C, 4>({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } });
threadgroup C c[4];
device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4];
c[gl_InvocationID] = _18[gl_InvocationID];
device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID];
patchOut.P_v = float4(0.0);
c[gl_InvocationID].v = float4(1.0);
patchOut.P_v = float4(2.0);
gl_out[gl_InvocationID].gl_Position = float4(3.0);
gl_out[gl_InvocationID].gl_PointSize = 4.0;
}

View File

@ -0,0 +1,81 @@
#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 C
{
float4 v;
};
struct P
{
float4 v;
};
struct main0_out
{
float4 C_v;
float4 gl_Position;
float gl_PointSize;
};
struct main0_patchOut
{
};
kernel void main0(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)]])
{
spvUnsafeArray<C, 4> _18 = spvUnsafeArray<C, 4>({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } });
threadgroup P p;
device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4];
gl_out[gl_InvocationID].C_v = _18[gl_InvocationID].v;
device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID];
p = P{ float4(0.0) };
gl_out[gl_InvocationID].C_v = float4(1.0);
p.v = float4(2.0);
gl_out[gl_InvocationID].gl_Position = float4(3.0);
gl_out[gl_InvocationID].gl_PointSize = 4.0;
}

View File

@ -0,0 +1,100 @@
#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 C
{
float4 v;
};
struct P
{
float4 v;
};
struct gl_PerVertex
{
float4 gl_Position;
float gl_PointSize;
float gl_ClipDistance[1];
float gl_CullDistance[1];
};
constant spvUnsafeArray<float, 1> _51 = spvUnsafeArray<float, 1>({ 0.0 });
constant spvUnsafeArray<float, 1> _52 = spvUnsafeArray<float, 1>({ 0.0 });
struct main0_out
{
float4 C_v;
float4 gl_Position;
float gl_ClipDistance[1];
float gl_CullDistance[1];
};
struct main0_patchOut
{
float4 P_v;
};
kernel void main0(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)]])
{
spvUnsafeArray<C, 4> _18 = spvUnsafeArray<C, 4>({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } });
spvUnsafeArray<gl_PerVertex, 4> _33 = spvUnsafeArray<gl_PerVertex, 4>({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) } });
threadgroup gl_PerVertex gl_out_masked[4];
device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4];
gl_out[gl_InvocationID].C_v = _18[gl_InvocationID].v;
gl_out[gl_InvocationID].gl_Position = _33[gl_InvocationID].gl_Position;
gl_out[gl_InvocationID].gl_ClipDistance = _33[gl_InvocationID].gl_ClipDistance;
gl_out[gl_InvocationID].gl_CullDistance = _33[gl_InvocationID].gl_CullDistance;
gl_out_masked[gl_InvocationID] = _33[gl_InvocationID];
device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID];
patchOut.P_v = float4(0.0);
gl_out[gl_InvocationID].C_v = float4(1.0);
patchOut.P_v = float4(2.0);
gl_out[gl_InvocationID].gl_Position = float4(3.0);
gl_out_masked[gl_InvocationID].gl_PointSize = 4.0;
}

View File

@ -0,0 +1,100 @@
#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 C
{
float4 v;
};
struct P
{
float4 v;
};
struct gl_PerVertex
{
float4 gl_Position;
float gl_PointSize;
float gl_ClipDistance[1];
float gl_CullDistance[1];
};
constant spvUnsafeArray<float, 1> _51 = spvUnsafeArray<float, 1>({ 0.0 });
constant spvUnsafeArray<float, 1> _52 = spvUnsafeArray<float, 1>({ 0.0 });
struct main0_out
{
float4 C_v;
float gl_PointSize;
float gl_ClipDistance[1];
float gl_CullDistance[1];
};
struct main0_patchOut
{
float4 P_v;
};
kernel void main0(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)]])
{
spvUnsafeArray<C, 4> _18 = spvUnsafeArray<C, 4>({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } });
spvUnsafeArray<gl_PerVertex, 4> _33 = spvUnsafeArray<gl_PerVertex, 4>({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) } });
threadgroup gl_PerVertex gl_out_masked[4];
device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4];
gl_out[gl_InvocationID].C_v = _18[gl_InvocationID].v;
gl_out[gl_InvocationID].gl_PointSize = _33[gl_InvocationID].gl_PointSize;
gl_out[gl_InvocationID].gl_ClipDistance = _33[gl_InvocationID].gl_ClipDistance;
gl_out[gl_InvocationID].gl_CullDistance = _33[gl_InvocationID].gl_CullDistance;
gl_out_masked[gl_InvocationID] = _33[gl_InvocationID];
device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID];
patchOut.P_v = float4(0.0);
gl_out[gl_InvocationID].C_v = float4(1.0);
patchOut.P_v = float4(2.0);
gl_out_masked[gl_InvocationID].gl_Position = float4(3.0);
gl_out[gl_InvocationID].gl_PointSize = 4.0;
}

View File

@ -0,0 +1,90 @@
#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 _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex
{
float4 _RESERVED_IDENTIFIER_FIXUP_gl_Position;
float _RESERVED_IDENTIFIER_FIXUP_gl_PointSize;
float _RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance[1];
float _RESERVED_IDENTIFIER_FIXUP_gl_CullDistance[1];
};
constant spvUnsafeArray<float4, 4> _15 = spvUnsafeArray<float4, 4>({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) });
constant spvUnsafeArray<float, 1> _45 = spvUnsafeArray<float, 1>({ 0.0 });
constant spvUnsafeArray<float, 1> _46 = spvUnsafeArray<float, 1>({ 0.0 });
struct main0_out
{
float4 gl_Position;
float gl_PointSize;
float gl_ClipDistance[1];
float gl_CullDistance[1];
};
struct main0_patchOut
{
float4 foo_patch;
};
kernel void main0(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)]])
{
spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4> _29 = spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4>({ _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) } });
threadgroup float4 foo[4];
device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4];
foo[gl_InvocationID] = _15[gl_InvocationID];
gl_out[gl_InvocationID].gl_Position = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_Position;
gl_out[gl_InvocationID].gl_PointSize = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_PointSize;
gl_out[gl_InvocationID].gl_ClipDistance = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance;
gl_out[gl_InvocationID].gl_CullDistance = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_CullDistance;
device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID];
patchOut.foo_patch = float4(0.0);
foo[gl_InvocationID] = float4(1.0);
patchOut.foo_patch = float4(2.0);
gl_out[gl_InvocationID].gl_Position = float4(3.0);
gl_out[gl_InvocationID].gl_PointSize = 4.0;
}

View File

@ -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 _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex
{
float4 _RESERVED_IDENTIFIER_FIXUP_gl_Position;
float _RESERVED_IDENTIFIER_FIXUP_gl_PointSize;
float _RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance[1];
float _RESERVED_IDENTIFIER_FIXUP_gl_CullDistance[1];
};
constant spvUnsafeArray<float4, 4> _15 = spvUnsafeArray<float4, 4>({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) });
constant spvUnsafeArray<float, 1> _45 = spvUnsafeArray<float, 1>({ 0.0 });
constant spvUnsafeArray<float, 1> _46 = spvUnsafeArray<float, 1>({ 0.0 });
struct main0_out
{
float4 foo;
float4 gl_Position;
float gl_PointSize;
float gl_ClipDistance[1];
float gl_CullDistance[1];
};
struct main0_patchOut
{
};
kernel void main0(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)]])
{
spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4> _29 = spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4>({ _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) } });
threadgroup float4 foo_patch;
device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4];
gl_out[gl_InvocationID].foo = _15[gl_InvocationID];
gl_out[gl_InvocationID].gl_Position = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_Position;
gl_out[gl_InvocationID].gl_PointSize = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_PointSize;
gl_out[gl_InvocationID].gl_ClipDistance = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance;
gl_out[gl_InvocationID].gl_CullDistance = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_CullDistance;
device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID];
foo_patch = float4(0.0);
gl_out[gl_InvocationID].foo = float4(1.0);
foo_patch = float4(2.0);
gl_out[gl_InvocationID].gl_Position = float4(3.0);
gl_out[gl_InvocationID].gl_PointSize = 4.0;
}

View File

@ -0,0 +1,90 @@
#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 gl_PerVertex
{
float4 gl_Position;
float gl_PointSize;
float gl_ClipDistance[1];
float gl_CullDistance[1];
};
constant spvUnsafeArray<float4, 4> _15 = spvUnsafeArray<float4, 4>({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) });
constant spvUnsafeArray<float, 1> _45 = spvUnsafeArray<float, 1>({ 0.0 });
constant spvUnsafeArray<float, 1> _46 = spvUnsafeArray<float, 1>({ 0.0 });
struct main0_out
{
float4 foo;
float4 gl_Position;
float gl_ClipDistance[1];
float gl_CullDistance[1];
};
struct main0_patchOut
{
float4 foo_patch;
};
kernel void main0(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)]])
{
spvUnsafeArray<gl_PerVertex, 4> _29 = spvUnsafeArray<gl_PerVertex, 4>({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) } });
threadgroup gl_PerVertex gl_out_masked[4];
device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4];
gl_out[gl_InvocationID].foo = _15[gl_InvocationID];
gl_out[gl_InvocationID].gl_Position = _29[gl_InvocationID].gl_Position;
gl_out[gl_InvocationID].gl_ClipDistance = _29[gl_InvocationID].gl_ClipDistance;
gl_out[gl_InvocationID].gl_CullDistance = _29[gl_InvocationID].gl_CullDistance;
gl_out_masked[gl_InvocationID] = _29[gl_InvocationID];
device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID];
patchOut.foo_patch = float4(0.0);
gl_out[gl_InvocationID].foo = float4(1.0);
patchOut.foo_patch = float4(2.0);
gl_out[gl_InvocationID].gl_Position = float4(3.0);
gl_out_masked[gl_InvocationID].gl_PointSize = 4.0;
}

View File

@ -0,0 +1,90 @@
#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 gl_PerVertex
{
float4 gl_Position;
float gl_PointSize;
float gl_ClipDistance[1];
float gl_CullDistance[1];
};
constant spvUnsafeArray<float4, 4> _15 = spvUnsafeArray<float4, 4>({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) });
constant spvUnsafeArray<float, 1> _45 = spvUnsafeArray<float, 1>({ 0.0 });
constant spvUnsafeArray<float, 1> _46 = spvUnsafeArray<float, 1>({ 0.0 });
struct main0_out
{
float4 foo;
float gl_PointSize;
float gl_ClipDistance[1];
float gl_CullDistance[1];
};
struct main0_patchOut
{
float4 foo_patch;
};
kernel void main0(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)]])
{
spvUnsafeArray<gl_PerVertex, 4> _29 = spvUnsafeArray<gl_PerVertex, 4>({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray<float, 1>({ 0.0 }), spvUnsafeArray<float, 1>({ 0.0 }) } });
threadgroup gl_PerVertex gl_out_masked[4];
device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4];
gl_out[gl_InvocationID].foo = _15[gl_InvocationID];
gl_out[gl_InvocationID].gl_PointSize = _29[gl_InvocationID].gl_PointSize;
gl_out[gl_InvocationID].gl_ClipDistance = _29[gl_InvocationID].gl_ClipDistance;
gl_out[gl_InvocationID].gl_CullDistance = _29[gl_InvocationID].gl_CullDistance;
gl_out_masked[gl_InvocationID] = _29[gl_InvocationID];
device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID];
patchOut.foo_patch = float4(0.0);
gl_out[gl_InvocationID].foo = float4(1.0);
patchOut.foo_patch = float4(2.0);
gl_out_masked[gl_InvocationID].gl_Position = float4(3.0);
gl_out[gl_InvocationID].gl_PointSize = 4.0;
}

View File

@ -0,0 +1,85 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 44
; Schema: 0
OpCapability Tessellation
OpCapability TessellationPointSize
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint TessellationControl %main "main" %c %gl_InvocationID %p %gl_out
OpExecutionMode %main OutputVertices 4
OpSource GLSL 450
OpName %main "main"
OpName %C "C"
OpMemberName %C 0 "v"
OpName %c "c"
OpName %gl_InvocationID "gl_InvocationID"
OpName %P "P"
OpMemberName %P 0 "v"
OpName %p "p"
OpName %gl_PerVertex "gl_PerVertex"
OpMemberName %gl_PerVertex 0 "gl_Position"
OpMemberName %gl_PerVertex 1 "gl_PointSize"
OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
OpMemberName %gl_PerVertex 3 "gl_CullDistance"
OpName %gl_out "gl_out"
OpDecorate %C Block
OpDecorate %c Location 0
OpDecorate %gl_InvocationID BuiltIn InvocationId
OpMemberDecorate %P 0 Patch
OpDecorate %P Block
OpDecorate %p Location 1
OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
OpDecorate %gl_PerVertex Block
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%C = OpTypeStruct %v4float
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
%_arr_C_uint_4 = OpTypeArray %C %uint_4
%_ptr_Output__arr_C_uint_4 = OpTypePointer Output %_arr_C_uint_4
%zero_c = OpConstantNull %_arr_C_uint_4
%c = OpVariable %_ptr_Output__arr_C_uint_4 Output %zero_c
%int = OpTypeInt 32 1
%_ptr_Input_int = OpTypePointer Input %int
%gl_InvocationID = OpVariable %_ptr_Input_int Input
%int_0 = OpConstant %int 0
%float_1 = OpConstant %float 1
%20 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Output_v4float = OpTypePointer Output %v4float
%P = OpTypeStruct %v4float
%_ptr_Output_P = OpTypePointer Output %P
%zero_p = OpConstantNull %P
%p = OpVariable %_ptr_Output_P Output %zero_p
%float_2 = OpConstant %float 2
%27 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
%uint_1 = OpConstant %uint 1
%_arr_float_uint_1 = OpTypeArray %float %uint_1
%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1
%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4
%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4
%gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output
%float_3 = OpConstant %float 3
%37 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3
%int_1 = OpConstant %int 1
%float_4 = OpConstant %float 4
%_ptr_Output_float = OpTypePointer Output %float
%main = OpFunction %void None %3
%5 = OpLabel
%17 = OpLoad %int %gl_InvocationID
%22 = OpAccessChain %_ptr_Output_v4float %c %17 %int_0
OpStore %22 %20
%28 = OpAccessChain %_ptr_Output_v4float %p %int_0
OpStore %28 %27
%38 = OpAccessChain %_ptr_Output_v4float %gl_out %17 %int_0
OpStore %38 %37
%43 = OpAccessChain %_ptr_Output_float %gl_out %17 %int_1
OpStore %43 %float_4
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,85 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 44
; Schema: 0
OpCapability Tessellation
OpCapability TessellationPointSize
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint TessellationControl %main "main" %c %gl_InvocationID %p %gl_out
OpExecutionMode %main OutputVertices 4
OpSource GLSL 450
OpName %main "main"
OpName %C "C"
OpMemberName %C 0 "v"
OpName %c "c"
OpName %gl_InvocationID "gl_InvocationID"
OpName %P "P"
OpMemberName %P 0 "v"
OpName %p "p"
OpName %gl_PerVertex "gl_PerVertex"
OpMemberName %gl_PerVertex 0 "gl_Position"
OpMemberName %gl_PerVertex 1 "gl_PointSize"
OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
OpMemberName %gl_PerVertex 3 "gl_CullDistance"
OpName %gl_out "gl_out"
OpDecorate %C Block
OpDecorate %c Location 0
OpDecorate %gl_InvocationID BuiltIn InvocationId
OpMemberDecorate %P 0 Patch
OpDecorate %P Block
OpDecorate %p Location 1
OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
OpDecorate %gl_PerVertex Block
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%C = OpTypeStruct %v4float
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
%_arr_C_uint_4 = OpTypeArray %C %uint_4
%_ptr_Output__arr_C_uint_4 = OpTypePointer Output %_arr_C_uint_4
%zero_c = OpConstantNull %_arr_C_uint_4
%c = OpVariable %_ptr_Output__arr_C_uint_4 Output %zero_c
%int = OpTypeInt 32 1
%_ptr_Input_int = OpTypePointer Input %int
%gl_InvocationID = OpVariable %_ptr_Input_int Input
%int_0 = OpConstant %int 0
%float_1 = OpConstant %float 1
%20 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Output_v4float = OpTypePointer Output %v4float
%P = OpTypeStruct %v4float
%_ptr_Output_P = OpTypePointer Output %P
%zero_p = OpConstantNull %P
%p = OpVariable %_ptr_Output_P Output %zero_p
%float_2 = OpConstant %float 2
%27 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
%uint_1 = OpConstant %uint 1
%_arr_float_uint_1 = OpTypeArray %float %uint_1
%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1
%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4
%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4
%gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output
%float_3 = OpConstant %float 3
%37 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3
%int_1 = OpConstant %int 1
%float_4 = OpConstant %float 4
%_ptr_Output_float = OpTypePointer Output %float
%main = OpFunction %void None %3
%5 = OpLabel
%17 = OpLoad %int %gl_InvocationID
%22 = OpAccessChain %_ptr_Output_v4float %c %17 %int_0
OpStore %22 %20
%28 = OpAccessChain %_ptr_Output_v4float %p %int_0
OpStore %28 %27
%38 = OpAccessChain %_ptr_Output_v4float %gl_out %17 %int_0
OpStore %38 %37
%43 = OpAccessChain %_ptr_Output_float %gl_out %17 %int_1
OpStore %43 %float_4
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,86 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 44
; Schema: 0
OpCapability Tessellation
OpCapability TessellationPointSize
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint TessellationControl %main "main" %c %gl_InvocationID %p %gl_out
OpExecutionMode %main OutputVertices 4
OpSource GLSL 450
OpName %main "main"
OpName %C "C"
OpMemberName %C 0 "v"
OpName %c "c"
OpName %gl_InvocationID "gl_InvocationID"
OpName %P "P"
OpMemberName %P 0 "v"
OpName %p "p"
OpName %gl_PerVertex "gl_PerVertex"
OpMemberName %gl_PerVertex 0 "gl_Position"
OpMemberName %gl_PerVertex 1 "gl_PointSize"
OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
OpMemberName %gl_PerVertex 3 "gl_CullDistance"
OpName %gl_out "gl_out"
OpDecorate %C Block
OpDecorate %c Location 0
OpDecorate %gl_InvocationID BuiltIn InvocationId
OpMemberDecorate %P 0 Patch
OpDecorate %P Block
OpDecorate %p Location 1
OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
OpDecorate %gl_PerVertex Block
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%C = OpTypeStruct %v4float
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
%_arr_C_uint_4 = OpTypeArray %C %uint_4
%_ptr_Output__arr_C_uint_4 = OpTypePointer Output %_arr_C_uint_4
%zero_c = OpConstantNull %_arr_C_uint_4
%c = OpVariable %_ptr_Output__arr_C_uint_4 Output %zero_c
%int = OpTypeInt 32 1
%_ptr_Input_int = OpTypePointer Input %int
%gl_InvocationID = OpVariable %_ptr_Input_int Input
%int_0 = OpConstant %int 0
%float_1 = OpConstant %float 1
%20 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Output_v4float = OpTypePointer Output %v4float
%P = OpTypeStruct %v4float
%_ptr_Output_P = OpTypePointer Output %P
%zero_p = OpConstantNull %P
%p = OpVariable %_ptr_Output_P Output %zero_p
%float_2 = OpConstant %float 2
%27 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
%uint_1 = OpConstant %uint 1
%_arr_float_uint_1 = OpTypeArray %float %uint_1
%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1
%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4
%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4
%zero_gl_out = OpConstantNull %_arr_gl_PerVertex_uint_4
%gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %zero_gl_out
%float_3 = OpConstant %float 3
%37 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3
%int_1 = OpConstant %int 1
%float_4 = OpConstant %float 4
%_ptr_Output_float = OpTypePointer Output %float
%main = OpFunction %void None %3
%5 = OpLabel
%17 = OpLoad %int %gl_InvocationID
%22 = OpAccessChain %_ptr_Output_v4float %c %17 %int_0
OpStore %22 %20
%28 = OpAccessChain %_ptr_Output_v4float %p %int_0
OpStore %28 %27
%38 = OpAccessChain %_ptr_Output_v4float %gl_out %17 %int_0
OpStore %38 %37
%43 = OpAccessChain %_ptr_Output_float %gl_out %17 %int_1
OpStore %43 %float_4
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,86 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 44
; Schema: 0
OpCapability Tessellation
OpCapability TessellationPointSize
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint TessellationControl %main "main" %c %gl_InvocationID %p %gl_out
OpExecutionMode %main OutputVertices 4
OpSource GLSL 450
OpName %main "main"
OpName %C "C"
OpMemberName %C 0 "v"
OpName %c "c"
OpName %gl_InvocationID "gl_InvocationID"
OpName %P "P"
OpMemberName %P 0 "v"
OpName %p "p"
OpName %gl_PerVertex "gl_PerVertex"
OpMemberName %gl_PerVertex 0 "gl_Position"
OpMemberName %gl_PerVertex 1 "gl_PointSize"
OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
OpMemberName %gl_PerVertex 3 "gl_CullDistance"
OpName %gl_out "gl_out"
OpDecorate %C Block
OpDecorate %c Location 0
OpDecorate %gl_InvocationID BuiltIn InvocationId
OpMemberDecorate %P 0 Patch
OpDecorate %P Block
OpDecorate %p Location 1
OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
OpDecorate %gl_PerVertex Block
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%C = OpTypeStruct %v4float
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
%_arr_C_uint_4 = OpTypeArray %C %uint_4
%_ptr_Output__arr_C_uint_4 = OpTypePointer Output %_arr_C_uint_4
%zero_c = OpConstantNull %_arr_C_uint_4
%c = OpVariable %_ptr_Output__arr_C_uint_4 Output %zero_c
%int = OpTypeInt 32 1
%_ptr_Input_int = OpTypePointer Input %int
%gl_InvocationID = OpVariable %_ptr_Input_int Input
%int_0 = OpConstant %int 0
%float_1 = OpConstant %float 1
%20 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Output_v4float = OpTypePointer Output %v4float
%P = OpTypeStruct %v4float
%_ptr_Output_P = OpTypePointer Output %P
%zero_p = OpConstantNull %P
%p = OpVariable %_ptr_Output_P Output %zero_p
%float_2 = OpConstant %float 2
%27 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
%uint_1 = OpConstant %uint 1
%_arr_float_uint_1 = OpTypeArray %float %uint_1
%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1
%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4
%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4
%zero_gl_out = OpConstantNull %_arr_gl_PerVertex_uint_4
%gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %zero_gl_out
%float_3 = OpConstant %float 3
%37 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3
%int_1 = OpConstant %int 1
%float_4 = OpConstant %float 4
%_ptr_Output_float = OpTypePointer Output %float
%main = OpFunction %void None %3
%5 = OpLabel
%17 = OpLoad %int %gl_InvocationID
%22 = OpAccessChain %_ptr_Output_v4float %c %17 %int_0
OpStore %22 %20
%28 = OpAccessChain %_ptr_Output_v4float %p %int_0
OpStore %28 %27
%38 = OpAccessChain %_ptr_Output_v4float %gl_out %17 %int_0
OpStore %38 %37
%43 = OpAccessChain %_ptr_Output_float %gl_out %17 %int_1
OpStore %43 %float_4
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,76 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 40
; Schema: 0
OpCapability Tessellation
OpCapability TessellationPointSize
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint TessellationControl %main "main" %foo %gl_InvocationID %foo_patch %gl_out
OpExecutionMode %main OutputVertices 4
OpSource GLSL 450
OpName %main "main"
OpName %foo "foo"
OpName %gl_InvocationID "gl_InvocationID"
OpName %foo_patch "foo_patch"
OpName %gl_PerVertex "gl_PerVertex"
OpMemberName %gl_PerVertex 0 "gl_Position"
OpMemberName %gl_PerVertex 1 "gl_PointSize"
OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
OpMemberName %gl_PerVertex 3 "gl_CullDistance"
OpName %gl_out "gl_out"
OpDecorate %foo Location 0
OpDecorate %gl_InvocationID BuiltIn InvocationId
OpDecorate %foo_patch Patch
OpDecorate %foo_patch Location 1
OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
OpDecorate %gl_PerVertex Block
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4
%zero_foo = OpConstantNull %_arr_v4float_uint_4
%_ptr_Output__arr_v4float_uint_4 = OpTypePointer Output %_arr_v4float_uint_4
%foo = OpVariable %_ptr_Output__arr_v4float_uint_4 Output %zero_foo
%int = OpTypeInt 32 1
%_ptr_Input_int = OpTypePointer Input %int
%gl_InvocationID = OpVariable %_ptr_Input_int Input
%float_1 = OpConstant %float 1
%18 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Output_v4float = OpTypePointer Output %v4float
%zero_foo_patch = OpConstantNull %v4float
%foo_patch = OpVariable %_ptr_Output_v4float Output %zero_foo_patch
%float_2 = OpConstant %float 2
%23 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
%uint_1 = OpConstant %uint 1
%_arr_float_uint_1 = OpTypeArray %float %uint_1
%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1
%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4
%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4
%zero_gl_out = OpConstantNull %_arr_gl_PerVertex_uint_4
%gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %zero_gl_out
%int_0 = OpConstant %int 0
%float_3 = OpConstant %float 3
%33 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3
%int_1 = OpConstant %int 1
%float_4 = OpConstant %float 4
%_ptr_Output_float = OpTypePointer Output %float
%main = OpFunction %void None %3
%5 = OpLabel
%16 = OpLoad %int %gl_InvocationID
%20 = OpAccessChain %_ptr_Output_v4float %foo %16
OpStore %20 %18
OpStore %foo_patch %23
%34 = OpAccessChain %_ptr_Output_v4float %gl_out %16 %int_0
OpStore %34 %33
%39 = OpAccessChain %_ptr_Output_float %gl_out %16 %int_1
OpStore %39 %float_4
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,76 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 40
; Schema: 0
OpCapability Tessellation
OpCapability TessellationPointSize
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint TessellationControl %main "main" %foo %gl_InvocationID %foo_patch %gl_out
OpExecutionMode %main OutputVertices 4
OpSource GLSL 450
OpName %main "main"
OpName %foo "foo"
OpName %gl_InvocationID "gl_InvocationID"
OpName %foo_patch "foo_patch"
OpName %gl_PerVertex "gl_PerVertex"
OpMemberName %gl_PerVertex 0 "gl_Position"
OpMemberName %gl_PerVertex 1 "gl_PointSize"
OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
OpMemberName %gl_PerVertex 3 "gl_CullDistance"
OpName %gl_out "gl_out"
OpDecorate %foo Location 0
OpDecorate %gl_InvocationID BuiltIn InvocationId
OpDecorate %foo_patch Patch
OpDecorate %foo_patch Location 1
OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
OpDecorate %gl_PerVertex Block
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4
%zero_foo = OpConstantNull %_arr_v4float_uint_4
%_ptr_Output__arr_v4float_uint_4 = OpTypePointer Output %_arr_v4float_uint_4
%foo = OpVariable %_ptr_Output__arr_v4float_uint_4 Output %zero_foo
%int = OpTypeInt 32 1
%_ptr_Input_int = OpTypePointer Input %int
%gl_InvocationID = OpVariable %_ptr_Input_int Input
%float_1 = OpConstant %float 1
%18 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Output_v4float = OpTypePointer Output %v4float
%zero_foo_patch = OpConstantNull %v4float
%foo_patch = OpVariable %_ptr_Output_v4float Output %zero_foo_patch
%float_2 = OpConstant %float 2
%23 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
%uint_1 = OpConstant %uint 1
%_arr_float_uint_1 = OpTypeArray %float %uint_1
%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1
%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4
%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4
%zero_gl_out = OpConstantNull %_arr_gl_PerVertex_uint_4
%gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %zero_gl_out
%int_0 = OpConstant %int 0
%float_3 = OpConstant %float 3
%33 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3
%int_1 = OpConstant %int 1
%float_4 = OpConstant %float 4
%_ptr_Output_float = OpTypePointer Output %float
%main = OpFunction %void None %3
%5 = OpLabel
%16 = OpLoad %int %gl_InvocationID
%20 = OpAccessChain %_ptr_Output_v4float %foo %16
OpStore %20 %18
OpStore %foo_patch %23
%34 = OpAccessChain %_ptr_Output_v4float %gl_out %16 %int_0
OpStore %34 %33
%39 = OpAccessChain %_ptr_Output_float %gl_out %16 %int_1
OpStore %39 %float_4
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,76 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 40
; Schema: 0
OpCapability Tessellation
OpCapability TessellationPointSize
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint TessellationControl %main "main" %foo %gl_InvocationID %foo_patch %gl_out
OpExecutionMode %main OutputVertices 4
OpSource GLSL 450
OpName %main "main"
OpName %foo "foo"
OpName %gl_InvocationID "gl_InvocationID"
OpName %foo_patch "foo_patch"
OpName %gl_PerVertex "gl_PerVertex"
OpMemberName %gl_PerVertex 0 "gl_Position"
OpMemberName %gl_PerVertex 1 "gl_PointSize"
OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
OpMemberName %gl_PerVertex 3 "gl_CullDistance"
OpName %gl_out "gl_out"
OpDecorate %foo Location 0
OpDecorate %gl_InvocationID BuiltIn InvocationId
OpDecorate %foo_patch Patch
OpDecorate %foo_patch Location 1
OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
OpDecorate %gl_PerVertex Block
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4
%zero_foo = OpConstantNull %_arr_v4float_uint_4
%_ptr_Output__arr_v4float_uint_4 = OpTypePointer Output %_arr_v4float_uint_4
%foo = OpVariable %_ptr_Output__arr_v4float_uint_4 Output %zero_foo
%int = OpTypeInt 32 1
%_ptr_Input_int = OpTypePointer Input %int
%gl_InvocationID = OpVariable %_ptr_Input_int Input
%float_1 = OpConstant %float 1
%18 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Output_v4float = OpTypePointer Output %v4float
%zero_foo_patch = OpConstantNull %v4float
%foo_patch = OpVariable %_ptr_Output_v4float Output %zero_foo_patch
%float_2 = OpConstant %float 2
%23 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
%uint_1 = OpConstant %uint 1
%_arr_float_uint_1 = OpTypeArray %float %uint_1
%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1
%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4
%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4
%zero_gl_out = OpConstantNull %_arr_gl_PerVertex_uint_4
%gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %zero_gl_out
%int_0 = OpConstant %int 0
%float_3 = OpConstant %float 3
%33 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3
%int_1 = OpConstant %int 1
%float_4 = OpConstant %float 4
%_ptr_Output_float = OpTypePointer Output %float
%main = OpFunction %void None %3
%5 = OpLabel
%16 = OpLoad %int %gl_InvocationID
%20 = OpAccessChain %_ptr_Output_v4float %foo %16
OpStore %20 %18
OpStore %foo_patch %23
%34 = OpAccessChain %_ptr_Output_v4float %gl_out %16 %int_0
OpStore %34 %33
%39 = OpAccessChain %_ptr_Output_float %gl_out %16 %int_1
OpStore %39 %float_4
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,76 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 40
; Schema: 0
OpCapability Tessellation
OpCapability TessellationPointSize
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint TessellationControl %main "main" %foo %gl_InvocationID %foo_patch %gl_out
OpExecutionMode %main OutputVertices 4
OpSource GLSL 450
OpName %main "main"
OpName %foo "foo"
OpName %gl_InvocationID "gl_InvocationID"
OpName %foo_patch "foo_patch"
OpName %gl_PerVertex "gl_PerVertex"
OpMemberName %gl_PerVertex 0 "gl_Position"
OpMemberName %gl_PerVertex 1 "gl_PointSize"
OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
OpMemberName %gl_PerVertex 3 "gl_CullDistance"
OpName %gl_out "gl_out"
OpDecorate %foo Location 0
OpDecorate %gl_InvocationID BuiltIn InvocationId
OpDecorate %foo_patch Patch
OpDecorate %foo_patch Location 1
OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
OpDecorate %gl_PerVertex Block
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4
%zero_foo = OpConstantNull %_arr_v4float_uint_4
%_ptr_Output__arr_v4float_uint_4 = OpTypePointer Output %_arr_v4float_uint_4
%foo = OpVariable %_ptr_Output__arr_v4float_uint_4 Output %zero_foo
%int = OpTypeInt 32 1
%_ptr_Input_int = OpTypePointer Input %int
%gl_InvocationID = OpVariable %_ptr_Input_int Input
%float_1 = OpConstant %float 1
%18 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Output_v4float = OpTypePointer Output %v4float
%zero_foo_patch = OpConstantNull %v4float
%foo_patch = OpVariable %_ptr_Output_v4float Output %zero_foo_patch
%float_2 = OpConstant %float 2
%23 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
%uint_1 = OpConstant %uint 1
%_arr_float_uint_1 = OpTypeArray %float %uint_1
%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1
%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4
%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4
%zero_gl_out = OpConstantNull %_arr_gl_PerVertex_uint_4
%gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %zero_gl_out
%int_0 = OpConstant %int 0
%float_3 = OpConstant %float 3
%33 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3
%int_1 = OpConstant %int 1
%float_4 = OpConstant %float 4
%_ptr_Output_float = OpTypePointer Output %float
%main = OpFunction %void None %3
%5 = OpLabel
%16 = OpLoad %int %gl_InvocationID
%20 = OpAccessChain %_ptr_Output_v4float %foo %16
OpStore %20 %18
OpStore %foo_patch %23
%34 = OpAccessChain %_ptr_Output_v4float %gl_out %16 %int_0
OpStore %34 %33
%39 = OpAccessChain %_ptr_Output_float %gl_out %16 %int_1
OpStore %39 %float_4
OpReturn
OpFunctionEnd

View File

@ -12897,7 +12897,7 @@ string CompilerGLSL::variable_decl(const SPIRVariable &variable)
else if (options.force_zero_initialized_variables && type_can_zero_initialize(type))
res += join(" = ", to_zero_initialized_expression(get_variable_data_type_id(variable)));
}
else if (variable.initializer)
else if (variable.initializer && !variable_decl_is_remapped_storage(variable, StorageClassWorkgroup))
{
uint32_t expr = variable.initializer;
if (ir.ids[expr].get_type() != TypeUndef)

View File

@ -2950,10 +2950,32 @@ void CompilerMSL::add_variable_to_interface_block(StorageClass storage, const st
auto builtin = BuiltIn(get_decoration(var.self, DecorationBuiltIn));
bool is_block = has_decoration(var_type.self, DecorationBlock);
const auto emit_local_masked_variable = [this, &entry_func](const SPIRVariable &masked_var) {
const auto emit_local_masked_variable = [this, &entry_func, meta](SPIRVariable &masked_var) {
entry_func.add_local_variable(masked_var.self);
if (!variable_decl_is_remapped_storage(masked_var, StorageClassWorkgroup))
{
vars_needing_early_declaration.push_back(masked_var.self);
}
else if (masked_var.initializer)
{
// Cannot directly initialize threadgroup variables. Need fixup hooks.
ID initializer = masked_var.initializer;
if (meta.strip_array)
{
entry_func.fixup_hooks_in.push_back([this, &masked_var, initializer]() {
statement(to_expression(masked_var.self), "[",
builtin_to_glsl(BuiltInInvocationId, StorageClassInput), "] = ",
to_expression(initializer), "[",
builtin_to_glsl(BuiltInInvocationId, StorageClassInput), "];");
});
}
else
{
entry_func.fixup_hooks_in.push_back([this, &masked_var, initializer]() {
statement(to_expression(masked_var.self), " = ", to_expression(initializer), ";");
});
}
}
};
// If stage variables are masked out, emit them as plain variables instead.