Skip to content
Snippets Groups Projects
Commit d200f29b authored by Sebastian Gaida's avatar Sebastian Gaida
Browse files

[#96] commented tipsify

parent f6ed4e09
No related branches found
No related tags found
1 merge request!97Resolve "Dokumentation vervollständigen"
Pipeline #27464 passed
...@@ -18,18 +18,18 @@ namespace vkcv::meshlet { ...@@ -18,18 +18,18 @@ namespace vkcv::meshlet {
/** /**
* searches for the next VertexIndex that was used before or returns any vertexIndex if no used was found * searches for the next VertexIndex that was used before or returns any vertexIndex if no used was found
* @param livingTriangles * @param livingVertices vertice that still has a living triangle
* @param usedVerticeStack * @param usedVerticeStack stack of vertices that are recently used
* @param usedVerticeCount * @param usedVerticeCount number of last used vertices that maxes at @param maxUsedVertices
* @param usedVerticeOffset * @param usedVerticeOffset the @param usedVerticeStack wraps around and overrides old vertices, this offset keeps the wrapping intact
* @param vertexCount * @param vertexCount total vertex count to terminate correctly
* @param lowestLivingVertexIndex * @param lowestLivingVertexIndex vertexIndex with the lowest number
* @param currentTriangleIndex * @param currentTriangleIndex index of the currently fanned triangle
* @param skippedIndices * @param skippedIndices indices that define a new meshlet, even if they are close in memory
* @return a VertexIndex to be used as fanningVertexIndex * @return a VertexIndex to be used as fanningVertexIndex
*/ */
int skipDeadEnd( int skipDeadEnd(
const std::vector<uint8_t> &livingTriangles, const std::vector<uint8_t> &livingVertices,
const std::vector<uint32_t> &usedVerticeStack, const std::vector<uint32_t> &usedVerticeStack,
int &usedVerticeCount, int &usedVerticeCount,
int &usedVerticeOffset, int &usedVerticeOffset,
...@@ -43,14 +43,14 @@ namespace vkcv::meshlet { ...@@ -43,14 +43,14 @@ namespace vkcv::meshlet {
// iterate from the latest to the oldest. + maxUsedVertices to always make it a positive number in the range 0 to maxUsedVertices -1 // iterate from the latest to the oldest. + maxUsedVertices to always make it a positive number in the range 0 to maxUsedVertices -1
int nextVertex = usedVerticeStack[mod(--usedVerticeCount)]; int nextVertex = usedVerticeStack[mod(--usedVerticeCount)];
if (livingTriangles[nextVertex] > 0) { if (livingVertices[nextVertex] > 0) {
return nextVertex; return nextVertex;
} }
} }
// returns any vertexIndex since no last used has a living triangle // returns any vertexIndex since no last used has a living triangle
while (lowestLivingVertexIndex + 1 < vertexCount) { while (lowestLivingVertexIndex + 1 < vertexCount) {
lowestLivingVertexIndex++; lowestLivingVertexIndex++;
if (livingTriangles[lowestLivingVertexIndex] > 0) { if (livingVertices[lowestLivingVertexIndex] > 0) {
// add index of the vertex to skippedIndices // add index of the vertex to skippedIndices
skippedIndices.push_back(static_cast<uint32_t>(currentTriangleIndex * 3)); skippedIndices.push_back(static_cast<uint32_t>(currentTriangleIndex * 3));
return lowestLivingVertexIndex; return lowestLivingVertexIndex;
...@@ -61,19 +61,19 @@ namespace vkcv::meshlet { ...@@ -61,19 +61,19 @@ namespace vkcv::meshlet {
/** /**
* searches for the best next candidate as a fanningVertexIndex * searches for the best next candidate as a fanningVertexIndex
* @param vertexCount * @param vertexCount total vertexCount of the mesh
* @param lowestLivingVertexIndex * @param lowestLivingVertexIndex vertexIndex with the lowest number
* @param cacheSize * @param cacheSize number to determine in which range vertices are prioritized to me reused
* @param possibleCandidates * @param possibleCandidates candidates for the next vertex to be fanned out
* @param numPossibleCandidates * @param numPossibleCandidates number of all possible candidates
* @param lastTimestampCache * @param lastTimestampCache number of the last iteration the vertex was used
* @param currentTimeStamp * @param currentTimeStamp current iteration of all vertices
* @param livingTriangles * @param livingVertices vertice that still has a living triangle
* @param usedVerticeStack * @param usedVerticeStack stack of vertices that are recently used
* @param usedVerticeCount * @param usedVerticeCount number of last used vertices that maxes at @param maxUsedVertices
* @param usedVerticeOffset * @param usedVerticeOffset the @param usedVerticeStack wraps around and overrides old vertices, this offset keeps the wrapping intact
* @param currentTriangleIndex * @param currentTriangleIndex index of the currently fanned triangle
* @param skippedIndices * @param skippedIndices indices that define a new meshlet, even if they are close in memory
* @return a VertexIndex to be used as fanningVertexIndex * @return a VertexIndex to be used as fanningVertexIndex
*/ */
int getNextVertexIndex(int vertexCount, int getNextVertexIndex(int vertexCount,
...@@ -83,7 +83,7 @@ namespace vkcv::meshlet { ...@@ -83,7 +83,7 @@ namespace vkcv::meshlet {
int numPossibleCandidates, int numPossibleCandidates,
const std::vector<uint32_t> &lastTimestampCache, const std::vector<uint32_t> &lastTimestampCache,
int currentTimeStamp, int currentTimeStamp,
const std::vector<uint8_t> &livingTriangles, const std::vector<uint8_t> &livingVertices,
const std::vector<uint32_t> &usedVerticeStack, const std::vector<uint32_t> &usedVerticeStack,
int &usedVerticeCount, int &usedVerticeCount,
int &usedVerticeOffset, int &usedVerticeOffset,
...@@ -96,12 +96,12 @@ namespace vkcv::meshlet { ...@@ -96,12 +96,12 @@ namespace vkcv::meshlet {
int vertexIndex = possibleCandidates[j]; int vertexIndex = possibleCandidates[j];
// the candidate needs to be not fanned out yet // the candidate needs to be not fanned out yet
if (livingTriangles[vertexIndex] > 0) { if (livingVertices[vertexIndex] > 0) {
int priority = -1; int priority = -1;
// prioritizes recent used vertices, but tries not to pick one that has many triangles -> fills holes better // prioritizes recent used vertices, but tries not to pick one that has many triangles -> fills holes better
if ( currentTimeStamp - lastTimestampCache[vertexIndex] + 2 * livingTriangles[vertexIndex] <= if ( currentTimeStamp - lastTimestampCache[vertexIndex] + 2 * livingVertices[vertexIndex] <=
cacheSize) { cacheSize) {
priority = currentTimeStamp - lastTimestampCache[vertexIndex]; priority = currentTimeStamp - lastTimestampCache[vertexIndex];
} }
// select the vertexIndex with the highest priority // select the vertexIndex with the highest priority
...@@ -115,14 +115,14 @@ namespace vkcv::meshlet { ...@@ -115,14 +115,14 @@ namespace vkcv::meshlet {
// if no candidate is alive, try and find another one // if no candidate is alive, try and find another one
if (nextVertexIndex == -1) { if (nextVertexIndex == -1) {
nextVertexIndex = skipDeadEnd( nextVertexIndex = skipDeadEnd(
livingTriangles, livingVertices,
usedVerticeStack, usedVerticeStack,
usedVerticeCount, usedVerticeCount,
usedVerticeOffset, usedVerticeOffset,
vertexCount, vertexCount,
lowestLivingVertexIndex, lowestLivingVertexIndex,
currentTriangleIndex, currentTriangleIndex,
skippedIndices); skippedIndices);
} }
return nextVertexIndex; return nextVertexIndex;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment