Jump to content

Enabling Basis to avoid webgl context loss


tuneboy
 Share

Recommended Posts

I've been facing an issue where the webgl context is lost after loading ~2500 textures each 1920 x 1080 and assigning about 700 of them. To get around this I'm attempting to use basis so the textures don't overload the GPU. Based on the documentation https://pixijs.download/dev/docs/PIXI.BasisLoader.html I think it should be working, but when I try running the program it loses context at 700 assigned textures again indicating no performance gain. I'm not getting issues about finding the basis files when calling loadTranscoder. Is there anything wrong with my basis implementation?

 

package.json

{
  "main": "main.js",
  "scripts": {
    "start": "electron ."
  },
  "devDependencies": {
    "electron": "^6.0.10"
  },
  "dependencies": {
    "@pixi/compressed-textures": "6.0.4",
    "@pixi/basis": "6.0.4",
    "pixi-filters": "^4.1.1",
    "pixi.js": "6.0.4",
  }
}

Renderer

const BASIS = require('@pixi/basis');
const PIXI = require('pixi.js');

module.exports = class PixiRenderer {
    constructor(config) {
        this.app = new PIXI.Application({width: config.width, height: config.height, antialias: config.antialias});

        BASIS.BasisLoader.loadTranscoder('./public/scripts/basis_transcoder.js', './public/wasm/basis_transcoder.wasm');
        PIXI.Loader.registerPlugin(BASIS.BasisLoader);
    }
}

Loader

const PIXI = require('pixi.js');

module.exports = class Loader {
    constructor(config) {
        this.config = config;

        this.loader = new PIXI.Loader();

        config.Frames.forEach((framePath) => {
            this.loader.add(framePath, framePath);
        });
        
        this.loader.load((loader) => {
            config.sprite.texture = this.loader.resources[config.Frames[0]].texture;
        });
    }

    draw(frame) {
        this.config.sprite.texture = this.loader.resources[frame].texture;
    }
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...