Benchmark
This commit is contained in:
@@ -202,6 +202,11 @@ export class ClientLevel {
|
||||
if (!this.#in_storage_range(x, z)) {
|
||||
return;
|
||||
}
|
||||
this.set_chunk(x, z, blocks, biomes);
|
||||
}
|
||||
|
||||
// a whole chunk, replacing it if it was already here. blocks are this client's numeric ids with their state bits
|
||||
set_chunk(x: number, z: number, blocks: Uint32Array, biomes: string[]) {
|
||||
const biome_colors = new Uint32Array(CHUNK_AREA * 3);
|
||||
biomes.forEach((biome, column) => {
|
||||
biome_colors[column] = grass_color(biome);
|
||||
@@ -590,10 +595,30 @@ export class ClientLevel {
|
||||
|
||||
// meshes asked of the workers that haven't come back, for the f3 performance window
|
||||
meshes_in_flight = 0;
|
||||
// the rest wait for the next frame. chunks from the server come a few at a time, but the benchmark's level has every
|
||||
// chunk at once, and each request copies its 3x3 chunks
|
||||
max_meshes_in_flight = Infinity;
|
||||
|
||||
// dirty chunks that can be meshed and the meshes the workers are on, 0 once every chunk that can be is meshed
|
||||
get meshes_pending() {
|
||||
let pending = this.meshes_in_flight;
|
||||
for (const chunk of this.#dirty) {
|
||||
if (this.can_mesh(chunk)) pending += 1;
|
||||
}
|
||||
return pending;
|
||||
}
|
||||
|
||||
// meshes every chunk again, for the benchmark to time
|
||||
remesh_all() {
|
||||
for (const chunk of this.chunks.values()) this.#mark_dirty(chunk);
|
||||
}
|
||||
|
||||
// sends every dirty chunk that can be meshed to the workers
|
||||
request_meshes(camera: Camera) {
|
||||
for (const chunk of this.#dirty) {
|
||||
if (this.meshes_in_flight >= this.max_meshes_in_flight) {
|
||||
break;
|
||||
}
|
||||
if (!this.can_mesh(chunk)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user