precise_struct_block.vert 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #version 450
  2. struct T {
  3. float f1;
  4. float f2;
  5. };
  6. out B1 {precise T s; float x;} partial_precise_block;
  7. precise out B2 {T s; float x;} all_precise_block;
  8. float struct_member() {
  9. float a = 1.0;
  10. float b = 2.0;
  11. float c = 3.0;
  12. float d = 4.0;
  13. precise float result;
  14. T S, S2, S3;
  15. S2.f1 = a + 0.2; // NoContraction
  16. S2.f2 = b + 0.2; // NOT NoContraction
  17. S3.f1 = a + b; // NOT NoContraction
  18. S = S2; // "precise" propagated through parent object nodes
  19. result = S.f1 + 0.1; // the ADD operation should be NoContraction
  20. return result;
  21. }
  22. float complex_array_struct() {
  23. precise float result;
  24. struct T1 {
  25. float t1_array[3];
  26. float t1_scalar;
  27. };
  28. struct T2 {
  29. T1 t1a[5];
  30. T1 t1b[6];
  31. T1 t1c[7];
  32. };
  33. struct T3 {float f; T2 t2; vec4 v; int p;};
  34. T3 t3[10];
  35. for(int i=0; i<10; i++) {
  36. t3[i].f = i / 3.0; // Not NoContraction
  37. t3[i].v = vec4(i * 1.5); // NoContraction
  38. t3[i].p = i + 1;
  39. for(int j=0; j<5; j++) {
  40. for(int k = 0; k<3; k++) {
  41. t3[i].t2.t1a[j].t1_array[k] = i * j + k; // Not NoContraction
  42. }
  43. t3[i].t2.t1a[j].t1_scalar = j * 2.0 / i; // Not NoContration
  44. }
  45. for(int j=0; j<6; j++) {
  46. for(int k = 0; k<3; k++) {
  47. t3[i].t2.t1b[j].t1_array[k] = i * j + k; // Not NoContraction
  48. }
  49. t3[i].t2.t1b[j].t1_scalar = j * 2.0 / i; // NoContraction
  50. }
  51. for(int j=0; j<6; j++) {
  52. for(int k = 0; k<3; k++) {
  53. t3[i].t2.t1c[j].t1_array[k] = i * j + k; // Not NoContraction because all operands are integers
  54. }
  55. t3[i].t2.t1c[j].t1_scalar = j * 2.0 / i; // Not NoContraction
  56. }
  57. }
  58. int i = 2;
  59. result = t3[5].t2.t1c[6].t1_array[1]
  60. + t3[2].t2.t1b[1].t1_scalar
  61. + t3[i - 1].v.xy.x; // NoContraction
  62. return result;
  63. }
  64. float out_block() {
  65. float a = 0.1;
  66. float b = 0.2;
  67. partial_precise_block.s.f1 = a + b; // NoContraction
  68. partial_precise_block.s.f2 = a - b; // NoContraction
  69. partial_precise_block.x = a * b; // Not NoContraction
  70. all_precise_block.s.f1 = a + b + 1.0; // NoContraction
  71. all_precise_block.s.f2 = a - b - 1.0; // NoContraction
  72. all_precise_block.x = a * b * 2.0; // Also NoContraction
  73. return a + b; // Not NoContraction
  74. }
  75. void main(){}