Repository navigation
perf: pool exact-size filter render targets across slots - #9
Merged
bbbreaddd merged 6 commits intoNov 16, 2026
Merged
Conversation
Battle turns reallocated ~1,000 filter targets per session because ensureFilterTarget accepted a target only at the exact requested POT size; two group slots flipped between 1024x512, 512x128, 512x8 and 64x32 almost every frame, at ~1 ms per create. Targets now carry a logical size (the POT of the frame, exactly today's value) and a physical allocation that may be larger. A target is kept while it fits dimension-wise; the game and its shaders keep seeing the logical size in filterArea, filterClamp and the vertex coordinates, and only texture2D(uSampler, ...) reads are scaled by logical/physical in the renderer's fragment transform. Group targets drawn for custom filter plans reuse the same rule; other filter paths keep their exact-size allocation. A reused target is cleared over the whole physical allocation before the group content is drawn, so samples outside the frame read transparent instead of stale pixels. Oversized targets shrink back after 120 frames without a request at their size. The exact-size path remains available through PMJS_DISABLE_OPT=render.filter-target-reuse.
A reused target can be several POT buckets larger than the frame it holds. Clearing the whole physical allocation on every pass made the reuse path slower than the allocations it removed in a real battle: every pass paid the largest bucket instead of the current frame. New allocations still clear the whole physical texture once, so the tail beyond the logical extent stays transparent and out-of-frame samples cannot read stale pixels. Later clears scissor to the logical extent, which is exactly the area the exact-size path would have cleared. PMJS_DISABLE_OPT is validated against the registered optimization IDs at boot, so register render.filter-target-reuse in pmjs-pixi4; otherwise the fallback variant refused to boot instead of running the exact-size path.
AbdullahTrees
force-pushed
the
pr/filter-target-hysteresis
branch
from
November 5, 2026 20:53
979da36 to
df19236
Compare
bbbreaddd
marked this pull request as ready for review
November 15, 2026 23:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Filter slots currently retain only one displaced target each, so cycling through three or more sizes repeatedly allocates and evicts GPU targets.
Replace this PR's oversized-target hysteresis and shader rewriting with a shared pool matched by exact physical dimensions. The existing entry limit and 32 MiB cache budget remain, with LRU eviction. Shaders, sampling coordinates and clears keep their existing behavior. On allocation failure, reclaim idle cached targets, finish queued GPU work and retry once while preserving active targets.
Validation:
Merged the current main branch into this branch to resolve the previous source-layout conflicts. The pre-push hook also clears repository-local Git environment variables so provenance checks inspect their temporary fixture repositories correctly.