calculations.hlsl 813 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // RUN: %dxc -E main -T ps_6_0 -Od %s | FileCheck %s
  2. // CHECK: @main
  3. // CHECK: !dx.controlflow.hints
  4. // CHECK: !dx.controlflow.hints
  5. // CHECK: !dx.controlflow.hints
  6. // Make sure that even when we don't simplify cfg, DxilValueCache
  7. // is still able to figure out values.
  8. static int g_foo;
  9. static int g_bar;
  10. static int g_baz;
  11. Texture2D tex0 : register(t0);
  12. Texture2D tex1 : register(t1);
  13. Texture2D f(int foo, int bar, int baz) {
  14. foo += 10;
  15. if (foo+bar < baz*2)
  16. return tex0;
  17. else
  18. return tex1;
  19. }
  20. [RootSignature("DescriptorTable(SRV(t0, numDescriptors=2))")]
  21. float4 main() : sv_target {
  22. g_foo = 10;
  23. [branch]
  24. if (g_foo > 10)
  25. g_foo = 30;
  26. [branch]
  27. if (g_foo < 50)
  28. g_foo = 90;
  29. [branch]
  30. if (g_foo > 80)
  31. g_bar = 20;
  32. g_baz = 30;
  33. return f(g_foo, g_bar, g_baz).Load(0);
  34. };