Skip to content

Commit

Permalink
Update documentation to mention padding bytes
Browse files Browse the repository at this point in the history
For functions that rely on padding bytes for comparison, as well as for
vertex encoding, we now note that padding will be included in the
comparison and as such should be zero-initialized.

Closes zeux#193.
  • Loading branch information
zeux committed Nov 25, 2020
1 parent e78a2c8 commit 494ae7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ std::vector<unsigned int> remap(index_count); // allocate temporary memory for t
size_t vertex_count = meshopt_generateVertexRemap(&remap[0], NULL, index_count, &unindexed_vertices[0], index_count, sizeof(Vertex));
```
Note that in this case we only have an unindexed vertex buffer; the remap table is generated based on binary equivalence of the input vertices, so the resulting mesh will render the same way.
Note that in this case we only have an unindexed vertex buffer; the remap table is generated based on binary equivalence of the input vertices, so the resulting mesh will render the same way. Binary equivalence considers all input bytes, including padding which should be zero-initialized if the vertex structure has gaps.
After generating the remap table, you can allocate space for the target vertex buffer (`vertex_count` elements) and index buffer (`index_count` elements) and generate them:
Expand Down
5 changes: 5 additions & 0 deletions src/meshoptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct meshopt_Stream
* 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.
*
* destination must contain enough space for the resulting remap table (vertex_count elements)
* indices can be NULL if the input is unindexed
Expand All @@ -53,6 +54,7 @@ MESHOPTIMIZER_API size_t meshopt_generateVertexRemap(unsigned int* destination,
* 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.
*
* destination must contain enough space for the resulting remap table (vertex_count elements)
* indices can be NULL if the input is unindexed
Expand All @@ -79,6 +81,7 @@ MESHOPTIMIZER_API void meshopt_remapIndexBuffer(unsigned int* destination, const
* 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.
*
* destination must contain enough space for the resulting index buffer (index_count elements)
*/
Expand All @@ -88,6 +91,7 @@ MESHOPTIMIZER_API void meshopt_generateShadowIndexBuffer(unsigned int* destinati
* 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.
*
* destination must contain enough space for the resulting index buffer (index_count elements)
*/
Expand Down Expand Up @@ -209,6 +213,7 @@ MESHOPTIMIZER_EXPERIMENTAL int meshopt_decodeIndexSequence(void* destination, si
* 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.
*
* buffer must contain enough space for the encoded vertex buffer (use meshopt_encodeVertexBufferBound to compute worst case size)
*/
Expand Down

0 comments on commit 494ae7f

Please sign in to comment.