blob: 5321dcb957dc280c6a110996c84b44a6e612deda [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
Mathew Inwood15324472018-08-06 11:18:49 +010019import android.annotation.UnsupportedAppUsage;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -070020import java.util.Vector;
21
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -070022/**
Tim Murraya9084222013-04-05 22:06:43 +000023 * @hide
Jason Samsd4ca9912012-05-08 19:02:07 -070024 * @deprecated in API 16
Robert Ly11518ac2011-02-09 13:57:06 -080025 * <p>This class is a container for geometric data displayed with
Tim Murrayc11e25c2013-04-09 11:01:01 -070026 * RenderScript. Internally, a mesh is a collection of allocations that
Alex Sakhartchoukdf272022011-01-09 11:34:03 -080027 * represent vertex data (positions, normals, texture
Robert Ly11518ac2011-02-09 13:57:06 -080028 * coordinates) and index data such as triangles and lines. </p>
29 * <p>
30 * Vertex data could either be interleaved within one
31 * allocation that is provided separately, as multiple allocation
32 * objects, or done as a combination of both. When a
Alex Sakhartchoukdf272022011-01-09 11:34:03 -080033 * vertex channel name matches an input in the vertex program,
Tim Murrayc11e25c2013-04-09 11:01:01 -070034 * RenderScript automatically connects the two together.
Robert Ly11518ac2011-02-09 13:57:06 -080035 * </p>
36 * <p>
37 * Parts of the mesh can be rendered with either explicit
Alex Sakhartchoukdf272022011-01-09 11:34:03 -080038 * index sets or primitive types.
Robert Ly11518ac2011-02-09 13:57:06 -080039 * </p>
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -070040 **/
41public class Mesh extends BaseObj {
42
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -070043 /**
Jason Samsd4ca9912012-05-08 19:02:07 -070044 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -080045 * Describes the way mesh vertex data is interpreted when rendering
46 *
47 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -080048 public enum Primitive {
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -070049 /**
Jason Samsd4ca9912012-05-08 19:02:07 -070050 * @deprecated in API 16
Alex Sakhartchoukec0d3352011-01-17 15:23:22 -080051 * Vertex data will be rendered as a series of points
52 */
Mathew Inwood15324472018-08-06 11:18:49 +010053 @UnsupportedAppUsage
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -080054 POINT (0),
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -070055 /**
Jason Samsd4ca9912012-05-08 19:02:07 -070056 * @deprecated in API 16
Alex Sakhartchoukec0d3352011-01-17 15:23:22 -080057 * Vertex pairs will be rendered as lines
58 */
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -080059 LINE (1),
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -070060 /**
Jason Samsd4ca9912012-05-08 19:02:07 -070061 * @deprecated in API 16
Alex Sakhartchoukec0d3352011-01-17 15:23:22 -080062 * Vertex data will be rendered as a connected line strip
63 */
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -080064 LINE_STRIP (2),
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -070065 /**
Jason Samsd4ca9912012-05-08 19:02:07 -070066 * @deprecated in API 16
Alex Sakhartchoukec0d3352011-01-17 15:23:22 -080067 * Vertices will be rendered as individual triangles
68 */
Mathew Inwood15324472018-08-06 11:18:49 +010069 @UnsupportedAppUsage
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -080070 TRIANGLE (3),
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -070071 /**
Jason Samsd4ca9912012-05-08 19:02:07 -070072 * @deprecated in API 16
Alex Sakhartchoukec0d3352011-01-17 15:23:22 -080073 * Vertices will be rendered as a connected triangle strip
74 * defined by the first three vertices with each additional
75 * triangle defined by a new vertex
76 */
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -080077 TRIANGLE_STRIP (4),
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -070078 /**
Jason Samsd4ca9912012-05-08 19:02:07 -070079 * @deprecated in API 16
Alex Sakhartchoukec0d3352011-01-17 15:23:22 -080080 * Vertices will be rendered as a sequence of triangles that all
81 * share first vertex as the origin
82 */
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -080083 TRIANGLE_FAN (5);
84
85 int mID;
86 Primitive(int id) {
87 mID = id;
88 }
89 }
90
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -070091 Allocation[] mVertexBuffers;
92 Allocation[] mIndexBuffers;
93 Primitive[] mPrimitives;
94
Tim Murray460a0492013-11-19 12:45:54 -080095 Mesh(long id, RenderScript rs) {
Alex Sakhartchouk0de94442010-08-11 14:41:28 -070096 super(id, rs);
Yang Nieb4dd082016-03-24 09:40:32 -070097 guard.open("destroy");
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -070098 }
99
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700100 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700101 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800102 * @return number of allocations containing vertex data
103 *
104 **/
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700105 public int getVertexAllocationCount() {
106 if(mVertexBuffers == null) {
107 return 0;
108 }
109 return mVertexBuffers.length;
110 }
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700111 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700112 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800113 * @param slot index in the list of allocations to return
114 * @return vertex data allocation at the given index
115 *
116 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100117 @UnsupportedAppUsage
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700118 public Allocation getVertexAllocation(int slot) {
119 return mVertexBuffers[slot];
120 }
121
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700122 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700123 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800124 * @return number of primitives or index sets in the mesh
125 *
126 **/
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700127 public int getPrimitiveCount() {
128 if(mIndexBuffers == null) {
129 return 0;
130 }
131 return mIndexBuffers.length;
132 }
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800133
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700134 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700135 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800136 * @param slot locaton within the list of index set allocation
137 * @return allocation containing primtive index data or null if
138 * the index data is not specified explicitly
139 *
140 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800141 public Allocation getIndexSetAllocation(int slot) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700142 return mIndexBuffers[slot];
143 }
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700144 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700145 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800146 * @param slot locaiton within the list of index set primitives
147 * @return index set primitive type
148 *
149 **/
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700150 public Primitive getPrimitive(int slot) {
151 return mPrimitives[slot];
152 }
153
Alex Sakhartchouk80a4c2c2010-07-12 15:50:32 -0700154 @Override
155 void updateFromNative() {
Jason Sams06d69de2010-11-09 17:11:40 -0800156 super.updateFromNative();
Jason Samse07694b2012-04-03 15:36:36 -0700157 int vtxCount = mRS.nMeshGetVertexBufferCount(getID(mRS));
158 int idxCount = mRS.nMeshGetIndexCount(getID(mRS));
Alex Sakhartchouk80a4c2c2010-07-12 15:50:32 -0700159
Ashok Bhat98071552014-02-12 09:54:43 +0000160 long[] vtxIDs = new long[vtxCount];
161 long[] idxIDs = new long[idxCount];
Alex Sakhartchouk80a4c2c2010-07-12 15:50:32 -0700162 int[] primitives = new int[idxCount];
163
Jason Samse07694b2012-04-03 15:36:36 -0700164 mRS.nMeshGetVertices(getID(mRS), vtxIDs, vtxCount);
165 mRS.nMeshGetIndices(getID(mRS), idxIDs, primitives, idxCount);
Alex Sakhartchouk80a4c2c2010-07-12 15:50:32 -0700166
167 mVertexBuffers = new Allocation[vtxCount];
168 mIndexBuffers = new Allocation[idxCount];
169 mPrimitives = new Primitive[idxCount];
170
171 for(int i = 0; i < vtxCount; i ++) {
172 if(vtxIDs[i] != 0) {
Jason Samsd4b23b52010-12-13 15:32:35 -0800173 mVertexBuffers[i] = new Allocation(vtxIDs[i], mRS, null, Allocation.USAGE_SCRIPT);
Alex Sakhartchouk80a4c2c2010-07-12 15:50:32 -0700174 mVertexBuffers[i].updateFromNative();
175 }
176 }
177
178 for(int i = 0; i < idxCount; i ++) {
179 if(idxIDs[i] != 0) {
Jason Samsd4b23b52010-12-13 15:32:35 -0800180 mIndexBuffers[i] = new Allocation(idxIDs[i], mRS, null, Allocation.USAGE_SCRIPT);
Alex Sakhartchouk80a4c2c2010-07-12 15:50:32 -0700181 mIndexBuffers[i].updateFromNative();
182 }
183 mPrimitives[i] = Primitive.values()[primitives[i]];
184 }
185 }
186
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700187 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700188 * @deprecated in API 16
Robert Ly11518ac2011-02-09 13:57:06 -0800189 * Mesh builder object. It starts empty and requires you to
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800190 * add the types necessary to create vertex and index
Robert Ly11518ac2011-02-09 13:57:06 -0800191 * allocations.
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800192 *
193 */
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700194 public static class Builder {
195 RenderScript mRS;
Jason Samsd1952402010-12-20 12:55:28 -0800196 int mUsage;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700197
198 class Entry {
199 Type t;
200 Element e;
201 int size;
202 Primitive prim;
Jason Samsd1952402010-12-20 12:55:28 -0800203 int usage;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700204 }
205
206 int mVertexTypeCount;
207 Entry[] mVertexTypes;
208 Vector mIndexTypes;
209
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700210 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700211 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800212 * Creates builder object
Alex Sakhartchoukf5c876e2011-01-13 14:53:43 -0800213 * @param rs Context to which the mesh will belong.
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800214 * @param usage specifies how the mesh allocations are to be
215 * handled, whether they need to be uploaded to a
216 * buffer on the gpu, maintain a cpu copy, etc
217 */
Jason Samsd1952402010-12-20 12:55:28 -0800218 public Builder(RenderScript rs, int usage) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700219 mRS = rs;
Jason Samsd1952402010-12-20 12:55:28 -0800220 mUsage = usage;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700221 mVertexTypeCount = 0;
222 mVertexTypes = new Entry[16];
223 mIndexTypes = new Vector();
224 }
225
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700226 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700227 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800228 * @return internal index of the last vertex buffer type added to
229 * builder
230 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800231 public int getCurrentVertexTypeIndex() {
232 return mVertexTypeCount - 1;
233 }
234
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700235 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700236 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800237 * @return internal index of the last index set added to the
238 * builder
239 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800240 public int getCurrentIndexSetIndex() {
241 return mIndexTypes.size() - 1;
242 }
243
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700244 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700245 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800246 * Adds a vertex data type to the builder object
247 *
Stephen Hinesb11e3d22011-01-11 19:30:58 -0800248 * @param t type of the vertex data allocation to be created
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800249 *
250 * @return this
251 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800252 public Builder addVertexType(Type t) throws IllegalStateException {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700253 if (mVertexTypeCount >= mVertexTypes.length) {
254 throw new IllegalStateException("Max vertex types exceeded.");
255 }
256
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700257 mVertexTypes[mVertexTypeCount] = new Entry();
258 mVertexTypes[mVertexTypeCount].t = t;
259 mVertexTypes[mVertexTypeCount].e = null;
260 mVertexTypeCount++;
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800261 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700262 }
263
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700264 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700265 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800266 * Adds a vertex data type to the builder object
267 *
268 * @param e element describing the vertex data layout
269 * @param size number of elements in the buffer
270 *
271 * @return this
272 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800273 public Builder addVertexType(Element e, int size) throws IllegalStateException {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700274 if (mVertexTypeCount >= mVertexTypes.length) {
275 throw new IllegalStateException("Max vertex types exceeded.");
276 }
277
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700278 mVertexTypes[mVertexTypeCount] = new Entry();
279 mVertexTypes[mVertexTypeCount].t = null;
280 mVertexTypes[mVertexTypeCount].e = e;
281 mVertexTypes[mVertexTypeCount].size = size;
282 mVertexTypeCount++;
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800283 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700284 }
285
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700286 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700287 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800288 * Adds an index set data type to the builder object
289 *
290 * @param t type of the index set data, could be null
291 * @param p primitive type
292 *
293 * @return this
294 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800295 public Builder addIndexSetType(Type t, Primitive p) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700296 Entry indexType = new Entry();
297 indexType.t = t;
298 indexType.e = null;
299 indexType.size = 0;
300 indexType.prim = p;
301 mIndexTypes.addElement(indexType);
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800302 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700303 }
304
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700305 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700306 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800307 * Adds an index set primitive type to the builder object
308 *
309 * @param p primitive type
310 *
311 * @return this
312 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800313 public Builder addIndexSetType(Primitive p) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700314 Entry indexType = new Entry();
315 indexType.t = null;
316 indexType.e = null;
317 indexType.size = 0;
318 indexType.prim = p;
319 mIndexTypes.addElement(indexType);
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800320 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700321 }
322
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700323 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700324 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800325 * Adds an index set data type to the builder object
326 *
327 * @param e element describing the index set data layout
328 * @param size number of elements in the buffer
329 * @param p primitive type
330 *
331 * @return this
332 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800333 public Builder addIndexSetType(Element e, int size, Primitive p) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700334 Entry indexType = new Entry();
335 indexType.t = null;
336 indexType.e = e;
337 indexType.size = size;
338 indexType.prim = p;
339 mIndexTypes.addElement(indexType);
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800340 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700341 }
342
343 Type newType(Element e, int size) {
344 Type.Builder tb = new Type.Builder(mRS, e);
Jason Samsbf6ef8d2010-12-06 15:59:59 -0800345 tb.setX(size);
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700346 return tb.create();
347 }
348
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700349 /**
Jason Samsd4ca9912012-05-08 19:02:07 -0700350 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800351 * Create a Mesh object from the current state of the builder
352 *
353 **/
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700354 public Mesh create() {
355 mRS.validate();
Ashok Bhat98071552014-02-12 09:54:43 +0000356 long[] vtx = new long[mVertexTypeCount];
357 long[] idx = new long[mIndexTypes.size()];
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700358 int[] prim = new int[mIndexTypes.size()];
359
360 Allocation[] vertexBuffers = new Allocation[mVertexTypeCount];
361 Allocation[] indexBuffers = new Allocation[mIndexTypes.size()];
362 Primitive[] primitives = new Primitive[mIndexTypes.size()];
363
364 for(int ct = 0; ct < mVertexTypeCount; ct ++) {
365 Allocation alloc = null;
366 Entry entry = mVertexTypes[ct];
367 if (entry.t != null) {
368 alloc = Allocation.createTyped(mRS, entry.t, mUsage);
369 } else if(entry.e != null) {
370 alloc = Allocation.createSized(mRS, entry.e, entry.size, mUsage);
Jason Samsae5be382015-03-26 14:47:17 -0700371 } else {
372 // Should never happen because the builder will always set one
373 throw new IllegalStateException("Builder corrupt, no valid element in entry.");
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700374 }
375 vertexBuffers[ct] = alloc;
Ashok Bhat98071552014-02-12 09:54:43 +0000376 vtx[ct] = alloc.getID(mRS);
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700377 }
378
379 for(int ct = 0; ct < mIndexTypes.size(); ct ++) {
380 Allocation alloc = null;
381 Entry entry = (Entry)mIndexTypes.elementAt(ct);
382 if (entry.t != null) {
383 alloc = Allocation.createTyped(mRS, entry.t, mUsage);
384 } else if(entry.e != null) {
385 alloc = Allocation.createSized(mRS, entry.e, entry.size, mUsage);
Jason Samsae5be382015-03-26 14:47:17 -0700386 } else {
387 // Should never happen because the builder will always set one
388 throw new IllegalStateException("Builder corrupt, no valid element in entry.");
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700389 }
Tim Murray460a0492013-11-19 12:45:54 -0800390 long allocID = (alloc == null) ? 0 : alloc.getID(mRS);
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700391 indexBuffers[ct] = alloc;
392 primitives[ct] = entry.prim;
393
Ashok Bhat98071552014-02-12 09:54:43 +0000394 idx[ct] = allocID;
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700395 prim[ct] = entry.prim.mID;
396 }
397
Tim Murray460a0492013-11-19 12:45:54 -0800398 long id = mRS.nMeshCreate(vtx, idx, prim);
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700399 Mesh newMesh = new Mesh(id, mRS);
400 newMesh.mVertexBuffers = vertexBuffers;
401 newMesh.mIndexBuffers = indexBuffers;
402 newMesh.mPrimitives = primitives;
403
404 return newMesh;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700405 }
406 }
407
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700408 /**
Jason Samse619de62012-05-08 18:40:58 -0700409 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800410 * Mesh builder object. It starts empty and requires the user to
411 * add all the vertex and index allocations that comprise the
412 * mesh
413 *
414 */
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700415 public static class AllocationBuilder {
416 RenderScript mRS;
417
418 class Entry {
419 Allocation a;
420 Primitive prim;
421 }
422
423 int mVertexTypeCount;
424 Entry[] mVertexTypes;
425
426 Vector mIndexTypes;
427
Jason Samse619de62012-05-08 18:40:58 -0700428 /**
429 * @deprecated in API 16
430 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100431 @UnsupportedAppUsage
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700432 public AllocationBuilder(RenderScript rs) {
433 mRS = rs;
434 mVertexTypeCount = 0;
435 mVertexTypes = new Entry[16];
436 mIndexTypes = new Vector();
437 }
438
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700439 /**
Jason Samse619de62012-05-08 18:40:58 -0700440 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800441 * @return internal index of the last vertex buffer type added to
442 * builder
443 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800444 public int getCurrentVertexTypeIndex() {
445 return mVertexTypeCount - 1;
446 }
447
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700448 /**
Jason Samse619de62012-05-08 18:40:58 -0700449 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800450 * @return internal index of the last index set added to the
451 * builder
452 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800453 public int getCurrentIndexSetIndex() {
454 return mIndexTypes.size() - 1;
455 }
456
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700457 /**
Jason Samse619de62012-05-08 18:40:58 -0700458 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800459 * Adds an allocation containing vertex buffer data to the
460 * builder
461 *
462 * @param a vertex data allocation
463 *
464 * @return this
465 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100466 @UnsupportedAppUsage
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800467 public AllocationBuilder addVertexAllocation(Allocation a) throws IllegalStateException {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700468 if (mVertexTypeCount >= mVertexTypes.length) {
469 throw new IllegalStateException("Max vertex types exceeded.");
470 }
471
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700472 mVertexTypes[mVertexTypeCount] = new Entry();
473 mVertexTypes[mVertexTypeCount].a = a;
474 mVertexTypeCount++;
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800475 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700476 }
477
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700478 /**
Jason Samse619de62012-05-08 18:40:58 -0700479 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800480 * Adds an allocation containing index buffer data and index type
481 * to the builder
482 *
483 * @param a index set data allocation, could be null
484 * @param p index set primitive type
485 *
486 * @return this
487 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100488 @UnsupportedAppUsage
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800489 public AllocationBuilder addIndexSetAllocation(Allocation a, Primitive p) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700490 Entry indexType = new Entry();
491 indexType.a = a;
492 indexType.prim = p;
493 mIndexTypes.addElement(indexType);
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800494 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700495 }
496
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700497 /**
Jason Samse619de62012-05-08 18:40:58 -0700498 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800499 * Adds an index set type to the builder
500 *
501 * @param p index set primitive type
502 *
503 * @return this
504 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100505 @UnsupportedAppUsage
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800506 public AllocationBuilder addIndexSetType(Primitive p) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700507 Entry indexType = new Entry();
508 indexType.a = null;
509 indexType.prim = p;
510 mIndexTypes.addElement(indexType);
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800511 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700512 }
513
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700514 /**
Jason Samse619de62012-05-08 18:40:58 -0700515 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800516 * Create a Mesh object from the current state of the builder
517 *
518 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100519 @UnsupportedAppUsage
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700520 public Mesh create() {
521 mRS.validate();
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700522
Ashok Bhat98071552014-02-12 09:54:43 +0000523 long[] vtx = new long[mVertexTypeCount];
524 long[] idx = new long[mIndexTypes.size()];
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700525 int[] prim = new int[mIndexTypes.size()];
526
527 Allocation[] indexBuffers = new Allocation[mIndexTypes.size()];
528 Primitive[] primitives = new Primitive[mIndexTypes.size()];
529 Allocation[] vertexBuffers = new Allocation[mVertexTypeCount];
530
531 for(int ct = 0; ct < mVertexTypeCount; ct ++) {
532 Entry entry = mVertexTypes[ct];
533 vertexBuffers[ct] = entry.a;
Ashok Bhat98071552014-02-12 09:54:43 +0000534 vtx[ct] = entry.a.getID(mRS);
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700535 }
536
537 for(int ct = 0; ct < mIndexTypes.size(); ct ++) {
538 Entry entry = (Entry)mIndexTypes.elementAt(ct);
Tim Murray460a0492013-11-19 12:45:54 -0800539 long allocID = (entry.a == null) ? 0 : entry.a.getID(mRS);
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700540 indexBuffers[ct] = entry.a;
541 primitives[ct] = entry.prim;
542
Ashok Bhat98071552014-02-12 09:54:43 +0000543 idx[ct] = allocID;
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700544 prim[ct] = entry.prim.mID;
545 }
546
Tim Murray460a0492013-11-19 12:45:54 -0800547 long id = mRS.nMeshCreate(vtx, idx, prim);
Alex Sakhartchouk25999a02011-05-12 10:38:03 -0700548 Mesh newMesh = new Mesh(id, mRS);
549 newMesh.mVertexBuffers = vertexBuffers;
550 newMesh.mIndexBuffers = indexBuffers;
551 newMesh.mPrimitives = primitives;
552
553 return newMesh;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700554 }
555 }
556
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700557 /**
Jason Samse619de62012-05-08 18:40:58 -0700558 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800559 * Builder that allows creation of a mesh object point by point
560 * and triangle by triangle
561 *
562 **/
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700563 public static class TriangleMeshBuilder {
564 float mVtxData[];
565 int mVtxCount;
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800566 int mMaxIndex;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700567 short mIndexData[];
568 int mIndexCount;
569 RenderScript mRS;
570 Element mElement;
571
572 float mNX = 0;
573 float mNY = 0;
574 float mNZ = -1;
575 float mS0 = 0;
576 float mT0 = 0;
577 float mR = 1;
578 float mG = 1;
579 float mB = 1;
580 float mA = 1;
581
582 int mVtxSize;
583 int mFlags;
584
Jason Samse619de62012-05-08 18:40:58 -0700585 /**
586 * @deprecated in API 16
587 **/
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700588 public static final int COLOR = 0x0001;
Jason Samse619de62012-05-08 18:40:58 -0700589 /**
590 * @deprecated in API 16
591 **/
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700592 public static final int NORMAL = 0x0002;
Jason Samse619de62012-05-08 18:40:58 -0700593 /**
594 * @deprecated in API 16
595 **/
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700596 public static final int TEXTURE_0 = 0x0100;
597
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700598 /**
Jason Samse619de62012-05-08 18:40:58 -0700599 * @deprecated in API 16
Alex Sakhartchoukf5c876e2011-01-13 14:53:43 -0800600 * @param rs Context to which the mesh will belong.
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800601 * @param vtxSize specifies whether the vertex is a float2 or
602 * float3
603 * @param flags bitfield that is a combination of COLOR, NORMAL,
604 * and TEXTURE_0 that specifies what vertex data
605 * channels are present in the mesh
606 *
607 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100608 @UnsupportedAppUsage
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700609 public TriangleMeshBuilder(RenderScript rs, int vtxSize, int flags) {
610 mRS = rs;
611 mVtxCount = 0;
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800612 mMaxIndex = 0;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700613 mIndexCount = 0;
614 mVtxData = new float[128];
615 mIndexData = new short[128];
616 mVtxSize = vtxSize;
617 mFlags = flags;
618
619 if (vtxSize < 2 || vtxSize > 3) {
620 throw new IllegalArgumentException("Vertex size out of range.");
621 }
622 }
623
624 private void makeSpace(int count) {
625 if ((mVtxCount + count) >= mVtxData.length) {
626 float t[] = new float[mVtxData.length * 2];
627 System.arraycopy(mVtxData, 0, t, 0, mVtxData.length);
628 mVtxData = t;
629 }
630 }
631
632 private void latch() {
633 if ((mFlags & COLOR) != 0) {
634 makeSpace(4);
635 mVtxData[mVtxCount++] = mR;
636 mVtxData[mVtxCount++] = mG;
637 mVtxData[mVtxCount++] = mB;
638 mVtxData[mVtxCount++] = mA;
639 }
640 if ((mFlags & TEXTURE_0) != 0) {
641 makeSpace(2);
642 mVtxData[mVtxCount++] = mS0;
643 mVtxData[mVtxCount++] = mT0;
644 }
645 if ((mFlags & NORMAL) != 0) {
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800646 makeSpace(4);
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700647 mVtxData[mVtxCount++] = mNX;
648 mVtxData[mVtxCount++] = mNY;
649 mVtxData[mVtxCount++] = mNZ;
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800650 mVtxData[mVtxCount++] = 0.0f;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700651 }
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800652 mMaxIndex ++;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700653 }
654
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700655 /**
Jason Samse619de62012-05-08 18:40:58 -0700656 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800657 * Adds a float2 vertex to the mesh
658 *
659 * @param x position x
660 * @param y position y
661 *
662 * @return this
663 *
664 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100665 @UnsupportedAppUsage
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800666 public TriangleMeshBuilder addVertex(float x, float y) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700667 if (mVtxSize != 2) {
668 throw new IllegalStateException("add mistmatch with declared components.");
669 }
670 makeSpace(2);
671 mVtxData[mVtxCount++] = x;
672 mVtxData[mVtxCount++] = y;
673 latch();
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800674 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700675 }
676
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700677 /**
Jason Samse619de62012-05-08 18:40:58 -0700678 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800679 * Adds a float3 vertex to the mesh
680 *
681 * @param x position x
682 * @param y position y
683 * @param z position z
684 *
685 * @return this
686 *
687 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800688 public TriangleMeshBuilder addVertex(float x, float y, float z) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700689 if (mVtxSize != 3) {
690 throw new IllegalStateException("add mistmatch with declared components.");
691 }
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800692 makeSpace(4);
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700693 mVtxData[mVtxCount++] = x;
694 mVtxData[mVtxCount++] = y;
695 mVtxData[mVtxCount++] = z;
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800696 mVtxData[mVtxCount++] = 1.0f;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700697 latch();
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800698 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700699 }
700
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700701 /**
Jason Samse619de62012-05-08 18:40:58 -0700702 * @deprecated in API 16
Robert Lyf11ffc112012-02-22 10:59:12 -0800703 * Sets the texture coordinate for the vertices that are added after this method call.
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800704 *
705 * @param s texture coordinate s
706 * @param t texture coordinate t
707 *
708 * @return this
709 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800710 public TriangleMeshBuilder setTexture(float s, float t) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700711 if ((mFlags & TEXTURE_0) == 0) {
712 throw new IllegalStateException("add mistmatch with declared components.");
713 }
714 mS0 = s;
715 mT0 = t;
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800716 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700717 }
718
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700719 /**
Jason Samse619de62012-05-08 18:40:58 -0700720 * @deprecated in API 16
Robert Lyf11ffc112012-02-22 10:59:12 -0800721 * Sets the normal vector for the vertices that are added after this method call.
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800722 *
723 * @param x normal vector x
724 * @param y normal vector y
725 * @param z normal vector z
726 *
727 * @return this
728 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800729 public TriangleMeshBuilder setNormal(float x, float y, float z) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700730 if ((mFlags & NORMAL) == 0) {
731 throw new IllegalStateException("add mistmatch with declared components.");
732 }
733 mNX = x;
734 mNY = y;
735 mNZ = z;
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800736 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700737 }
738
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700739 /**
Jason Samse619de62012-05-08 18:40:58 -0700740 * @deprecated in API 16
Robert Lyf11ffc112012-02-22 10:59:12 -0800741 * Sets the color for the vertices that are added after this method call.
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800742 *
743 * @param r red component
744 * @param g green component
745 * @param b blue component
746 * @param a alpha component
747 *
748 * @return this
749 **/
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800750 public TriangleMeshBuilder setColor(float r, float g, float b, float a) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700751 if ((mFlags & COLOR) == 0) {
752 throw new IllegalStateException("add mistmatch with declared components.");
753 }
754 mR = r;
755 mG = g;
756 mB = b;
757 mA = a;
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800758 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700759 }
760
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700761 /**
Jason Samse619de62012-05-08 18:40:58 -0700762 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800763 * Adds a new triangle to the mesh builder
764 *
765 * @param idx1 index of the first vertex in the triangle
766 * @param idx2 index of the second vertex in the triangle
767 * @param idx3 index of the third vertex in the triangle
768 *
769 * @return this
770 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100771 @UnsupportedAppUsage
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800772 public TriangleMeshBuilder addTriangle(int idx1, int idx2, int idx3) {
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800773 if((idx1 >= mMaxIndex) || (idx1 < 0) ||
774 (idx2 >= mMaxIndex) || (idx2 < 0) ||
775 (idx3 >= mMaxIndex) || (idx3 < 0)) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700776 throw new IllegalStateException("Index provided greater than vertex count.");
777 }
778 if ((mIndexCount + 3) >= mIndexData.length) {
779 short t[] = new short[mIndexData.length * 2];
780 System.arraycopy(mIndexData, 0, t, 0, mIndexData.length);
781 mIndexData = t;
782 }
783 mIndexData[mIndexCount++] = (short)idx1;
784 mIndexData[mIndexCount++] = (short)idx2;
785 mIndexData[mIndexCount++] = (short)idx3;
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800786 return this;
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700787 }
788
Stephen Hines9c9ad3f8c22012-05-07 15:34:29 -0700789 /**
Jason Samse619de62012-05-08 18:40:58 -0700790 * @deprecated in API 16
Alex Sakhartchoukdf272022011-01-09 11:34:03 -0800791 * Creates the mesh object from the current state of the builder
792 *
793 * @param uploadToBufferObject specifies whether the vertex data
794 * is to be uploaded into the buffer
795 * object indicating that it's likely
796 * not going to be modified and
797 * rendered many times.
798 * Alternatively, it indicates the
799 * mesh data will be updated
800 * frequently and remain in script
801 * accessible memory
802 *
803 **/
Mathew Inwood15324472018-08-06 11:18:49 +0100804 @UnsupportedAppUsage
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700805 public Mesh create(boolean uploadToBufferObject) {
806 Element.Builder b = new Element.Builder(mRS);
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700807 b.add(Element.createVector(mRS,
808 Element.DataType.FLOAT_32,
809 mVtxSize), "position");
810 if ((mFlags & COLOR) != 0) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700811 b.add(Element.F32_4(mRS), "color");
812 }
813 if ((mFlags & TEXTURE_0) != 0) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700814 b.add(Element.F32_2(mRS), "texture0");
815 }
816 if ((mFlags & NORMAL) != 0) {
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700817 b.add(Element.F32_3(mRS), "normal");
818 }
819 mElement = b.create();
820
Jason Samsd1952402010-12-20 12:55:28 -0800821 int usage = Allocation.USAGE_SCRIPT;
822 if (uploadToBufferObject) {
823 usage |= Allocation.USAGE_GRAPHICS_VERTEX;
824 }
825
826 Builder smb = new Builder(mRS, usage);
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800827 smb.addVertexType(mElement, mMaxIndex);
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800828 smb.addIndexSetType(Element.U16(mRS), mIndexCount, Primitive.TRIANGLE);
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700829
830 Mesh sm = smb.create();
831
Alex Sakhartchouke60149d2011-11-15 15:15:21 -0800832 sm.getVertexAllocation(0).copy1DRangeFromUnchecked(0, mMaxIndex, mVtxData);
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700833 if(uploadToBufferObject) {
Andreas Gampe16720c12015-03-17 19:10:14 -0700834 sm.getVertexAllocation(0).syncAll(Allocation.USAGE_SCRIPT);
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700835 }
836
Jason Samsb97b2512011-01-16 15:04:08 -0800837 sm.getIndexSetAllocation(0).copy1DRangeFromUnchecked(0, mIndexCount, mIndexData);
Jason Samsd1952402010-12-20 12:55:28 -0800838 if (uploadToBufferObject) {
Alex Sakhartchoukb4d7bb62010-12-21 14:42:26 -0800839 sm.getIndexSetAllocation(0).syncAll(Allocation.USAGE_SCRIPT);
Jason Samsd1952402010-12-20 12:55:28 -0800840 }
Alex Sakhartchouk164aaed2010-07-01 16:14:06 -0700841
842 return sm;
843 }
844 }
845}
846