1#version 450 2 3vec4 undeclared_errors(vec4 f4) 4{ 5 vec4 result; 6 gl_SubgroupSize; // ERROR, extension not enabled (basic) 7 gl_SubgroupInvocationID; // ERROR, extension not enabled (basic) 8 subgroupBarrier(); // ERROR, extension not enabled (basic) 9 subgroupMemoryBarrier(); // ERROR, extension not enabled (basic) 10 subgroupMemoryBarrierBuffer(); // ERROR, extension not enabled (basic) 11 subgroupMemoryBarrierImage(); // ERROR, extension not enabled (basic) 12 subgroupElect(); // ERROR, extension not enabled (basic) 13 gl_NumSubgroups; // ERROR, extension not enabled (basic) 14 gl_SubgroupID; // ERROR, extension not enabled (basic) 15 subgroupMemoryBarrierShared(); // ERROR, extension not enabled (basic) 16 17 subgroupAll(true); // ERROR extension not enabled (vote) 18 subgroupAny(false); // ERROR extension not enabled (vote) 19 subgroupAllEqual(f4); // ERROR extension not enabled (vote) 20 21 gl_SubgroupEqMask; // ERROR extension not enabled (ballot) 22 gl_SubgroupGeMask; // ERROR extension not enabled (ballot) 23 gl_SubgroupGtMask; // ERROR extension not enabled (ballot) 24 gl_SubgroupLeMask; // ERROR extension not enabled (ballot) 25 gl_SubgroupLtMask; // ERROR extension not enabled (ballot) 26 subgroupBroadcast(f4, 0); // ERROR extension not enabled (ballot) 27 subgroupBroadcastFirst(f4); // ERROR extension not enabled (ballot) 28 uvec4 ballot = subgroupBallot(false); // ERROR extension not enabled (ballot) 29 subgroupInverseBallot(uvec4(0x1)); // ERROR extension not enabled (ballot) 30 subgroupBallotBitExtract(ballot, 0); // ERROR extension not enabled (ballot) 31 subgroupBallotBitCount(ballot); // ERROR extension not enabled (ballot) 32 subgroupBallotInclusiveBitCount(ballot); // ERROR extension not enabled (ballot) 33 subgroupBallotExclusiveBitCount(ballot); // ERROR extension not enabled (ballot) 34 subgroupBallotFindLSB(ballot); // ERROR extension not enabled (ballot) 35 subgroupBallotFindMSB(ballot); // ERROR extension not enabled (ballot) 36 37 subgroupShuffle(f4, 0); // ERROR extension not enabled (shuffle) 38 subgroupShuffleXor(f4, 0x1); // ERROR extension not enabled (shuffle) 39 subgroupShuffleUp(f4, 1); // ERROR extension not enabled (shuffle_relative) 40 subgroupShuffleDown(f4, 1); // ERROR extension not enabled (shuffle_relative) 41 42 result = subgroupAdd(f4); // ERROR, extension not enabled (arith) 43 subgroupMul(f4); // ERROR, extension not enabled (arith) 44 subgroupMin(f4); // ERROR, extension not enabled (arith) 45 subgroupMax(f4); // ERROR, extension not enabled (arith) 46 subgroupAnd(ballot); // ERROR, extension not enabled (arith) 47 subgroupOr(ballot); // ERROR, extension not enabled (arith) 48 subgroupXor(ballot); // ERROR, extension not enabled (arith) 49 subgroupInclusiveAdd(f4); // ERROR, extension not enabled (arith) 50 subgroupInclusiveMul(f4); // ERROR, extension not enabled (arith) 51 subgroupInclusiveMin(f4); // ERROR, extension not enabled (arith) 52 subgroupInclusiveMax(f4); // ERROR, extension not enabled (arith) 53 subgroupInclusiveAnd(ballot); // ERROR, extension not enabled (arith) 54 subgroupInclusiveOr(ballot); // ERROR, extension not enabled (arith) 55 subgroupInclusiveXor(ballot); // ERROR, extension not enabled (arith) 56 subgroupExclusiveAdd(f4); // ERROR, extension not enabled (arith) 57 subgroupExclusiveMul(f4); // ERROR, extension not enabled (arith) 58 subgroupExclusiveMin(f4); // ERROR, extension not enabled (arith) 59 subgroupExclusiveMax(f4); // ERROR, extension not enabled (arith) 60 subgroupExclusiveAnd(ballot); // ERROR, extension not enabled (arith) 61 subgroupExclusiveOr(ballot); // ERROR, extension not enabled (arith) 62 subgroupExclusiveXor(ballot); // ERROR, extension not enabled (arith) 63 64 subgroupClusteredAdd(f4, 2); // ERROR, extension not enabled (clustered) 65 subgroupClusteredMul(f4, 2); // ERROR, extension not enabled (clustered) 66 subgroupClusteredMin(f4, 2); // ERROR, extension not enabled (clustered) 67 subgroupClusteredMax(f4, 2); // ERROR, extension not enabled (clustered) 68 subgroupClusteredAnd(ballot, 2); // ERROR, extension not enabled (clustered) 69 subgroupClusteredOr(ballot, 2); // ERROR, extension not enabled (clustered) 70 subgroupClusteredXor(ballot, 2); // ERROR, extension not enabled (clustered) 71 72 subgroupQuadBroadcast(f4, 0); // ERROR, extension not enabled (quad) 73 subgroupQuadSwapHorizontal(f4); // ERROR, extension not enabled (quad) 74 subgroupQuadSwapVertical(f4); // ERROR, extension not enabled (quad) 75 subgroupQuadSwapDiagonal(f4); // ERROR, extension not enabled (quad) 76 77 uvec4 parti = subgroupPartitionNV(f4); // ERROR, extension not enabled (partitioned) 78 subgroupPartitionedAddNV(f4, parti); // ERROR, extension not enabled (partitioned) 79 subgroupPartitionedMulNV(f4, parti); // ERROR, extension not enabled (partitioned) 80 subgroupPartitionedMinNV(f4, parti); // ERROR, extension not enabled (partitioned) 81 subgroupPartitionedMaxNV(f4, parti); // ERROR, extension not enabled (partitioned) 82 subgroupPartitionedAndNV(ballot, parti); // ERROR, extension not enabled (partitioned) 83 subgroupPartitionedOrNV(ballot, parti); // ERROR, extension not enabled (partitioned) 84 subgroupPartitionedXorNV(ballot, parti); // ERROR, extension not enabled (partitioned) 85 subgroupPartitionedInclusiveAddNV(f4, parti); // ERROR, extension not enabled (partitioned) 86 subgroupPartitionedInclusiveMulNV(f4, parti); // ERROR, extension not enabled (partitioned) 87 subgroupPartitionedInclusiveMinNV(f4, parti); // ERROR, extension not enabled (partitioned) 88 subgroupPartitionedInclusiveMaxNV(f4, parti); // ERROR, extension not enabled (partitioned) 89 subgroupPartitionedInclusiveAndNV(ballot, parti); // ERROR, extension not enabled (partitioned) 90 subgroupPartitionedInclusiveOrNV(ballot, parti); // ERROR, extension not enabled (partitioned) 91 subgroupPartitionedInclusiveXorNV(ballot, parti); // ERROR, extension not enabled (partitioned) 92 subgroupPartitionedExclusiveAddNV(f4, parti); // ERROR, extension not enabled (partitioned) 93 subgroupPartitionedExclusiveMulNV(f4, parti); // ERROR, extension not enabled (partitioned) 94 subgroupPartitionedExclusiveMinNV(f4, parti); // ERROR, extension not enabled (partitioned) 95 subgroupPartitionedExclusiveMaxNV(f4, parti); // ERROR, extension not enabled (partitioned) 96 subgroupPartitionedExclusiveAndNV(ballot, parti); // ERROR, extension not enabled (partitioned) 97 subgroupPartitionedExclusiveOrNV(ballot, parti); // ERROR, extension not enabled (partitioned) 98 subgroupPartitionedExclusiveXorNV(ballot, parti); // ERROR, extension not enabled (partitioned) 99 100 return result; 101} 102 103#extension GL_KHR_shader_subgroup_basic: enable 104 105layout (local_size_x = 8, local_size_y = 8, local_size_z = 1) in; 106 107layout(binding = 0) buffer Buffer 108{ 109 int a[]; 110} data; 111 112void main() 113{ 114 data.a[gl_SubgroupSize] = 1; 115 data.a[gl_SubgroupInvocationID] = 1; 116 data.a[gl_NumSubgroups] = 1; 117 data.a[gl_SubgroupID] = (subgroupElect()) ? 1 : 0; 118 subgroupBarrier(); 119 subgroupMemoryBarrier(); 120 subgroupMemoryBarrierBuffer(); 121 subgroupMemoryBarrierShared(); 122 subgroupMemoryBarrierImage(); 123} 124 125#extension GL_KHR_shader_subgroup_ballot: enable 126void ballot_works(vec4 f4) { 127 gl_SubgroupEqMask; 128 gl_SubgroupGeMask; 129 gl_SubgroupGtMask; 130 gl_SubgroupLeMask; 131 gl_SubgroupLtMask; 132 subgroupBroadcast(f4, 0); 133 subgroupBroadcastFirst(f4); 134 uvec4 ballot = subgroupBallot(false); 135 subgroupInverseBallot(uvec4(0x1)); 136 subgroupBallotBitExtract(ballot, 0); 137 subgroupBallotBitCount(ballot); 138 subgroupBallotInclusiveBitCount(ballot); 139 subgroupBallotExclusiveBitCount(ballot); 140 subgroupBallotFindLSB(ballot); 141 subgroupBallotFindMSB(ballot); 142} 143 144#extension GL_KHR_shader_subgroup_vote: enable 145void vote_works(vec4 f4) 146{ 147 subgroupAll(true); 148 subgroupAny(false); 149 subgroupAllEqual(f4); 150} 151 152#extension GL_KHR_shader_subgroup_shuffle: enable 153#extension GL_KHR_shader_subgroup_shuffle_relative: enable 154void shuffle_works(vec4 f4) 155{ 156 subgroupShuffle(f4, 0); 157 subgroupShuffleXor(f4, 0x1); 158 subgroupShuffleUp(f4, 1); 159 subgroupShuffleDown(f4, 1); 160} 161 162#extension GL_KHR_shader_subgroup_arithmetic: enable 163void arith_works(vec4 f4) 164{ 165 uvec4 ballot; 166 subgroupAdd(f4); 167 subgroupMul(f4); 168 subgroupMin(f4); 169 subgroupMax(f4); 170 subgroupAnd(ballot); 171 subgroupOr(ballot); 172 subgroupXor(ballot); 173 subgroupInclusiveAdd(f4); 174 subgroupInclusiveMul(f4); 175 subgroupInclusiveMin(f4); 176 subgroupInclusiveMax(f4); 177 subgroupInclusiveAnd(ballot); 178 subgroupInclusiveOr(ballot); 179 subgroupInclusiveXor(ballot); 180 subgroupExclusiveAdd(f4); 181 subgroupExclusiveMul(f4); 182 subgroupExclusiveMin(f4); 183 subgroupExclusiveMax(f4); 184 subgroupExclusiveAnd(ballot); 185 subgroupExclusiveOr(ballot); 186 subgroupExclusiveXor(ballot); 187} 188 189#extension GL_KHR_shader_subgroup_clustered: enable 190void clustered_works(vec4 f4) 191{ 192 uvec4 ballot = uvec4(0x55,0,0,0); 193 subgroupClusteredAdd(f4, 2); 194 subgroupClusteredMul(f4, 2); 195 subgroupClusteredMin(f4, 2); 196 subgroupClusteredMax(f4, 2); 197 subgroupClusteredAnd(ballot, 2); 198 subgroupClusteredOr(ballot, 2); 199 subgroupClusteredXor(ballot, 2); 200} 201 202#extension GL_KHR_shader_subgroup_quad: enable 203void quad_works(vec4 f4) 204{ 205 subgroupQuadBroadcast(f4, 0); 206 subgroupQuadSwapHorizontal(f4); 207 subgroupQuadSwapVertical(f4); 208 subgroupQuadSwapDiagonal(f4); 209} 210 211#extension GL_NV_shader_subgroup_partitioned: enable 212void partitioned_works(vec4 f4) 213{ 214 uvec4 parti = subgroupPartitionNV(f4); 215 uvec4 ballot = uvec4(0x55,0,0,0); 216 subgroupPartitionedAddNV(f4, parti); 217 subgroupPartitionedMulNV(f4, parti); 218 subgroupPartitionedMinNV(f4, parti); 219 subgroupPartitionedMaxNV(f4, parti); 220 subgroupPartitionedAndNV(ballot, parti); 221 subgroupPartitionedOrNV(ballot, parti); 222 subgroupPartitionedXorNV(ballot, parti); 223 subgroupPartitionedInclusiveAddNV(f4, parti); 224 subgroupPartitionedInclusiveMulNV(f4, parti); 225 subgroupPartitionedInclusiveMinNV(f4, parti); 226 subgroupPartitionedInclusiveMaxNV(f4, parti); 227 subgroupPartitionedInclusiveAndNV(ballot, parti); 228 subgroupPartitionedInclusiveOrNV(ballot, parti); 229 subgroupPartitionedInclusiveXorNV(ballot, parti); 230 subgroupPartitionedExclusiveAddNV(f4, parti); 231 subgroupPartitionedExclusiveMulNV(f4, parti); 232 subgroupPartitionedExclusiveMinNV(f4, parti); 233 subgroupPartitionedExclusiveMaxNV(f4, parti); 234 subgroupPartitionedExclusiveAndNV(ballot, parti); 235 subgroupPartitionedExclusiveOrNV(ballot, parti); 236 subgroupPartitionedExclusiveXorNV(ballot, parti); 237} 238 239// tests for NV_shader_sm_builtins 240void sm_builtins_err() 241{ 242 gl_WarpsPerSMNV; // ERROR, no extension 243 gl_SMCountNV; // ERROR, no extension 244 gl_WarpIDNV; // ERROR, no extension 245 gl_SMIDNV; // ERROR, no extension 246} 247 248#ifdef GL_NV_shader_sm_builtins 249#extension GL_NV_shader_sm_builtins : enable 250#endif 251 252void sm_builtins() 253{ 254 gl_WarpsPerSMNV; 255 gl_SMCountNV; 256 gl_WarpIDNV; 257 gl_SMIDNV; 258} 259