Profiler: real-GPU breakdown by zoom, look and scene, with a baseline (t88 phase 0)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -64,6 +64,7 @@ function smoothDraw(lighting, glowOn) {
|
||||
gl.viewport(0, 0, cw, ch);
|
||||
gl.useProgram(SM.prog);
|
||||
const bw = R.bw, bh = R.bh;
|
||||
const uploadStart = PERF_MARKS ? performance.now() : 0;
|
||||
smUpload('tCol', bw, bh, smBytes(R.px));
|
||||
smUpload('tColL', bw, bh, smBytes(R.px));
|
||||
smUpload('tBack', bw, bh, smBytes(R.backPx));
|
||||
@@ -71,6 +72,8 @@ function smoothDraw(lighting, glowOn) {
|
||||
smUpload('tField', bw, bh, smBytes(R.fieldPx));
|
||||
if (lighting && R.lightImg) smUpload('tLight', R.lw, R.lh, smBytes(R.lightImg.data)); else smUpload('tLight', 1, 1, SM.white);
|
||||
if (glowOn) smUpload('tGlow', R.glowC.width, R.glowC.height, smBytes(R.glowImg.data)); else smUpload('tGlow', 1, 1, SM.white);
|
||||
const blitStart = PERF_MARKS ? performance.now() : 0;
|
||||
if (PERF_MARKS) { perfMarks.upload = blitStart - uploadStart; perfMarks.prepare += uploadStart - t0; }
|
||||
gl.uniform2f(u.uSize, bw, bh);
|
||||
gl.uniform2f(u.uOrigin, R.vx0, R.vy0);
|
||||
gl.uniform4f(u.uView, R.camX - R.vx0, R.camY - R.vy0, R.zp * (ch / R.canvas.height), ch);
|
||||
@@ -85,6 +88,7 @@ function smoothDraw(lighting, glowOn) {
|
||||
const ctx = R.ctx;
|
||||
ctx.imageSmoothingEnabled = true;
|
||||
ctx.drawImage(cv, 0, 0, cw, ch, 0, 0, R.canvas.width, R.canvas.height);
|
||||
if (PERF_MARKS) perfMarks.blit = performance.now() - blitStart;
|
||||
smoothPace(performance.now() - t0);
|
||||
}
|
||||
// Keep the frame rate up: drop the GPU pass's resolution when it is slow, raise it again when there
|
||||
|
||||
+16
-1
@@ -3,6 +3,8 @@ function fogColor(c, k) { return (c & 0xff000000) | (((c >>> 16 & 255) * k) << 1
|
||||
// drawWorld: the per-grain pixel buffer (pixel look), also the input of the smooth look.
|
||||
// ---------- World pixels ----------
|
||||
function drawWorld() {
|
||||
const perfStart = PERF_MARKS ? performance.now() : 0;
|
||||
if (PERF_MARKS) perfMarks.light = 0;
|
||||
const bw = R.bw, bh = R.bh, px = R.px;
|
||||
R.vx0 = Math.floor(R.camX); R.vy0 = Math.floor(R.camY);
|
||||
const vx0 = R.vx0, vy0 = R.vy0;
|
||||
@@ -31,7 +33,12 @@ function drawWorld() {
|
||||
const useFog = SET.fog;
|
||||
const OUT = sm ? 0x04000000 : 0xff000000; // unexplored and off the map: black
|
||||
const lighting = SET.lighting !== 'off' && !R.lens;
|
||||
if (lighting && (R.frame % SET.lightEvery === 0 || !R.lw)) computeLight();
|
||||
if (lighting && (R.frame % SET.lightEvery === 0 || !R.lw)) {
|
||||
const lightStart = PERF_MARKS ? performance.now() : 0;
|
||||
computeLight();
|
||||
if (PERF_MARKS) perfMarks.light = performance.now() - lightStart;
|
||||
}
|
||||
const colorStart = PERF_MARKS ? performance.now() : 0;
|
||||
const grain = SET.grain, incand = SET.incandescence;
|
||||
const anim = R.frame;
|
||||
const lens = R.lens, tl = THERM[SET.thermalPalette] || THERM.inferno;
|
||||
@@ -374,8 +381,15 @@ function drawWorld() {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (PERF_MARKS) {
|
||||
perfMarks.color = performance.now() - colorStart;
|
||||
perfMarks.prepare = colorStart - perfStart - perfMarks.light;
|
||||
}
|
||||
if (sm) { smoothDraw(lighting, glowOn); return; }
|
||||
const uploadStart = PERF_MARKS ? performance.now() : 0;
|
||||
R.bctx.putImageData(R.img, 0, 0);
|
||||
const blitStart = PERF_MARKS ? performance.now() : 0;
|
||||
if (PERF_MARKS) perfMarks.upload = blitStart - uploadStart;
|
||||
const ctx = R.ctx, zp = R.zp;
|
||||
ctx.imageSmoothingEnabled = false;
|
||||
const ox = -(R.camX - vx0) * zp, oy = -(R.camY - vy0) * zp;
|
||||
@@ -401,4 +415,5 @@ function drawWorld() {
|
||||
ctx.filter = 'none';
|
||||
ctx.restore();
|
||||
}
|
||||
if (PERF_MARKS) perfMarks.blit = performance.now() - blitStart;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user