1#version 460 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#define MAX_VER 81 104#define MAX_PRIM 32 105 106#define BARRIER() \ 107 memoryBarrierShared(); \ 108 barrier(); 109 110#extension GL_NV_mesh_shader : enable 111 112layout(local_size_x = 32) in; 113 114layout(max_vertices=MAX_VER) out; 115layout(max_primitives=MAX_PRIM) out; 116layout(triangles) out; 117 118// test use of builtins in mesh shaders: 119 120void main() 121{ 122 uint iid = gl_LocalInvocationID.x; 123 uint gid = gl_WorkGroupID.x; 124 125 gl_MeshVerticesNV[iid].gl_Position = vec4(1.0); 126 gl_MeshVerticesNV[iid].gl_PointSize = 2.0; 127 gl_MeshVerticesNV[iid].gl_ClipDistance[3] = 3.0; 128 gl_MeshVerticesNV[iid].gl_CullDistance[2] = 4.0; 129 130 BARRIER(); 131 132 gl_MeshVerticesNV[iid+1].gl_Position = gl_MeshVerticesNV[iid].gl_Position; 133 gl_MeshVerticesNV[iid+1].gl_PointSize = gl_MeshVerticesNV[iid].gl_PointSize; 134 gl_MeshVerticesNV[iid+1].gl_ClipDistance[3] = gl_MeshVerticesNV[iid].gl_ClipDistance[3]; 135 gl_MeshVerticesNV[iid+1].gl_CullDistance[2] = gl_MeshVerticesNV[iid].gl_CullDistance[2]; 136 137 BARRIER(); 138 139 gl_MeshPrimitivesNV[iid].gl_PrimitiveID = 6; 140 gl_MeshPrimitivesNV[iid].gl_Layer = 7; 141 gl_MeshPrimitivesNV[iid].gl_ViewportIndex = 8; 142 gl_MeshPrimitivesNV[iid].gl_ViewportMask[0] = 9; 143 144 BARRIER(); 145 146 gl_MeshPrimitivesNV[iid+1].gl_PrimitiveID = gl_MeshPrimitivesNV[iid].gl_PrimitiveID; 147 gl_MeshPrimitivesNV[iid+1].gl_Layer = gl_MeshPrimitivesNV[iid].gl_Layer; 148 gl_MeshPrimitivesNV[iid+1].gl_ViewportIndex = gl_MeshPrimitivesNV[iid].gl_ViewportIndex; 149 gl_MeshPrimitivesNV[iid+1].gl_ViewportMask[0] = gl_MeshPrimitivesNV[iid].gl_ViewportMask[0]; 150 151 BARRIER(); 152 153 // check bound limits 154 gl_PrimitiveIndicesNV[0] = 257; // should truncate 257 -> 1 155 gl_PrimitiveIndicesNV[(MAX_PRIM * 3) - 1] = 2; 156 gl_PrimitiveIndicesNV[gid] = gl_PrimitiveIndicesNV[gid-1]; 157 158 // writes 4 indices at offset gl_DrawID 159 writePackedPrimitiveIndices4x8NV(gl_DrawID, 0x01020304); 160 161 gl_PrimitiveCountNV = MAX_PRIM * 3; 162 163 BARRIER(); 164} 165 166#extension GL_KHR_shader_subgroup_basic: enable 167void basic_works (void) 168{ 169 gl_SubgroupSize; 170 gl_SubgroupInvocationID; 171 subgroupBarrier(); 172 subgroupMemoryBarrier(); 173 subgroupMemoryBarrierBuffer(); 174 subgroupMemoryBarrierImage(); 175 subgroupElect(); 176 gl_NumSubgroups; // allowed in mesh 177 gl_SubgroupID; // allowed in mesh 178 subgroupMemoryBarrierShared(); // allowed in mesh 179} 180 181#extension GL_KHR_shader_subgroup_ballot: enable 182void ballot_works(vec4 f4) { 183 gl_SubgroupEqMask; 184 gl_SubgroupGeMask; 185 gl_SubgroupGtMask; 186 gl_SubgroupLeMask; 187 gl_SubgroupLtMask; 188 subgroupBroadcast(f4, 0); 189 subgroupBroadcastFirst(f4); 190 uvec4 ballot = subgroupBallot(false); 191 subgroupInverseBallot(uvec4(0x1)); 192 subgroupBallotBitExtract(ballot, 0); 193 subgroupBallotBitCount(ballot); 194 subgroupBallotInclusiveBitCount(ballot); 195 subgroupBallotExclusiveBitCount(ballot); 196 subgroupBallotFindLSB(ballot); 197 subgroupBallotFindMSB(ballot); 198} 199 200#extension GL_KHR_shader_subgroup_vote: enable 201void vote_works(vec4 f4) 202{ 203 subgroupAll(true); 204 subgroupAny(false); 205 subgroupAllEqual(f4); 206} 207 208#extension GL_KHR_shader_subgroup_shuffle: enable 209#extension GL_KHR_shader_subgroup_shuffle_relative: enable 210void shuffle_works(vec4 f4) 211{ 212 subgroupShuffle(f4, 0); 213 subgroupShuffleXor(f4, 0x1); 214 subgroupShuffleUp(f4, 1); 215 subgroupShuffleDown(f4, 1); 216} 217 218#extension GL_KHR_shader_subgroup_arithmetic: enable 219void arith_works(vec4 f4) 220{ 221 uvec4 ballot; 222 subgroupAdd(f4); 223 subgroupMul(f4); 224 subgroupMin(f4); 225 subgroupMax(f4); 226 subgroupAnd(ballot); 227 subgroupOr(ballot); 228 subgroupXor(ballot); 229 subgroupInclusiveAdd(f4); 230 subgroupInclusiveMul(f4); 231 subgroupInclusiveMin(f4); 232 subgroupInclusiveMax(f4); 233 subgroupInclusiveAnd(ballot); 234 subgroupInclusiveOr(ballot); 235 subgroupInclusiveXor(ballot); 236 subgroupExclusiveAdd(f4); 237 subgroupExclusiveMul(f4); 238 subgroupExclusiveMin(f4); 239 subgroupExclusiveMax(f4); 240 subgroupExclusiveAnd(ballot); 241 subgroupExclusiveOr(ballot); 242 subgroupExclusiveXor(ballot); 243} 244 245#extension GL_KHR_shader_subgroup_clustered: enable 246void clustered_works(vec4 f4) 247{ 248 uvec4 ballot = uvec4(0x55,0,0,0); 249 subgroupClusteredAdd(f4, 2); 250 subgroupClusteredMul(f4, 2); 251 subgroupClusteredMin(f4, 2); 252 subgroupClusteredMax(f4, 2); 253 subgroupClusteredAnd(ballot, 2); 254 subgroupClusteredOr(ballot, 2); 255 subgroupClusteredXor(ballot, 2); 256} 257 258#extension GL_KHR_shader_subgroup_quad: enable 259void quad_works(vec4 f4) 260{ 261 subgroupQuadBroadcast(f4, 0); 262 subgroupQuadSwapHorizontal(f4); 263 subgroupQuadSwapVertical(f4); 264 subgroupQuadSwapDiagonal(f4); 265} 266 267#extension GL_NV_shader_subgroup_partitioned: enable 268void partitioned_works(vec4 f4) 269{ 270 uvec4 parti = subgroupPartitionNV(f4); 271 uvec4 ballot = uvec4(0x55,0,0,0); 272 subgroupPartitionedAddNV(f4, parti); 273 subgroupPartitionedMulNV(f4, parti); 274 subgroupPartitionedMinNV(f4, parti); 275 subgroupPartitionedMaxNV(f4, parti); 276 subgroupPartitionedAndNV(ballot, parti); 277 subgroupPartitionedOrNV(ballot, parti); 278 subgroupPartitionedXorNV(ballot, parti); 279 subgroupPartitionedInclusiveAddNV(f4, parti); 280 subgroupPartitionedInclusiveMulNV(f4, parti); 281 subgroupPartitionedInclusiveMinNV(f4, parti); 282 subgroupPartitionedInclusiveMaxNV(f4, parti); 283 subgroupPartitionedInclusiveAndNV(ballot, parti); 284 subgroupPartitionedInclusiveOrNV(ballot, parti); 285 subgroupPartitionedInclusiveXorNV(ballot, parti); 286 subgroupPartitionedExclusiveAddNV(f4, parti); 287 subgroupPartitionedExclusiveMulNV(f4, parti); 288 subgroupPartitionedExclusiveMinNV(f4, parti); 289 subgroupPartitionedExclusiveMaxNV(f4, parti); 290 subgroupPartitionedExclusiveAndNV(ballot, parti); 291 subgroupPartitionedExclusiveOrNV(ballot, parti); 292 subgroupPartitionedExclusiveXorNV(ballot, parti); 293} 294 295// tests for NV_shader_sm_builtins 296void sm_builtins_err() 297{ 298 gl_WarpsPerSMNV; // ERROR, no extension 299 gl_SMCountNV; // ERROR, no extension 300 gl_WarpIDNV; // ERROR, no extension 301 gl_SMIDNV; // ERROR, no extension 302} 303 304#ifdef GL_NV_shader_sm_builtins 305#extension GL_NV_shader_sm_builtins : enable 306#endif 307 308void sm_builtins() 309{ 310 gl_WarpsPerSMNV; 311 gl_SMCountNV; 312 gl_WarpIDNV; 313 gl_SMIDNV; 314} 315