glsl.450.subgroup.vert 11 KB

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