Hi everyone,
Thought I’d share this to potentially save you some headaches. ![]()
I have been migrating from WebGL to WebGPU and encountered a massive increase
in my game startup time. From a default timing report I already got the culprit: scene.executeWhenReady
But why? I had just ported all shaders to wgsl and there should not have been any glsl-to-wgsl transpiling stuff going on (which is slow).
What nailed was this debug code :
export default function Override(BABYLON, win) {
BABYLON.Scene.prototype.isReady = function(checkRenderTargets = true) { ... }
BABYLON.Engine.prototype.areAllEffectsReady = function() { ... }
//e.g.
BABYLON.WebGPUEngine.prototype.areAllEffectsReady = function() {
for (const key in this._compiledEffects) {
const effect = this._compiledEffects[key];
if (!effect.isReady()) {
if(typeof effect.name === "string") report("effects:"+effect.name)
else report("effects:"+effect.name.fragment+"/"+effect.name.vertex);
return false;
}
}
return true;
}
}
This way you know what is taking so long in executeWhenReady.You log a debug message (or whatever) whenever any of the function is about to return false / set return var to false. I do this per call, so that I will get a sorted history. And there I got the perpetrator: weaponSwingTrail nodeMaterial ![]()
Since it is a node material it does not live in the shaders directory and so I missed to port it. The moment I set material.shaderLanguage = Engine.ShaderLanguage.WGSL, startup time was on par with WebGL.
Phew, I was about to rage quite a ditch WebGPU ![]()
Best wishes
Joe
**Don’t forget to turn off the debug code ![]()