Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pixi V8 Upgrade #1495

Draft
wants to merge 65 commits into
base: main
Choose a base branch
from
Draft

Pixi V8 Upgrade #1495

wants to merge 65 commits into from

Conversation

tannerwuster
Copy link
Contributor

Upgrade to Pixi v7 to v8 highlights several key changes that are expected to lead to significant performance improvements. These include:

  • WebGPU Renderer: The new version of Pixi introduces a WebGPU-based renderer as a core rendering paradigm, which is expected to provide better performance and set the stage for future advancements as WebGL phases out.
  • Graphics and Texture Upgrades: The update includes numerous upgrades to graphics and texture handling, which should result in improved performance.

Additionally, the description mentions that there are many other changes included in the update, which can be found in the here. Overall, the upgrade to Pixi v8 is expected to bring significant performance gains and improvements to the library.

The variables are a little different in v8.
This is still hacky, but I'm not sure another way around it.

The `TickerPlugin` code that adds the Ticker to `PIXI.Application`
really wants to do `ticker.add(this.render, this, UPDATE_PRIORITY.LOW);`
even if we were to replace it with a different Ticker.

Our issue is we need to call `render` ourselves at the time of our choosing.
Our texture atlases seem to be getting corrupted.  This will show up as either
the Bitmap Fonts getting messed up, or leaking into the background tiles.

I've tried commenting out the minimap for now, and also doing some other
cleanups around the code to isolate whether textures are getting destroyed
propertly.
This switches from using `@rapideditor/pixi-texture-allocator`
"fork of the plugin" to just including the code we need in Rapid.

The old code worked ok for v7, but the v8 upgrade was causing texture
corruption, and it became easier to just massively simplify things
than to debug and fix whatever was going on with the plugin code.
Also passing more options in the AtlasSource/TextureSource constructor,
preferring to leave nothing to chance here.

Also add some more comments and make sure everything has labels for
better debug-ability.
This is an older trick that I removed in dd24e91
In pixi v7, we switched to using `SVGResource`, which did this for us
In pixi v8, `SVGResource` is gone and there is now a SVG parser, but it
 doesn't fully support svg syntax, so we can go back to the old way for now.
- Uncomments the `PixiLayerLabels` layer
- Restores both bitmap text (ascii text placed next to pins)
  and textured text (complex text next to pins or along ropes)
- Moves the text-to-texture code from `PixiLayerLabels.getLabelSprite()`
  to `PixiTextures.textToTexture()` in the texture manager
  (there are other functions in texture manager like this)

Todo:
- Polygon labels remain commented out because we need to calculate
  the buffer inside the perimeter.  We were (ab)using `PIXI.buildLine`
  for this, but maybe there is a better way now..

Also:
- There was previously some code in `PixiLayerLabels` that would do
  `toGlobal(position, point, true)` to skip updating the transform
  We can not pass `true` for `skipUpdate` anymore in pixi v8,
  Probably related to pixijs/pixijs#10433
This was used before for calculating buffers around lines,
which was used for hit testing and label placement.
…i has started, and change the allocator to send ImageBitmaps instead of raw pixel arrays.
I went back to doing things the old way:
- Make a `PIXI.Graphic` using strokes,
  Then force generate it’s geometry,
  Then and extract the geometry into a `PIXI.Mesh`.

The mesh works well for both hit testing and masking.

Other approaches that didn't work:
- In Pixi v8, stroke graphics can work for hit testing, but the
  hit test ignores `alignment` which we need when partial filling.

- Tried using our `lineToPoly` buffer generating function
  to convert the stroke into a Graphic that would both hit test and mask,
  but it's too buggy. (it uses pixi's linebuilder, then walks the perimeter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants