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 19rs_allocation A; 20rs_allocation B; 21uint32_t gDimX, gDimY; 22static bool failed = false; 23 24void init_vars(int *out) { 25 *out = 7; 26} 27 28void xform(const int *in, int *out, rs_kernel_context context, uint32_t x, uint32_t y) { 29 if (!_RS_ASSERT_EQU(*in, 7)) 30 rsDebug("xform at x, y", x, y); 31 uint32_t dimX = rsGetDimX(context); 32 uint32_t dimY = rsGetDimY(context); 33 _RS_ASSERT_EQU(dimX, gDimX); 34 _RS_ASSERT_EQU(dimY, gDimY); 35 *out = *in + x + dimX * y; 36} 37 38static bool test_xform_output() { 39 bool failed = false; 40 int i, j; 41 42 for (i = 0; i < gDimX; i++) { 43 for (j = 0; j < gDimY; j++) { 44 int bElt = rsGetElementAt_int(B, i, j); 45 int aElt = rsGetElementAt_int(A, i, j); 46 if (!_RS_ASSERT_EQU(bElt, (aElt + i + gDimX * j))) 47 rsDebug("test_xform_output at i, j", i, j); 48 } 49 } 50 51 if (failed) { 52 rsDebug("kernel2d (old style) test_xform_output FAILED", 0); 53 } 54 else { 55 rsDebug("kernel2d (old style) test_xform_output PASSED", 0); 56 } 57 58 return failed; 59} 60 61void verify_xform() { 62 failed |= test_xform_output(); 63} 64 65void kernel_test() { 66 if (failed) { 67 rsSendToClientBlocking(RS_MSG_TEST_FAILED); 68 } 69 else { 70 rsSendToClientBlocking(RS_MSG_TEST_PASSED); 71 } 72} 73