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 half gHalf; 20 half2 gHalf2; 21 half3 gHalf3; 22 half4 gHalf4; 23 24 static bool failed = false; 25 26 void validateHalf(half h) { 27 _RS_ASSERT_EQU((float) h, 10.f); 28 } 29 30 void validateHalf2(half2 h2) { 31 _RS_ASSERT_EQU((float) h2.x, 10.f); 32 _RS_ASSERT_EQU((float) h2.y, 11.f); 33 } 34 35 void validateHalf3(half3 h3) { 36 _RS_ASSERT_EQU((float) h3.x, 10.f); 37 _RS_ASSERT_EQU((float) h3.y, 11.f); 38 _RS_ASSERT_EQU((float) h3.z, -12.f); 39 } 40 41 void validateHalf4(half4 h4) { 42 _RS_ASSERT_EQU((float) h4.x, 10.f); 43 _RS_ASSERT_EQU((float) h4.y, 11.f); 44 _RS_ASSERT_EQU((float) h4.z, -12.f); 45 _RS_ASSERT_EQU((float) h4.w, -13.f); 46 } 47 48 void test(half h, half2 h2, half3 h3, half4 h4) { 49 validateHalf(gHalf); 50 validateHalf2(gHalf2); 51 validateHalf3(gHalf3); 52 validateHalf4(gHalf4); 53 54 validateHalf(h); 55 validateHalf2(h2); 56 validateHalf3(h3); 57 validateHalf4(h4); 58 59 if (failed) { 60 rsSendToClientBlocking(RS_MSG_TEST_FAILED); 61 } 62 else { 63 rsSendToClientBlocking(RS_MSG_TEST_PASSED); 64 } 65 } 66