private void initializeGlobals(RenderScript RS, ScriptC_kernel s) { Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS)); int X = 5; s.set_dimX(X); typeBuilder.setX(X); A = Allocation.createTyped(RS, typeBuilder.create()); s.bind_ain(A); B = Allocation.createTyped(RS, typeBuilder.create()); s.bind_aout(B); return; }
/** @deprecated in API 16 Create a Mesh object from the current state of the builder */ public Mesh create() { mRS.validate(); long[] vtx = new long[mVertexTypeCount]; long[] idx = new long[mIndexTypes.size()]; int[] prim = new int[mIndexTypes.size()]; Allocation[] vertexBuffers = new Allocation[mVertexTypeCount]; Allocation[] indexBuffers = new Allocation[mIndexTypes.size()]; Primitive[] primitives = new Primitive[mIndexTypes.size()]; for (int ct = 0; ct < mVertexTypeCount; ct++) { Allocation alloc = null; Entry entry = mVertexTypes[ct]; if (entry.t != null) { alloc = Allocation.createTyped(mRS, entry.t, mUsage); } else if (entry.e != null) { alloc = Allocation.createSized(mRS, entry.e, entry.size, mUsage); } else { // Should never happen because the builder will always set one throw new IllegalStateException("Builder corrupt, no valid element in entry."); } vertexBuffers[ct] = alloc; vtx[ct] = alloc.getID(mRS); } for (int ct = 0; ct < mIndexTypes.size(); ct++) { Allocation alloc = null; Entry entry = (Entry) mIndexTypes.elementAt(ct); if (entry.t != null) { alloc = Allocation.createTyped(mRS, entry.t, mUsage); } else if (entry.e != null) { alloc = Allocation.createSized(mRS, entry.e, entry.size, mUsage); } else { // Should never happen because the builder will always set one throw new IllegalStateException("Builder corrupt, no valid element in entry."); } long allocID = (alloc == null) ? 0 : alloc.getID(mRS); indexBuffers[ct] = alloc; primitives[ct] = entry.prim; idx[ct] = allocID; prim[ct] = entry.prim.mID; } long id = mRS.nMeshCreate(vtx, idx, prim); Mesh newMesh = new Mesh(id, mRS); newMesh.mVertexBuffers = vertexBuffers; newMesh.mIndexBuffers = indexBuffers; newMesh.mPrimitives = primitives; return newMesh; }
private void testSetup(Element e) { int vs = e.getVectorSize(); if (vs == 3) { vs = 4; } createWalk(vs); Type t1 = Type.createX(mRS, e, gWidth * gHeight * gDepth / vs); in1DAlloc = Allocation.createTyped(mRS, t1); out1DAlloc = Allocation.createTyped(mRS, t1); script.set_gAlloc1DIn(in1DAlloc); script.set_gAlloc1DOut(out1DAlloc); scriptRelaxed.set_gAlloc1DIn(in1DAlloc); scriptRelaxed.set_gAlloc1DOut(out1DAlloc); Type t2 = Type.createXY(mRS, e, gWidth / vs, gHeight * gDepth); in2DAlloc = Allocation.createTyped(mRS, t2); out2DAlloc = Allocation.createTyped(mRS, t2); script.set_gAlloc2DIn(in2DAlloc); script.set_gAlloc2DOut(out2DAlloc); scriptRelaxed.set_gAlloc2DIn(in2DAlloc); scriptRelaxed.set_gAlloc2DOut(out2DAlloc); Type t3 = Type.createXYZ(mRS, e, gWidth / vs, gHeight, gDepth); in3DAlloc = Allocation.createTyped(mRS, t3); out3DAlloc = Allocation.createTyped(mRS, t3); script.set_gAlloc3DIn(in3DAlloc); script.set_gAlloc3DOut(out3DAlloc); scriptRelaxed.set_gAlloc3DIn(in3DAlloc); scriptRelaxed.set_gAlloc3DOut(out3DAlloc); }