Fix redondant modification test in batch sorting.
This commit is contained in:
parent
39a95e24c3
commit
74b6f58794
@ -770,26 +770,23 @@ static void rk_sort_batch(
|
|||||||
bucket.indices[bucket.count++] = index;
|
bucket.indices[bucket.count++] = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool modified = false;
|
|
||||||
rk_ushort * __restrict indices = batch.indices;
|
rk_ushort * __restrict indices = batch.indices;
|
||||||
rk_command * __restrict command = batch.commands;
|
rk_command * __restrict command = batch.commands;
|
||||||
rk_mesh const * __restrict mesh = batch.vertices->meshes;
|
rk_mesh const * __restrict mesh = batch.vertices->meshes;
|
||||||
for (rk_bucket const * __restrict bucket = rk_buckets; bucket < last_bucket; ++bucket, ++mesh) {
|
for (rk_bucket const * __restrict bucket = rk_buckets; bucket < last_bucket; ++bucket, ++mesh) {
|
||||||
if (bucket->count) {
|
if (bucket->count) {
|
||||||
|
memcpy(indices, bucket->indices, bucket->count * sizeof(rk_ushort));
|
||||||
command->nvertices = static_cast<GLuint>(mesh->ntriangles) * 3;
|
command->nvertices = static_cast<GLuint>(mesh->ntriangles) * 3;
|
||||||
command->ninstances = bucket->count;
|
command->ninstances = bucket->count;
|
||||||
command->base_index = mesh->base_index;
|
command->base_index = mesh->base_index;
|
||||||
command->base_instance = indices - batch.indices;
|
command->base_instance = indices - batch.indices;
|
||||||
modified |= rk_cmp_memcpy<sizeof(rk_ushort)>(indices, bucket->indices, bucket->count * sizeof(rk_ushort));
|
|
||||||
indices += bucket->count;
|
indices += bucket->count;
|
||||||
++command;
|
++command;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsigned const ninstances = indices - batch.indices;
|
batch.ninstances = indices - batch.indices;
|
||||||
modified |= (ninstances != batch.ninstances);
|
|
||||||
batch.ninstances = ninstances;
|
|
||||||
batch.ncommands = command - batch.commands;
|
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);
|
glBufferSubData(GL_DRAW_INDIRECT_BUFFER, 0, batch.ncommands * sizeof(rk_command), batch.commands);
|
||||||
}
|
}
|
||||||
batch.state = RK_BATCH_STATE_SORTED;
|
batch.state = RK_BATCH_STATE_SORTED;
|
||||||
|
Loading…
Reference in New Issue
Block a user