summaryrefslogtreecommitdiff
path: root/tests/java_api/RSTest_CompatLibLegacy/src/com/android/rs/test/vector.rscript
blob: 0430a2fc5f1904915d839cb634c15919122e1e53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#include "shared.rsh"

// Testing vector types
float2 f2 = { 1.0f, 2.0f };
float3 f3 = { 1.0f, 2.0f, 3.0f };
float4 f4 = { 1.0f, 2.0f, 3.0f, 4.0f };

double2 d2 = { 1.0, 2.0 };
double3 d3 = { 1.0, 2.0, 3.0 };
double4 d4 = { 1.0, 2.0, 3.0, 4.0 };

char2 i8_2 = { 1, 2 };
char3 i8_3 = { 1, 2, 3 };
char4 i8_4 = { 1, 2, 3, 4 };

uchar2 u8_2 = { 1, 2 };
uchar3 u8_3 = { 1, 2, 3 };
uchar4 u8_4 = { 1, 2, 3, 4 };

short2 i16_2 = { 1, 2 };
short3 i16_3 = { 1, 2, 3 };
short4 i16_4 = { 1, 2, 3, 4 };

ushort2 u16_2 = { 1, 2 };
ushort3 u16_3 = { 1, 2, 3 };
ushort4 u16_4 = { 1, 2, 3, 4 };

int2 i32_2 = { 1, 2 };
int3 i32_3 = { 1, 2, 3 };
int4 i32_4 = { 1, 2, 3, 4 };

uint2 u32_2 = { 1, 2 };
uint3 u32_3 = { 1, 2, 3 };
uint4 u32_4 = { 1, 2, 3, 4 };

long2 i64_2 = { 1, 2 };
long3 i64_3 = { 1, 2, 3 };
long4 i64_4 = { 1, 2, 3, 4 };

ulong2 u64_2 = { 1, 2 };
ulong3 u64_3 = { 1, 2, 3 };
ulong4 u64_4 = { 1, 2, 3, 4 };

