[SOLVED] Profiling and optimization

When I run my app it quickly gobbles up GPU memory and murders performance.

Anyone have recommendations for profilers or optimisation tips†?
† I’ve reviewed PlayCanvas’s tips and they don’t seem to apply.

My app (https://playcanvas.com/editor/scene/1733137) renders two portals using two extra cameras and three custom shaders. Surely, that’s not overly burdensome?

Looking at how well something like “After The Flood” performs I’m sure that there must be some performance gains to be had, or I’ve messed up somewhere (a memory leak or something).
But I don’t know how to run a performance analysis and find out. The performance is so bad I’m considering just giving up.

Many thanks in advance.

Looks like its related to your passthrough shader.

With it disabled, the profiler looks decent. Render time is sub 1ms and the number of drawcalls is fine:

However, when you enable the shader, the draw calls increase over time:
Kapture 2023-05-21 at 16.03.06

Er, why are you adding a new instance of the post effect every frame? :sweat_smile:

// update code called every frame
Passthrough.prototype.update = function(dt) {
    this.effect = new pc.PassthroughEffect(this.app.graphicsDevice, this.vs.resource, this.fs.resource);
    // add the effect to the camera's postEffects queue
    var queue = this.entity.camera.postEffects;
    // when the script is enabled add our effect to the camera's postEffects queue
    this.on('enable', function () {
        queue.addEffect(this.effect, false); 
    // when the script is disabled remove our effect from the camera's postEffects queue
    this.on('disable', function () {
1 Like

Oops. I thought I’d disabled that.

Aaaand, I’ve just seen the profiler option under [Launch].

Big thanks!

I know next to nothing of how post effects work and just modified the PlayCanvas example.
How would I stop it from being added repeatedly?

Don’t put it in the update function which is called every frame :slight_smile:

Classic foot-shot mistake.


Thanks. That’s a lot better.

I just reached a stage where I couldn’t think straight. So much appreciated.