5 memoryBarrierShared(); \
8 #extension GL_EXT_mesh_shader : enable
10 layout(local_size_x = 32, local_size_y=1, local_size_z=1) in;
12 // test use of shared memory in task shaders:
13 layout(binding=0) writeonly uniform image2D uni_image;
19 // test use of task memory in task shaders:
25 taskPayloadSharedEXT Task mytask;
28 uint iid = gl_LocalInvocationID.x;
29 uint gid = gl_WorkGroupID.x;
31 // 1. shared memory load and stores
32 for (uint i = 0; i < 10; ++i) {
33 mem[i] = vec4(i + uni_value);
35 imageStore(uni_image, ivec2(iid), mem[gid]);
36 imageStore(uni_image, ivec2(iid), mem[gid+1]);
40 // 2. task memory stores
42 mytask.dummy = vec2(30.0, 31.0);
43 mytask.submesh[0] = vec2(32.0, 33.0);
44 mytask.submesh[1] = vec2(34.0, 35.0);
45 mytask.submesh[2] = mytask.submesh[gid%2];
49 // 3. emit task count under uniform control flow
50 EmitMeshTasksEXT(3U, 1U, 1U);
53 #extension GL_KHR_shader_subgroup_basic: enable
54 void basic_works (void)
57 gl_SubgroupInvocationID;
59 subgroupMemoryBarrier();
60 subgroupMemoryBarrierBuffer();
61 subgroupMemoryBarrierImage();
63 gl_NumSubgroups; // allowed in task
64 gl_SubgroupID; // allowed in task
65 subgroupMemoryBarrierShared(); // allowed in task
68 #extension GL_KHR_shader_subgroup_ballot: enable
69 void ballot_works(vec4 f4) {
75 subgroupBroadcast(f4, 0);
76 subgroupBroadcastFirst(f4);
77 uvec4 ballot = subgroupBallot(false);
78 subgroupInverseBallot(uvec4(0x1));
79 subgroupBallotBitExtract(ballot, 0);
80 subgroupBallotBitCount(ballot);
81 subgroupBallotInclusiveBitCount(ballot);
82 subgroupBallotExclusiveBitCount(ballot);
83 subgroupBallotFindLSB(ballot);
84 subgroupBallotFindMSB(ballot);
87 #extension GL_KHR_shader_subgroup_vote: enable
88 void vote_works(vec4 f4)
95 #extension GL_KHR_shader_subgroup_shuffle: enable
96 #extension GL_KHR_shader_subgroup_shuffle_relative: enable
97 void shuffle_works(vec4 f4)
99 subgroupShuffle(f4, 0);
100 subgroupShuffleXor(f4, 0x1);
101 subgroupShuffleUp(f4, 1);
102 subgroupShuffleDown(f4, 1);
105 #extension GL_KHR_shader_subgroup_arithmetic: enable
106 void arith_works(vec4 f4)
116 subgroupInclusiveAdd(f4);
117 subgroupInclusiveMul(f4);
118 subgroupInclusiveMin(f4);
119 subgroupInclusiveMax(f4);
120 subgroupInclusiveAnd(ballot);
121 subgroupInclusiveOr(ballot);
122 subgroupInclusiveXor(ballot);
123 subgroupExclusiveAdd(f4);
124 subgroupExclusiveMul(f4);
125 subgroupExclusiveMin(f4);
126 subgroupExclusiveMax(f4);
127 subgroupExclusiveAnd(ballot);
128 subgroupExclusiveOr(ballot);
129 subgroupExclusiveXor(ballot);
132 #extension GL_KHR_shader_subgroup_clustered: enable
133 void clustered_works(vec4 f4)
135 uvec4 ballot = uvec4(0x55,0,0,0);
136 subgroupClusteredAdd(f4, 2);
137 subgroupClusteredMul(f4, 2);
138 subgroupClusteredMin(f4, 2);
139 subgroupClusteredMax(f4, 2);
140 subgroupClusteredAnd(ballot, 2);
141 subgroupClusteredOr(ballot, 2);
142 subgroupClusteredXor(ballot, 2);
145 #extension GL_KHR_shader_subgroup_quad: enable
146 void quad_works(vec4 f4)
148 subgroupQuadBroadcast(f4, 0);
149 subgroupQuadSwapHorizontal(f4);
150 subgroupQuadSwapVertical(f4);
151 subgroupQuadSwapDiagonal(f4);