blob: 826225a70d8662fd7ebf91e581ff89a9e46eca0b [file] [log] [blame]
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -07001/*
Jason Samse619de62012-05-08 18:40:58 -07002 * Copyright (C) 2008-2012 The Android Open Source Project
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -07003 *
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 android.renderscript;
18
Artur Satayev2ebb31c2020-01-08 12:24:36 +000019import android.compat.annotation.UnsupportedAppUsage;
20
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -070021import java.util.Vector;
22
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -070023/**
Tim Murraya9084222013-04-05 22:06:43 +000024 * @hide
Jason Samsd4ca9912012-05-08 19:02:07 -070025 * @deprecated in API 16
Robert Ly11518ac2011-02-09 13:57:06 -080026 * <p>This class is a container for geometric data displayed with
Tim Murrayc11e25c2013-04-09 11:01:01 -070027 * RenderScript. Internally, a mesh is a collection of allocations that
Alex Sakhartchoukdf272022011-01-09 11:34:03 -080028 * represent vertex data (positions, normals, texture
Robert Ly11518ac2011-02-09 13:57:06 -080029 * coordinates) and index data such as triangles and lines. </p>
30 * <p>
31 * Vertex data could either be interleaved within one
32 * allocation that is provided separately, as multiple allocation
33 * objects, or done as a combination of both. When a
Alex Sakhartchoukdf272022011-01-09 11:34:03 -080034 * vertex channel name matches an input in the vertex program,
Tim Murrayc11e25c2013-04-09 11:01:01 -070035 * RenderScript automatically connects the two together.
Robert Ly11518ac2011-02-09 13:57:06 -080036 * </p>
37 * <p>
38 * Parts of the mesh can be rendered with either explicit
Alex Sakhartchoukdf272022011-01-09 11:34:03 -080039 * index sets or primitive types.
Robert Ly11518ac2011-02-09 13:57:06 -080040 * </p>
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -070041 **/
42public class Mesh extends BaseObj {
43
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -070044 /**
Jason Samsd4ca9912012-05-08 19:02:07 -070045 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -080046 * Describes the way mesh vertex data is interpreted when rendering
47 *
48 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -080049 public enum Primitive {
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -070050 /**
Jason Samsd4ca9912012-05-08 19:02:07 -070051 * @deprecated in API 16
Alex Sakhartchoukec0d3352011-01-17 15:23:22 -080052 * Vertex data will be rendered as a series of points
53 */
Mathew Inwood15324472018-08-06 11:18:49 +010054 @UnsupportedAppUsage
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -080055 POINT (0),
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -070056 /**
Jason Samsd4ca9912012-05-08 19:02:07 -070057 * @deprecated in API 16
Alex Sakhartchoukec0d3352011-01-17 15:23:22 -080058 * Vertex pairs will be rendered as lines
59 */
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -080060 LINE (1),
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -070061 /**
Jason Samsd4ca9912012-05-08 19:02:07 -070062 * @deprecated in API 16
Alex Sakhartchoukec0d3352011-01-17 15:23:22 -080063 * Vertex data will be rendered as a connected line strip
64 */
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -080065 LINE_STRIP (2),
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -070066 /**
Jason Samsd4ca9912012-05-08 19:02:07 -070067 * @deprecated in API 16
Alex Sakhartchoukec0d3352011-01-17 15:23:22 -080068 * Vertices will be rendered as individual triangles
69 */
Mathew Inwood15324472018-08-06 11:18:49 +010070 @UnsupportedAppUsage
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -080071 TRIANGLE (3),
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -070072 /**
Jason Samsd4ca9912012-05-08 19:02:07 -070073 * @deprecated in API 16
Alex Sakhartchoukec0d3352011-01-17 15:23:22 -080074 * Vertices will be rendered as a connected triangle strip
75 * defined by the first three vertices with each additional
76 * triangle defined by a new vertex
77 */
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -080078 TRIANGLE_STRIP (4),
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -070079 /**
Jason Samsd4ca9912012-05-08 19:02:07 -070080 * @deprecated in API 16
Alex Sakhartchoukec0d3352011-01-17 15:23:22 -080081 * Vertices will be rendered as a sequence of triangles that all
82 * share first vertex as the origin
83 */
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -080084 TRIANGLE_FAN (5);
85
86 int mID;
87 Primitive(int id) {
88 mID = id;
89 }
90 }
91
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -070092 Allocation[] mVertexBuffers;
93 Allocation[] mIndexBuffers;
94 Primitive[] mPrimitives;
95
Tim Murray460a0492013-11-19 12:45:54 -080096 Mesh(long id, RenderScript rs) {
Alex Sakhartchouk0de94442010-08-11 14:41:28 -070097 super(id, rs);
Yang Nieb4dd082016-03-24 09:40:32 -070098 guard.open("destroy");
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -070099 }
100
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700101 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700102 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800103 * @return number of allocations containing vertex data
104 *
105 **/
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700106 public int getVertexAllocationCount() {
107 if(mVertexBuffers == null) {
108 return 0;
109 }
110 return mVertexBuffers.length;
111 }
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700112 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700113 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800114 * @param slot index in the list of allocations to return
115 * @return vertex data allocation at the given index
116 *
117 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100118 @UnsupportedAppUsage
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700119 public Allocation getVertexAllocation(int slot) {
120 return mVertexBuffers[slot];
121 }
122
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700123 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700124 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800125 * @return number of primitives or index sets in the mesh
126 *
127 **/
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700128 public int getPrimitiveCount() {
129 if(mIndexBuffers == null) {
130 return 0;
131 }
132 return mIndexBuffers.length;
133 }
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800134
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700135 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700136 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800137 * @param slot locaton within the list of index set allocation
138 * @return allocation containing primtive index data or null if
139 * the index data is not specified explicitly
140 *
141 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800142 public Allocation getIndexSetAllocation(int slot) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700143 return mIndexBuffers[slot];
144 }
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700145 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700146 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800147 * @param slot locaiton within the list of index set primitives
148 * @return index set primitive type
149 *
150 **/
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700151 public Primitive getPrimitive(int slot) {
152 return mPrimitives[slot];
153 }
154
Alex Sakhartchouk80a4c2c2010-07-12 15:50:32 -0700155 @Override
156 void updateFromNative() {
Jason Sams06d69de2010-11-09 17:11:40 -0800157 super.updateFromNative();
Jason Samse07694b2012-04-03 15:36:36 -0700158 int vtxCount = mRS.nMeshGetVertexBufferCount(getID(mRS));
159 int idxCount = mRS.nMeshGetIndexCount(getID(mRS));
Alex Sakhartchouk80a4c2c2010-07-12 15:50:32 -0700160
Ashok Bhat98071552014-02-12 09:54:43 +0000161 long[] vtxIDs = new long[vtxCount];
162 long[] idxIDs = new long[idxCount];
Alex Sakhartchouk80a4c2c2010-07-12 15:50:32 -0700163 int[] primitives = new int[idxCount];
164
Jason Samse07694b2012-04-03 15:36:36 -0700165 mRS.nMeshGetVertices(getID(mRS), vtxIDs, vtxCount);
166 mRS.nMeshGetIndices(getID(mRS), idxIDs, primitives, idxCount);
Alex Sakhartchouk80a4c2c2010-07-12 15:50:32 -0700167
168 mVertexBuffers = new Allocation[vtxCount];
169 mIndexBuffers = new Allocation[idxCount];
170 mPrimitives = new Primitive[idxCount];
171
172 for(int i = 0; i < vtxCount; i ++) {
173 if(vtxIDs[i] != 0) {
Jason Samsd4b23b52010-12-13 15:32:35 -0800174 mVertexBuffers[i] = new Allocation(vtxIDs[i], mRS, null, Allocation.USAGE_SCRIPT);
Alex Sakhartchouk80a4c2c2010-07-12 15:50:32 -0700175 mVertexBuffers[i].updateFromNative();
176 }
177 }
178
179 for(int i = 0; i < idxCount; i ++) {
180 if(idxIDs[i] != 0) {
Jason Samsd4b23b52010-12-13 15:32:35 -0800181 mIndexBuffers[i] = new Allocation(idxIDs[i], mRS, null, Allocation.USAGE_SCRIPT);
Alex Sakhartchouk80a4c2c2010-07-12 15:50:32 -0700182 mIndexBuffers[i].updateFromNative();
183 }
184 mPrimitives[i] = Primitive.values()[primitives[i]];
185 }
186 }
187
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700188 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700189 * @deprecated in API 16
Robert Ly11518ac2011-02-09 13:57:06 -0800190 * Mesh builder object. It starts empty and requires you to
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800191 * add the types necessary to create vertex and index
Robert Ly11518ac2011-02-09 13:57:06 -0800192 * allocations.
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800193 *
194 */
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700195 public static class Builder {
196 RenderScript mRS;
Jason Samsd1952402010-12-20 12:55:28 -0800197 int mUsage;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700198
199 class Entry {
200 Type t;
201 Element e;
202 int size;
203 Primitive prim;
Jason Samsd1952402010-12-20 12:55:28 -0800204 int usage;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700205 }
206
207 int mVertexTypeCount;
208 Entry[] mVertexTypes;
209 Vector mIndexTypes;
210
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700211 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700212 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800213 * Creates builder object
Alex Sakhartchoukf5c876e2011-01-13 14:53:43 -0800214 * @param rs Context to which the mesh will belong.
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800215 * @param usage specifies how the mesh allocations are to be
216 * handled, whether they need to be uploaded to a
217 * buffer on the gpu, maintain a cpu copy, etc
218 */
Jason Samsd1952402010-12-20 12:55:28 -0800219 public Builder(RenderScript rs, int usage) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700220 mRS = rs;
Jason Samsd1952402010-12-20 12:55:28 -0800221 mUsage = usage;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700222 mVertexTypeCount = 0;
223 mVertexTypes = new Entry[16];
224 mIndexTypes = new Vector();
225 }
226
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700227 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700228 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800229 * @return internal index of the last vertex buffer type added to
230 * builder
231 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800232 public int getCurrentVertexTypeIndex() {
233 return mVertexTypeCount - 1;
234 }
235
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700236 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700237 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800238 * @return internal index of the last index set added to the
239 * builder
240 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800241 public int getCurrentIndexSetIndex() {
242 return mIndexTypes.size() - 1;
243 }
244
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700245 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700246 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800247 * Adds a vertex data type to the builder object
248 *
Stephen Hinesb11e3d22011-01-11 19:30:58 -0800249 * @param t type of the vertex data allocation to be created
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800250 *
251 * @return this
252 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800253 public Builder addVertexType(Type t) throws IllegalStateException {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700254 if (mVertexTypeCount >= mVertexTypes.length) {
255 throw new IllegalStateException("Max vertex types exceeded.");
256 }
257
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700258 mVertexTypes[mVertexTypeCount] = new Entry();
259 mVertexTypes[mVertexTypeCount].t = t;
260 mVertexTypes[mVertexTypeCount].e = null;
261 mVertexTypeCount++;
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800262 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700263 }
264
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700265 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700266 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800267 * Adds a vertex data type to the builder object
268 *
269 * @param e element describing the vertex data layout
270 * @param size number of elements in the buffer
271 *
272 * @return this
273 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800274 public Builder addVertexType(Element e, int size) throws IllegalStateException {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700275 if (mVertexTypeCount >= mVertexTypes.length) {
276 throw new IllegalStateException("Max vertex types exceeded.");
277 }
278
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700279 mVertexTypes[mVertexTypeCount] = new Entry();
280 mVertexTypes[mVertexTypeCount].t = null;
281 mVertexTypes[mVertexTypeCount].e = e;
282 mVertexTypes[mVertexTypeCount].size = size;
283 mVertexTypeCount++;
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800284 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700285 }
286
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700287 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700288 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800289 * Adds an index set data type to the builder object
290 *
291 * @param t type of the index set data, could be null
292 * @param p primitive type
293 *
294 * @return this
295 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800296 public Builder addIndexSetType(Type t, Primitive p) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700297 Entry indexType = new Entry();
298 indexType.t = t;
299 indexType.e = null;
300 indexType.size = 0;
301 indexType.prim = p;
302 mIndexTypes.addElement(indexType);
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800303 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700304 }
305
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700306 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700307 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800308 * Adds an index set primitive type to the builder object
309 *
310 * @param p primitive type
311 *
312 * @return this
313 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800314 public Builder addIndexSetType(Primitive p) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700315 Entry indexType = new Entry();
316 indexType.t = null;
317 indexType.e = null;
318 indexType.size = 0;
319 indexType.prim = p;
320 mIndexTypes.addElement(indexType);
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800321 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700322 }
323
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700324 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700325 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800326 * Adds an index set data type to the builder object
327 *
328 * @param e element describing the index set data layout
329 * @param size number of elements in the buffer
330 * @param p primitive type
331 *
332 * @return this
333 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800334 public Builder addIndexSetType(Element e, int size, Primitive p) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700335 Entry indexType = new Entry();
336 indexType.t = null;
337 indexType.e = e;
338 indexType.size = size;
339 indexType.prim = p;
340 mIndexTypes.addElement(indexType);
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800341 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700342 }
343
344 Type newType(Element e, int size) {
345 Type.Builder tb = new Type.Builder(mRS, e);
Jason Samsbf6ef8d2010-12-06 15:59:59 -0800346 tb.setX(size);
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700347 return tb.create();
348 }
349
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700350 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700351 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800352 * Create a Mesh object from the current state of the builder
353 *
354 **/
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700355 public Mesh create() {
356 mRS.validate();
Ashok Bhat98071552014-02-12 09:54:43 +0000357 long[] vtx = new long[mVertexTypeCount];
358 long[] idx = new long[mIndexTypes.size()];
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700359 int[] prim = new int[mIndexTypes.size()];
360
361 Allocation[] vertexBuffers = new Allocation[mVertexTypeCount];
362 Allocation[] indexBuffers = new Allocation[mIndexTypes.size()];
363 Primitive[] primitives = new Primitive[mIndexTypes.size()];
364
365 for(int ct = 0; ct < mVertexTypeCount; ct ++) {
366 Allocation alloc = null;
367 Entry entry = mVertexTypes[ct];
368 if (entry.t != null) {
369 alloc = Allocation.createTyped(mRS, entry.t, mUsage);
370 } else if(entry.e != null) {
371 alloc = Allocation.createSized(mRS, entry.e, entry.size, mUsage);
Jason Samsae5be382015-03-26 14:47:17 -0700372 } else {
373 // Should never happen because the builder will always set one
374 throw new IllegalStateException("Builder corrupt, no valid element in entry.");
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700375 }
376 vertexBuffers[ct] = alloc;
Ashok Bhat98071552014-02-12 09:54:43 +0000377 vtx[ct] = alloc.getID(mRS);
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700378 }
379
380 for(int ct = 0; ct < mIndexTypes.size(); ct ++) {
381 Allocation alloc = null;
382 Entry entry = (Entry)mIndexTypes.elementAt(ct);
383 if (entry.t != null) {
384 alloc = Allocation.createTyped(mRS, entry.t, mUsage);
385 } else if(entry.e != null) {
386 alloc = Allocation.createSized(mRS, entry.e, entry.size, mUsage);
Jason Samsae5be382015-03-26 14:47:17 -0700387 } else {
388 // Should never happen because the builder will always set one
389 throw new IllegalStateException("Builder corrupt, no valid element in entry.");
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700390 }
Tim Murray460a0492013-11-19 12:45:54 -0800391 long allocID = (alloc == null) ? 0 : alloc.getID(mRS);
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700392 indexBuffers[ct] = alloc;
393 primitives[ct] = entry.prim;
394
Ashok Bhat98071552014-02-12 09:54:43 +0000395 idx[ct] = allocID;
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700396 prim[ct] = entry.prim.mID;
397 }
398
Tim Murray460a0492013-11-19 12:45:54 -0800399 long id = mRS.nMeshCreate(vtx, idx, prim);
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700400 Mesh newMesh = new Mesh(id, mRS);
401 newMesh.mVertexBuffers = vertexBuffers;
402 newMesh.mIndexBuffers = indexBuffers;
403 newMesh.mPrimitives = primitives;
404
405 return newMesh;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700406 }
407 }
408
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700409 /**
Jason Samse619de62012-05-08 18:40:58 -0700410 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800411 * Mesh builder object. It starts empty and requires the user to
412 * add all the vertex and index allocations that comprise the
413 * mesh
414 *
415 */
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700416 public static class AllocationBuilder {
417 RenderScript mRS;
418
419 class Entry {
420 Allocation a;
421 Primitive prim;
422 }
423
424 int mVertexTypeCount;
425 Entry[] mVertexTypes;
426
427 Vector mIndexTypes;
428
Jason Samse619de62012-05-08 18:40:58 -0700429 /**
430 * @deprecated in API 16
431 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100432 @UnsupportedAppUsage
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700433 public AllocationBuilder(RenderScript rs) {
434 mRS = rs;
435 mVertexTypeCount = 0;
436 mVertexTypes = new Entry[16];
437 mIndexTypes = new Vector();
438 }
439
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700440 /**
Jason Samse619de62012-05-08 18:40:58 -0700441 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800442 * @return internal index of the last vertex buffer type added to
443 * builder
444 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800445 public int getCurrentVertexTypeIndex() {
446 return mVertexTypeCount - 1;
447 }
448
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700449 /**
Jason Samse619de62012-05-08 18:40:58 -0700450 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800451 * @return internal index of the last index set added to the
452 * builder
453 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800454 public int getCurrentIndexSetIndex() {
455 return mIndexTypes.size() - 1;
456 }
457
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700458 /**
Jason Samse619de62012-05-08 18:40:58 -0700459 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800460 * Adds an allocation containing vertex buffer data to the
461 * builder
462 *
463 * @param a vertex data allocation
464 *
465 * @return this
466 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100467 @UnsupportedAppUsage
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800468 public AllocationBuilder addVertexAllocation(Allocation a) throws IllegalStateException {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700469 if (mVertexTypeCount >= mVertexTypes.length) {
470 throw new IllegalStateException("Max vertex types exceeded.");
471 }
472
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700473 mVertexTypes[mVertexTypeCount] = new Entry();
474 mVertexTypes[mVertexTypeCount].a = a;
475 mVertexTypeCount++;
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800476 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700477 }
478
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700479 /**
Jason Samse619de62012-05-08 18:40:58 -0700480 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800481 * Adds an allocation containing index buffer data and index type
482 * to the builder
483 *
484 * @param a index set data allocation, could be null
485 * @param p index set primitive type
486 *
487 * @return this
488 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100489 @UnsupportedAppUsage
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800490 public AllocationBuilder addIndexSetAllocation(Allocation a, Primitive p) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700491 Entry indexType = new Entry();
492 indexType.a = a;
493 indexType.prim = p;
494 mIndexTypes.addElement(indexType);
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800495 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700496 }
497
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700498 /**
Jason Samse619de62012-05-08 18:40:58 -0700499 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800500 * Adds an index set type to the builder
501 *
502 * @param p index set primitive type
503 *
504 * @return this
505 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100506 @UnsupportedAppUsage
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800507 public AllocationBuilder addIndexSetType(Primitive p) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700508 Entry indexType = new Entry();
509 indexType.a = null;
510 indexType.prim = p;
511 mIndexTypes.addElement(indexType);
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800512 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700513 }
514
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700515 /**
Jason Samse619de62012-05-08 18:40:58 -0700516 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800517 * Create a Mesh object from the current state of the builder
518 *
519 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100520 @UnsupportedAppUsage
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700521 public Mesh create() {
522 mRS.validate();
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700523
Ashok Bhat98071552014-02-12 09:54:43 +0000524 long[] vtx = new long[mVertexTypeCount];
525 long[] idx = new long[mIndexTypes.size()];
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700526 int[] prim = new int[mIndexTypes.size()];
527
528 Allocation[] indexBuffers = new Allocation[mIndexTypes.size()];
529 Primitive[] primitives = new Primitive[mIndexTypes.size()];
530 Allocation[] vertexBuffers = new Allocation[mVertexTypeCount];
531
532 for(int ct = 0; ct < mVertexTypeCount; ct ++) {
533 Entry entry = mVertexTypes[ct];
534 vertexBuffers[ct] = entry.a;
Ashok Bhat98071552014-02-12 09:54:43 +0000535 vtx[ct] = entry.a.getID(mRS);
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700536 }
537
538 for(int ct = 0; ct < mIndexTypes.size(); ct ++) {
539 Entry entry = (Entry)mIndexTypes.elementAt(ct);
Tim Murray460a0492013-11-19 12:45:54 -0800540 long allocID = (entry.a == null) ? 0 : entry.a.getID(mRS);
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700541 indexBuffers[ct] = entry.a;
542 primitives[ct] = entry.prim;
543
Ashok Bhat98071552014-02-12 09:54:43 +0000544 idx[ct] = allocID;
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700545 prim[ct] = entry.prim.mID;
546 }
547
Tim Murray460a0492013-11-19 12:45:54 -0800548 long id = mRS.nMeshCreate(vtx, idx, prim);
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700549 Mesh newMesh = new Mesh(id, mRS);
550 newMesh.mVertexBuffers = vertexBuffers;
551 newMesh.mIndexBuffers = indexBuffers;
552 newMesh.mPrimitives = primitives;
553
554 return newMesh;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700555 }
556 }
557
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700558 /**
Jason Samse619de62012-05-08 18:40:58 -0700559 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800560 * Builder that allows creation of a mesh object point by point
561 * and triangle by triangle
562 *
563 **/
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700564 public static class TriangleMeshBuilder {
565 float mVtxData[];
566 int mVtxCount;
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800567 int mMaxIndex;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700568 short mIndexData[];
569 int mIndexCount;
570 RenderScript mRS;
571 Element mElement;
572
573 float mNX = 0;
574 float mNY = 0;
575 float mNZ = -1;
576 float mS0 = 0;
577 float mT0 = 0;
578 float mR = 1;
579 float mG = 1;
580 float mB = 1;
581 float mA = 1;
582
583 int mVtxSize;
584 int mFlags;
585
Jason Samse619de62012-05-08 18:40:58 -0700586 /**
587 * @deprecated in API 16
588 **/
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700589 public static final int COLOR = 0x0001;
Jason Samse619de62012-05-08 18:40:58 -0700590 /**
591 * @deprecated in API 16
592 **/
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700593 public static final int NORMAL = 0x0002;
Jason Samse619de62012-05-08 18:40:58 -0700594 /**
595 * @deprecated in API 16
596 **/
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700597 public static final int TEXTURE_0 = 0x0100;
598
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700599 /**
Jason Samse619de62012-05-08 18:40:58 -0700600 * @deprecated in API 16
Alex Sakhartchoukf5c876e2011-01-13 14:53:43 -0800601 * @param rs Context to which the mesh will belong.
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800602 * @param vtxSize specifies whether the vertex is a float2 or
603 * float3
604 * @param flags bitfield that is a combination of COLOR, NORMAL,
605 * and TEXTURE_0 that specifies what vertex data
606 * channels are present in the mesh
607 *
608 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100609 @UnsupportedAppUsage
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700610 public TriangleMeshBuilder(RenderScript rs, int vtxSize, int flags) {
611 mRS = rs;
612 mVtxCount = 0;
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800613 mMaxIndex = 0;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700614 mIndexCount = 0;
615 mVtxData = new float[128];
616 mIndexData = new short[128];
617 mVtxSize = vtxSize;
618 mFlags = flags;
619
620 if (vtxSize < 2 || vtxSize > 3) {
621 throw new IllegalArgumentException("Vertex size out of range.");
622 }
623 }
624
625 private void makeSpace(int count) {
626 if ((mVtxCount + count) >= mVtxData.length) {
627 float t[] = new float[mVtxData.length * 2];
628 System.arraycopy(mVtxData, 0, t, 0, mVtxData.length);
629 mVtxData = t;
630 }
631 }
632
633 private void latch() {
634 if ((mFlags & COLOR) != 0) {
635 makeSpace(4);
636 mVtxData[mVtxCount++] = mR;
637 mVtxData[mVtxCount++] = mG;
638 mVtxData[mVtxCount++] = mB;
639 mVtxData[mVtxCount++] = mA;
640 }
641 if ((mFlags & TEXTURE_0) != 0) {
642 makeSpace(2);
643 mVtxData[mVtxCount++] = mS0;
644 mVtxData[mVtxCount++] = mT0;
645 }
646 if ((mFlags & NORMAL) != 0) {
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800647 makeSpace(4);
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700648 mVtxData[mVtxCount++] = mNX;
649 mVtxData[mVtxCount++] = mNY;
650 mVtxData[mVtxCount++] = mNZ;
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800651 mVtxData[mVtxCount++] = 0.0f;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700652 }
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800653 mMaxIndex ++;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700654 }
655
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700656 /**
Jason Samse619de62012-05-08 18:40:58 -0700657 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800658 * Adds a float2 vertex to the mesh
659 *
660 * @param x position x
661 * @param y position y
662 *
663 * @return this
664 *
665 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100666 @UnsupportedAppUsage
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800667 public TriangleMeshBuilder addVertex(float x, float y) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700668 if (mVtxSize != 2) {
669 throw new IllegalStateException("add mistmatch with declared components.");
670 }
671 makeSpace(2);
672 mVtxData[mVtxCount++] = x;
673 mVtxData[mVtxCount++] = y;
674 latch();
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800675 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700676 }
677
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700678 /**
Jason Samse619de62012-05-08 18:40:58 -0700679 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800680 * Adds a float3 vertex to the mesh
681 *
682 * @param x position x
683 * @param y position y
684 * @param z position z
685 *
686 * @return this
687 *
688 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800689 public TriangleMeshBuilder addVertex(float x, float y, float z) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700690 if (mVtxSize != 3) {
691 throw new IllegalStateException("add mistmatch with declared components.");
692 }
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800693 makeSpace(4);
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700694 mVtxData[mVtxCount++] = x;
695 mVtxData[mVtxCount++] = y;
696 mVtxData[mVtxCount++] = z;
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800697 mVtxData[mVtxCount++] = 1.0f;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700698 latch();
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800699 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700700 }
701
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700702 /**
Jason Samse619de62012-05-08 18:40:58 -0700703 * @deprecated in API 16
Robert Lyf11ffc112012-02-22 10:59:12 -0800704 * Sets the texture coordinate for the vertices that are added after this method call.
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800705 *
706 * @param s texture coordinate s
707 * @param t texture coordinate t
708 *
709 * @return this
710 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800711 public TriangleMeshBuilder setTexture(float s, float t) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700712 if ((mFlags & TEXTURE_0) == 0) {
713 throw new IllegalStateException("add mistmatch with declared components.");
714 }
715 mS0 = s;
716 mT0 = t;
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800717 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700718 }
719
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700720 /**
Jason Samse619de62012-05-08 18:40:58 -0700721 * @deprecated in API 16
Robert Lyf11ffc112012-02-22 10:59:12 -0800722 * Sets the normal vector for the vertices that are added after this method call.
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800723 *
724 * @param x normal vector x
725 * @param y normal vector y
726 * @param z normal vector z
727 *
728 * @return this
729 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800730 public TriangleMeshBuilder setNormal(float x, float y, float z) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700731 if ((mFlags & NORMAL) == 0) {
732 throw new IllegalStateException("add mistmatch with declared components.");
733 }
734 mNX = x;
735 mNY = y;
736 mNZ = z;
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800737 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700738 }
739
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700740 /**
Jason Samse619de62012-05-08 18:40:58 -0700741 * @deprecated in API 16
Robert Lyf11ffc112012-02-22 10:59:12 -0800742 * Sets the color for the vertices that are added after this method call.
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800743 *
744 * @param r red component
745 * @param g green component
746 * @param b blue component
747 * @param a alpha component
748 *
749 * @return this
750 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800751 public TriangleMeshBuilder setColor(float r, float g, float b, float a) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700752 if ((mFlags & COLOR) == 0) {
753 throw new IllegalStateException("add mistmatch with declared components.");
754 }
755 mR = r;
756 mG = g;
757 mB = b;
758 mA = a;
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800759 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700760 }
761
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700762 /**
Jason Samse619de62012-05-08 18:40:58 -0700763 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800764 * Adds a new triangle to the mesh builder
765 *
766 * @param idx1 index of the first vertex in the triangle
767 * @param idx2 index of the second vertex in the triangle
768 * @param idx3 index of the third vertex in the triangle
769 *
770 * @return this
771 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100772 @UnsupportedAppUsage
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800773 public TriangleMeshBuilder addTriangle(int idx1, int idx2, int idx3) {
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800774 if((idx1 >= mMaxIndex) || (idx1 < 0) ||
775 (idx2 >= mMaxIndex) || (idx2 < 0) ||
776 (idx3 >= mMaxIndex) || (idx3 < 0)) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700777 throw new IllegalStateException("Index provided greater than vertex count.");
778 }
779 if ((mIndexCount + 3) >= mIndexData.length) {
780 short t[] = new short[mIndexData.length * 2];
781 System.arraycopy(mIndexData, 0, t, 0, mIndexData.length);
782 mIndexData = t;
783 }
784 mIndexData[mIndexCount++] = (short)idx1;
785 mIndexData[mIndexCount++] = (short)idx2;
786 mIndexData[mIndexCount++] = (short)idx3;
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800787 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700788 }
789
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700790 /**
Jason Samse619de62012-05-08 18:40:58 -0700791 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800792 * Creates the mesh object from the current state of the builder
793 *
794 * @param uploadToBufferObject specifies whether the vertex data
795 * is to be uploaded into the buffer
796 * object indicating that it's likely
797 * not going to be modified and
798 * rendered many times.
799 * Alternatively, it indicates the
800 * mesh data will be updated
801 * frequently and remain in script
802 * accessible memory
803 *
804 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100805 @UnsupportedAppUsage
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700806 public Mesh create(boolean uploadToBufferObject) {
807 Element.Builder b = new Element.Builder(mRS);
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700808 b.add(Element.createVector(mRS,
809 Element.DataType.FLOAT_32,
810 mVtxSize), "position");
811 if ((mFlags & COLOR) != 0) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700812 b.add(Element.F32_4(mRS), "color");
813 }
814 if ((mFlags & TEXTURE_0) != 0) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700815 b.add(Element.F32_2(mRS), "texture0");
816 }
817 if ((mFlags & NORMAL) != 0) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700818 b.add(Element.F32_3(mRS), "normal");
819 }
820 mElement = b.create();
821
Jason Samsd1952402010-12-20 12:55:28 -0800822 int usage = Allocation.USAGE_SCRIPT;
823 if (uploadToBufferObject) {
824 usage |= Allocation.USAGE_GRAPHICS_VERTEX;
825 }
826
827 Builder smb = new Builder(mRS, usage);
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800828 smb.addVertexType(mElement, mMaxIndex);
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800829 smb.addIndexSetType(Element.U16(mRS), mIndexCount, Primitive.TRIANGLE);
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700830
831 Mesh sm = smb.create();
832
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800833 sm.getVertexAllocation(0).copy1DRangeFromUnchecked(0, mMaxIndex, mVtxData);
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700834 if(uploadToBufferObject) {
Andreas Gampe16720c12015-03-17 19:10:14 -0700835 sm.getVertexAllocation(0).syncAll(Allocation.USAGE_SCRIPT);
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700836 }
837
Jason Samsb97b2512011-01-16 15:04:08 -0800838 sm.getIndexSetAllocation(0).copy1DRangeFromUnchecked(0, mIndexCount, mIndexData);
Jason Samsd1952402010-12-20 12:55:28 -0800839 if (uploadToBufferObject) {
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800840 sm.getIndexSetAllocation(0).syncAll(Allocation.USAGE_SCRIPT);
Jason Samsd1952402010-12-20 12:55:28 -0800841 }
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700842
843 return sm;
844 }
845 }
846}
847