Class Tootle


  • public class Tootle
    extends java.lang.Object
    Bindings to AMD 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.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      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
      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
      static int nTootleFastOptimizeVCacheAndClusterMesh​(long pnIB, int nFaces, int nVertices, int nCacheSize, long pnIBOut, long pnClustersOut, long pnNumClustersOut, float fAlpha)
      static int nTootleMeasureCacheEfficiency​(long pnIB, int nFaces, int nCacheSize, long pfEfficiencyOut)
      Unsafe version of: MeasureCacheEfficiency
      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
      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
      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
      static int nTootleOptimizeVCache​(long pnIB, int nFaces, int nVertices, int nCacheSize, long pnIBOut, long pnFaceRemapOut, int eVCacheOptimizer)
      Unsafe version of: OptimizeVCache
      static int nTootleOptimizeVertexMemory​(long pVB, long pnIB, int nVertices, int nFaces, int nVBStride, long pVBOut, long pnIBOut, long pnVertexRemapOut)
      Unsafe version of: OptimizeVertexMemory
      static int nTootleVCacheClusters​(long pnIB, int nFaces, int nVertices, int nCacheSize, long pnFaceClusters, long pnIBOut, long pnFaceRemapOut, int eVCacheOptimizer)
      Unsafe version of: VCacheClusters
      static void TootleCleanup()
      Frees all resources held by Tootle.
      static int TootleClusterMesh​(java.nio.ByteBuffer pVB, java.nio.IntBuffer pnIB, int nVBStride, int nTargetClusters, java.nio.IntBuffer pnClusteredIBOut, java.nio.IntBuffer pnFaceClustersOut, java.nio.IntBuffer pnFaceRemapOut)
      This function partitions a mesh into a set of connected, roughly planar clusters.
      static int TootleClusterMesh​(java.nio.FloatBuffer pVB, java.nio.IntBuffer pnIB, int nVBStride, int nTargetClusters, java.nio.IntBuffer pnClusteredIBOut, java.nio.IntBuffer pnFaceClustersOut, java.nio.IntBuffer pnFaceRemapOut)
      This function partitions a mesh into a set of connected, roughly planar clusters.
      static int TootleFastOptimize​(java.nio.ByteBuffer pVB, java.nio.IntBuffer pnIB, int nVBStride, int nCacheSize, int eFrontWinding, java.nio.IntBuffer pnIBOut, java.nio.IntBuffer pnNumClustersOut, float fAlpha)
      This is a utility function that performs the entire optimization using the new algorithm from SIGGRAPH 2007.
      static int TootleFastOptimize​(java.nio.FloatBuffer pVB, java.nio.IntBuffer pnIB, int nVBStride, int nCacheSize, int eFrontWinding, java.nio.IntBuffer pnIBOut, java.nio.IntBuffer pnNumClustersOut, float fAlpha)
      This is a utility function that performs the entire optimization using the new algorithm from SIGGRAPH 2007.
      static int TootleFastOptimizeVCacheAndClusterMesh​(java.nio.IntBuffer pnIB, int nVertices, int nCacheSize, java.nio.IntBuffer pnIBOut, java.nio.IntBuffer pnClustersOut, java.nio.IntBuffer pnNumClustersOut, float fAlpha)
      This function performs vertex cache optimization and clustering the mesh based on the algorithm from SIGGRAPH 2007.
      static int TootleInit()
      Performs one-time initialization required by Tootle.
      static int TootleMeasureCacheEfficiency​(java.nio.IntBuffer pnIB, int nCacheSize, java.nio.FloatBuffer pfEfficiencyOut)
      A utility function to simulate vertex processing and measures the cache efficiency of an index buffer.
      static int TootleMeasureOverdraw​(java.nio.ByteBuffer pVB, java.nio.IntBuffer pnIB, int nVBStride, java.nio.FloatBuffer pfViewpoint, int eFrontWinding, java.nio.FloatBuffer pfAvgODOut, java.nio.FloatBuffer pfMaxODOut, int eOverdrawOptimizer)
      A utility function to measure the amount of overdraw that occurs over a set of views.
      static int TootleMeasureOverdraw​(java.nio.FloatBuffer pVB, java.nio.IntBuffer pnIB, int nVBStride, java.nio.FloatBuffer pfViewpoint, int eFrontWinding, java.nio.FloatBuffer pfAvgODOut, java.nio.FloatBuffer pfMaxODOut, int eOverdrawOptimizer)
      A utility function to measure the amount of overdraw that occurs over a set of views.
      static int TootleOptimize​(java.nio.ByteBuffer pVB, java.nio.IntBuffer pnIB, int nVBStride, int nCacheSize, java.nio.FloatBuffer pViewpoints, int eFrontWinding, java.nio.IntBuffer pnIBOut, java.nio.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 int TootleOptimize​(java.nio.FloatBuffer pVB, java.nio.IntBuffer pnIB, int nVBStride, int nCacheSize, java.nio.FloatBuffer pViewpoints, int eFrontWinding, java.nio.IntBuffer pnIBOut, java.nio.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 int TootleOptimizeOverdraw​(java.nio.ByteBuffer pVB, java.nio.IntBuffer pnIB, int nVBStride, java.nio.FloatBuffer pfViewpoint, int eFrontWinding, java.nio.IntBuffer pnFaceClusters, java.nio.IntBuffer pnIBOut, java.nio.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 int TootleOptimizeOverdraw​(java.nio.FloatBuffer pVB, java.nio.IntBuffer pnIB, int nVBStride, java.nio.FloatBuffer pfViewpoint, int eFrontWinding, java.nio.IntBuffer pnFaceClusters, java.nio.IntBuffer pnIBOut, java.nio.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 int TootleOptimizeVCache​(java.nio.IntBuffer pnIB, int nVertices, int nCacheSize, java.nio.IntBuffer pnIBOut, java.nio.IntBuffer pnFaceRemapOut, int eVCacheOptimizer)
      This function performs vertex cache optimization on an index buffer.
      static int TootleOptimizeVertexMemory​(java.nio.ByteBuffer pVB, java.nio.IntBuffer pnIB, int nVBStride, java.nio.ByteBuffer pVBOut, java.nio.IntBuffer pnIBOut, java.nio.IntBuffer pnVertexRemapOut)
      This function rearranges the vertex buffer's memory location based on the index buffer.
      static int TootleOptimizeVertexMemory​(java.nio.FloatBuffer pVB, java.nio.IntBuffer pnIB, int nVBStride, java.nio.FloatBuffer pVBOut, java.nio.IntBuffer pnIBOut, java.nio.IntBuffer pnVertexRemapOut)
      This function rearranges the vertex buffer's memory location based on the index buffer.
      static int TootleVCacheClusters​(java.nio.IntBuffer pnIB, int nVertices, int nCacheSize, java.nio.IntBuffer pnFaceClusters, java.nio.IntBuffer pnIBOut, java.nio.IntBuffer pnFaceRemapOut, int eVCacheOptimizer)
      This is a utility function to optimize vertex cache on a clustered index buffer.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • 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 than MAX_FACES.
      • TootleOptimizeVCache

        public static int TootleOptimizeVCache​(java.nio.IntBuffer pnIB,
                                               int nVertices,
                                               int nCacheSize,
                                               @Nullable
                                               java.nio.IntBuffer pnIBOut,
                                               @Nullable
                                               java.nio.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 than MAX_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 pass DEFAULT_VCACHE_SIZE. This value must be non-zero.
        pnIBOut - a pointer that will be filled with an optimized index buffer. May be NULL. May equal pnIB.
        pnFaceRemapOut - a pointer to an array that will be filled with a face re-mapping. May be NULL. This is an array of nFaces elements.

        Element i in the array will contain the position of input face i in 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 than MAX_VERTICES.
        nFaces - number of faces. This must be non-zero and less than MAX_FACES.
      • TootleClusterMesh

        public static int TootleClusterMesh​(java.nio.ByteBuffer pVB,
                                            java.nio.IntBuffer pnIB,
                                            int nVBStride,
                                            int nTargetClusters,
                                            java.nio.IntBuffer pnClusteredIBOut,
                                            java.nio.IntBuffer pnFaceClustersOut,
                                            @Nullable
                                            java.nio.IntBuffer pnFaceRemapOut)
        
        public static int TootleClusterMesh​(java.nio.FloatBuffer pVB,
                                            java.nio.IntBuffer pnIB,
                                            int nVBStride,
                                            int nTargetClusters,
                                            java.nio.IntBuffer pnClusteredIBOut,
                                            java.nio.IntBuffer pnFaceClustersOut,
                                            @Nullable
                                            java.nio.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 to pFaceClustersOut[ nFaces-1 ] + 1.
        Parameters:
        pVB - a pointer to the vertex buffer. The pointer pVB must 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 least 3*sizeof(float).
        nTargetClusters - a target number of clusters. The clustering algorithm will create at least this many clusters, but not more than nFaces. 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 be NULL. May equal pnIB.
        pnFaceClustersOut - an array of nFaces+1 unsigned 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 be NULL.
        pnFaceRemapOut - an array that will receive a face re-mapping. May be NULL. If not NULL, must be an array of size nFaces. The i'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)
        Parameters:
        nFaces - the number of faces in the index buffer
      • TootleFastOptimizeVCacheAndClusterMesh

        public static int TootleFastOptimizeVCacheAndClusterMesh​(java.nio.IntBuffer pnIB,
                                                                 int nVertices,
                                                                 int nCacheSize,
                                                                 java.nio.IntBuffer pnIBOut,
                                                                 java.nio.IntBuffer pnClustersOut,
                                                                 java.nio.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 to OptimizeOverdraw.
        Parameters:
        pnIB - the input index buffer: 3 unsigned int per triangle.
        nVertices - the number of vertices in the vertex buffer
        nCacheSize - hardware cache size (12 to 24 are good options)
        pnIBOut - the updated index buffer (the output). May not be NULL. May equal pnIB.
        pnClustersOut - the output clusters which is an array of nFaces+1 unsigned ints. It is of a compact format type. Entry i and i+1 mark all face ids in [i, i+1) to be in cluster i. The last element of the array contains the number of clusters. May not be NULL. This has to be pre-allocated of size nFaces+1.
        pnNumClustersOut - the total number of clusters in pnClustersOut
        fAlpha - a linear parameter to compute lambda term from the algorithm. Pass DEFAULT_ALPHA as 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 than MAX_VERTICES.
        nFaces - the number of faces in the mesh. This must be non-zero and less than MAX_FACES.
        nViewpoints - the number of viewpoints in the viewpoint array
      • TootleOptimizeOverdraw

        public static int TootleOptimizeOverdraw​(java.nio.ByteBuffer pVB,
                                                 java.nio.IntBuffer pnIB,
                                                 int nVBStride,
                                                 @Nullable
                                                 java.nio.FloatBuffer pfViewpoint,
                                                 int eFrontWinding,
                                                 java.nio.IntBuffer pnFaceClusters,
                                                 @Nullable
                                                 java.nio.IntBuffer pnIBOut,
                                                 @Nullable
                                                 java.nio.IntBuffer pnClusterRemapOut,
                                                 int eOverdrawOptimizer)
        
        public static int TootleOptimizeOverdraw​(java.nio.FloatBuffer pVB,
                                                 java.nio.IntBuffer pnIB,
                                                 int nVBStride,
                                                 @Nullable
                                                 java.nio.FloatBuffer pfViewpoint,
                                                 int eFrontWinding,
                                                 java.nio.IntBuffer pnFaceClusters,
                                                 @Nullable
                                                 java.nio.IntBuffer pnIBOut,
                                                 @Nullable
                                                 java.nio.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 calling ClusterMesh, or the application can supply its own clustering.
        Parameters:
        pVB - a pointer to the vertex buffer. The pointer pVB must 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 least 3*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 is NULL, a default viewpoint set will be used.
        eFrontWinding - the winding order of front-faces in the mesh. One of:
        CCWCW
        pnFaceClusters - this array of nFaces+1 size can be either of two types: a full format (the output of ClusterMesh) or a compact format (the output of FastOptimizeVCacheAndClusterMesh).

        The full format is an array of mapping for each face to the cluster ID. The entry i of this array contains the cluster ID of face i.

        The compact format is an array that maps every face ID between entry i and i+1 to be in cluster i.

        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 be NULL. May equal pnIB.
        pnClusterRemapOut - an array that will receive the cluster ordering. May be NULL. 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 come i'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_ARGS 3D_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 than MAX_VERTICES.
        nFaces - number of faces. This must be non-zero and less than MAX_FACES.
        nViewpoints - the number of viewpoints in the viewpoint array
      • TootleOptimize

        public static int TootleOptimize​(java.nio.ByteBuffer pVB,
                                         java.nio.IntBuffer pnIB,
                                         int nVBStride,
                                         int nCacheSize,
                                         @Nullable
                                         java.nio.FloatBuffer pViewpoints,
                                         int eFrontWinding,
                                         java.nio.IntBuffer pnIBOut,
                                         @Nullable
                                         java.nio.IntBuffer pnNumClustersOut,
                                         int eVCacheOptimizer,
                                         int eOverdrawOptimizer)
        
        public static int TootleOptimize​(java.nio.FloatBuffer pVB,
                                         java.nio.IntBuffer pnIB,
                                         int nVBStride,
                                         int nCacheSize,
                                         @Nullable
                                         java.nio.FloatBuffer pViewpoints,
                                         int eFrontWinding,
                                         java.nio.IntBuffer pnIBOut,
                                         @Nullable
                                         java.nio.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 pointer pVB must 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 least 3*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 pass DEFAULT_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 is NULL, a default viewpoint set will be used.
        eFrontWinding - the winding order of front-faces in the model. One of:
        CCWCW
        pnIBOut - a pointer that will be filled with an optimized index buffer. May not be NULL. May equal pIB.
        pnNumClustersOut - the number of clusters generated by the algorithm. May be NULL if the output is not requested.
        eVCacheOptimizer - the selection for choosing the algorithm to optimize vertex cache. One of:
        VCACHE_AUTOVCACHE_DIRECT3DVCACHE_LSTRIPSVCACHE_TIPSY
        eOverdrawOptimizer - 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 buffer
        nFaces - the number of faces in the index buffer
      • TootleFastOptimize

        public static int TootleFastOptimize​(java.nio.ByteBuffer pVB,
                                             java.nio.IntBuffer pnIB,
                                             int nVBStride,
                                             int nCacheSize,
                                             int eFrontWinding,
                                             java.nio.IntBuffer pnIBOut,
                                             @Nullable
                                             java.nio.IntBuffer pnNumClustersOut,
                                             float fAlpha)
        
        public static int TootleFastOptimize​(java.nio.FloatBuffer pVB,
                                             java.nio.IntBuffer pnIB,
                                             int nVBStride,
                                             int nCacheSize,
                                             int eFrontWinding,
                                             java.nio.IntBuffer pnIBOut,
                                             @Nullable
                                             java.nio.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 pointer pVB must point to the vertex position. The vertex position must be a 3-component floating point value (X,Y,Z).
        pnIB - the input index buffer: 3 unsigned int per triangle
        nVBStride - the distance between successive vertices in the vertex buffer, in bytes. This must be at least 3*sizeof(float).
        nCacheSize - hardware cache size (12 to 24 are good options)
        eFrontWinding - the winding order of front-faces in the model. One of:
        CCWCW
        pnIBOut - the updated index buffer (the output). May not be NULL. May equal pnIB.
        pnNumClustersOut - the number of output clusters. May be NULL if not requested.
        fAlpha - a linear parameter to compute lambda term from the algorithm. Pass DEFAULT_ALPHA as 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 than MAX_FACES.
      • TootleVCacheClusters

        public static int TootleVCacheClusters​(java.nio.IntBuffer pnIB,
                                               int nVertices,
                                               int nCacheSize,
                                               java.nio.IntBuffer pnFaceClusters,
                                               @Nullable
                                               java.nio.IntBuffer pnIBOut,
                                               @Nullable
                                               java.nio.IntBuffer pnFaceRemapOut,
                                               int eVCacheOptimizer)
        This is a utility function to optimize vertex cache on a clustered index buffer. This function simply calls OptimizeVCache repeatedly. 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 than MAX_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 pass DEFAULT_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 size nFaces+1.
        pnIBOut - a pointer that will be filled with an optimized index buffer. May be NULL. May equal pnIB.
        pnFaceRemapOut - a pointer to an array that will be filled with a face re-mapping. May be NULL. This is an array of nFaces elements.

        Element i in the array will contain the position of input face i in 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 than MAX_FACES.
      • TootleMeasureCacheEfficiency

        public static int TootleMeasureCacheEfficiency​(java.nio.IntBuffer pnIB,
                                                       int nCacheSize,
                                                       java.nio.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 use DEFAULT_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 than MAX_VERTICES.
        nFaces - the number of indices. This must be non-zero and less than MAX_FACES.
        nViewpoints - the number of viewpoints in the viewpoint array
      • TootleMeasureOverdraw

        public static int TootleMeasureOverdraw​(java.nio.ByteBuffer pVB,
                                                java.nio.IntBuffer pnIB,
                                                int nVBStride,
                                                @Nullable
                                                java.nio.FloatBuffer pfViewpoint,
                                                int eFrontWinding,
                                                @Nullable
                                                java.nio.FloatBuffer pfAvgODOut,
                                                @Nullable
                                                java.nio.FloatBuffer pfMaxODOut,
                                                int eOverdrawOptimizer)
        
        public static int TootleMeasureOverdraw​(java.nio.FloatBuffer pVB,
                                                java.nio.IntBuffer pnIB,
                                                int nVBStride,
                                                @Nullable
                                                java.nio.FloatBuffer pfViewpoint,
                                                int eFrontWinding,
                                                @Nullable
                                                java.nio.FloatBuffer pfAvgODOut,
                                                @Nullable
                                                java.nio.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 pointer pVB must 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 least 3*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 is NULL, a default viewpoint set will be used.
        eFrontWinding - the winding order of front-faces in the model
        pfAvgODOut - a pointer to a variable to receive the average overdraw per pixel. May be NULL.
        pfMaxODOut - a pointer to a variable to receive the maximum overdraw per pixel. May be NULL.
        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 than MAX_VERTICES.
        nFaces - the number of faces in the mesh. This must be non-zero and less than MAX_FACES.
      • TootleOptimizeVertexMemory

        public static int TootleOptimizeVertexMemory​(java.nio.ByteBuffer pVB,
                                                     java.nio.IntBuffer pnIB,
                                                     int nVBStride,
                                                     java.nio.ByteBuffer pVBOut,
                                                     java.nio.IntBuffer pnIBOut,
                                                     @Nullable
                                                     java.nio.IntBuffer pnVertexRemapOut)
        
        public static int TootleOptimizeVertexMemory​(java.nio.FloatBuffer pVB,
                                                     java.nio.IntBuffer pnIB,
                                                     int nVBStride,
                                                     java.nio.FloatBuffer pVBOut,
                                                     java.nio.IntBuffer pnIBOut,
                                                     @Nullable
                                                     java.nio.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 pointer pVB must 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 least 3*sizeof(float).
        pVBOut - the output vertex buffer. May be NULL. May equal pVB.
        pnIBOut - the output index buffer. May not be NULL. May equal pnIB.
        pnVertexRemapOut - an array that will receive a vertex re-mapping. May be NULL if the output is not requested. If not NULL, must be an array of size nVertices. The i'th element of the output array contains the position of the input vertex i in the new vertex re-ordering.
        Returns:
        one of: OK, OUT_OF_MEMORY, INVALID_ARGS