perf improvements

This commit is contained in:
Wassim SAMAD
2026-05-13 09:05:09 -04:00
parent eeacae568c
commit 9de7a8ee77
10 changed files with 304 additions and 84 deletions
+26
View File
@@ -0,0 +1,26 @@
// GPU work-time measurement, gated by `?perf` in the URL.
//
// We can't use WebGPU timestamp queries here because the editor renders via
// a custom `RenderPipeline.render()` path that bypasses three.js's built-in
// timestamp infrastructure. Instead we use `device.queue.onSubmittedWorkDone()`,
// which resolves when the GPU finishes all submitted work — measuring the
// CPU→GPU-done delta gives a clean approximation of per-frame GPU duration
// regardless of which render path produced it.
export const PERF_OVERLAY_ENABLED =
typeof window !== 'undefined' && new URLSearchParams(window.location.search).has('perf')
const MAX_SAMPLES = 256
const samples: number[] = []
export function pushGpuSample(ms: number): void {
samples.push(ms)
if (samples.length > MAX_SAMPLES) samples.shift()
}
export function drainGpuSamples(): number[] {
if (samples.length === 0) return []
const out = samples.slice()
samples.length = 0
return out
}
+3 -5
View File
@@ -1,13 +1,13 @@
import {
getMaterialPresetByRef,
resolveMaterial,
type MaterialMapProperties,
type MaterialPresetPayload,
type MaterialProperties,
type MaterialSchema,
resolveMaterial,
} from '@pascal-app/core'
import * as THREE from 'three'
import { MeshStandardNodeMaterial } from 'three/webgpu'
import { MeshLambertNodeMaterial, MeshStandardNodeMaterial } from 'three/webgpu'
export const baseMaterial = new MeshStandardNodeMaterial({
color: '#f2f0ed',
@@ -15,10 +15,8 @@ export const baseMaterial = new MeshStandardNodeMaterial({
metalness: 0.0,
})
export const glassMaterial = new MeshStandardNodeMaterial({
export const glassMaterial = new MeshLambertNodeMaterial({
color: '#e0f2fe',
roughness: 0.05,
metalness: 0.0,
transparent: true,
opacity: 0.35,
side: THREE.DoubleSide,