mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-15 07:42:23 +00:00
Check the surface pass's time budget right before each tile sample
The 4 ms budget was checked at the top of each point, but projecting the point and reading the terrain came before its sample, so on Cesium a pick render could start after the deadline. The time is checked again just before the sample once the pass has taken one.
This commit is contained in:
1 parent
3ab0bbf7c1
commit
982d197111
2 files changed
+36
-3
No files matched your search
@@ -219,9 +219,12 @@ export function createSurfacePoints(
|
|||||||
)
|
)
|
||||||
: point.position;
|
: point.position;
|
||||||
if (!onScreen(position, size)) continue;
|
if (!onScreen(position, size)) continue;
|
||||||
// The camera estimate above counts too: leave this point for the
|
// The camera estimate and the work since the check above count too:
|
||||||
// next pass rather than go over the budget.
|
// leave this point for the next pass rather than go over the budget.
|
||||||
if (samples >= SAMPLES_PER_PASS) {
|
if (
|
||||||
|
samples >= SAMPLES_PER_PASS ||
|
||||||
|
(samples > 0 && performance.now() - started >= SAMPLE_BUDGET_MS)
|
||||||
|
) {
|
||||||
point.surfaceRevision = previousRevision;
|
point.surfaceRevision = previousRevision;
|
||||||
yieldPass();
|
yieldPass();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -263,3 +263,33 @@ test('placement makes progress when preparing a group exhausts the time budget',
|
|||||||
surface.place();
|
surface.place();
|
||||||
assert.equal(point.surfaceHeight, 50);
|
assert.equal(point.surfaceHeight, 50);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('no tile sample starts once the pass has used its time', async (t) => {
|
||||||
|
let now = 0;
|
||||||
|
const { engine, surface } = setup(t, 4);
|
||||||
|
t.mock.method(performance, 'now', () => now);
|
||||||
|
await engine.maps.setPhotorealTiles({});
|
||||||
|
engine.fake.script('terrainHeight', 10);
|
||||||
|
// Each sample takes 1.5 ms; projecting the next point another 0.4 ms.
|
||||||
|
engine.fake.script('sampleHeight', () => {
|
||||||
|
now += 1.5;
|
||||||
|
return 50;
|
||||||
|
});
|
||||||
|
const project = engine.projector.worldToWindow;
|
||||||
|
engine.projector.worldToWindow = (position) => {
|
||||||
|
now += 0.4;
|
||||||
|
return project(position);
|
||||||
|
};
|
||||||
|
const starts = [];
|
||||||
|
const sample = engine.surface.sampleHeight;
|
||||||
|
engine.surface.sampleHeight = (...args) => {
|
||||||
|
starts.push(now);
|
||||||
|
return sample(...args);
|
||||||
|
};
|
||||||
|
surface.place();
|
||||||
|
assert.ok(starts.length >= 1);
|
||||||
|
assert.ok(
|
||||||
|
starts.slice(1).every((ms) => ms < 4),
|
||||||
|
`samples started at ${starts.join(', ')} ms`,
|
||||||
|
);
|
||||||
|
});
|
||||||
Reference in new issue
Block a user