Skip to content

Stop uploading unused per-sprite and duplicate atlas textures (#110) - #121

Merged
sambvfx merged 2 commits into
mainfrom
devin/1795475408-drop-unused-sprite-uploads
Dec 2, 2026
Merged

sambvfx merged 2 commits into
mainfrom
devin/1795475408-drop-unused-sprite-uploads

Conversation

@nvzkupu

@nvzkupu nvzkupu commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Mod-side half of #110. On every atlas capture BlockTextureManager uploaded GPU textures that nothing samples. A resource reload destroys and re-uploads them, and the runtime keeps destroyed textures in its cache, so each reload left more memory behind.

What this PR removes:

  • The duplicate atlas albedo. captureAtlas() uploaded block_atlas, and buildAtlasMaterials() then replaced atlasAlbedo with atlas_albedo (after the atlas edits). Only the second upload is kept.
  • The per-sprite textures (s<i>_a, _n, _h, _r, _m, _s, _ssa, _e). Only the lazy getMaterial(SpriteEntry, int) path read them, and nothing in the repo calls it: terrain uses the atlas-level materials. That path is removed along with its materials cache and forgetCachedCutoutSpriteMaterials().

buildPBR becomes scanPBR. It still computes the facts other code reads from each sprite (hasSSS, and lightColor from the emissive channel), but uploads nothing. The atlas-level PBR, SSS and emissive textures are unchanged. The AGENTS.md Textures section is updated to match.

The runtime-side cache retention described in #110 still has to be fixed in dxvk-remix. This PR only stops the mod from feeding that cache.

Verification

  • Linux, outside Gradle: compiled renderer-core/src and rtxremix-java/src with javac 21 and ran the renderer-core/test suite through the JUnit console. 358 of 362 tests passed. The same 4 tests also fail on main in that setup: CanonicalCaptureSemanticsTest needs fixtures from versions/.../test/resources, and DirectoryRuntimePayloadTest depends on Windows file locking.
  • A full Gradle build couldn't run locally because the Fabric, Forge and Mojang Maven hosts aren't reachable from the dev box. Windows CI is the full check.
  • Not measured in-game: VRAM before and after F3+T.

Link to Devin session: https://nvidia-cloud.devinenterprise.com/sessions/b86e22769ec7473c926a194b84efd244
Open in Devin Desktop: https://nvidia-cloud.devinenterprise.com/desktop/session/b86e22769ec7473c926a194b84efd244?variant=devin
Requested by: @nvzkupu


👀 Devin fixed 1 finding · 1 finding for you to triage · Follow Devin's work

Devin Review

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 2 findings. Devin fixed 1 finding; 1 finding is left for you to triage below.

Fixed by Devin (1)
  • Unused sprite index after cache removal — Removed SpriteEntry.index and its counter; nothing reads it after the per-sprite material cache removal.

View findings in Devin Review · Follow Devin's work

Devin Review

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔍 Atlas reload lacks live verification

The live rendering check is missing from the PR. Repeat F3+T in game to check animated terrain and measure VRAM across reloads.

Devin left this for you to triage: The in-game check (F3+T repeated, animated terrain, VRAM per reload) needs Windows + an RTX GPU, which Devin's Linux VM doesn't have. Recommend the author run tools\rtx.bat launch and note before/after VRAM and visuals in the PR before merging.

(Refers to this code)

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@sambvfx sambvfx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed at a8da869 and checked in game. Approving.

Code

  • The removed path is dead: nothing calls getMaterial(SpriteEntry, int), and nothing outside BlockTextureManager reads the per-sprite texture fields, hasPBR or index.
  • block_atlas was replaced by atlas_albedo in buildAtlasMaterials before any material or the animation forwarder read it, so only the duplicate goes.
  • hasSSS and the sprite light colours are computed from the same inputs as before.

In-game check

PR head a8da869 against its base a37b3b4, two launches each, alternating. Fabric development client on Windows, showcase world restored from the same copy before every launch, Materials pack 0.61.0, 1920x1080.

I built a small scene (glowstone, sea lantern, magma, shroomlight, a lit redstone lamp, glass, stained glass, leaves, ice, gold, prismarine, amethyst, crying obsidian, lava, water, fire, a campfire, a torch and iron bars), took screenshots from a fixed pose, reloaded resources with F3+T four times (first pair) or six times (second pair), and read the process's dedicated GPU memory 30 seconds after each reload. A night shot closed each run.

  • Rendering: every block looks the same in both builds, before and after the reloads, by eye and by average colour per block. Emissive blocks light the floor and wall at night in both.
  • Animation: lava, water, magma and the sea lantern keep animating after the reloads in both builds.
  • Logs: no errors in any run. The atlas rebuilt on every reload with the same counts (1,686 sprites, 600 with LabPBR, 54 emissive).

GPU memory in MiB, two launches per build (reloads 5 and 6 were only run in the second pair):

Stage Base PR
In the world 4,287 / 4,284 4,243 / 4,239
Scene built 4,929 / 4,945 4,889 / 4,881
After reload 1 5,106 / 5,106 4,729 / 4,721
After reload 2 5,089 / 5,106 4,746 / 4,758
After reload 3 5,126 / 5,122 4,729 / 4,725
After reload 4 5,109 / 5,123 5,082 / 5,082
After reload 5 5,126 5,065
After reload 6 5,446 5,402

So the PR is about 45 MiB lower at rest. Memory moves in steps of roughly 170 to 350 MiB in both builds, and the PR's first step lands on reload 4 where the base's lands on reload 1, which is the whole of the gap after reloads 1 to 3. From the built scene to reload 6 the base grew by about 500 to 520 MiB and the PR by 521 MiB, so total growth across reloads is unchanged. The runtime-side half of #110 is still needed for that.

Not blocking, fine as follow-ups

  • buildSprites still copies every sprite's albedo and bakes AO into the copy, but the copy is now read only for sprites with _s emissive data or a luminance entry.
  • scanPBR sets hasSSS from the same conditions buildAtlasMaterials applies again before anything reads it.
  • A few comments still describe per-sprite textures: the SpriteEntry Javadoc ("texture handles, PBR flags"), the first line of the class Javadoc, and the "Per-sprite texture extraction" and "Sprite lookup + material factory" banners.
  • cleanup leaves atlasAlbedo and atlasEmissive set. Harmless today, since a destroyed texture's handle is 0 and flushAnimationPatches checks it, but nulling them with the other atlas fields would be tidier.

@sambvfx
sambvfx merged commit 05f7612 into main Dec 2, 2026
11 checks passed
@sambvfx
sambvfx deleted the devin/1795475408-drop-unused-sprite-uploads branch December 2, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants