UT_kernel3d.java revision dced5c96bc53c45a1aac782ea9bd738b0d50fd09
1dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross/* 2dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross * Copyright (C) 2015 The Android Open Source Project 3dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross * 4dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross * Licensed under the Apache License, Version 2.0 (the "License"); 5dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross * you may not use this file except in compliance with the License. 6dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross * You may obtain a copy of the License at 7dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross * 8dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross * http://www.apache.org/licenses/LICENSE-2.0 9dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross * 10dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross * Unless required by applicable law or agreed to in writing, software 11dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross * distributed under the License is distributed on an "AS IS" BASIS, 12dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross * See the License for the specific language governing permissions and 14dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross * limitations under the License. 15dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross */ 16dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross 17dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Grosspackage com.android.rs.test; 18dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross 19dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Grossimport android.content.Context; 20dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Grossimport android.content.res.Resources; 21dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Grossimport android.renderscript.*; 22dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Grossimport android.util.Log; 23dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross 24dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Grosspublic class UT_kernel3d extends UnitTest { 25dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross private Resources mRes; 26dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross private Allocation A; 27dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross private Allocation B; 28dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross 29dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross protected UT_kernel3d(RSTestCore rstc, Resources res, Context ctx) { 30dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross super(rstc, "Kernel 3d (pass-by-value)", ctx); 31dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross mRes = res; 32dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross } 33dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross 34dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross private void initializeGlobals(RenderScript RS, ScriptC_kernel3d s) { 35dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS)); 36dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross int X = 2; 37dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross s.set_gDimX(X); 38dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross typeBuilder.setX(X); 39dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross int Y = 5; 40dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross s.set_gDimY(Y); 41dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross typeBuilder.setY(Y); 42dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross int Z = 11; 43dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross s.set_gDimZ(Z); 44dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross typeBuilder.setZ(Z); 45dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross 46dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross A = Allocation.createTyped(RS, typeBuilder.create()); 47dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross s.set_A(A); 48dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross B = Allocation.createTyped(RS, typeBuilder.create()); 49dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross s.set_B(B); 50dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross return; 51dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross } 52dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross 53dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross public void run() { 54dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross RenderScript pRS = RenderScript.create(mCtx); 55dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross ScriptC_kernel3d s = new ScriptC_kernel3d(pRS); 56dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross pRS.setMessageHandler(mRsMessage); 57dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross initializeGlobals(pRS, s); 58dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross s.forEach_init_vars(A); 59dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross s.forEach_root(A, B); 60dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross s.invoke_verify_root(); 61dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross s.invoke_kernel_test(); 62dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross pRS.finish(); 63dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross waitForMessage(); 64dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross pRS.destroy(); 65dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross } 66dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross} 67