/** @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; }
protected void createWalk(int vsize) { // We do a random copy order to attempt to get multiple threads // reading and writing the same cache line // We could do this as a simple walk but that would likely miss // some caching issues. final int tw = gCount / vsize; int tmp[] = new int[tw]; boolean b[] = new boolean[tw]; int toCopy = tw; int i = 0; while (toCopy > 0) { int x = random.nextInt(tw); while ((x < tw) && b[x]) { x++; if (x >= tw) { x = 0; } } b[x] = true; toCopy--; // android.util.Log.v("rs", "walk " + i + ", " + x); tmp[i++] = x; } walkAlloc = Allocation.createSized(mRS, Element.I32(mRS), tw); walkAlloc.copy1DRangeFrom(0, tw, tmp); }