#version 450 #extension GL_KHR_shader_subgroup_basic : require #extension GL_KHR_shader_subgroup_ballot : require #extension GL_KHR_shader_subgroup_vote : 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(); bool elected = subgroupElect(); // ballot FragColor = float(gl_SubgroupEqMask); FragColor = float(gl_SubgroupGeMask); FragColor = float(gl_SubgroupGtMask); FragColor = float(gl_SubgroupLeMask); FragColor = float(gl_SubgroupLtMask); vec4 broadcasted = subgroupBroadcast(vec4(10.0), 8u); bvec2 broadcasted_bool = subgroupBroadcast(bvec2(true), 8u); vec3 first = subgroupBroadcastFirst(vec3(20.0)); bvec4 first_bool = subgroupBroadcastFirst(bvec4(false)); uvec4 ballot_value = subgroupBallot(true); bool inverse_ballot_value = subgroupInverseBallot(ballot_value); bool bit_extracted = subgroupBallotBitExtract(uvec4(10u), 8u); uint bit_count = subgroupBallotBitCount(ballot_value); uint inclusive_bit_count = subgroupBallotInclusiveBitCount(ballot_value); uint exclusive_bit_count = subgroupBallotExclusiveBitCount(ballot_value); uint lsb = subgroupBallotFindLSB(ballot_value); uint msb = subgroupBallotFindMSB(ballot_value); // 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); // vote bool has_all = subgroupAll(true); bool has_any = subgroupAny(true); bool has_equal = subgroupAllEqual(0); has_equal = subgroupAllEqual(true); has_equal = subgroupAllEqual(vec3(0.0, 1.0, 2.0)); has_equal = subgroupAllEqual(bvec4(true, true, false, true)); // 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); }