MSL: Add tests for vertex output masking.

This commit is contained in:
Hans-Kristian Arntzen 2021-04-06 11:49:07 +02:00
parent 394c038bfd
commit 88b54f5dab
16 changed files with 534 additions and 0 deletions

View File

@ -0,0 +1,67 @@
#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 main0_out
{
float4 v0 [[user(locn0)]];
float4 v1 [[user(locn1)]];
float4 gl_Position [[position]];
float gl_PointSize [[point_size]];
};
vertex main0_out main0()
{
main0_out out = {};
spvUnsafeArray<float, 2> gl_ClipDistance = {};
out.v0 = float4(1.0);
out.v1 = float4(2.0);
out.gl_Position = float4(3.0);
out.gl_PointSize = 4.0;
gl_ClipDistance[0] = 1.0;
gl_ClipDistance[1] = 0.5;
return out;
}

View File

@ -0,0 +1,30 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 v1 [[user(locn1)]];
float4 gl_Position [[position]];
float gl_PointSize [[point_size]];
float gl_ClipDistance [[clip_distance]] [2];
float gl_ClipDistance_0 [[user(clip0)]];
float gl_ClipDistance_1 [[user(clip1)]];
};
vertex main0_out main0()
{
main0_out out = {};
float4 v0 = {};
v0 = float4(1.0);
out.v1 = float4(2.0);
out.gl_Position = float4(3.0);
out.gl_PointSize = 4.0;
out.gl_ClipDistance[0] = 1.0;
out.gl_ClipDistance[1] = 0.5;
out.gl_ClipDistance_0 = out.gl_ClipDistance[0];
out.gl_ClipDistance_1 = out.gl_ClipDistance[1];
return out;
}

View File

@ -0,0 +1,30 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 v0 [[user(locn0)]];
float4 gl_Position [[position]];
float gl_PointSize [[point_size]];
float gl_ClipDistance [[clip_distance]] [2];
float gl_ClipDistance_0 [[user(clip0)]];
float gl_ClipDistance_1 [[user(clip1)]];
};
vertex main0_out main0()
{
main0_out out = {};
float4 v1 = {};
out.v0 = float4(1.0);
v1 = float4(2.0);
out.gl_Position = float4(3.0);
out.gl_PointSize = 4.0;
out.gl_ClipDistance[0] = 1.0;
out.gl_ClipDistance[1] = 0.5;
out.gl_ClipDistance_0 = out.gl_ClipDistance[0];
out.gl_ClipDistance_1 = out.gl_ClipDistance[1];
return out;
}

View File

@ -0,0 +1,30 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 v0 [[user(locn0)]];
float4 v1 [[user(locn1)]];
float4 gl_Position [[position]];
float gl_ClipDistance [[clip_distance]] [2];
float gl_ClipDistance_0 [[user(clip0)]];
float gl_ClipDistance_1 [[user(clip1)]];
};
vertex main0_out main0()
{
main0_out out = {};
float gl_PointSize = {};
out.v0 = float4(1.0);
out.v1 = float4(2.0);
out.gl_Position = float4(3.0);
gl_PointSize = 4.0;
out.gl_ClipDistance[0] = 1.0;
out.gl_ClipDistance[1] = 0.5;
out.gl_ClipDistance_0 = out.gl_ClipDistance[0];
out.gl_ClipDistance_1 = out.gl_ClipDistance[1];
return out;
}

View File

@ -0,0 +1,30 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 v0 [[user(locn0)]];
float4 v1 [[user(locn1)]];
float gl_PointSize [[point_size]];
float gl_ClipDistance [[clip_distance]] [2];
float gl_ClipDistance_0 [[user(clip0)]];
float gl_ClipDistance_1 [[user(clip1)]];
};
vertex main0_out main0()
{
main0_out out = {};
float4 gl_Position = {};
out.v0 = float4(1.0);
out.v1 = float4(2.0);
gl_Position = float4(3.0);
out.gl_PointSize = 4.0;
out.gl_ClipDistance[0] = 1.0;
out.gl_ClipDistance[1] = 0.5;
out.gl_ClipDistance_0 = out.gl_ClipDistance[0];
out.gl_ClipDistance_1 = out.gl_ClipDistance[1];
return out;
}

View File

