struct_exit.hlsl 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // RUN: %dxc -E main -Zi -O3 -T ps_6_0 -opt-enable structurize-loop-exits-for-unroll %s | FileCheck %s
  2. // RUN: %dxc -E main -Zi -Od -T ps_6_0 -opt-enable structurize-loop-exits-for-unroll %s -DFORCE_UNROLL | FileCheck %s
  3. // RUN: %dxc -E main -Zi -T ps_6_0 %s -opt-enable structurize-loop-exits-for-unroll -DFORCE_UNROLL | FileCheck %s
  4. // CHECK: %{{.+}} = call float @dx.op.unary.f32(i32 13
  5. // CHECK: dx.struct_exit.cond_body
  6. // CHECK: store float
  7. // CHECK: %{{.+}} = call float @dx.op.unary.f32(i32 13
  8. // CHECK: dx.struct_exit.cond_body
  9. // CHECK: store float
  10. // CHECK: %{{.+}} = call float @dx.op.unary.f32(i32 13
  11. // CHECK: dx.struct_exit.cond_body
  12. // CHECK: store float
  13. #ifdef FORCE_UNROLL
  14. #define UNROLL [unroll]
  15. #else
  16. #define UNROLL
  17. #endif
  18. Texture2D tex0;
  19. RWTexture1D<float> uav0;
  20. RWTexture1D<float> uav1;
  21. const uint idx;
  22. [RootSignature("CBV(b0), DescriptorTable(SRV(t0)), DescriptorTable(UAV(u0), UAV(u1))")]
  23. float main(uint a : A, uint b : B, uint c : C) : SV_Target {
  24. float ret = 0;
  25. float array[] = {1.0, 2.0, 3.0,};
  26. UNROLL for(uint i = 1; i <= 3; i++) {
  27. if ((a * i) & c) {
  28. ret += sin(i * b); // check for sin
  29. if ((a * i) & b) {
  30. if ((c | a) & b) {
  31. // loop exit here:
  32. uav0[i] += a;
  33. return 1;
  34. }
  35. array[(idx + i) % 5] += a; // check that this side-effect is bounded within exit cond
  36. }
  37. }
  38. }
  39. return ret + array[0];
  40. }
  41. // Exclude quoted source file (see readme)
  42. // CHECK-LABEL: {{!"[^"]*\\0A[^"]*"}}