spv.shortCircuit.frag 983 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #version 400
  2. flat in ivec4 uiv4;
  3. in vec4 uv4;
  4. bool ub;
  5. bool uba;
  6. bvec4 ub41, ub42;
  7. in float uf;
  8. flat in int ui;
  9. out float of1;
  10. out vec4 of4;
  11. bool foo() { ++of1; return of1 > 10.0; }
  12. void main()
  13. {
  14. of1 = 0.0;
  15. of4 = vec4(0.0);
  16. if (ub || ui > 2) // not worth short circuiting
  17. ++of1;
  18. if (ub && !uba) // not worth short circuiting
  19. ++of1;
  20. if (ub || foo()) // must short circuit
  21. ++of1;
  22. if (ub && foo()) // must short circuit
  23. ++of1;
  24. if (foo() || ub) // not worth short circuiting
  25. ++of1;
  26. if (foo() && ub) // not worth short circuiting
  27. ++of1;
  28. if (ub || ++of1 > 1.0) // must short circuit
  29. ++of4;
  30. if (++of1 > 1.0 || ub) // not worth short circuiting
  31. ++of4;
  32. if (ub || sin(uf) * 4.0 > of1) // worth short circuiting
  33. ++of1;
  34. if (ub && sin(uf) * 4.0 > of1) // worth short circuiting
  35. ++of1;
  36. }