Skip to content

Commit

Permalink
cachetable: remove redudant live count buffer
Browse files Browse the repository at this point in the history
Signed-off-by: Guilherme Avila <[email protected]>
  • Loading branch information
sciecode committed Dec 6, 2023
1 parent f7982fc commit be2fff8
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/vcacheoptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,6 @@ void meshopt_optimizeVertexCacheTable(unsigned int* destination, const unsigned
TriangleAdjacency adjacency = {};
buildTriangleAdjacency(adjacency, indices, index_count, vertex_count, allocator);

// live triangle counts
unsigned int* live_triangles = allocator.allocate<unsigned int>(vertex_count);
memcpy(live_triangles, adjacency.counts, vertex_count * sizeof(unsigned int));

// emitted flags
unsigned char* emitted_flags = allocator.allocate<unsigned char>(face_count);
memset(emitted_flags, 0, face_count);
Expand All @@ -207,7 +203,7 @@ void meshopt_optimizeVertexCacheTable(unsigned int* destination, const unsigned
float* vertex_scores = allocator.allocate<float>(vertex_count);

for (size_t i = 0; i < vertex_count; ++i)
vertex_scores[i] = vertexScore(table, -1, live_triangles[i]);
vertex_scores[i] = vertexScore(table, -1, adjacency.counts[i]);

// compute triangle scores
float* triangle_scores = allocator.allocate<float>(face_count);
Expand Down Expand Up @@ -268,11 +264,6 @@ void meshopt_optimizeVertexCacheTable(unsigned int* destination, const unsigned
cache = cache_new, cache_new = cache_temp;
cache_count = cache_write > cache_size ? cache_size : cache_write;

// update live triangle counts
live_triangles[a]--;
live_triangles[b]--;
live_triangles[c]--;

// remove emitted triangle from adjacency data
// this makes sure that we spend less time traversing these lists on subsequent iterations
for (size_t k = 0; k < 3; ++k)
Expand Down Expand Up @@ -310,7 +301,7 @@ void meshopt_optimizeVertexCacheTable(unsigned int* destination, const unsigned
int cache_position = i >= cache_size ? -1 : int(i);

// update vertex score
float score = vertexScore(table, cache_position, live_triangles[index]);
float score = vertexScore(table, cache_position, adjacency.counts[index]);
float score_diff = score - vertex_scores[index];

vertex_scores[index] = score;
Expand Down

0 comments on commit be2fff8

Please sign in to comment.