UT_kernel3d.java revision c619e32616d4f6f02fb4bc74a6e6907270fc7c4e
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; 20c619e32616d4f6f02fb4bc74a6e6907270fc7c4eMiao Wangimport android.renderscript.Allocation; 21c619e32616d4f6f02fb4bc74a6e6907270fc7c4eMiao Wangimport android.renderscript.Element; 22c619e32616d4f6f02fb4bc74a6e6907270fc7c4eMiao Wangimport android.renderscript.RenderScript; 23c619e32616d4f6f02fb4bc74a6e6907270fc7c4eMiao Wangimport android.renderscript.Type; 24dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross 25dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Grosspublic class UT_kernel3d extends UnitTest { 26dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross private Allocation A; 27dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross private Allocation B; 28dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross 2933709e1da5e801ca331642c25a61847ced8539e8Miao Wang protected UT_kernel3d(RSTestCore rstc, Context ctx) { 30dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross super(rstc, "Kernel 3d (pass-by-value)", ctx); 31dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross } 32dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross 33dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross private void initializeGlobals(RenderScript RS, ScriptC_kernel3d s) { 34dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS)); 35dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross int X = 2; 36dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross s.set_gDimX(X); 37dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross typeBuilder.setX(X); 38dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross int Y = 5; 39dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross s.set_gDimY(Y); 40dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross typeBuilder.setY(Y); 41dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross int Z = 11; 42dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross s.set_gDimZ(Z); 43dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross typeBuilder.setZ(Z); 44dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross 45dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross A = Allocation.createTyped(RS, typeBuilder.create()); 46dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross s.set_A(A); 47dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross B = Allocation.createTyped(RS, typeBuilder.create()); 48dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross s.set_B(B); 49dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross return; 50dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross } 51dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross 52dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross public void run() { 53dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross RenderScript pRS = RenderScript.create(mCtx); 54dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross ScriptC_kernel3d s = new ScriptC_kernel3d(pRS); 55dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross pRS.setMessageHandler(mRsMessage); 56dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross initializeGlobals(pRS, s); 57dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross s.forEach_init_vars(A); 58dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross s.forEach_root(A, B); 59dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross s.invoke_verify_root(); 60dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross s.invoke_kernel_test(); 61dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross pRS.finish(); 62dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross waitForMessage(); 63dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross pRS.destroy(); 64dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross } 65dced5c96bc53c45a1aac782ea9bd738b0d50fd09David Gross} 66