@ -0,0 +1,73 @@
#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 main0_out
{
float4 v0 [[user(locn0)]];
float4 v1 [[user(locn1)]];
float4 gl_Position [[position]];
float gl_PointSize [[point_size]];
};
static inline __attribute__((always_inline))
void write_in_func(thread float4& v0, thread float4& v1, thread float4& gl_Position, thread float& gl_PointSize, thread float (&gl_ClipDistance)[2])
{
v0 = float4(1.0);
v1 = float4(2.0);
gl_Position = float4(3.0);
gl_PointSize = 4.0;
gl_ClipDistance[0] = 1.0;
gl_ClipDistance[1] = 0.5;
}
vertex main0_out main0()
{
main0_out out = {};
spvUnsafeArray<float, 2> gl_ClipDistance = {};
write_in_func(out.v0, out.v1, out.gl_Position, out.gl_PointSize, gl_ClipDistance);
return out;
}

View File

@ -0,0 +1,38 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 v1 [[user(locn1)]];
float4 gl_Position [[position]];
float gl_PointSize [[point_size]];
float gl_ClipDistance [[clip_distance]] [2];
float gl_ClipDistance_0 [[user(clip0)]];
float gl_ClipDistance_1 [[user(clip1)]];
};
static inline __attribute__((always_inline))
void write_in_func(thread float4& v0, thread float4& v1, thread float4& gl_Position, thread float& gl_PointSize, thread float (&gl_ClipDistance)[2])
{
v0 = float4(1.0);
v1 = float4(2.0);
gl_Position = float4(3.0);
gl_PointSize = 4.0;
gl_ClipDistance[0] = 1.0;
gl_ClipDistance[1] = 0.5;
}
vertex main0_out main0()
{
main0_out out = {};
float4 v0 = {};
write_in_func(v0, out.v1, out.gl_Position, out.gl_PointSize, out.gl_ClipDistance);
out.gl_ClipDistance_0 = out.gl_ClipDistance[0];
out.gl_ClipDistance_1 = out.gl_ClipDistance[1];
return out;
}

View File

@ -0,0 +1,38 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 v0 [[user(locn0)]];
float4 gl_Position [[position]];
float gl_PointSize [[point_size]];
float gl_ClipDistance [[clip_distance]] [2];
float gl_ClipDistance_0 [[user(clip0)]];
float gl_ClipDistance_1 [[user(clip1)]];
};
static inline __attribute__((always_inline))
void write_in_func(thread float4& v0, thread float4& v1, thread float4& gl_Position, thread float& gl_PointSize, thread float (&gl_ClipDistance)[2])
{
v0 = float4(1.0);
v1 = float4(2.0);
gl_Position = float4(3.0);
gl_PointSize = 4.0;
gl_ClipDistance[0] = 1.0;
gl_ClipDistance[1] = 0.5;
}
vertex main0_out main0()
{
main0_out out = {};
float4 v1 = {};
write_in_func(out.v0, v1, out.gl_Position, out.gl_PointSize, out.gl_ClipDistance);
out.gl_ClipDistance_0 = out.gl_ClipDistance[0];
out.gl_ClipDistance_1 = out.gl_ClipDistance[1];
return out;
}

View File

@ -0,0 +1,38 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 v0 [[user(locn0)]];
float4 v1 [[user(locn1)]];
float4 gl_Position [[position]];
float gl_ClipDistance [[clip_distance]] [2];
float gl_ClipDistance_0 [[user(clip0)]];
float gl_ClipDistance_1 [[user(clip1)]];
};
static inline __attribute__((always_inline))
void write_in_func(thread float4& v0, thread float4& v1, thread float4& gl_Position, thread float& gl_PointSize, thread float (&gl_ClipDistance)[2])
{
v0 = float4(1.0);
v1 = float4(2.0);
gl_Position = float4(3.0);
gl_PointSize = 4.0;
gl_ClipDistance[0] = 1.0;
gl_ClipDistance[1] = 0.5;
}
vertex main0_out main0()
{
main0_out out = {};
float gl_PointSize = {};
write_in_func(out.v0, out.v1, out.gl_Position, gl_PointSize, out.gl_ClipDistance);
out.gl_ClipDistance_0 = out.gl_ClipDistance[0];
out.gl_ClipDistance_1 = out.gl_ClipDistance[1];
return out;
}

View File

