glsl.450.subgroupBasic.comp 12 KB

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