Skip to content

Conversation

GoodBoyDigital
Copy link
Member

@GoodBoyDigital GoodBoyDigital commented Mar 22, 2025

Description of change

Moved though all the renderables and removed the hashes found on the render pipes. Instead this PR now stores _gpuData on the renderables themselves. This means that a lot of code could be removed around how renderables are destroyed and ultimatly we end up with a simpler system!

This also removed the need for the RenderableGCSystem which can be depricated / removed in another PR

Pre-Merge Checklist
  • Tests and/or benchmarks are included
  • Documentation is changed or added
  • Lint process passed (npm run lint)
  • Tests passed (npm run test)

… rendering

- Removed the `_getKey` method from `AbstractText` and related texture management logic from `CanvasTextSystem`, `CanvasTextPipe`, and `HTMLTextPipe`.
- Updated texture retrieval methods to use promises for better async handling.
- Cleaned up tests to reflect changes in texture management and ensure proper rendering of HTML text.
- Added `_gpuData` property to various renderable classes (e.g., Sprite, Mesh, TilingSprite) to manage GPU-related data.
- Updated rendering pipes to utilize the new `_gpuData` structure, replacing previous hash maps for better performance and memory management.
- Removed obsolete methods related to renderable destruction and GPU data handling.
- Ensured proper cleanup of GPU data during the destruction of renderables to prevent memory leaks.
- Updated text-related classes (AbstractText, Text, BitmapText, HTMLText) to utilize a new GPU data structure for improved performance.
- Introduced BatchableText and BatchableHTMLText for efficient GPU management in text rendering.
- Modified rendering pipes (CanvasTextPipe, BitmapTextPipe, HTMLTextPipe) to leverage the new GPU data, streamlining texture handling and updates.
- Removed obsolete GPU management methods and ensured proper cleanup during text destruction to prevent memory leaks.
- Adjusted tests to reflect changes in GPU data handling and ensure accurate rendering behavior.
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR simplifies the render pipeline by moving GPU-related data from globally managed hash maps (such as _tilingSpriteDataHash, _gpuSpriteHash, etc.) to a dedicated _gpuData property on each renderable. The changes remove the now-redundant RenderableGCSystem logic and update cleanup methods and tests accordingly.

  • Removed all per-renderable hash maps and replaced them with a _gpuData property.
  • Updated initialization and destruction paths for renderables in sprite-tiling, graphics, nine-slice sprites, meshes, and particle containers.
  • Modified tests to verify _gpuData cleanup instead of the old hash maps.

Reviewed Changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/scene/sprite-tiling/TilingSpritePipe.ts Refactored to use tilingSprite._gpuData instead of a hash map; updated initialization and data access.
src/scene/graphics/shared/Graphics.ts Added _gpuData property and cleanup in destroy method.
src/scene/sprite-nine-slice/NineSliceSpritePipe.ts Replaced _gpuSpriteHash usage with NineSliceSprite._gpuData.
src/scene/TilingSprite.ts Introduced _gpuData property and its cleanup logic.
src/scene/graphics/shared/GraphicsPipe.ts Removed graphics batches hash in favor of graphics._gpuData; updated GPU batch handling.
src/scene/mesh/shared/MeshPipe.ts Replaced usage of hash maps with Mesh._gpuData for GPU data storage.
Other test files Updated expectations and cleanup to verify _gpuData is properly cleaned up.
Comments suppressed due to low confidence (1)

src/scene/graphics/shared/GraphicsPipe.ts:225

  • The variable 'batches' is referenced without being defined. Ensure that the correct batches array is declared or passed, so that the GPU data for graphics is properly cleaned up.
graphics._gpuData.batches = batches;

Copy link

codesandbox-ci bot commented Mar 22, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@GoodBoyDigital GoodBoyDigital marked this pull request as draft March 22, 2025 23:18
@GoodBoyDigital GoodBoyDigital marked this pull request as ready for review March 22, 2025 23:26
Copy link
Collaborator

@ivanpopelyshev ivanpopelyshev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally.

- Updated various renderable classes (DOMContainer, Renderable, Graphics, Mesh, Sprite, TilingSprite, etc.) to utilize a new GPU data structure for improved performance and memory management.
- Modified the ViewContainer class to support a generic GPU data type, allowing for better organization of GPU-related data.
- Adjusted rendering pipes to leverage the new `_gpuData` structure, ensuring efficient handling of GPU resources.
- Removed obsolete GPU management methods and ensured proper cleanup during destruction to prevent memory leaks.
- Updated tests to reflect changes in GPU data handling and ensure accurate rendering behavior.
Base automatically changed from chore/text-simplify to dev May 4, 2025 14:20
@Zyie Zyie added the ✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t label May 8, 2025
@Zyie Zyie added this pull request to the merge queue May 8, 2025
Merged via the queue into dev with commit 4f97bc5 May 8, 2025
5 checks passed
@Zyie Zyie deleted the chore/gpuData branch May 8, 2025 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants