glsl.460.subgroup.rchit 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. #version 460
  2. #extension GL_NV_ray_tracing : enable
  3. vec4 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. subgroupAll(true); // ERROR extension not enabled (vote)
  17. subgroupAny(false); // ERROR extension not enabled (vote)
  18. subgroupAllEqual(f4); // ERROR extension not enabled (vote)
  19. gl_SubgroupEqMask; // ERROR extension not enabled (ballot)
  20. gl_SubgroupGeMask; // ERROR extension not enabled (ballot)
  21. gl_SubgroupGtMask; // ERROR extension not enabled (ballot)
  22. gl_SubgroupLeMask; // ERROR extension not enabled (ballot)
  23. gl_SubgroupLtMask; // ERROR extension not enabled (ballot)
  24. subgroupBroadcast(f4, 0); // ERROR extension not enabled (ballot)
  25. subgroupBroadcastFirst(f4); // ERROR extension not enabled (ballot)
  26. uvec4 ballot = subgroupBallot(false); // ERROR extension not enabled (ballot)
  27. subgroupInverseBallot(uvec4(0x1)); // ERROR extension not enabled (ballot)
  28. subgroupBallotBitExtract(ballot, 0); // ERROR extension not enabled (ballot)
  29. subgroupBallotBitCount(ballot); // ERROR extension not enabled (ballot)
  30. subgroupBallotInclusiveBitCount(ballot); // ERROR extension not enabled (ballot)
  31. subgroupBallotExclusiveBitCount(ballot); // ERROR extension not enabled (ballot)
  32. subgroupBallotFindLSB(ballot); // ERROR extension not enabled (ballot)
  33. subgroupBallotFindMSB(ballot); // ERROR extension not enabled (ballot)
  34. subgroupShuffle(f4, 0); // ERROR extension not enabled (shuffle)
  35. subgroupShuffleXor(f4, 0x1); // ERROR extension not enabled (shuffle)
  36. subgroupShuffleUp(f4, 1); // ERROR extension not enabled (shuffle_relative)
  37. subgroupShuffleDown(f4, 1); // ERROR extension not enabled (shuffle_relative)
  38. result = subgroupAdd(f4); // ERROR, extension not enabled (arith)
  39. subgroupMul(f4); // ERROR, extension not enabled (arith)
  40. subgroupMin(f4); // ERROR, extension not enabled (arith)
  41. subgroupMax(f4); // ERROR, extension not enabled (arith)
  42. subgroupAnd(ballot); // ERROR, extension not enabled (arith)
  43. subgroupOr(ballot); // ERROR, extension not enabled (arith)
  44. subgroupXor(ballot); // ERROR, extension not enabled (arith)
  45. subgroupInclusiveAdd(f4); // ERROR, extension not enabled (arith)
  46. subgroupInclusiveMul(f4); // ERROR, extension not enabled (arith)
  47. subgroupInclusiveMin(f4); // ERROR, extension not enabled (arith)
  48. subgroupInclusiveMax(f4); // ERROR, extension not enabled (arith)
  49. subgroupInclusiveAnd(ballot); // ERROR, extension not enabled (arith)
  50. subgroupInclusiveOr(ballot); // ERROR, extension not enabled (arith)
  51. subgroupInclusiveXor(ballot); // ERROR, extension not enabled (arith)
  52. subgroupExclusiveAdd(f4); // ERROR, extension not enabled (arith)
  53. subgroupExclusiveMul(f4); // ERROR, extension not enabled (arith)
  54. subgroupExclusiveMin(f4); // ERROR, extension not enabled (arith)
  55. subgroupExclusiveMax(f4); // ERROR, extension not enabled (arith)
  56. subgroupExclusiveAnd(ballot); // ERROR, extension not enabled (arith)
  57. subgroupExclusiveOr(ballot); // ERROR, extension not enabled (arith)
  58. subgroupExclusiveXor(ballot); // ERROR, extension not enabled (arith)
  59. subgroupClusteredAdd(f4, 2); // ERROR, extension not enabled (clustered)
  60. subgroupClusteredMul(f4, 2); // ERROR, extension not enabled (clustered)
  61. subgroupClusteredMin(f4, 2); // ERROR, extension not enabled (clustered)
  62. subgroupClusteredMax(f4, 2); // ERROR, extension not enabled (clustered)
  63. subgroupClusteredAnd(ballot, 2); // ERROR, extension not enabled (clustered)
  64. subgroupClusteredOr(ballot, 2); // ERROR, extension not enabled (clustered)
  65. subgroupClusteredXor(ballot, 2); // ERROR, extension not enabled (clustered)
  66. subgroupQuadBroadcast(f4, 0); // ERROR, extension not enabled (quad)
  67. subgroupQuadSwapHorizontal(f4); // ERROR, extension not enabled (quad)
  68. subgroupQuadSwapVertical(f4); // ERROR, extension not enabled (quad)
  69. subgroupQuadSwapDiagonal(f4); // ERROR, extension not enabled (quad)
  70. uvec4 parti = subgroupPartitionNV(f4); // ERROR, extension not enabled (partitioned)
  71. subgroupPartitionedAddNV(f4, parti); // ERROR, extension not enabled (partitioned)
  72. subgroupPartitionedMulNV(f4, parti); // ERROR, extension not enabled (partitioned)
  73. subgroupPartitionedMinNV(f4, parti); // ERROR, extension not enabled (partitioned)
  74. subgroupPartitionedMaxNV(f4, parti); // ERROR, extension not enabled (partitioned)
  75. subgroupPartitionedAndNV(ballot, parti); // ERROR, extension not enabled (partitioned)
  76. subgroupPartitionedOrNV(ballot, parti); // ERROR, extension not enabled (partitioned)
  77. subgroupPartitionedXorNV(ballot, parti); // ERROR, extension not enabled (partitioned)
  78. subgroupPartitionedInclusiveAddNV(f4, parti); // ERROR, extension not enabled (partitioned)
  79. subgroupPartitionedInclusiveMulNV(f4, parti); // ERROR, extension not enabled (partitioned)
  80. subgroupPartitionedInclusiveMinNV(f4, parti); // ERROR, extension not enabled (partitioned)
  81. subgroupPartitionedInclusiveMaxNV(f4, parti); // ERROR, extension not enabled (partitioned)
  82. subgroupPartitionedInclusiveAndNV(ballot, parti); // ERROR, extension not enabled (partitioned)
  83. subgroupPartitionedInclusiveOrNV(ballot, parti); // ERROR, extension not enabled (partitioned)
  84. subgroupPartitionedInclusiveXorNV(ballot, parti); // ERROR, extension not enabled (partitioned)
  85. subgroupPartitionedExclusiveAddNV(f4, parti); // ERROR, extension not enabled (partitioned)
  86. subgroupPartitionedExclusiveMulNV(f4, parti); // ERROR, extension not enabled (partitioned)
  87. subgroupPartitionedExclusiveMinNV(f4, parti); // ERROR, extension not enabled (partitioned)
  88. subgroupPartitionedExclusiveMaxNV(f4, parti); // ERROR, extension not enabled (partitioned)
  89. subgroupPartitionedExclusiveAndNV(ballot, parti); // ERROR, extension not enabled (partitioned)
  90. subgroupPartitionedExclusiveOrNV(ballot, parti); // ERROR, extension not enabled (partitioned)
  91. subgroupPartitionedExclusiveXorNV(ballot, parti); // ERROR, extension not enabled (partitioned)
  92. return result;
  93. }
  94. layout(binding = 0, set = 0) uniform accelerationStructureNV accNV;
  95. layout(location = 0) rayPayloadNV vec4 localPayload;
  96. layout(location = 1) rayPayloadInNV vec4 incomingPayload;
  97. void main()
  98. {
  99. uvec3 v0 = gl_LaunchIDNV;
  100. uvec3 v1 = gl_LaunchSizeNV;
  101. int v2 = gl_PrimitiveID;
  102. int v3 = gl_InstanceID;
  103. int v4 = gl_InstanceCustomIndexNV;
  104. vec3 v5 = gl_WorldRayOriginNV;
  105. vec3 v6 = gl_WorldRayDirectionNV;
  106. vec3 v7 = gl_ObjectRayOriginNV;
  107. vec3 v8 = gl_ObjectRayDirectionNV;
  108. float v9 = gl_RayTminNV;
  109. float v10 = gl_RayTmaxNV;
  110. float v11 = gl_HitTNV;
  111. uint v12 = gl_HitKindNV;
  112. mat4x3 v13 = gl_ObjectToWorldNV;
  113. mat4x3 v14 = gl_WorldToObjectNV;
  114. traceNV(accNV, 0u, 1u, 2u, 3u, 0u, vec3(0.5f), 0.5f, vec3(1.0f), 0.75f, 1);
  115. }
  116. #extension GL_KHR_shader_subgroup_basic: enable
  117. void basic_works (void)
  118. {
  119. gl_SubgroupSize;
  120. gl_SubgroupInvocationID;
  121. subgroupBarrier();
  122. subgroupMemoryBarrier();
  123. subgroupMemoryBarrierBuffer();
  124. subgroupMemoryBarrierImage();
  125. subgroupElect();
  126. }
  127. #extension GL_KHR_shader_subgroup_ballot: enable
  128. void ballot_works(vec4 f4) {
  129. gl_SubgroupEqMask;
  130. gl_SubgroupGeMask;
  131. gl_SubgroupGtMask;
  132. gl_SubgroupLeMask;
  133. gl_SubgroupLtMask;
  134. subgroupBroadcast(f4, 0);
  135. subgroupBroadcastFirst(f4);
  136. uvec4 ballot = subgroupBallot(false);
  137. subgroupInverseBallot(uvec4(0x1));
  138. subgroupBallotBitExtract(ballot, 0);
  139. subgroupBallotBitCount(ballot);
  140. subgroupBallotInclusiveBitCount(ballot);
  141. subgroupBallotExclusiveBitCount(ballot);
  142. subgroupBallotFindLSB(ballot);
  143. subgroupBallotFindMSB(ballot);
  144. }
  145. #extension GL_KHR_shader_subgroup_vote: enable
  146. void vote_works(vec4 f4)
  147. {
  148. subgroupAll(true);
  149. subgroupAny(false);
  150. subgroupAllEqual(f4);
  151. }
  152. #extension GL_KHR_shader_subgroup_shuffle: enable
  153. #extension GL_KHR_shader_subgroup_shuffle_relative: enable
  154. void shuffle_works(vec4 f4)
  155. {
  156. subgroupShuffle(f4, 0);
  157. subgroupShuffleXor(f4, 0x1);
  158. subgroupShuffleUp(f4, 1);
  159. subgroupShuffleDown(f4, 1);
  160. }
  161. #extension GL_KHR_shader_subgroup_arithmetic: enable
  162. void arith_works(vec4 f4)
  163. {
  164. uvec4 ballot;
  165. subgroupAdd(f4);
  166. subgroupMul(f4);
  167. subgroupMin(f4);
  168. subgroupMax(f4);
  169. subgroupAnd(ballot);
  170. subgroupOr(ballot);
  171. subgroupXor(ballot);
  172. subgroupInclusiveAdd(f4);
  173. subgroupInclusiveMul(f4);
  174. subgroupInclusiveMin(f4);
  175. subgroupInclusiveMax(f4);
  176. subgroupInclusiveAnd(ballot);
  177. subgroupInclusiveOr(ballot);
  178. subgroupInclusiveXor(ballot);
  179. subgroupExclusiveAdd(f4);
  180. subgroupExclusiveMul(f4);
  181. subgroupExclusiveMin(f4);
  182. subgroupExclusiveMax(f4);
  183. subgroupExclusiveAnd(ballot);
  184. subgroupExclusiveOr(ballot);
  185. subgroupExclusiveXor(ballot);
  186. }
  187. #extension GL_KHR_shader_subgroup_clustered: enable
  188. void clustered_works(vec4 f4)
  189. {
  190. uvec4 ballot = uvec4(0x55,0,0,0);
  191. subgroupClusteredAdd(f4, 2);
  192. subgroupClusteredMul(f4, 2);
  193. subgroupClusteredMin(f4, 2);
  194. subgroupClusteredMax(f4, 2);
  195. subgroupClusteredAnd(ballot, 2);
  196. subgroupClusteredOr(ballot, 2);
  197. subgroupClusteredXor(ballot, 2);
  198. }
  199. #extension GL_KHR_shader_subgroup_quad: enable
  200. void quad_works(vec4 f4)
  201. {
  202. subgroupQuadBroadcast(f4, 0);
  203. subgroupQuadSwapHorizontal(f4);
  204. subgroupQuadSwapVertical(f4);
  205. subgroupQuadSwapDiagonal(f4);
  206. }
  207. #extension GL_NV_shader_subgroup_partitioned: enable
  208. void 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. // tests for NV_shader_sm_builtins
  235. void sm_builtins_err()
  236. {
  237. gl_WarpsPerSMNV; // ERROR, no extension
  238. gl_SMCountNV; // ERROR, no extension
  239. gl_WarpIDNV; // ERROR, no extension
  240. gl_SMIDNV; // ERROR, no extension
  241. }
  242. #ifdef GL_NV_shader_sm_builtins
  243. #extension GL_NV_shader_sm_builtins : enable
  244. #endif
  245. void sm_builtins()
  246. {
  247. gl_WarpsPerSMNV;
  248. gl_SMCountNV;
  249. gl_WarpIDNV;
  250. gl_SMIDNV;
  251. }