blob: c541540cbbb93a9a8eb60d8adb72b7232d1b1829 [file] [log] [blame]
qining9220dbb2016-05-04 17:34:38 -04001#version 450
2#extension GL_EXT_tessellation_shader : require
3#extension GL_EXT_gpu_shader5 : require
4
5float minimal() {
6 precise float result = 5.0;
7 float a = 10.0;
8 float b = 20.0;
9 float c = 30.0;
10 float d = 40.0;
11 result = a * b + c * d; // c * d, a * b and rvalue1 + rvalue2 should be 'noContraction'.
12 return result;
13}
14
15void continuous_assignment() {
16 precise float result = 5.0;
qining5bec2b52016-05-06 21:52:28 -040017 float a = 10.0;
18 float b = 20.0;
qining9220dbb2016-05-04 17:34:38 -040019 result = a = b + 4; // b + 4 should be 'noContraction'.
20}
21
22void convert() {
qining5bec2b52016-05-06 21:52:28 -040023 precise double result;
24 float a = 10.0;
25 float b = 20.0;
qining9220dbb2016-05-04 17:34:38 -040026 b = a + b; // a + b should be 'noContraction'.
qining5bec2b52016-05-06 21:52:28 -040027 result = double(b); // convert operation should not be 'noContraction'.
qining9220dbb2016-05-04 17:34:38 -040028}
29
30float loop_for() {
31 precise float r1 = 5.0;
32 precise float r2 = 10.0;
33 int a = 10;
34 int b = 20;
35 int c = 30;
36 for (int i = 0; i < a; i++) {
37 r1 += 3.12 + b + i; // 'noContration', this make i++ also 'noContraction'
38 c += 1; // 'noContration'
39 }
40 a += 1; // a + 1 should not be 'noContraction'.
41 r2 = c; // The calculation of c should be 'noContration'.
42 return float(r1 + r2); // conversion should not be 'noContration'.
43}
44
45void loop_array(void) {
qining5bec2b52016-05-06 21:52:28 -040046 precise float result;
qining9220dbb2016-05-04 17:34:38 -040047
48 int x = 22;
49 int y = 33;
50
qining5bec2b52016-05-06 21:52:28 -040051 float a0[3];
52 result += float(x) + float(y); // x + y should be 'noContraction' also result + rvalue.
qining9220dbb2016-05-04 17:34:38 -040053
54 for (int i = 0; i < 3; ++i) {
55 // a's dereference + 2 should be 'noContraction'.
56 result += a0[i] + 2;
57 // result + 1 and 3 - rvalue should be 'noContraction'.
58 a0[i] = 3 - result++;
59 }
60}
61
62void loop_while() {
63 precise float result = 5.0;
64 int a = 10;
65 int b = 20;
66 while (result < 10) {
67 result += 3.12 + b; // result + 3.12 should be 'noContraction'.
68 }
qining5bec2b52016-05-06 21:52:28 -040069 result = a + b + 5; // b + 5 should not be 'noCtraction' because all operands are integers.
qining9220dbb2016-05-04 17:34:38 -040070 result = 11.1;
71}
72
73float fma_not_decorated() {
74 precise float result;
75 float a = 1.0;
76 float b = 2.0;
77 float c = 3.0;
78 b = b + c; // b + c should be decorated with 'noContraction'
79 result = fma(a, b, c); // fma() should not be decorated with 'noContradtion'
80 return result;
81}
82
83precise float precise_return_exp_func() {
84 float a = 1.0;
85 float b = 2.0;
86 return a + b; // the ADD operation should be 'noContraction'
87}
88
89precise float precise_return_val_func() {
90 float a = 1.0;
91 float b = 2.0;
92 float result = a + b; // the ADD operation should be 'noContraction'
93 return result;
94}
95
96float precise_func_parameter(float b, precise out float c) {
97 float a = 0.5;
98 c = a + b; // noContration
99 return a - b; // Not noContraction
100}
101
qining0c96db52016-05-06 18:56:33 -0400102mat3 matrix (mat2x3 a, mat3x2 b) {
103 mat2x3 c = mat2x3(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
104 precise mat3 result;
105 result = (a + c) * b; // should be noContraction
106 return result;
107}
108
qining9220dbb2016-05-04 17:34:38 -0400109void main(){}