Skip to content

perf(items): render item icons from a GPU atlas - #1087

Merged
Wyvest merged 13 commits into
Polyfrost:v1from
saadndm:feat/live-item-icons
Sep 20, 2026
Merged

Wyvest merged 13 commits into
Polyfrost:v1from
saadndm:feat/live-item-icons

Conversation

@saadndm

@saadndm saadndm commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Improvements

  • Added animated item icon support in HUD and Compose
  • Perf tested on Evergreen inventory hud, reduces incremental rendering cost by 91%, (0.343ms -> 0.030ms per frame)
  • Added public PolyItemIcon API taking in a Minecraft Item, ItemStack or registry ID string
  • Initializes item data components if not loaded yet, icons can now render before first world join
  • Separates atlases by resolution so icons remain sharp after resizing or changing HUD scale
  • Fixed unaligned item picker dropdown
  • Recovers item atlases after resource reloads and window resizing

Impl Details

  • Uses GPU atlases for item icons, and related rendering optimizations, originally implemented by @anolithme
  • Improved atlas scheduling so the item picker renders icons immediately without visible loading state
  • The ItemStack overload renders vanilla-style count, durability, and cooldown decorations
  • Unified gameplay, editor, pre-world, and fallback HUD preparation so the rendering paths no longer drift
  • Rerenders icons when their Minecraft model state changes, static icons remain cached
  • Added render-target and scissor handling needed to render vanilla item models directly into atlas slots
  • Updates VulkanMod 1.21.1 to latest version fixing a crash, tested for compatibility on VulkanMod/Vulkan versions

Tested on all versions

Supersedes #982

Related Issue(s)

Closes #953
Closes #937

@saadndm

saadndm commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

Changes I made:

fix stuff & perf(items): rerender animated icons only on TickEvent:

  • Animated textures only advance per tick and glint offset moves sub-pixel per tick, so animated icons rerender once per tick instead of every frame

fix(items): mark icons available on server join:

  • Minor fix in case the pre-world component initialization failed

fix(items): request exact item render sizes:

  • Reverted the round up to 8 change because it made icons pixelated
  • Tested with a full inventory HUD dragged at max size, only cost ~0.3ms/frame on 26.2 while dragging

fix(items): register picker icons before render:

  • Registers picker icons in onPlaced again, and runs recomposition and layout before the atlas renders so icons revealed by pointer drag, smooth wheel scrolling, or a search all draw on the same frame

fix(hud): rebind main target after offscreen target changes:

  • Fixes all HUDs flickering for a frame whenever an atlas page was created/disposed, because creating or destroying a render target leaves framebuffer 0 bound on 1.21.1, where GUI draws don't rebind
  • Fixes preexisting bug where HUDs vanished during window resize in 1.21.1:
before.mp4

fix(skia): isolate Skia calls made outside a draw from Minecraft's GL state:

  • Fixes block icons rendering without depth test/cull on their first render in 1.21.1, 1.21.4, 1.21.5 like this:
image
  • Skia applies resetGLAll lazily on its next GL call. Since Complete Performance Overhaul #1036 some warm up frames open a GL window without making any Skia call, so the reset fired too late, outside any window, and left GlStateManager's cache stale
  • Also moves the framebuffer binding into StoredGLState instead of saving it by hand in every draw path

@Wyvest
Wyvest merged commit c198c24 into Polyfrost:v1 Sep 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

(feat): ItemList Item support decorations for the item renderer

3 participants