static bool test_vector_types() {
    bool failed = false;

    rsDebug("Testing F32", 0);
    _RS_ASSERT(f2.x == 2.99f);
    _RS_ASSERT(f2.y == 3.99f);

    _RS_ASSERT(f3.x == 2.99f);
    _RS_ASSERT(f3.y == 3.99f);
    _RS_ASSERT(f3.z == 4.99f);

    _RS_ASSERT(f4.x == 2.99f);
    _RS_ASSERT(f4.y == 3.99f);
    _RS_ASSERT(f4.z == 4.99f);
    _RS_ASSERT(f4.w == 5.99f);

    rsDebug("Testing F64", 0);
    _RS_ASSERT(d2.x == 2.99);
    _RS_ASSERT(d2.y == 3.99);

    _RS_ASSERT(d3.x == 2.99);
    _RS_ASSERT(d3.y == 3.99);
    _RS_ASSERT(d3.z == 4.99);

    _RS_ASSERT(d4.x == 2.99);
    _RS_ASSERT(d4.y == 3.99);
    _RS_ASSERT(d4.z == 4.99);
    _RS_ASSERT(d4.w == 5.99);

    rsDebug("Testing I8", 0);
    _RS_ASSERT(i8_2.x == 2);
    _RS_ASSERT(i8_2.y == 3);

    _RS_ASSERT(i8_3.x == 2);
    _RS_ASSERT(i8_3.y == 3);
    _RS_ASSERT(i8_3.z == 4);

    _RS_ASSERT(i8_4.x == 2);
    _RS_ASSERT(i8_4.y == 3);
    _RS_ASSERT(i8_4.z == 4);
    _RS_ASSERT(i8_4.w == 5);

    rsDebug("Testing U8", 0);
    _RS_ASSERT(u8_2.x == 2);
    _RS_ASSERT(u8_2.y == 3);

    _RS_ASSERT(u8_3.x == 2);
    _RS_ASSERT(u8_3.y == 3);
    _RS_ASSERT(u8_3.z == 4);

    _RS_ASSERT(u8_4.x == 2);
    _RS_ASSERT(u8_4.y == 3);
    _RS_ASSERT(u8_4.z == 4);
    _RS_ASSERT(u8_4.w == 5);

    rsDebug("Testing I16", 0);
    _RS_ASSERT(i16_2.x == 2);
    _RS_ASSERT(i16_2.y == 3);

    _RS_ASSERT(i16_3.x == 2);
    _RS_ASSERT(i16_3.y == 3);
    _RS_ASSERT(i16_3.z == 4);

    _RS_ASSERT(i16_4.x == 2);
    _RS_ASSERT(i16_4.y == 3);
    _RS_ASSERT(i16_4.z == 4);
    _RS_ASSERT(i16_4.w == 5);

    rsDebug("Testing U16", 0);
    _RS_ASSERT(u16_2.x == 2);
    _RS_ASSERT(u16_2.y == 3);

    _RS_ASSERT(u16_3.x == 2);
    _RS_ASSERT(u16_3.y == 3);
    _RS_ASSERT(u16_3.z == 4);

    _RS_ASSERT(u16_4.x == 2);
    _RS_ASSERT(u16_4.y == 3);
    _RS_ASSERT(u16_4.z == 4);
    _RS_ASSERT(u16_4.w == 5);

    rsDebug("Testing I32", 0);
    _RS_ASSERT(i32_2.x == 2);
    _RS_ASSERT(i32_2.y == 3);

    _RS_ASSERT(i32_3.x == 2);
    _RS_ASSERT(i32_3.y == 3);
    _RS_ASSERT(i32_3.z == 4);

    _RS_ASSERT(i32_4.x == 2);
    _RS_ASSERT(i32_4.y == 3);
    _RS_ASSERT(i32_4.z == 4);
    _RS_ASSERT(i32_4.w == 5);

    rsDebug("Testing U32", 0);
    _RS_ASSERT(u32_2.x == 2);
    _RS_ASSERT(u32_2.y == 3);

    _RS_ASSERT(u32_3.x == 2);
    _RS_ASSERT(u32_3.y == 3);
    _RS_ASSERT(u32_3.z == 4);

    _RS_ASSERT(u32_4.x == 2);
    _RS_ASSERT(u32_4.y == 3);
    _RS_ASSERT(u32_4.z == 4);
    _RS_ASSERT(u32_4.w == 5);

    rsDebug("Testing I64", 0);
    _RS_ASSERT(i64_2.x == 2);
    _RS_ASSERT(i64_2.y == 3);

    _RS_ASSERT(i64_3.x == 2);
    _RS_ASSERT(i64_3.y == 3);
    _RS_ASSERT(i64_3.z == 4);

    _RS_ASSERT(i64_4.x == 2);
    _RS_ASSERT(i64_4.y == 3);
    _RS_ASSERT(i64_4.z == 4);
    _RS_ASSERT(i64_4.w == 5);

    rsDebug("Testing U64", 0);
    _RS_ASSERT(u64_2.x == 2);
    _RS_ASSERT(u64_2.y == 3);

    _RS_ASSERT(u64_3.x == 2);
    _RS_ASSERT(u64_3.y == 3);
    _RS_ASSERT(u64_3.z == 4);

    _RS_ASSERT(u64_4.x == 2);
    _RS_ASSERT(u64_4.y == 3);
    _RS_ASSERT(u64_4.z == 4);
    _RS_ASSERT(u64_4.w == 5);

    if (failed) {
        rsDebug("test_vector FAILED", 0);
    }
    else {
        rsDebug("test_vector PASSED", 0);
    }

    return failed;
}

void vector_test() {
    bool failed = false;
    failed |= test_vector_types();

    if (failed) {
        rsSendToClientBlocking(RS_MSG_TEST_FAILED);
    }
    else {
        rsSendToClientBlocking(RS_MSG_TEST_PASSED);
    }
}