1 /* 2 * Copyright (C) 2014 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 #pragma version(1) 18 #pragma rs java_package_name(android.renderscript.cts) 19 20 rs_allocation gAllocIn; 21 rs_allocation gAllocOut; 22 23 24 25 #define COPY_2D(ty) \ 26 void __attribute__((kernel)) copy2d_##ty(int xy_v) { \ 27 int lx = xy_v & 0xff; \ 28 int vecsize = (xy_v & 0xff0000) >> 16; \ 29 switch(vecsize) { \ 30 case 1: { \ 31 ty i = rsGetElementAt_##ty(gAllocIn, lx); \ 32 rsSetElementAt_##ty(gAllocOut, i, lx); \ 33 } break; \ 34 case 2: { \ 35 ty##2 i = rsAllocationVLoadX_##ty##2(gAllocIn, lx); \ 36 rsAllocationVStoreX_##ty##2(gAllocOut, i, lx); \ 37 } break; \ 38 case 3: { \ 39 ty##3 i = rsAllocationVLoadX_##ty##3(gAllocIn, lx); \ 40 rsAllocationVStoreX_##ty##3(gAllocOut, i, lx); \ 41 } break; \ 42 case 4: { \ 43 ty##4 i = rsAllocationVLoadX_##ty##4(gAllocIn, lx); \ 44 rsAllocationVStoreX_##ty##4(gAllocOut, i, lx); \ 45 } break; \ 46 } \ 47 } 48 49 COPY_2D(char) 50 COPY_2D(uchar) 51 COPY_2D(short) 52 COPY_2D(ushort) 53 COPY_2D(int) 54 COPY_2D(uint) 55 COPY_2D(long) 56 COPY_2D(ulong) 57 58 COPY_2D(float) 59 COPY_2D(double) 60 61