1// This file is automatically generated from 2// frameworks/rs/tests/java_api/RSUnitTests/RSUnitTests.py 3/* 4 * Copyright (C) 2017 The Android Open Source Project 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19#include "shared.rsh" 20 21rs_allocation A; 22rs_allocation B; 23uint32_t gDimX; 24static bool failed = false; 25 26void init_vars(int *out) { 27 *out = 7; 28} 29 30int RS_KERNEL root(int ain, rs_kernel_context context, uint32_t x) { 31 _RS_ASSERT_EQU(rsGetArray0(context), 0); 32 _RS_ASSERT_EQU(rsGetArray1(context), 0); 33 _RS_ASSERT_EQU(rsGetArray2(context), 0); 34 _RS_ASSERT_EQU(rsGetArray3(context), 0); 35 _RS_ASSERT_EQU(rsGetFace(context), RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X); 36 _RS_ASSERT_EQU(rsGetLod(context), 0); 37 38 _RS_ASSERT_EQU(rsGetDimY(context), 0); 39 _RS_ASSERT_EQU(rsGetDimZ(context), 0); 40 _RS_ASSERT_EQU(rsGetDimArray0(context), 0); 41 _RS_ASSERT_EQU(rsGetDimArray1(context), 0); 42 _RS_ASSERT_EQU(rsGetDimArray2(context), 0); 43 _RS_ASSERT_EQU(rsGetDimArray3(context), 0); 44 _RS_ASSERT_EQU(rsGetDimHasFaces(context), false); 45 _RS_ASSERT_EQU(rsGetDimLod(context), 0); 46 47 if (!_RS_ASSERT_EQU(ain, 7)) 48 rsDebug("root at x", x); 49 uint32_t dimX = rsGetDimX(context); 50 _RS_ASSERT_EQU(dimX, gDimX); 51 return ain + x; 52} 53 54static bool test_root_output() { 55 bool failed = false; 56 int i; 57 58 for (i = 0; i < gDimX; i++) { 59 int bElt = rsGetElementAt_int(B, i); 60 int aElt = rsGetElementAt_int(A, i); 61 if (!_RS_ASSERT_EQU(bElt, (aElt + i))) 62 rsDebug("test_root_output at i", i); 63 } 64 65 if (failed) { 66 rsDebug("ctxt_default test_root_output FAILED", 0); 67 } 68 else { 69 rsDebug("ctxt_default test_root_output PASSED", 0); 70 } 71 72 return failed; 73} 74 75void verify_root() { 76 failed |= test_root_output(); 77} 78 79void kernel_test() { 80 if (failed) { 81 rsSendToClientBlocking(RS_MSG_TEST_FAILED); 82 } 83 else { 84 rsSendToClientBlocking(RS_MSG_TEST_PASSED); 85 } 86} 87