SPIRV-Cross/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl21.ios.comp
Chip Davis 1264e2705e MSL: Cast broadcast booleans to ushort.
Metal doesn't support broadcasting or shuffling boolean values, but we
can work around that by casting it to `ushort`, then casting it back to
`bool`. I used `ushort` instead of `uint` because 16-bit values give
better throughput on Apple GPUs.
2020-10-23 21:55:46 -05:00

50 lines
1.6 KiB
Plaintext

#version 450
#extension GL_KHR_shader_subgroup_basic : require
#extension GL_KHR_shader_subgroup_shuffle : require
#extension GL_KHR_shader_subgroup_shuffle_relative : require
#extension GL_KHR_shader_subgroup_quad : require
layout(local_size_x = 1) in;
layout(std430, binding = 0) buffer SSBO
{
float FragColor;
};
// Reduced test for functionality exposed on iOS.
void main()
{
// basic
FragColor = float(gl_NumSubgroups);
FragColor = float(gl_SubgroupID);
FragColor = float(gl_SubgroupSize);
FragColor = float(gl_SubgroupInvocationID);
subgroupBarrier();
subgroupMemoryBarrier();
subgroupMemoryBarrierBuffer();
subgroupMemoryBarrierShared();
subgroupMemoryBarrierImage();
// shuffle
uint shuffled = subgroupShuffle(10u, 8u);
bool shuffled_bool = subgroupShuffle(true, 9u);
uint shuffled_xor = subgroupShuffleXor(30u, 8u);
bool shuffled_xor_bool = subgroupShuffleXor(false, 9u);
// shuffle relative
uint shuffled_up = subgroupShuffleUp(20u, 4u);
bool shuffled_up_bool = subgroupShuffleUp(true, 4u);
uint shuffled_down = subgroupShuffleDown(20u, 4u);
bool shuffled_down_bool = subgroupShuffleDown(false, 4u);
// quad
vec4 swap_horiz = subgroupQuadSwapHorizontal(vec4(20.0));
bvec4 swap_horiz_bool = subgroupQuadSwapHorizontal(bvec4(true));
vec4 swap_vertical = subgroupQuadSwapVertical(vec4(20.0));
bvec4 swap_vertical_bool = subgroupQuadSwapVertical(bvec4(true));
vec4 swap_diagonal = subgroupQuadSwapDiagonal(vec4(20.0));
bvec4 swap_diagonal_bool = subgroupQuadSwapDiagonal(bvec4(true));
vec4 quad_broadcast = subgroupQuadBroadcast(vec4(20.0), 3u);
bvec4 quad_broadcast_bool = subgroupQuadBroadcast(bvec4(true), 3u);
}