glsl.450.subgroup.geom 11 KB

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