@ -0,0 +1,38 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 v0 [[user(locn0)]];
float4 v1 [[user(locn1)]];
float gl_PointSize [[point_size]];
float gl_ClipDistance [[clip_distance]] [2];
float gl_ClipDistance_0 [[user(clip0)]];
float gl_ClipDistance_1 [[user(clip1)]];
};
static inline __attribute__((always_inline))
void write_in_func(thread float4& v0, thread float4& v1, thread float4& gl_Position, thread float& gl_PointSize, thread float (&gl_ClipDistance)[2])
{
v0 = float4(1.0);
v1 = float4(2.0);
gl_Position = float4(3.0);
gl_PointSize = 4.0;
gl_ClipDistance[0] = 1.0;
gl_ClipDistance[1] = 0.5;
}
vertex main0_out main0()
{
main0_out out = {};
float4 gl_Position = {};
write_in_func(out.v0, out.v1, gl_Position, out.gl_PointSize, out.gl_ClipDistance);
out.gl_ClipDistance_0 = out.gl_ClipDistance[0];
out.gl_ClipDistance_1 = out.gl_ClipDistance[1];
return out;
}

View File

@ -0,0 +1,21 @@
#version 450
layout(location = 0) out vec4 v0;
layout(location = 1) out vec4 v1;
out float gl_ClipDistance[2];
void write_in_func()
{
v0 = vec4(1.0);
v1 = vec4(2.0);
gl_Position = vec4(3.0);
gl_PointSize = 4.0;
gl_ClipDistance[0] = 1.0;
gl_ClipDistance[1] = 0.5;
}
void main()
{
write_in_func();
}

View File

@ -0,0 +1,21 @@
#version 450
layout(location = 0) out vec4 v0;
layout(location = 1) out vec4 v1;
out float gl_ClipDistance[2];
void write_in_func()
{
v0 = vec4(1.0);
v1 = vec4(2.0);
gl_Position = vec4(3.0);
gl_PointSize = 4.0;
gl_ClipDistance[0] = 1.0;
gl_ClipDistance[1] = 0.5;
}
void main()
{
write_in_func();
}

View File

@ -0,0 +1,21 @@
#version 450
layout(location = 0) out vec4 v0;
layout(location = 1) out vec4 v1;
out float gl_ClipDistance[2];
void write_in_func()
{
v0 = vec4(1.0);
v1 = vec4(2.0);
gl_Position = vec4(3.0);
gl_PointSize = 4.0;
gl_ClipDistance[0] = 1.0;
gl_ClipDistance[1] = 0.5;
}
void main()
{
write_in_func();
}

View File

@ -0,0 +1,21 @@
#version 450
layout(location = 0) out vec4 v0;
layout(location = 1) out vec4 v1;
out float gl_ClipDistance[2];
void write_in_func()
{
v0 = vec4(1.0);
v1 = vec4(2.0);
gl_Position = vec4(3.0);
gl_PointSize = 4.0;
gl_ClipDistance[0] = 1.0;
gl_ClipDistance[1] = 0.5;
}
void main()
{
write_in_func();
}

View File

@ -0,0 +1,21 @@
#version 450
layout(location = 0) out vec4 v0;
layout(location = 1) out vec4 v1;
out float gl_ClipDistance[2];
void write_in_func()
{
v0 = vec4(1.0);
v1 = vec4(2.0);
gl_Position = vec4(3.0);
gl_PointSize = 4.0;
gl_ClipDistance[0] = 1.0;
gl_ClipDistance[1] = 0.5;
}
void main()
{
write_in_func();
}

View File

@ -324,6 +324,23 @@ def cross_compile_msl(shader, spirv, opt, iterations, paths):
msl_args.append('--msl-force-sample-rate-shading')
if '.decoration-binding.' in shader:
msl_args.append('--msl-decoration-binding')
if '.mask-location-0.' in shader:
msl_args.append('--mask-stage-output-location')
msl_args.append('0')
msl_args.append('0')
if '.mask-location-1.' in shader:
msl_args.append('--mask-stage-output-location')
msl_args.append('1')
msl_args.append('0')
if '.mask-position.' in shader:
msl_args.append('--mask-stage-output-builtin')
msl_args.append('Position')
if '.mask-point-size.' in shader:
msl_args.append('--mask-stage-output-builtin')
msl_args.append('PointSize')
if '.mask-clip-distance.' in shader:
msl_args.append('--mask-stage-output-builtin')
msl_args.append('ClipDistance')
subprocess.check_call(msl_args)