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 int *a; 20 int dimX; 21 int dimY; 22 int dimZ; 23 24 rs_allocation aRaw; 25 rs_allocation aFaces; 26 rs_allocation aLOD; 27 rs_allocation aFacesLOD; 28 29 void root(int *o, uint32_t x) { 30 *o = x; 31 } 32 33 static bool test_alloc_dims() { 34 bool failed = false; 35 int i; 36 37 _RS_ASSERT(rsAllocationGetDimX(aRaw) == dimX); 38 // Since we are binding with our A allocation, it has 0 Y/Z dimensions. 39 _RS_ASSERT(rsAllocationGetDimY(aRaw) == 0); 40 _RS_ASSERT(rsAllocationGetDimZ(aRaw) == 0); 41 42 // Test 1D addressing 43 for (i = 0; i < dimX; i++) { 44 rsDebug("Verifying ", i); 45 const void *p = rsGetElementAt(aRaw, i); 46 int val = *(const int *)p; 47 _RS_ASSERT(val == i); 48 } 49 50 _RS_ASSERT(rsAllocationGetDimX(aFaces) == dimX); 51 _RS_ASSERT(rsAllocationGetDimY(aFaces) == dimY); 52 _RS_ASSERT(rsAllocationGetDimZ(aFaces) == dimZ); 53 _RS_ASSERT(rsAllocationGetDimFaces(aFaces) != 0); 54 _RS_ASSERT(rsAllocationGetDimLOD(aFaces) == 0); 55 56 _RS_ASSERT(rsAllocationGetDimX(aLOD) == dimX); 57 _RS_ASSERT(rsAllocationGetDimY(aLOD) == dimY); 58 _RS_ASSERT(rsAllocationGetDimZ(aLOD) == dimZ); 59 _RS_ASSERT(rsAllocationGetDimFaces(aLOD) == 0); 60 _RS_ASSERT(rsAllocationGetDimLOD(aLOD) != 0); 61 62 _RS_ASSERT(rsAllocationGetDimX(aFacesLOD) == dimX); 63 _RS_ASSERT(rsAllocationGetDimY(aFacesLOD) == dimY); 64 _RS_ASSERT(rsAllocationGetDimZ(aFacesLOD) == dimZ); 65 _RS_ASSERT(rsAllocationGetDimFaces(aFacesLOD) != 0); 66 _RS_ASSERT(rsAllocationGetDimLOD(aFacesLOD) != 0); 67 68 if (failed) { 69 rsDebug("test_alloc_dims FAILED", 0); 70 } 71 else { 72 rsDebug("test_alloc_dims PASSED", 0); 73 } 74 75 return failed; 76 } 77 78 void alloc_test() { 79 bool failed = false; 80 failed |= test_alloc_dims(); 81 82 if (failed) { 83 rsSendToClientBlocking(RS_MSG_TEST_FAILED); 84 } 85 else { 86 rsSendToClientBlocking(RS_MSG_TEST_PASSED); 87 } 88 } 89 90