hlsl.params.default.frag 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. uniform int4 ui4;
  2. static const int cia = -4;
  3. static const int cib = -42;
  4. // ERROR: Ambiguous with fn1 below.
  5. // int4 fn1(int4 p0) { return int4(1,2,3,4); }
  6. int4 fn1(int4 p0, bool b1, bool b2 = false) {
  7. return p0;
  8. }
  9. int4 fn1(int4 p0,
  10. int4 p1 : FOO = int4(-1,-2,-3, cia),
  11. int p2[2] : BAR = { int(1), 2 },
  12. int p3 = abs(cib) )
  13. {
  14. return p0 + p1 + p2[0] + p3;
  15. }
  16. // These should not be ambiguous if given either an int or a float explicit second parameter.
  17. int4 fn2(int4 p0, int x = 3)
  18. {
  19. return int4(10,11,12,13);
  20. }
  21. int4 fn2(int4 p0, float x = sin(3.3)) // OK to have a const expression as a default value
  22. {
  23. return p0 + int4(20,21,22,23);
  24. }
  25. void fn3(int p0 = 3) { }
  26. int4 main() : SV_Target0
  27. {
  28. int myarray[2] = {30,31};
  29. fn3();
  30. fn3(5);
  31. return fn1(100) +
  32. fn1(101, ui4) +
  33. fn1(102, ui4, myarray) +
  34. fn1(103, ui4, myarray, 99) +
  35. fn1(104, false) +
  36. fn1(105, false, true) +
  37. fn2(110, 11.11) + // calls int4, float form
  38. fn2(111, 12); // calls int4, int form
  39. }