1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include "shared.rsh" 18 19 // Testing vector types 20 float2 f2 = { 1.0f, 2.0f }; 21 float3 f3 = { 1.0f, 2.0f, 3.0f }; 22 float4 f4 = { 1.0f, 2.0f, 3.0f, 4.0f }; 23 24 double2 d2 = { 1.0, 2.0 }; 25 double3 d3 = { 1.0, 2.0, 3.0 }; 26 double4 d4 = { 1.0, 2.0, 3.0, 4.0 }; 27 28 char2 i8_2 = { 1, 2 }; 29 char3 i8_3 = { 1, 2, 3 }; 30 char4 i8_4 = { 1, 2, 3, 4 }; 31 32 uchar2 u8_2 = { 1, 2 }; 33 uchar3 u8_3 = { 1, 2, 3 }; 34 uchar4 u8_4 = { 1, 2, 3, 4 }; 35 36 short2 i16_2 = { 1, 2 }; 37 short3 i16_3 = { 1, 2, 3 }; 38 short4 i16_4 = { 1, 2, 3, 4 }; 39 40 ushort2 u16_2 = { 1, 2 }; 41 ushort3 u16_3 = { 1, 2, 3 }; 42 ushort4 u16_4 = { 1, 2, 3, 4 }; 43 44 int2 i32_2 = { 1, 2 }; 45 int3 i32_3 = { 1, 2, 3 }; 46 int4 i32_4 = { 1, 2, 3, 4 }; 47 48 uint2 u32_2 = { 1, 2 }; 49 uint3 u32_3 = { 1, 2, 3 }; 50 uint4 u32_4 = { 1, 2, 3, 4 }; 51 52 long2 i64_2 = { 1, 2 }; 53 long3 i64_3 = { 1, 2, 3 }; 54 long4 i64_4 = { 1, 2, 3, 4 }; 55 56 ulong2 u64_2 = { 1, 2 }; 57 ulong3 u64_3 = { 1, 2, 3 }; 58 ulong4 u64_4 = { 1, 2, 3, 4 }; 59 60 static bool test_vector_types() { 61 bool failed = false; 62 63 rsDebug("Testing F32", 0); 64 _RS_ASSERT(f2.x == 2.99f); 65 _RS_ASSERT(f2.y == 3.99f); 66 67 _RS_ASSERT(f3.x == 2.99f); 68 _RS_ASSERT(f3.y == 3.99f); 69 _RS_ASSERT(f3.z == 4.99f); 70 71 _RS_ASSERT(f4.x == 2.99f); 72 _RS_ASSERT(f4.y == 3.99f); 73 _RS_ASSERT(f4.z == 4.99f); 74 _RS_ASSERT(f4.w == 5.99f); 75 76 rsDebug("Testing F64", 0); 77 _RS_ASSERT(d2.x == 2.99); 78 _RS_ASSERT(d2.y == 3.99); 79 80 _RS_ASSERT(d3.x == 2.99); 81 _RS_ASSERT(d3.y == 3.99); 82 _RS_ASSERT(d3.z == 4.99); 83 84 _RS_ASSERT(d4.x == 2.99); 85 _RS_ASSERT(d4.y == 3.99); 86 _RS_ASSERT(d4.z == 4.99); 87 _RS_ASSERT(d4.w == 5.99); 88 89 rsDebug("Testing I8", 0); 90 _RS_ASSERT(i8_2.x == 2); 91 _RS_ASSERT(i8_2.y == 3); 92 93 _RS_ASSERT(i8_3.x == 2); 94 _RS_ASSERT(i8_3.y == 3); 95 _RS_ASSERT(i8_3.z == 4); 96 97 _RS_ASSERT(i8_4.x == 2); 98 _RS_ASSERT(i8_4.y == 3); 99 _RS_ASSERT(i8_4.z == 4); 100 _RS_ASSERT(i8_4.w == 5); 101 102 rsDebug("Testing U8", 0); 103 _RS_ASSERT(u8_2.x == 2); 104 _RS_ASSERT(u8_2.y == 3); 105 106 _RS_ASSERT(u8_3.x == 2); 107 _RS_ASSERT(u8_3.y == 3); 108 _RS_ASSERT(u8_3.z == 4); 109 110 _RS_ASSERT(u8_4.x == 2); 111 _RS_ASSERT(u8_4.y == 3); 112 _RS_ASSERT(u8_4.z == 4); 113 _RS_ASSERT(u8_4.w == 5); 114 115 rsDebug("Testing I16", 0); 116 _RS_ASSERT(i16_2.x == 2); 117 _RS_ASSERT(i16_2.y == 3); 118 119 _RS_ASSERT(i16_3.x == 2); 120 _RS_ASSERT(i16_3.y == 3); 121 _RS_ASSERT(i16_3.z == 4); 122 123 _RS_ASSERT(i16_4.x == 2); 124 _RS_ASSERT(i16_4.y == 3); 125 _RS_ASSERT(i16_4.z == 4); 126 _RS_ASSERT(i16_4.w == 5); 127 128 rsDebug("Testing U16", 0); 129 _RS_ASSERT(u16_2.x == 2); 130 _RS_ASSERT(u16_2.y == 3); 131 132 _RS_ASSERT(u16_3.x == 2); 133 _RS_ASSERT(u16_3.y == 3); 134 _RS_ASSERT(u16_3.z == 4); 135 136 _RS_ASSERT(u16_4.x == 2); 137 _RS_ASSERT(u16_4.y == 3); 138 _RS_ASSERT(u16_4.z == 4); 139 _RS_ASSERT(u16_4.w == 5); 140 141 rsDebug("Testing I32", 0); 142 _RS_ASSERT(i32_2.x == 2); 143 _RS_ASSERT(i32_2.y == 3); 144 145 _RS_ASSERT(i32_3.x == 2); 146 _RS_ASSERT(i32_3.y == 3); 147 _RS_ASSERT(i32_3.z == 4); 148 149 _RS_ASSERT(i32_4.x == 2); 150 _RS_ASSERT(i32_4.y == 3); 151 _RS_ASSERT(i32_4.z == 4); 152 _RS_ASSERT(i32_4.w == 5); 153 154 rsDebug("Testing U32", 0); 155 _RS_ASSERT(u32_2.x == 2); 156 _RS_ASSERT(u32_2.y == 3); 157 158 _RS_ASSERT(u32_3.x == 2); 159 _RS_ASSERT(u32_3.y == 3); 160 _RS_ASSERT(u32_3.z == 4); 161 162 _RS_ASSERT(u32_4.x == 2); 163 _RS_ASSERT(u32_4.y == 3); 164 _RS_ASSERT(u32_4.z == 4); 165 _RS_ASSERT(u32_4.w == 5); 166 167 rsDebug("Testing I64", 0); 168 _RS_ASSERT(i64_2.x == 2); 169 _RS_ASSERT(i64_2.y == 3); 170 171 _RS_ASSERT(i64_3.x == 2); 172 _RS_ASSERT(i64_3.y == 3); 173 _RS_ASSERT(i64_3.z == 4); 174 175 _RS_ASSERT(i64_4.x == 2); 176 _RS_ASSERT(i64_4.y == 3); 177 _RS_ASSERT(i64_4.z == 4); 178 _RS_ASSERT(i64_4.w == 5); 179 180 rsDebug("Testing U64", 0); 181 _RS_ASSERT(u64_2.x == 2); 182 _RS_ASSERT(u64_2.y == 3); 183 184 _RS_ASSERT(u64_3.x == 2); 185 _RS_ASSERT(u64_3.y == 3); 186 _RS_ASSERT(u64_3.z == 4); 187 188 _RS_ASSERT(u64_4.x == 2); 189 _RS_ASSERT(u64_4.y == 3); 190 _RS_ASSERT(u64_4.z == 4); 191 _RS_ASSERT(u64_4.w == 5); 192 193 if (failed) { 194 rsDebug("test_vector FAILED", 0); 195 } 196 else { 197 rsDebug("test_vector PASSED", 0); 198 } 199 200 return failed; 201 } 202 203 void vector_test() { 204 bool failed = false; 205 failed |= test_vector_types(); 206 207 if (failed) { 208 rsSendToClientBlocking(RS_MSG_TEST_FAILED); 209 } 210 else { 211 rsSendToClientBlocking(RS_MSG_TEST_PASSED); 212 } 213 } 214 215