1/* 2 * Copyright (C) 2013 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 17package com.android.rs.test_compat; 18 19import android.content.Context; 20import android.content.res.Resources; 21import android.support.v8.renderscript.*; 22import android.util.Log; 23 24public class UT_kernel extends UnitTest { 25 private Resources mRes; 26 private Allocation A; 27 private Allocation B; 28 29 protected UT_kernel(RSTestCore rstc, Resources res, Context ctx) { 30 super(rstc, "Kernels (pass-by-value)", ctx); 31 mRes = res; 32 } 33 34 private void initializeGlobals(RenderScript RS, ScriptC_kernel s) { 35 Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS)); 36 int X = 5; 37 s.set_dimX(X); 38 typeBuilder.setX(X); 39 A = Allocation.createTyped(RS, typeBuilder.create()); 40 s.bind_ain(A); 41 B = Allocation.createTyped(RS, typeBuilder.create()); 42 s.bind_aout(B); 43 44 return; 45 } 46 47 public void run() { 48 RenderScript pRS = RenderScript.create(mCtx); 49 ScriptC_kernel s = new ScriptC_kernel(pRS); 50 pRS.setMessageHandler(mRsMessage); 51 initializeGlobals(pRS, s); 52 s.forEach_init_vars(A); 53 s.forEach_root(A, B); 54 s.invoke_verify_root(); 55 s.invoke_kernel_test(); 56 pRS.finish(); 57 waitForMessage(); 58 pRS.destroy(); 59 } 60} 61