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, only defined in compute 14 gl_SubgroupID; // ERROR, only defined in compute 15 subgroupMemoryBarrierShared(); // ERROR, only defined in compute 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 104layout(location = 0) out uvec4 data; 105void main (void) 106{ 107 data = uvec4(gl_SubgroupSize, gl_SubgroupInvocationID, 0, 0); 108 subgroupBarrier(); 109 subgroupMemoryBarrier(); 110 subgroupMemoryBarrierBuffer(); 111 subgroupMemoryBarrierImage(); 112 subgroupElect(); 113} 114 115#extension GL_KHR_shader_subgroup_ballot: enable 116void ballot_works(vec4 f4) { 117 int i; 118 gl_SubgroupEqMask; 119 gl_SubgroupGeMask; 120 gl_SubgroupGtMask; 121 gl_SubgroupLeMask; 122 gl_SubgroupLtMask; 123 subgroupBroadcast(f4, 0); 124 subgroupBroadcast(f4, i); 125 subgroupBroadcastFirst(f4); 126 uvec4 ballot = subgroupBallot(false); 127 subgroupInverseBallot(uvec4(0x1)); 128 subgroupBallotBitExtract(ballot, 0); 129 subgroupBallotBitCount(ballot); 130 subgroupBallotInclusiveBitCount(ballot); 131 subgroupBallotExclusiveBitCount(ballot); 132 subgroupBallotFindLSB(ballot); 133 subgroupBallotFindMSB(ballot); 134} 135 136#extension GL_KHR_shader_subgroup_vote: enable 137void vote_works(vec4 f4) 138{ 139 subgroupAll(true); 140 subgroupAny(false); 141 subgroupAllEqual(f4); 142} 143 144#extension GL_KHR_shader_subgroup_shuffle: enable 145#extension GL_KHR_shader_subgroup_shuffle_relative: enable 146void shuffle_works(vec4 f4) 147{ 148 subgroupShuffle(f4, 0); 149 subgroupShuffleXor(f4, 0x1); 150 subgroupShuffleUp(f4, 1); 151 subgroupShuffleDown(f4, 1); 152} 153 154#extension GL_KHR_shader_subgroup_arithmetic: enable 155void arith_works(vec4 f4) 156{ 157 uvec4 ballot; 158 subgroupAdd(f4); 159 subgroupMul(f4); 160 subgroupMin(f4); 161 subgroupMax(f4); 162 subgroupAnd(ballot); 163 subgroupOr(ballot); 164 subgroupXor(ballot); 165 subgroupInclusiveAdd(f4); 166 subgroupInclusiveMul(f4); 167 subgroupInclusiveMin(f4); 168 subgroupInclusiveMax(f4); 169 subgroupInclusiveAnd(ballot); 170 subgroupInclusiveOr(ballot); 171 subgroupInclusiveXor(ballot); 172 subgroupExclusiveAdd(f4); 173 subgroupExclusiveMul(f4); 174 subgroupExclusiveMin(f4); 175 subgroupExclusiveMax(f4); 176 subgroupExclusiveAnd(ballot); 177 subgroupExclusiveOr(ballot); 178 subgroupExclusiveXor(ballot); 179} 180 181#extension GL_KHR_shader_subgroup_clustered: enable 182void clustered_works(vec4 f4) 183{ 184 uvec4 ballot = uvec4(0x55,0,0,0); 185 subgroupClusteredAdd(f4, 2); 186 subgroupClusteredMul(f4, 2); 187 subgroupClusteredMin(f4, 2); 188 subgroupClusteredMax(f4, 2); 189 subgroupClusteredAnd(ballot, 2); 190 subgroupClusteredOr(ballot, 2); 191 subgroupClusteredXor(ballot, 2); 192} 193 194#extension GL_KHR_shader_subgroup_quad: enable 195void quad_works(vec4 f4) 196{ 197 int i; 198 subgroupQuadBroadcast(f4, 0); 199 subgroupQuadBroadcast(f4, i); 200 subgroupQuadSwapHorizontal(f4); 201 subgroupQuadSwapVertical(f4); 202 subgroupQuadSwapDiagonal(f4); 203} 204 205#extension GL_NV_shader_subgroup_partitioned: enable 206void partitioned_works(vec4 f4) 207{ 208 uvec4 parti = subgroupPartitionNV(f4); 209 uvec4 ballot = uvec4(0x55,0,0,0); 210 subgroupPartitionedAddNV(f4, parti); 211 subgroupPartitionedMulNV(f4, parti); 212 subgroupPartitionedMinNV(f4, parti); 213 subgroupPartitionedMaxNV(f4, parti); 214 subgroupPartitionedAndNV(ballot, parti); 215 subgroupPartitionedOrNV(ballot, parti); 216 subgroupPartitionedXorNV(ballot, parti); 217 subgroupPartitionedInclusiveAddNV(f4, parti); 218 subgroupPartitionedInclusiveMulNV(f4, parti); 219 subgroupPartitionedInclusiveMinNV(f4, parti); 220 subgroupPartitionedInclusiveMaxNV(f4, parti); 221 subgroupPartitionedInclusiveAndNV(ballot, parti); 222 subgroupPartitionedInclusiveOrNV(ballot, parti); 223 subgroupPartitionedInclusiveXorNV(ballot, parti); 224 subgroupPartitionedExclusiveAddNV(f4, parti); 225 subgroupPartitionedExclusiveMulNV(f4, parti); 226 subgroupPartitionedExclusiveMinNV(f4, parti); 227 subgroupPartitionedExclusiveMaxNV(f4, parti); 228 subgroupPartitionedExclusiveAndNV(ballot, parti); 229 subgroupPartitionedExclusiveOrNV(ballot, parti); 230 subgroupPartitionedExclusiveXorNV(ballot, parti); 231} 232 233// tests for NV_shader_sm_builtins 234void sm_builtins_err() 235{ 236 gl_WarpsPerSMNV; // ERROR, no extension 237 gl_SMCountNV; // ERROR, no extension 238 gl_WarpIDNV; // ERROR, no extension 239 gl_SMIDNV; // ERROR, no extension 240} 241 242#ifdef GL_NV_shader_sm_builtins 243#extension GL_NV_shader_sm_builtins : enable 244#endif 245 246void sm_builtins() 247{ 248 gl_WarpsPerSMNV; 249 gl_SMCountNV; 250 gl_WarpIDNV; 251 gl_SMIDNV; 252} 253