Lighting on the GPU in the WebGPU path (t88 phase 2b)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -41,10 +41,13 @@ async function perfRender(lighting, overlays) {
|
||||
draw += perfLast.drawWorld / n;
|
||||
for (const [key, value] of Object.entries(perfMarks)) marks[key] = (marks[key] || 0) + value / n;
|
||||
}
|
||||
let light = 0;
|
||||
if (!R.gpuOn) {
|
||||
for (let k = 0; k < 5; k++) computeLight();
|
||||
const l0 = performance.now();
|
||||
for (let k = 0; k < n; k++) computeLight();
|
||||
const light = (performance.now() - l0) / n;
|
||||
light = (performance.now() - l0) / n;
|
||||
}
|
||||
// Exercise the actual overlay calls and their arguments/conditions in frame().
|
||||
PERF_MARKS = false;
|
||||
for (let k = 0; k < 5; k++) frame(lastT + 1000 / 60);
|
||||
@@ -58,7 +61,7 @@ async function perfRender(lighting, overlays) {
|
||||
await GPU.timingPromise;
|
||||
PERF_MARKS = true; drawWorld();
|
||||
await GPU.timingPromise;
|
||||
PERF_MARKS = false; gpu_ms = GPU.gpuMs; marks.gpu = gpu_ms;
|
||||
PERF_MARKS = false; gpu_ms = GPU.gpuMs; marks.gpu = gpu_ms; marks.gpuLight = GPU.lightMs;
|
||||
}
|
||||
return { frame_ms, drawWorld_ms: draw, computeLight_ms: light, marks_ms: marks,
|
||||
overlays: Object.fromEntries(Object.entries(data).map(([key, d]) => [key, { ms_per_frame: d.ms / n, calls: d.calls }])),
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Frozen light comparisons, also used by the WebGPU browser regression suite.
|
||||
window.lightScene = kind => {
|
||||
const cx = (W / 2) & ~3, cy = (H / 2) & ~3;
|
||||
window.CAM = [cx, cy];
|
||||
SET.fog = false; SET.shake = false; SET.cameraLead = false;
|
||||
SET.daylight = kind === 'fire' ? 0 : 1; SET.ambient = 0.12;
|
||||
bot.lamp = kind === 'lamp'; weather.next = 1e15; R.rain = 0;
|
||||
const x0 = Math.max(0,cx-550), x1 = Math.min(W,cx+550);
|
||||
const y0 = Math.max(0,cy-330), y1 = Math.min(H,cy+330);
|
||||
for(let y=y0;y<y1;y++) for(let x=x0;x<x1;x++) {
|
||||
const i=y*W+x;
|
||||
const cave = x>cx-95 && x<cx+95 && y>cy-38 && y<cy+36;
|
||||
const opening = kind==='opening' && x>=cx+24 && x<cx+40 && y<cy;
|
||||
setCell(i, cave || opening || y<cy-100 ? EMPTY : STONE,20,F_NAT);
|
||||
bgm[i]=part[i]=mach[i]=occ[i]=0; blockP[(y>>2)*BW+(x>>2)]=0;
|
||||
}
|
||||
for(let x=x0;x<x1;x++) { surfY[x]=cy-100; dirtY[x]=cy-90; graniteY[x]=cy+100; basaltY[x]=cy+200; }
|
||||
if(kind==='magma' || kind==='fire') {
|
||||
for(let y=cy+15;y<cy+23;y++) for(let x=cx-25;x<cx-8;x++) setCell(y*W+x,kind==='magma'?MAGMA:FIRE,kind==='magma'?1450:1100,F_NAT);
|
||||
}
|
||||
// A ledge makes occlusion/turning light paths visible around each source.
|
||||
for(let y=cy-5;y<cy+7;y++) for(let x=cx+12;x<cx+45;x++) setCell(y*W+x,STONE,20,F_NAT);
|
||||
updateRoof(); buildSky();
|
||||
};
|
||||
lightScene('lamp');
|
||||
Reference in New Issue
Block a user