Module meshopt::ffi

source ·

Structs§

Constants§

Functions§

  • Overdraw analyzer Returns overdraw statistics using a software rasterizer Results may not match actual GPU performance
  • Vertex transform cache analyzer Returns cache hit statistics using a simplified FIFO model Results may not match actual GPU performance
  • Vertex fetch cache analyzer Returns cache hit statistics using a simplified direct mapped model Results may not match actual GPU performance
  • Meshlet builder Splits the mesh into a set of meshlets where each meshlet has a micro index buffer indexing into meshlet vertices that refer to the original vertex buffer The resulting data can be used to render meshes using NVidia programmable mesh shading pipeline, or in other cluster-based renderers. When using buildMeshlets, vertex positions need to be provided to minimize the size of the resulting clusters. When using buildMeshletsScan, for maximum efficiency the index buffer being converted has to be optimized for vertex cache first.
  • Cluster bounds generator Creates bounding volumes that can be used for frustum, backface and occlusion culling.
  • Vertex buffer filters These functions can be used to filter output of meshopt_decodeVertexBuffer in-place.
  • Index buffer decoder Decodes index data from an array of bytes generated by meshopt_encodeIndexBuffer Returns 0 if decoding was successful, and an error code otherwise The decoder is safe to use for untrusted input, but it may produce garbage data (e.g. out of range indices).
  • Index sequence decoder Decodes index data from an array of bytes generated by meshopt_encodeIndexSequence Returns 0 if decoding was successful, and an error code otherwise The decoder is safe to use for untrusted input, but it may produce garbage data (e.g. out of range indices).
  • Vertex buffer decoder Decodes vertex data from an array of bytes generated by meshopt_encodeVertexBuffer Returns 0 if decoding was successful, and an error code otherwise The decoder is safe to use for untrusted input, but it may produce garbage data.
  • Index buffer encoder Encodes index data into an array of bytes that is generally much smaller (<1.5 bytes/triangle) and compresses better (<1 bytes/triangle) compared to original. Input index buffer must represent a triangle list. Returns encoded data size on success, 0 on error; the only error condition is if buffer doesn’t have enough space For maximum efficiency the index buffer being encoded has to be optimized for vertex cache and vertex fetch first.
  • Index sequence encoder Encodes index sequence into an array of bytes that is generally smaller and compresses better compared to original. Input index sequence can represent arbitrary topology; for triangle lists meshopt_encodeIndexBuffer is likely to be better. Returns encoded data size on success, 0 on error; the only error condition is if buffer doesn’t have enough space
  • Set index encoder format version version must specify the data format version to encode; valid values are 0 (decodable by all library versions) and 1 (decodable by 0.14+)
  • Vertex buffer encoder Encodes vertex data into an array of bytes that is generally smaller and compresses better compared to original. Returns encoded data size on success, 0 on error; the only error condition is if buffer doesn’t have enough space This function works for a single vertex stream; for multiple vertex streams, call meshopt_encodeVertexBuffer for each stream. Note that all vertex_size bytes of each vertex are encoded verbatim, including padding which should be zero-initialized.
  • Set vertex encoder format version version must specify the data format version to encode; valid values are 0 (decodable by all library versions)
  • Generate index buffer that can be used as a geometry shader input with triangle adjacency topology Each triangle is converted into a 6-vertex patch with the following layout:
  • Generate index buffer that can be used for more efficient rendering when only a subset of the vertex attributes is necessary All vertices that are binary equivalent (wrt first vertex_size bytes) map to the first vertex in the original vertex buffer. This makes it possible to use the index buffer for Z pre-pass or shadowmap rendering, while using the original index buffer for regular rendering. Note that binary equivalence considers all vertex_size bytes, including padding which should be zero-initialized.
  • Generate index buffer that can be used for more efficient rendering when only a subset of the vertex attributes is necessary All vertices that are binary equivalent (wrt specified streams) map to the first vertex in the original vertex buffer. This makes it possible to use the index buffer for Z pre-pass or shadowmap rendering, while using the original index buffer for regular rendering. Note that binary equivalence considers all size bytes in each stream, including padding which should be zero-initialized.
  • Generate index buffer that can be used for PN-AEN tessellation with crack-free displacement Each triangle is converted into a 12-vertex patch with the following layout:
  • Generates a vertex remap table from the vertex buffer and an optional index buffer and returns number of unique vertices As a result, all vertices that are binary equivalent map to the same (new) location, with no gaps in the resulting sequence. Resulting remap table maps old vertices to new vertices and can be used in meshopt_remapVertexBuffer/meshopt_remapIndexBuffer. Note that binary equivalence considers all vertex_size bytes, including padding which should be zero-initialized.
  • Generates a vertex remap table from multiple vertex streams and an optional index buffer and returns number of unique vertices As a result, all vertices that are binary equivalent map to the same (new) location, with no gaps in the resulting sequence. Resulting remap table maps old vertices to new vertices and can be used in meshopt_remapVertexBuffer/meshopt_remapIndexBuffer. To remap vertex buffers, you will need to call meshopt_remapVertexBuffer for each vertex stream. Note that binary equivalence considers all size bytes in each stream, including padding which should be zero-initialized.
  • Experimental: Meshlet optimizer Reorders meshlet vertices and triangles to maximize locality to improve rasterizer throughput
  • Overdraw optimizer Reorders indices to reduce the number of GPU vertex shader invocations and the pixel overdraw If index buffer contains multiple ranges for multiple draw calls, this functions needs to be called on each range individually.
  • Vertex transform cache optimizer Reorders indices to reduce the number of GPU vertex shader invocations If index buffer contains multiple ranges for multiple draw calls, this functions needs to be called on each range individually.
  • Vertex transform cache optimizer for FIFO caches Reorders indices to reduce the number of GPU vertex shader invocations Generally takes ~3x less time to optimize meshes but produces inferior results compared to meshopt_optimizeVertexCache If index buffer contains multiple ranges for multiple draw calls, this functions needs to be called on each range individually.
  • Vertex transform cache optimizer for strip-like caches Produces inferior results to meshopt_optimizeVertexCache from the GPU vertex cache perspective However, the resulting index order is more optimal if the goal is to reduce the triangle strip length or improve compression efficiency
  • Vertex fetch cache optimizer Reorders vertices and changes indices to reduce the amount of GPU memory fetches during vertex processing Returns the number of unique vertices, which is the same as input vertex count unless some vertices are unused This functions works for a single vertex stream; for multiple vertex streams, use meshopt_optimizeVertexFetchRemap + meshopt_remapVertexBuffer for each stream.
  • Vertex fetch cache optimizer Generates vertex remap to reduce the amount of GPU memory fetches during vertex processing Returns the number of unique vertices, which is the same as input vertex count unless some vertices are unused The resulting remap table should be used to reorder vertex/index buffers using meshopt_remapVertexBuffer/meshopt_remapIndexBuffer
  • Generate index buffer from the source index buffer and remap table generated by meshopt_generateVertexRemap
  • Generates vertex buffer from the source vertex buffer and remap table generated by meshopt_generateVertexRemap
  • Set allocation callbacks These callbacks will be used instead of the default operator new/operator delete for all temporary allocations in the library. Note that all algorithms only allocate memory for temporary use. allocate/deallocate are always called in a stack-like order - last pointer to be allocated is deallocated first.
  • Mesh simplifier Reduces the number of triangles in the mesh, attempting to preserve mesh appearance as much as possible The algorithm tries to preserve mesh topology and can stop short of the target goal based on topology constraints or target error. If not all attributes from the input mesh are required, it’s recommended to reindex the mesh using meshopt_generateShadowIndexBuffer prior to simplification. Returns the number of indices after simplification, with destination containing new index data The resulting index buffer references vertices from the original vertex buffer. If the original vertex data isn’t required, creating a compact vertex buffer using meshopt_optimizeVertexFetch is recommended.
  • Experimental: Point cloud simplifier Reduces the number of points in the cloud to reach the given target Returns the number of points after simplification, with destination containing new index data The resulting index buffer references vertices from the original vertex buffer. If the original vertex data isn’t required, creating a compact vertex buffer using meshopt_optimizeVertexFetch is recommended.
  • Returns the error scaling factor used by the simplifier to convert between absolute and relative extents
  • Experimental: Mesh simplifier (sloppy) Reduces the number of triangles in the mesh, sacrificing mesh appearance for simplification performance The algorithm doesn’t preserve mesh topology but can stop short of the target goal based on target error. Returns the number of indices after simplification, with destination containing new index data The resulting index buffer references vertices from the original vertex buffer. If the original vertex data isn’t required, creating a compact vertex buffer using meshopt_optimizeVertexFetch is recommended.
  • Experimental: Mesh simplifier with attribute metric The algorithm ehnahces meshopt_simplify by incorporating attribute values into the error metric used to prioritize simplification order; see meshopt_simplify documentation for details. Note that the number of attributes affects memory requirements and running time; this algorithm requires ~1.5x more memory and time compared to meshopt_simplify when using 4 scalar attributes.
  • Spatial sorter Generates a remap table that can be used to reorder points for spatial locality. Resulting remap table maps old vertices to new vertices and can be used in meshopt_remapVertexBuffer.
  • Experimental: Spatial sorter Reorders triangles for spatial locality, and generates a new index buffer. The resulting index buffer can be used with other functions like optimizeVertexCache.
  • Mesh stripifier Converts a previously vertex cache optimized triangle list to triangle strip, stitching strips using restart index or degenerate triangles Returns the number of indices in the resulting strip, with destination containing new index data For maximum efficiency the index buffer being converted has to be optimized for vertex cache first. Using restart indices can result in ~10% smaller index buffers, but on some GPUs restart indices may result in decreased performance.
  • Mesh unstripifier Converts a triangle strip to a triangle list Returns the number of indices in the resulting list, with destination containing new index data

Type Aliases§

  • Vertex buffer filter encoders These functions can be used to encode data in a format that meshopt_decodeFilter can decode