Class Tootle
AMD Tootle (Triangle Order Optimization Tool) is a 3D triangle mesh optimization library that improves on existing mesh preprocessing techniques. By using AMD Tootle, developers can optimize their models for pixel overdraw as well as vertex cache performance. This can provide significant performance improvements in pixel limited situations, with no penalty in vertex-limited scenarios, and no runtime cost.
Features
- Vertex cache optimization: Triangles are re-ordered to optimize for the post-transform vertex cache in modern GPUs. This will yield significant performance improvements in vertex-tranform limited scenes.
- Overdraw optimization: To reduce the pixel cost of rendering a mesh, the AMD Tootle library further re-orders the triangles in the mesh to reduce pixel overdraw. Significant reductions in pixel overdraw (2x or higher) can be achieved. This can yield significant performance improvements in pixel-limited scenes, and incurs no penalty in vertex-limited scenarios.
- Vertex prefetch cache optimization: Triangle indices are re-indexed in the order of their occurrence in the triangle list. The vertex buffer is re-ordered to match these new indices. Thus, vertices are accessed close to each other in memory. This optimization exploits the input vertex cache because vertices are typically fetched in a cacheline (that may contains more than one vertex data).
The Direct3D optimizers are currently not supported.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intEnumeration for Tootle return codes.static final intEnumeration for face winding order.static final intEnumeration for face winding order.static final floatThe parameter forFastOptimizeto create more clusters (lower number generates more clusters).static final intThe default vertex cache size.static final intEnumeration for Tootle return codes.static final intEnumeration for Tootle return codes.static final intThe maximum allowed number of faces in the mesh.static final intThe maximum allowed number of vertices in the mesh.static final intEnumeration for Tootle return codes.static final intEnumeration for Tootle return codes.static final intEnumeration for Tootle return codes.static final intEnumeration for the algorithm for overdraw optimization.static final intEnumeration for the algorithm for overdraw optimization.static final intEnumeration for the algorithm for overdraw optimization.static final intEnumeration for the algorithm for overdraw optimization.static final intEnumeration for the algorithm for vertex optimization.static final intEnumeration for the algorithm for vertex optimization.static final intEnumeration for the algorithm for vertex optimization.static final intEnumeration for the algorithm for vertex optimization. -
Method Summary
Modifier and TypeMethodDescriptionstatic intnTootleClusterMesh(long pVB, long pnIB, int nVertices, int nFaces, int nVBStride, int nTargetClusters, long pnClusteredIBOut, long pnFaceClustersOut, long pnFaceRemapOut) Unsafe version of:ClusterMeshstatic intnTootleFastOptimize(long pVB, long pnIB, int nVertices, int nFaces, int nVBStride, int nCacheSize, int eFrontWinding, long pnIBOut, long pnNumClustersOut, float fAlpha) Unsafe version of:FastOptimizestatic intnTootleFastOptimizeVCacheAndClusterMesh(long pnIB, int nFaces, int nVertices, int nCacheSize, long pnIBOut, long pnClustersOut, long pnNumClustersOut, float fAlpha) Unsafe version of:FastOptimizeVCacheAndClusterMeshstatic intnTootleMeasureCacheEfficiency(long pnIB, int nFaces, int nCacheSize, long pfEfficiencyOut) Unsafe version of:MeasureCacheEfficiencystatic intnTootleMeasureOverdraw(long pVB, long pnIB, int nVertices, int nFaces, int nVBStride, long pfViewpoint, int nViewpoints, int eFrontWinding, long pfAvgODOut, long pfMaxODOut, int eOverdrawOptimizer) Unsafe version of:MeasureOverdrawstatic intnTootleOptimize(long pVB, long pnIB, int nVertices, int nFaces, int nVBStride, int nCacheSize, long pViewpoints, int nViewpoints, int eFrontWinding, long pnIBOut, long pnNumClustersOut, int eVCacheOptimizer, int eOverdrawOptimizer) Unsafe version of:Optimizestatic intnTootleOptimizeOverdraw(long pVB, long pnIB, int nVertices, int nFaces, int nVBStride, long pfViewpoint, int nViewpoints, int eFrontWinding, long pnFaceClusters, long pnIBOut, long pnClusterRemapOut, int eOverdrawOptimizer) Unsafe version of:OptimizeOverdrawstatic intnTootleOptimizeVCache(long pnIB, int nFaces, int nVertices, int nCacheSize, long pnIBOut, long pnFaceRemapOut, int eVCacheOptimizer) Unsafe version of:OptimizeVCachestatic intnTootleOptimizeVertexMemory(long pVB, long pnIB, int nVertices, int nFaces, int nVBStride, long pVBOut, long pnIBOut, long pnVertexRemapOut) Unsafe version of:OptimizeVertexMemorystatic intnTootleVCacheClusters(long pnIB, int nFaces, int nVertices, int nCacheSize, long pnFaceClusters, long pnIBOut, long pnFaceRemapOut, int eVCacheOptimizer) Unsafe version of:VCacheClustersstatic voidFrees all resources held by Tootle.static intTootleClusterMesh(ByteBuffer pVB, IntBuffer pnIB, int nVBStride, int nTargetClusters, IntBuffer pnClusteredIBOut, IntBuffer pnFaceClustersOut, @Nullable IntBuffer pnFaceRemapOut) This function partitions a mesh into a set of connected, roughly planar clusters.static intTootleClusterMesh(FloatBuffer pVB, IntBuffer pnIB, int nVBStride, int nTargetClusters, IntBuffer pnClusteredIBOut, IntBuffer pnFaceClustersOut, @Nullable IntBuffer pnFaceRemapOut) This function partitions a mesh into a set of connected, roughly planar clusters.static intTootleFastOptimize(ByteBuffer pVB, IntBuffer pnIB, int nVBStride, int nCacheSize, int eFrontWinding, IntBuffer pnIBOut, @Nullable IntBuffer pnNumClustersOut, float fAlpha) This is a utility function that performs the entire optimization using the new algorithm from SIGGRAPH 2007.static intTootleFastOptimize(FloatBuffer pVB, IntBuffer pnIB, int nVBStride, int nCacheSize, int eFrontWinding, IntBuffer pnIBOut, @Nullable IntBuffer pnNumClustersOut, float fAlpha) This is a utility function that performs the entire optimization using the new algorithm from SIGGRAPH 2007.static intTootleFastOptimizeVCacheAndClusterMesh(IntBuffer pnIB, int nVertices, int nCacheSize, IntBuffer pnIBOut, IntBuffer pnClustersOut, IntBuffer pnNumClustersOut, float fAlpha) This function performs vertex cache optimization and clustering the mesh based on the algorithm from SIGGRAPH 2007.static intPerforms one-time initialization required by Tootle.static intTootleMeasureCacheEfficiency(IntBuffer pnIB, int nCacheSize, FloatBuffer pfEfficiencyOut) A utility function to simulate vertex processing and measures the cache efficiency of an index buffer.static intTootleMeasureOverdraw(ByteBuffer pVB, IntBuffer pnIB, int nVBStride, @Nullable FloatBuffer pfViewpoint, int eFrontWinding, @Nullable FloatBuffer pfAvgODOut, @Nullable FloatBuffer pfMaxODOut, int eOverdrawOptimizer) A utility function to measure the amount of overdraw that occurs over a set of views.static intTootleMeasureOverdraw(FloatBuffer pVB, IntBuffer pnIB, int nVBStride, @Nullable FloatBuffer pfViewpoint, int eFrontWinding, @Nullable FloatBuffer pfAvgODOut, @Nullable FloatBuffer pfMaxODOut, int eOverdrawOptimizer) A utility function to measure the amount of overdraw that occurs over a set of views.static intTootleOptimize(ByteBuffer pVB, IntBuffer pnIB, int nVBStride, int nCacheSize, @Nullable FloatBuffer pViewpoints, int eFrontWinding, IntBuffer pnIBOut, @Nullable IntBuffer pnNumClustersOut, int eVCacheOptimizer, int eOverdrawOptimizer) This is a utility function that is provided for developers to perform the entire optimization for a mesh.static intTootleOptimize(FloatBuffer pVB, IntBuffer pnIB, int nVBStride, int nCacheSize, @Nullable FloatBuffer pViewpoints, int eFrontWinding, IntBuffer pnIBOut, @Nullable IntBuffer pnNumClustersOut, int eVCacheOptimizer, int eOverdrawOptimizer) This is a utility function that is provided for developers to perform the entire optimization for a mesh.static intTootleOptimizeOverdraw(ByteBuffer pVB, IntBuffer pnIB, int nVBStride, @Nullable FloatBuffer pfViewpoint, int eFrontWinding, IntBuffer pnFaceClusters, @Nullable IntBuffer pnIBOut, @Nullable IntBuffer pnClusterRemapOut, int eOverdrawOptimizer) Given a clustered mesh, this function computes a cluster ordering that minimizes expected overdraw, and sorts the clusters according to this ordering.static intTootleOptimizeOverdraw(FloatBuffer pVB, IntBuffer pnIB, int nVBStride, @Nullable FloatBuffer pfViewpoint, int eFrontWinding, IntBuffer pnFaceClusters, @Nullable IntBuffer pnIBOut, @Nullable IntBuffer pnClusterRemapOut, int eOverdrawOptimizer) Given a clustered mesh, this function computes a cluster ordering that minimizes expected overdraw, and sorts the clusters according to this ordering.static intTootleOptimizeVCache(IntBuffer pnIB, int nVertices, int nCacheSize, @Nullable IntBuffer pnIBOut, @Nullable IntBuffer pnFaceRemapOut, int eVCacheOptimizer) This function performs vertex cache optimization on an index buffer.static intTootleOptimizeVertexMemory(ByteBuffer pVB, IntBuffer pnIB, int nVBStride, ByteBuffer pVBOut, IntBuffer pnIBOut, @Nullable IntBuffer pnVertexRemapOut) This function rearranges the vertex buffer's memory location based on the index buffer.static intTootleOptimizeVertexMemory(FloatBuffer pVB, IntBuffer pnIB, int nVBStride, FloatBuffer pVBOut, IntBuffer pnIBOut, @Nullable IntBuffer pnVertexRemapOut) This function rearranges the vertex buffer's memory location based on the index buffer.static intTootleVCacheClusters(IntBuffer pnIB, int nVertices, int nCacheSize, IntBuffer pnFaceClusters, @Nullable IntBuffer pnIBOut, @Nullable IntBuffer pnFaceRemapOut, int eVCacheOptimizer) This is a utility function to optimize vertex cache on a clustered index buffer.
-
Field Details
-
TOOTLE_DEFAULT_VCACHE_SIZE
public static final int TOOTLE_DEFAULT_VCACHE_SIZEThe default vertex cache size.- See Also:
-
TOOTLE_MAX_FACES
public static final int TOOTLE_MAX_FACESThe maximum allowed number of faces in the mesh.- See Also:
-
TOOTLE_MAX_VERTICES
public static final int TOOTLE_MAX_VERTICESThe maximum allowed number of vertices in the mesh.- See Also:
-
TOOTLE_DEFAULT_ALPHA
public static final float TOOTLE_DEFAULT_ALPHAThe parameter forFastOptimizeto create more clusters (lower number generates more clusters).This parameter decides where to put extra breaks to create more clusters (refer to the SIGGRAPH 2007 paper for the full description of the parameter).
- See Also:
-
TOOTLE_OK
public static final int TOOTLE_OKEnumeration for Tootle return codes. (TootleResult)Enum values:
OK- All is wellINVALID_ARGS- Illegal arguments were passed.OUT_OF_MEMORY- Tootle ran out of memory while trying to complete the call.3D_API_ERROR- Errors occurred while setting up the 3D API. This generally means that D3D isn't installed properly.INTERNAL_ERROR- Something happened that really, really shouldn't.NOT_INITIALIZED- Tootle was not initialized before a function call.
- See Also:
-
TOOTLE_INVALID_ARGS
public static final int TOOTLE_INVALID_ARGSEnumeration for Tootle return codes. (TootleResult)Enum values:
OK- All is wellINVALID_ARGS- Illegal arguments were passed.OUT_OF_MEMORY- Tootle ran out of memory while trying to complete the call.3D_API_ERROR- Errors occurred while setting up the 3D API. This generally means that D3D isn't installed properly.INTERNAL_ERROR- Something happened that really, really shouldn't.NOT_INITIALIZED- Tootle was not initialized before a function call.
- See Also:
-
TOOTLE_OUT_OF_MEMORY
public static final int TOOTLE_OUT_OF_MEMORYEnumeration for Tootle return codes. (TootleResult)Enum values:
OK- All is wellINVALID_ARGS- Illegal arguments were passed.OUT_OF_MEMORY- Tootle ran out of memory while trying to complete the call.3D_API_ERROR- Errors occurred while setting up the 3D API. This generally means that D3D isn't installed properly.INTERNAL_ERROR- Something happened that really, really shouldn't.NOT_INITIALIZED- Tootle was not initialized before a function call.
- See Also:
-
TOOTLE_3D_API_ERROR
public static final int TOOTLE_3D_API_ERROREnumeration for Tootle return codes. (TootleResult)Enum values:
OK- All is wellINVALID_ARGS- Illegal arguments were passed.OUT_OF_MEMORY- Tootle ran out of memory while trying to complete the call.3D_API_ERROR- Errors occurred while setting up the 3D API. This generally means that D3D isn't installed properly.INTERNAL_ERROR- Something happened that really, really shouldn't.NOT_INITIALIZED- Tootle was not initialized before a function call.
- See Also:
-
TOOTLE_INTERNAL_ERROR
public static final int TOOTLE_INTERNAL_ERROREnumeration for Tootle return codes. (TootleResult)Enum values:
OK- All is wellINVALID_ARGS- Illegal arguments were passed.OUT_OF_MEMORY- Tootle ran out of memory while trying to complete the call.3D_API_ERROR- Errors occurred while setting up the 3D API. This generally means that D3D isn't installed properly.INTERNAL_ERROR- Something happened that really, really shouldn't.NOT_INITIALIZED- Tootle was not initialized before a function call.
- See Also:
-
TOOTLE_NOT_INITIALIZED
public static final int TOOTLE_NOT_INITIALIZEDEnumeration for Tootle return codes. (TootleResult)Enum values:
OK- All is wellINVALID_ARGS- Illegal arguments were passed.OUT_OF_MEMORY- Tootle ran out of memory while trying to complete the call.3D_API_ERROR- Errors occurred while setting up the 3D API. This generally means that D3D isn't installed properly.INTERNAL_ERROR- Something happened that really, really shouldn't.NOT_INITIALIZED- Tootle was not initialized before a function call.
- See Also:
-
TOOTLE_CCW
public static final int TOOTLE_CCWEnumeration for face winding order. (TootleFaceWinding)Enum values:
- See Also:
-
TOOTLE_CW
public static final int TOOTLE_CWEnumeration for face winding order. (TootleFaceWinding)Enum values:
- See Also:
-
TOOTLE_VCACHE_AUTO
public static final int TOOTLE_VCACHE_AUTOEnumeration for the algorithm for vertex optimization. (TootleVCacheOptimizer)Enum values:
VCACHE_AUTO- If vertex cache size is less than 7, use LSTRIPS algorithm otherwise TIPSY.VCACHE_DIRECT3D- Use D3DXOptimizeFaces to optimize faces.VCACHE_LSTRIPS- Build a list like triangle strips to optimize faces.VCACHE_TIPSY- Use TIPSY (the algorithm from SIGGRAPH 2007) to optimize faces.
- See Also:
-
TOOTLE_VCACHE_DIRECT3D
public static final int TOOTLE_VCACHE_DIRECT3DEnumeration for the algorithm for vertex optimization. (TootleVCacheOptimizer)Enum values:
VCACHE_AUTO- If vertex cache size is less than 7, use LSTRIPS algorithm otherwise TIPSY.VCACHE_DIRECT3D- Use D3DXOptimizeFaces to optimize faces.VCACHE_LSTRIPS- Build a list like triangle strips to optimize faces.VCACHE_TIPSY- Use TIPSY (the algorithm from SIGGRAPH 2007) to optimize faces.
- See Also:
-
TOOTLE_VCACHE_LSTRIPS
public static final int TOOTLE_VCACHE_LSTRIPSEnumeration for the algorithm for vertex optimization. (TootleVCacheOptimizer)Enum values:
VCACHE_AUTO- If vertex cache size is less than 7, use LSTRIPS algorithm otherwise TIPSY.VCACHE_DIRECT3D- Use D3DXOptimizeFaces to optimize faces.VCACHE_LSTRIPS- Build a list like triangle strips to optimize faces.VCACHE_TIPSY- Use TIPSY (the algorithm from SIGGRAPH 2007) to optimize faces.
- See Also:
-
TOOTLE_VCACHE_TIPSY
public static final int TOOTLE_VCACHE_TIPSYEnumeration for the algorithm for vertex optimization. (TootleVCacheOptimizer)Enum values:
VCACHE_AUTO- If vertex cache size is less than 7, use LSTRIPS algorithm otherwise TIPSY.VCACHE_DIRECT3D- Use D3DXOptimizeFaces to optimize faces.VCACHE_LSTRIPS- Build a list like triangle strips to optimize faces.VCACHE_TIPSY- Use TIPSY (the algorithm from SIGGRAPH 2007) to optimize faces.
- See Also:
-
TOOTLE_OVERDRAW_AUTO
public static final int TOOTLE_OVERDRAW_AUTOEnumeration for the algorithm for overdraw optimization. (TootleOverdrawOptimizer)Enum values:
OVERDRAW_AUTO- Use either Direct3D or raytracing to reorder clusters (depending on the number of clusters).OVERDRAW_DIRECT3D- Use Direct3D rendering to reorder clusters to optimize overdraw (slowO(N^2)).OVERDRAW_RAYTRACE- Use CPU raytracing to reorder clusters to optimize overdraw (slowO(N^2)).OVERDRAW_FAST- Use a fast approximation algorithm (from SIGGRAPH 2007) to reorder clusters.
- See Also:
-
TOOTLE_OVERDRAW_DIRECT3D
public static final int TOOTLE_OVERDRAW_DIRECT3DEnumeration for the algorithm for overdraw optimization. (TootleOverdrawOptimizer)Enum values:
OVERDRAW_AUTO- Use either Direct3D or raytracing to reorder clusters (depending on the number of clusters).OVERDRAW_DIRECT3D- Use Direct3D rendering to reorder clusters to optimize overdraw (slowO(N^2)).OVERDRAW_RAYTRACE- Use CPU raytracing to reorder clusters to optimize overdraw (slowO(N^2)).OVERDRAW_FAST- Use a fast approximation algorithm (from SIGGRAPH 2007) to reorder clusters.
- See Also:
-
TOOTLE_OVERDRAW_RAYTRACE
public static final int TOOTLE_OVERDRAW_RAYTRACEEnumeration for the algorithm for overdraw optimization. (TootleOverdrawOptimizer)Enum values:
OVERDRAW_AUTO- Use either Direct3D or raytracing to reorder clusters (depending on the number of clusters).OVERDRAW_DIRECT3D- Use Direct3D rendering to reorder clusters to optimize overdraw (slowO(N^2)).OVERDRAW_RAYTRACE- Use CPU raytracing to reorder clusters to optimize overdraw (slowO(N^2)).OVERDRAW_FAST- Use a fast approximation algorithm (from SIGGRAPH 2007) to reorder clusters.
- See Also:
-
TOOTLE_OVERDRAW_FAST
public static final int TOOTLE_OVERDRAW_FASTEnumeration for the algorithm for overdraw optimization. (TootleOverdrawOptimizer)Enum values:
OVERDRAW_AUTO- Use either Direct3D or raytracing to reorder clusters (depending on the number of clusters).OVERDRAW_DIRECT3D- Use Direct3D rendering to reorder clusters to optimize overdraw (slowO(N^2)).OVERDRAW_RAYTRACE- Use CPU raytracing to reorder clusters to optimize overdraw (slowO(N^2)).OVERDRAW_FAST- Use a fast approximation algorithm (from SIGGRAPH 2007) to reorder clusters.
- See Also:
-
-
Method Details
-
TootleInit
public static int TootleInit()Performs one-time initialization required by Tootle. -
nTootleOptimizeVCache
public static int nTootleOptimizeVCache(long pnIB, int nFaces, int nVertices, int nCacheSize, long pnIBOut, long pnFaceRemapOut, int eVCacheOptimizer) Unsafe version of:OptimizeVCache- Parameters:
nFaces- the number of faces in the index buffer. This must be non-zero and less thanMAX_FACES.
-
TootleOptimizeVCache
public static int TootleOptimizeVCache(IntBuffer pnIB, int nVertices, int nCacheSize, @Nullable IntBuffer pnIBOut, @Nullable IntBuffer pnFaceRemapOut, int eVCacheOptimizer) This function performs vertex cache optimization on an index buffer. It returns a face re-mapping if requested.- Parameters:
pnIB- the index buffer to optimize. Must be a triangle list.nVertices- the number of vertices in the model. This must non-zero and less thanMAX_VERTICES.nCacheSize- the number of vertices that will fit in cache. If the application does not know or care about the vertex cache size, then it should passDEFAULT_VCACHE_SIZE. This value must be non-zero.pnIBOut- a pointer that will be filled with an optimized index buffer. May beNULL. May equalpnIB.pnFaceRemapOut- a pointer to an array that will be filled with a face re-mapping. May beNULL. This is an array ofnFaceselements.Element
iin the array will contain the position of input faceiin the output face ordering.eVCacheOptimizer- the selection for choosing the algorithm to optimize vertex cache. One of:VCACHE_AUTOVCACHE_DIRECT3DVCACHE_LSTRIPSVCACHE_TIPSY- Returns:
- one of:
OK,OUT_OF_MEMORY,INVALID_ARGS
-
nTootleClusterMesh
public static int nTootleClusterMesh(long pVB, long pnIB, int nVertices, int nFaces, int nVBStride, int nTargetClusters, long pnClusteredIBOut, long pnFaceClustersOut, long pnFaceRemapOut) Unsafe version of:ClusterMesh- Parameters:
nVertices- number of vertices. This must be non-zero and less thanMAX_VERTICES.nFaces- number of faces. This must be non-zero and less thanMAX_FACES.
-
TootleClusterMesh
public static int TootleClusterMesh(ByteBuffer pVB, IntBuffer pnIB, int nVBStride, int nTargetClusters, IntBuffer pnClusteredIBOut, IntBuffer pnFaceClustersOut, @Nullable IntBuffer pnFaceRemapOut) This function partitions a mesh into a set of connected, roughly planar clusters. It generates a new mesh that is re-arranged in cluster order. This clustering is required as a pre-cursor to overdraw optimization. This function returns a mesh that is clustered. That is, the faces are sorted in ascending order by cluster ID. The number of clusters in the mesh will be equal topFaceClustersOut[ nFaces-1 ] + 1.- Parameters:
pVB- a pointer to the vertex buffer. The pointerpVBmust point to the vertex position. The vertex position must be a 3-component floating point value (X,Y,Z).pnIB- an index buffer. Must be a triangle list.nVBStride- the distance between successive vertices in the vertex buffer, in bytes. This must be at least3*sizeof(float).nTargetClusters- a target number of clusters. The clustering algorithm will create at least this many clusters, but not more thannFaces. This value is only a hint. More clusters may be created if Tootle considers it necessary. (for example, if there are numerous connected components in the mesh).Passing 0 for this value causes Tootle to use an automatic method to determine when to stop creating clusters.
pnClusteredIBOut- an array that will receive a copy of the index buffer, sorted by cluster ID. May not beNULL. May equalpnIB.pnFaceClustersOut- an array ofnFaces+1unsigned ints, that will be filled with the cluster ID that was assigned to each face in the output index buffer. The last element of the array contains the number of cluster. This is of a full format type. May not beNULL.pnFaceRemapOut- an array that will receive a face re-mapping. May beNULL. If notNULL, must be an array of sizenFaces. Thei'th element of the output array contains the position of input face i in the new face ordering.- Returns:
- one of:
OK,OUT_OF_MEMORY,INVALID_ARGS
-
TootleClusterMesh
public static int TootleClusterMesh(FloatBuffer pVB, IntBuffer pnIB, int nVBStride, int nTargetClusters, IntBuffer pnClusteredIBOut, IntBuffer pnFaceClustersOut, @Nullable IntBuffer pnFaceRemapOut) This function partitions a mesh into a set of connected, roughly planar clusters. It generates a new mesh that is re-arranged in cluster order. This clustering is required as a pre-cursor to overdraw optimization. This function returns a mesh that is clustered. That is, the faces are sorted in ascending order by cluster ID. The number of clusters in the mesh will be equal topFaceClustersOut[ nFaces-1 ] + 1.- Parameters:
pVB- a pointer to the vertex buffer. The pointerpVBmust point to the vertex position. The vertex position must be a 3-component floating point value (X,Y,Z).pnIB- an index buffer. Must be a triangle list.nVBStride- the distance between successive vertices in the vertex buffer, in bytes. This must be at least3*sizeof(float).nTargetClusters- a target number of clusters. The clustering algorithm will create at least this many clusters, but not more thannFaces. This value is only a hint. More clusters may be created if Tootle considers it necessary. (for example, if there are numerous connected components in the mesh).Passing 0 for this value causes Tootle to use an automatic method to determine when to stop creating clusters.
pnClusteredIBOut- an array that will receive a copy of the index buffer, sorted by cluster ID. May not beNULL. May equalpnIB.pnFaceClustersOut- an array ofnFaces+1unsigned ints, that will be filled with the cluster ID that was assigned to each face in the output index buffer. The last element of the array contains the number of cluster. This is of a full format type. May not beNULL.pnFaceRemapOut- an array that will receive a face re-mapping. May beNULL. If notNULL, must be an array of sizenFaces. Thei'th element of the output array contains the position of input face i in the new face ordering.- Returns:
- one of:
OK,OUT_OF_MEMORY,INVALID_ARGS
-
nTootleFastOptimizeVCacheAndClusterMesh
public static int nTootleFastOptimizeVCacheAndClusterMesh(long pnIB, int nFaces, int nVertices, int nCacheSize, long pnIBOut, long pnClustersOut, long pnNumClustersOut, float fAlpha) Unsafe version of:FastOptimizeVCacheAndClusterMesh- Parameters:
nFaces- the number of faces in the index buffer
-
TootleFastOptimizeVCacheAndClusterMesh
public static int TootleFastOptimizeVCacheAndClusterMesh(IntBuffer pnIB, int nVertices, int nCacheSize, IntBuffer pnIBOut, IntBuffer pnClustersOut, IntBuffer pnNumClustersOut, float fAlpha) This function performs vertex cache optimization and clustering the mesh based on the algorithm from SIGGRAPH 2007. It produces the re-ordered index buffer and an array of the resulting clusters. The result can be used as inputs toOptimizeOverdraw.- Parameters:
pnIB- the input index buffer: 3unsigned intper triangle.nVertices- the number of vertices in the vertex buffernCacheSize- hardware cache size (12 to 24 are good options)pnIBOut- the updated index buffer (the output). May not beNULL. May equalpnIB.pnClustersOut- the output clusters which is an array ofnFaces+1unsigned ints. It is of a compact format type. Entryiandi+1mark all face ids in[i, i+1)to be in clusteri. The last element of the array contains the number of clusters. May not beNULL. This has to be pre-allocated of sizenFaces+1.pnNumClustersOut- the total number of clusters inpnClustersOutfAlpha- a linear parameter to compute lambda term from the algorithm. PassDEFAULT_ALPHAas a default.- Returns:
- one of:
OK,OUT_OF_MEMORY,INVALID_ARGS
-
nTootleOptimizeOverdraw
public static int nTootleOptimizeOverdraw(long pVB, long pnIB, int nVertices, int nFaces, int nVBStride, long pfViewpoint, int nViewpoints, int eFrontWinding, long pnFaceClusters, long pnIBOut, long pnClusterRemapOut, int eOverdrawOptimizer) Unsafe version of:OptimizeOverdraw- Parameters:
nVertices- the number of vertices in the mesh. This must be non-zero and less thanMAX_VERTICES.nFaces- the number of faces in the mesh. This must be non-zero and less thanMAX_FACES.nViewpoints- the number of viewpoints in the viewpoint array
-
TootleOptimizeOverdraw
public static int TootleOptimizeOverdraw(ByteBuffer pVB, IntBuffer pnIB, int nVBStride, @Nullable FloatBuffer pfViewpoint, int eFrontWinding, IntBuffer pnFaceClusters, @Nullable IntBuffer pnIBOut, @Nullable IntBuffer pnClusterRemapOut, int eOverdrawOptimizer) Given a clustered mesh, this function computes a cluster ordering that minimizes expected overdraw, and sorts the clusters according to this ordering. The input is a mesh whose faces are seperated into clusters. The clustering can be obtained by callingClusterMesh, or the application can supply its own clustering.- Parameters:
pVB- a pointer to the vertex buffer. The pointerpVBmust point to the vertex position. The vertex position must be a 3-component floating point value (X,Y,Z).pnIB- the mesh index buffer. This must be a triangle list. The faces must be clustered.nVBStride- the distance between successive vertices in the vertex buffer, in bytes. This must be at least3*sizeof(float).pfViewpoint- an array of viewpoints to use to measure overdraw. Each viewpoint must be a point on or in the unit sphere. When measuring overdraw, the mesh will be scaled and translated so that it lies inside the unit sphere. The mesh will be rendered with orthographic projections, with the camera centered at the given point looking at the origin. If this argument isNULL, a default viewpoint set will be used.eFrontWinding- the winding order of front-faces in the mesh. One of:CCWCWpnFaceClusters- this array ofnFaces+1size can be either of two types: a full format (the output ofClusterMesh) or a compact format (the output ofFastOptimizeVCacheAndClusterMesh).The full format is an array of mapping for each face to the cluster ID. The entry
iof this array contains the cluster ID of facei.The compact format is an array that maps every face ID between entry
iandi+1to be in clusteri.For both formats, the last entry of the array (
pnFaceClusters[ nFaces ]) should contains the number of total clusters.pnIBOut- an array that will receive the re-ordered index buffer. May beNULL. May equalpnIB.pnClusterRemapOut- an array that will receive the cluster ordering. May beNULL. If non-null, the size of the array must be equal to the number of clusters in the mesh.pClusterRemapOut[i]will be set to the ID of the cluster that should comei'th in the draw order.eOverdrawOptimizer- the algorithm selection for optimizing overdraw. One of:OVERDRAW_AUTOOVERDRAW_DIRECT3DOVERDRAW_RAYTRACEOVERDRAW_FAST- Returns:
- one of:
OK,OUT_OF_MEMORY,INVALID_ARGS3D_API_ERROR,NOT_INITIALIZED
-
TootleOptimizeOverdraw
public static int TootleOptimizeOverdraw(FloatBuffer pVB, IntBuffer pnIB, int nVBStride, @Nullable FloatBuffer pfViewpoint, int eFrontWinding, IntBuffer pnFaceClusters, @Nullable IntBuffer pnIBOut, @Nullable IntBuffer pnClusterRemapOut, int eOverdrawOptimizer) Given a clustered mesh, this function computes a cluster ordering that minimizes expected overdraw, and sorts the clusters according to this ordering. The input is a mesh whose faces are seperated into clusters. The clustering can be obtained by callingClusterMesh, or the application can supply its own clustering.- Parameters:
pVB- a pointer to the vertex buffer. The pointerpVBmust point to the vertex position. The vertex position must be a 3-component floating point value (X,Y,Z).pnIB- the mesh index buffer. This must be a triangle list. The faces must be clustered.nVBStride- the distance between successive vertices in the vertex buffer, in bytes. This must be at least3*sizeof(float).pfViewpoint- an array of viewpoints to use to measure overdraw. Each viewpoint must be a point on or in the unit sphere. When measuring overdraw, the mesh will be scaled and translated so that it lies inside the unit sphere. The mesh will be rendered with orthographic projections, with the camera centered at the given point looking at the origin. If this argument isNULL, a default viewpoint set will be used.eFrontWinding- the winding order of front-faces in the mesh. One of:CCWCWpnFaceClusters- this array ofnFaces+1size can be either of two types: a full format (the output ofClusterMesh) or a compact format (the output ofFastOptimizeVCacheAndClusterMesh).The full format is an array of mapping for each face to the cluster ID. The entry
iof this array contains the cluster ID of facei.The compact format is an array that maps every face ID between entry
iandi+1to be in clusteri.For both formats, the last entry of the array (
pnFaceClusters[ nFaces ]) should contains the number of total clusters.pnIBOut- an array that will receive the re-ordered index buffer. May beNULL. May equalpnIB.pnClusterRemapOut- an array that will receive the cluster ordering. May beNULL. If non-null, the size of the array must be equal to the number of clusters in the mesh.pClusterRemapOut[i]will be set to the ID of the cluster that should comei'th in the draw order.eOverdrawOptimizer- the algorithm selection for optimizing overdraw. One of:OVERDRAW_AUTOOVERDRAW_DIRECT3DOVERDRAW_RAYTRACEOVERDRAW_FAST- Returns:
- one of:
OK,OUT_OF_MEMORY,INVALID_ARGS3D_API_ERROR,NOT_INITIALIZED
-
TootleCleanup
public static void TootleCleanup()Frees all resources held by Tootle. -
nTootleOptimize
public static int nTootleOptimize(long pVB, long pnIB, int nVertices, int nFaces, int nVBStride, int nCacheSize, long pViewpoints, int nViewpoints, int eFrontWinding, long pnIBOut, long pnNumClustersOut, int eVCacheOptimizer, int eOverdrawOptimizer) Unsafe version of:Optimize- Parameters:
nVertices- number of vertices. This must be non-zero and less thanMAX_VERTICES.nFaces- number of faces. This must be non-zero and less thanMAX_FACES.nViewpoints- the number of viewpoints in the viewpoint array
-
TootleOptimize
public static int TootleOptimize(ByteBuffer pVB, IntBuffer pnIB, int nVBStride, int nCacheSize, @Nullable FloatBuffer pViewpoints, int eFrontWinding, IntBuffer pnIBOut, @Nullable IntBuffer pnNumClustersOut, int eVCacheOptimizer, int eOverdrawOptimizer) This is a utility function that is provided for developers to perform the entire optimization for a mesh.The function calls the three core functions to create clusters for the mesh (
ClusterMesh), optimize vertex cache for each cluster (VCacheClusters), and reorder the clusters to optimize overdraw (OptimizeOverdraw). It generates a new indices for faces that is optimized for post-transform vertex cache and overdraw.- Parameters:
pVB- a pointer to the vertex buffer. The pointerpVBmust point to the vertex position. The vertex position must be a 3-component floating point value (X,Y,Z).pnIB- an index buffer. Must be a triangle list.nVBStride- the distance between successive vertices in the vertex buffer, in bytes. This must be at least3*sizeof(float).nCacheSize- the number of vertices that will fit in cache. If the application does not know or care about the vertex cache size, then it should passDEFAULT_VCACHE_SIZE. This value must be non-zero.pViewpoints- an array of viewpoints to use to measure overdraw. Each viewpoint must be a point on or in the unit sphere. When measuring overdraw, the mesh will be scaled and translated so that it lies inside the unit sphere. The mesh will be rendered with orthographic projections, with the camera centered at the given point looking at the origin. If this argument isNULL, a default viewpoint set will be used.eFrontWinding- the winding order of front-faces in the model. One of:CCWCWpnIBOut- a pointer that will be filled with an optimized index buffer. May not beNULL. May equalpIB.pnNumClustersOut- the number of clusters generated by the algorithm. May beNULLif the output is not requested.eVCacheOptimizer- the selection for choosing the algorithm to optimize vertex cache. One of:VCACHE_AUTOVCACHE_DIRECT3DVCACHE_LSTRIPSVCACHE_TIPSYeOverdrawOptimizer- the algorithm selection for optimizing overdraw. One of:OVERDRAW_AUTOOVERDRAW_DIRECT3DOVERDRAW_RAYTRACEOVERDRAW_FAST- Returns:
- one of:
OK,OUT_OF_MEMORY,INVALID_ARGS
-
TootleOptimize
public static int TootleOptimize(FloatBuffer pVB, IntBuffer pnIB, int nVBStride, int nCacheSize, @Nullable FloatBuffer pViewpoints, int eFrontWinding, IntBuffer pnIBOut, @Nullable IntBuffer pnNumClustersOut, int eVCacheOptimizer, int eOverdrawOptimizer) This is a utility function that is provided for developers to perform the entire optimization for a mesh.The function calls the three core functions to create clusters for the mesh (
ClusterMesh), optimize vertex cache for each cluster (VCacheClusters), and reorder the clusters to optimize overdraw (OptimizeOverdraw). It generates a new indices for faces that is optimized for post-transform vertex cache and overdraw.- Parameters:
pVB- a pointer to the vertex buffer. The pointerpVBmust point to the vertex position. The vertex position must be a 3-component floating point value (X,Y,Z).pnIB- an index buffer. Must be a triangle list.nVBStride- the distance between successive vertices in the vertex buffer, in bytes. This must be at least3*sizeof(float).nCacheSize- the number of vertices that will fit in cache. If the application does not know or care about the vertex cache size, then it should passDEFAULT_VCACHE_SIZE. This value must be non-zero.pViewpoints- an array of viewpoints to use to measure overdraw. Each viewpoint must be a point on or in the unit sphere. When measuring overdraw, the mesh will be scaled and translated so that it lies inside the unit sphere. The mesh will be rendered with orthographic projections, with the camera centered at the given point looking at the origin. If this argument isNULL, a default viewpoint set will be used.eFrontWinding- the winding order of front-faces in the model. One of:CCWCWpnIBOut- a pointer that will be filled with an optimized index buffer. May not beNULL. May equalpIB.pnNumClustersOut- the number of clusters generated by the algorithm. May beNULLif the output is not requested.eVCacheOptimizer- the selection for choosing the algorithm to optimize vertex cache. One of:VCACHE_AUTOVCACHE_DIRECT3DVCACHE_LSTRIPSVCACHE_TIPSYeOverdrawOptimizer- the algorithm selection for optimizing overdraw. One of:OVERDRAW_AUTOOVERDRAW_DIRECT3DOVERDRAW_RAYTRACEOVERDRAW_FAST- Returns:
- one of:
OK,OUT_OF_MEMORY,INVALID_ARGS
-
nTootleFastOptimize
public static int nTootleFastOptimize(long pVB, long pnIB, int nVertices, int nFaces, int nVBStride, int nCacheSize, int eFrontWinding, long pnIBOut, long pnNumClustersOut, float fAlpha) Unsafe version of:FastOptimize- Parameters:
nVertices- the number of vertices in the vertex buffernFaces- the number of faces in the index buffer
-
TootleFastOptimize
public static int TootleFastOptimize(ByteBuffer pVB, IntBuffer pnIB, int nVBStride, int nCacheSize, int eFrontWinding, IntBuffer pnIBOut, @Nullable IntBuffer pnNumClustersOut, float fAlpha) This is a utility function that performs the entire optimization using the new algorithm from SIGGRAPH 2007. This function performs vertex cache optimization and clustering, then optimize overdraw on the clusters generated. It generates a new indices for faces that is optimized for post-transform vertex cache and overdraw.- Parameters:
pVB- a pointer to the vertex buffer. The pointerpVBmust point to the vertex position. The vertex position must be a 3-component floating point value (X,Y,Z).pnIB- the input index buffer: 3unsigned intper trianglenVBStride- the distance between successive vertices in the vertex buffer, in bytes. This must be at least3*sizeof(float).nCacheSize- hardware cache size (12 to 24 are good options)eFrontWinding- the winding order of front-faces in the model. One of:CCWCWpnIBOut- the updated index buffer (the output). May not beNULL. May equalpnIB.pnNumClustersOut- the number of output clusters. May beNULLif not requested.fAlpha- a linear parameter to compute lambda term from the algorithm. PassDEFAULT_ALPHAas a default.- Returns:
- one of:
OK,OUT_OF_MEMORY,INVALID_ARGS
-
TootleFastOptimize
public static int TootleFastOptimize(FloatBuffer pVB, IntBuffer pnIB, int nVBStride, int nCacheSize, int eFrontWinding, IntBuffer pnIBOut, @Nullable IntBuffer pnNumClustersOut, float fAlpha) This is a utility function that performs the entire optimization using the new algorithm from SIGGRAPH 2007. This function performs vertex cache optimization and clustering, then optimize overdraw on the clusters generated. It generates a new indices for faces that is optimized for post-transform vertex cache and overdraw.- Parameters:
pVB- a pointer to the vertex buffer. The pointerpVBmust point to the vertex position. The vertex position must be a 3-component floating point value (X,Y,Z).pnIB- the input index buffer: 3unsigned intper trianglenVBStride- the distance between successive vertices in the vertex buffer, in bytes. This must be at least3*sizeof(float).nCacheSize- hardware cache size (12 to 24 are good options)eFrontWinding- the winding order of front-faces in the model. One of:CCWCWpnIBOut- the updated index buffer (the output). May not beNULL. May equalpnIB.pnNumClustersOut- the number of output clusters. May beNULLif not requested.fAlpha- a linear parameter to compute lambda term from the algorithm. PassDEFAULT_ALPHAas a default.- Returns:
- one of:
OK,OUT_OF_MEMORY,INVALID_ARGS
-
nTootleVCacheClusters
public static int nTootleVCacheClusters(long pnIB, int nFaces, int nVertices, int nCacheSize, long pnFaceClusters, long pnIBOut, long pnFaceRemapOut, int eVCacheOptimizer) Unsafe version of:VCacheClusters- Parameters:
nFaces- the number of faces in the index buffer. This must be non-zero and less thanMAX_FACES.
-
TootleVCacheClusters
public static int TootleVCacheClusters(IntBuffer pnIB, int nVertices, int nCacheSize, IntBuffer pnFaceClusters, @Nullable IntBuffer pnIBOut, @Nullable IntBuffer pnFaceRemapOut, int eVCacheOptimizer) This is a utility function to optimize vertex cache on a clustered index buffer. This function simply callsOptimizeVCacherepeatedly. The faces within each cluster will be re-ordered, but the clustering will be maintained.- Parameters:
pnIB- the index buffer to optimize. Must be a triangle list.nVertices- the number of vertices in the model. This must be non-zero and less thanMAX_VERTICES.nCacheSize- the number of vertices that will fit in cache. If the application does not know or care about the vertex cache size, then it should passDEFAULT_VCACHE_SIZE. This value must be non-zero.pnFaceClusters- an array giving the cluster ID for each face. All faces in a particular cluster should appear consecutively in the index buffer, as well as in this array. It should be of sizenFaces+1.pnIBOut- a pointer that will be filled with an optimized index buffer. May beNULL. May equalpnIB.pnFaceRemapOut- a pointer to an array that will be filled with a face re-mapping. May beNULL. This is an array ofnFaceselements.Element
iin the array will contain the position of input faceiin the output face ordering.eVCacheOptimizer- the selection for choosing the algorithm to optimize vertex cache. One of:VCACHE_AUTOVCACHE_DIRECT3DVCACHE_LSTRIPSVCACHE_TIPSY- Returns:
- one of:
OK,OUT_OF_MEMORY,INVALID_ARGS
-
nTootleMeasureCacheEfficiency
public static int nTootleMeasureCacheEfficiency(long pnIB, int nFaces, int nCacheSize, long pfEfficiencyOut) Unsafe version of:MeasureCacheEfficiency- Parameters:
nFaces- the number of faces in the index buffer. This must be non-zero and less thanMAX_FACES.
-
TootleMeasureCacheEfficiency
public static int TootleMeasureCacheEfficiency(IntBuffer pnIB, int nCacheSize, FloatBuffer pfEfficiencyOut) A utility function to simulate vertex processing and measures the cache efficiency of an index buffer.The return cache efficiency is the ACMR (Average Cache Miss Ratio) of the mesh. It ranges between 0.5 to 3. 0.5 is the best optimal value, 3 is the worst ratio.
- Parameters:
pnIB- the index buffer whose efficiency should be measured. Must be a triangle list.nCacheSize- the number of vertices that will fit in cache. If the application doesn't know or care, it should useDEFAULT_VCACHE_SIZE.pfEfficiencyOut- a pointer to receive the vertex cache efficiency. This is defined as the number of cache misses per triangle.- Returns:
- one of:
OK,OUT_OF_MEMORY,INVALID_ARGS
-
nTootleMeasureOverdraw
public static int nTootleMeasureOverdraw(long pVB, long pnIB, int nVertices, int nFaces, int nVBStride, long pfViewpoint, int nViewpoints, int eFrontWinding, long pfAvgODOut, long pfMaxODOut, int eOverdrawOptimizer) Unsafe version of:MeasureOverdraw- Parameters:
nVertices- the number of vertices. This must be non-zero and less thanMAX_VERTICES.nFaces- the number of indices. This must be non-zero and less thanMAX_FACES.nViewpoints- the number of viewpoints in the viewpoint array
-
TootleMeasureOverdraw
public static int TootleMeasureOverdraw(ByteBuffer pVB, IntBuffer pnIB, int nVBStride, @Nullable FloatBuffer pfViewpoint, int eFrontWinding, @Nullable FloatBuffer pfAvgODOut, @Nullable FloatBuffer pfMaxODOut, int eOverdrawOptimizer) A utility function to measure the amount of overdraw that occurs over a set of views. Overdraw is defined as the number of pixels rendered divided by the number of pixels covered by an object, minus one.- Parameters:
pVB- a pointer to the vertex buffer. The pointerpVBmust point to the vertex position. The vertex position must be a 3-component floating point value (X,Y,Z).pnIB- the index buffer. Must be a triangle list.nVBStride- the distance between successive vertices in the vertex buffer, in bytes. This must be at least3*sizeof(float).pfViewpoint- an array of viewpoints to use to measure overdraw. Each viewpoint must be a point on or in the unit sphere. When measuring overdraw, the mesh will be scaled and translated so that it lies inside the unit sphere. The mesh will be rendered with orthographic projections, with the camera centered at the given point looking at the origin. If this argument isNULL, a default viewpoint set will be used.eFrontWinding- the winding order of front-faces in the modelpfAvgODOut- a pointer to a variable to receive the average overdraw per pixel. May beNULL.pfMaxODOut- a pointer to a variable to receive the maximum overdraw per pixel. May beNULL.eOverdrawOptimizer- the algorithm selection for optimizing overdraw. One of:OVERDRAW_AUTOOVERDRAW_DIRECT3DOVERDRAW_RAYTRACEOVERDRAW_FAST- Returns:
- one of:
OK,OUT_OF_MEMORY,INVALID_ARGS,NOT_INITIALIZED
-
TootleMeasureOverdraw
public static int TootleMeasureOverdraw(FloatBuffer pVB, IntBuffer pnIB, int nVBStride, @Nullable FloatBuffer pfViewpoint, int eFrontWinding, @Nullable FloatBuffer pfAvgODOut, @Nullable FloatBuffer pfMaxODOut, int eOverdrawOptimizer) A utility function to measure the amount of overdraw that occurs over a set of views. Overdraw is defined as the number of pixels rendered divided by the number of pixels covered by an object, minus one.- Parameters:
pVB- a pointer to the vertex buffer. The pointerpVBmust point to the vertex position. The vertex position must be a 3-component floating point value (X,Y,Z).pnIB- the index buffer. Must be a triangle list.nVBStride- the distance between successive vertices in the vertex buffer, in bytes. This must be at least3*sizeof(float).pfViewpoint- an array of viewpoints to use to measure overdraw. Each viewpoint must be a point on or in the unit sphere. When measuring overdraw, the mesh will be scaled and translated so that it lies inside the unit sphere. The mesh will be rendered with orthographic projections, with the camera centered at the given point looking at the origin. If this argument isNULL, a default viewpoint set will be used.eFrontWinding- the winding order of front-faces in the modelpfAvgODOut- a pointer to a variable to receive the average overdraw per pixel. May beNULL.pfMaxODOut- a pointer to a variable to receive the maximum overdraw per pixel. May beNULL.eOverdrawOptimizer- the algorithm selection for optimizing overdraw. One of:OVERDRAW_AUTOOVERDRAW_DIRECT3DOVERDRAW_RAYTRACEOVERDRAW_FAST- Returns:
- one of:
OK,OUT_OF_MEMORY,INVALID_ARGS,NOT_INITIALIZED
-
nTootleOptimizeVertexMemory
public static int nTootleOptimizeVertexMemory(long pVB, long pnIB, int nVertices, int nFaces, int nVBStride, long pVBOut, long pnIBOut, long pnVertexRemapOut) Unsafe version of:OptimizeVertexMemory- Parameters:
nVertices- the number of vertices in the mesh. This must be non-zero and less thanMAX_VERTICES.nFaces- the number of faces in the mesh. This must be non-zero and less thanMAX_FACES.
-
TootleOptimizeVertexMemory
public static int TootleOptimizeVertexMemory(ByteBuffer pVB, IntBuffer pnIB, int nVBStride, ByteBuffer pVBOut, IntBuffer pnIBOut, @Nullable IntBuffer pnVertexRemapOut) This function rearranges the vertex buffer's memory location based on the index buffer.Call this function after you have optimized the index buffer for vertex cache post-tranform and/or overdraw. The idea is to rearrange the memory location for vertex buffer such that it will be optimized for vertex prefetch cache. Typically vertices are fetched in a cacheline (more than one vertex at a time). Thus, the vertex in the next memory location will come for free if they are processed next in line. This is what we want to exploit. It will compute a new Vertex Buffer and Index Buffer (since the vertices have been reordered).
- Parameters:
pVB- a pointer to the vertex buffer. The pointerpVBmust point to the vertex position. The vertex position must be a 3-component floating point value (X,Y,Z).pnIB- the mesh index buffer. This must be a triangle list.nVBStride- the distance between successive vertices in the vertex buffer, in bytes. This must be at least3*sizeof(float).pVBOut- the output vertex buffer. May beNULL. May equalpVB.pnIBOut- the output index buffer. May not beNULL. May equalpnIB.pnVertexRemapOut- an array that will receive a vertex re-mapping. May beNULLif the output is not requested. If notNULL, must be an array of sizenVertices. Thei'th element of the output array contains the position of the input vertexiin the new vertex re-ordering.- Returns:
- one of:
OK,OUT_OF_MEMORY,INVALID_ARGS
-
TootleOptimizeVertexMemory
public static int TootleOptimizeVertexMemory(FloatBuffer pVB, IntBuffer pnIB, int nVBStride, FloatBuffer pVBOut, IntBuffer pnIBOut, @Nullable IntBuffer pnVertexRemapOut) This function rearranges the vertex buffer's memory location based on the index buffer.Call this function after you have optimized the index buffer for vertex cache post-tranform and/or overdraw. The idea is to rearrange the memory location for vertex buffer such that it will be optimized for vertex prefetch cache. Typically vertices are fetched in a cacheline (more than one vertex at a time). Thus, the vertex in the next memory location will come for free if they are processed next in line. This is what we want to exploit. It will compute a new Vertex Buffer and Index Buffer (since the vertices have been reordered).
- Parameters:
pVB- a pointer to the vertex buffer. The pointerpVBmust point to the vertex position. The vertex position must be a 3-component floating point value (X,Y,Z).pnIB- the mesh index buffer. This must be a triangle list.nVBStride- the distance between successive vertices in the vertex buffer, in bytes. This must be at least3*sizeof(float).pVBOut- the output vertex buffer. May beNULL. May equalpVB.pnIBOut- the output index buffer. May not beNULL. May equalpnIB.pnVertexRemapOut- an array that will receive a vertex re-mapping. May beNULLif the output is not requested. If notNULL, must be an array of sizenVertices. Thei'th element of the output array contains the position of the input vertexiin the new vertex re-ordering.- Returns:
- one of:
OK,OUT_OF_MEMORY,INVALID_ARGS
-