wave.hlsl 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -ffreestanding -fno-spell-checking -verify %s
  2. // we use -Wno-unused-value because we generate some no-op expressions to yield errors
  3. // without also putting them in a static assertion
  4. // __decltype is the GCC way of saying 'decltype', but doesn't require C++11
  5. // _Static_assert is the C11 way of saying 'static_assert', but doesn't require C++11
  6. #ifdef VERIFY_FXC
  7. #define _Static_assert(a,b,c) ;
  8. #endif
  9. float4 main() : SV_Target {
  10. if (WaveIsFirstLane()) {
  11. // Divergent, single thread executing here.
  12. }
  13. uint a = WaveGetLaneIndex();
  14. if (WaveGetLaneCount() == 0) {
  15. // Unlikely!
  16. }
  17. if (WaveActiveAnyTrue(true)) {
  18. // Always true.
  19. }
  20. if (WaveActiveAllTrue(true)) {
  21. // Always true.
  22. }
  23. if (WaveActiveAllEqual(WaveGetLaneIndex())) {
  24. // true only if 'w' has a single lane active
  25. }
  26. uint4 val = WaveActiveBallot(true);
  27. if (val.x == 1) {
  28. // Only true if lane 0 was the only active lane at this point.
  29. }
  30. float3 f3 = { 1, 2, 3 };
  31. uint3 u3 = { 1, 2 ,3 };
  32. uint u;
  33. uint2 u2 = { 1, 2 };
  34. float f1 = 1;
  35. f3 = WaveReadLaneAt(f3, 1);
  36. f3 = WaveReadLaneFirst(f3);
  37. f3 = WaveActiveSum(f3);
  38. f3 = WaveActiveProduct(f3);
  39. // WaveActiveBit* with an invalid signature suggests the use of WaveActiveBallot instead.
  40. // expected-note@? {{'WaveActiveBallot' declared here}}
  41. // expected-note@? {{'WaveActiveBallot' declared here}}
  42. WaveActiveBitAnd(f1); // expected-error {{use of undeclared identifier 'WaveActiveBitAnd'}}
  43. WaveActiveBitOr(f1); // expected-error {{use of undeclared identifier 'WaveActiveBitOr'}}
  44. WaveActiveBitXor(f1); // expected-error {{use of undeclared identifier 'WaveActiveBitXor'}}
  45. u3 = WaveActiveBitAnd(u3);
  46. u3 = WaveActiveBitOr(u3);
  47. u3 = WaveActiveBitXor(u3);
  48. u3 = WaveActiveMin(u3);
  49. u3 = WaveActiveMax(u3);
  50. f3 = WavePrefixSum(3);
  51. f3 = WavePrefixProduct(3);
  52. f3 = QuadReadLaneAt(f3, 1);
  53. u = QuadReadAcrossX(u);
  54. u2 = QuadReadAcrossY(u2);
  55. };