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