Fix redondant modification test in batch sorting.

This commit is contained in:
Roz K 2023-01-03 21:41:03 +01:00
parent 39a95e24c3
commit 74b6f58794
Signed by: roz
GPG Key ID: 51FBF4E483E1C822

View File

@ -770,26 +770,23 @@ static void rk_sort_batch(
bucket.indices[bucket.count++] = index;
}
}
bool modified = false;
rk_ushort * __restrict indices = batch.indices;
rk_command * __restrict command = batch.commands;
rk_mesh const * __restrict mesh = batch.vertices->meshes;
for (rk_bucket const * __restrict bucket = rk_buckets; bucket < last_bucket; ++bucket, ++mesh) {
if (bucket->count) {
memcpy(indices, bucket->indices, bucket->count * sizeof(rk_ushort));
command->nvertices = static_cast<GLuint>(mesh->ntriangles) * 3;
command->ninstances = bucket->count;
command->base_index = mesh->base_index;
command->base_instance = indices - batch.indices;
modified |= rk_cmp_memcpy<sizeof(rk_ushort)>(indices, bucket->indices, bucket->count * sizeof(rk_ushort));
indices += bucket->count;
++command;
}
}
unsigned const ninstances = indices - batch.indices;
modified |= (ninstances != batch.ninstances);
batch.ninstances = ninstances;
batch.ninstances = indices - batch.indices;
batch.ncommands = command - batch.commands;
if (modified && rk_MultiDrawElementsIndirect) {
if (rk_MultiDrawElementsIndirect) {
glBufferSubData(GL_DRAW_INDIRECT_BUFFER, 0, batch.ncommands * sizeof(rk_command), batch.commands);
}
batch.state = RK_BATCH_STATE_SORTED;