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