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, gDimY, gDimZ;
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, uint32_t y, uint32_t z) {
31    if (!_RS_ASSERT_EQU(ain, 7))
32        rsDebug("root at x, y, z", x, y, z);
33    uint32_t dimX = rsGetDimX(context);
34    uint32_t dimY = rsGetDimY(context);
35    uint32_t dimZ = rsGetDimZ(context);
36    _RS_ASSERT_EQU(dimX, gDimX);
37    _RS_ASSERT_EQU(dimY, gDimY);
38    _RS_ASSERT_EQU(dimZ, gDimZ);
39    return ain + x + dimX * y + dimX * dimY * z;
40}
41
42static bool test_root_output() {
43    bool failed = false;
44    int i, j, k;
45
46    for (i = 0; i < gDimX; i++) {
47        for (j = 0; j < gDimY; j++) {
48            for (k = 0; k < gDimZ; k++) {
49                int bElt = rsGetElementAt_int(B, i, j, k);
50                int aElt = rsGetElementAt_int(A, i, j, k);
51                if (!_RS_ASSERT_EQU(bElt, (aElt + i + gDimX * j + gDimX * gDimY * k)))
52                    rsDebug("test_root_output at i, j, k", i, j, k);
53            }
54        }
55    }
56
57    if (failed) {
58        rsDebug("kernel3d test_root_output FAILED", 0);
59    }
60    else {
61        rsDebug("kernel3d test_root_output PASSED", 0);
62    }
63
64    return failed;
65}
66
67void verify_root() {
68    failed |= test_root_output();
69}
70
71void kernel_test() {
72    if (failed) {
73        rsSendToClientBlocking(RS_MSG_TEST_FAILED);
74    }
75    else {
76        rsSendToClientBlocking(RS_MSG_TEST_PASSED);
77    }
78}
79