Skip to content

Reduce allocations and redundant work in a few render paths - #869

Open
BonsUnleashed wants to merge 1 commit into
Asek3:1.20.1-newfrom
BonsUnleashed:bons-furious/oculus
Open

BonsUnleashed wants to merge 1 commit into
Asek3:1.20.1-newfrom
BonsUnleashed:bons-furious/oculus

Conversation

@BonsUnleashed

@BonsUnleashed BonsUnleashed commented Sep 29, 2026 •

Copy link
Copy Markdown

A set of small, independent changes on per-frame paths. Each keeps the same output. Happy to split them up if that's easier to review.

  • FullyBufferedMultiBufferSource: the buffer affinity LRU is an Object2IntLinkedOpenHashMap (getAndMoveToLast / removeFirstInt) instead of a LinkedHashMap<RenderType, Integer>, so lookups don't box.
  • GraphTranslucencyRenderOrderManager: reset() keeps graphs that stayed empty instead of allocating new ones, and empty graphs skip the feedback arc set and toposort.
  • IrisRenderSystem.unbindAllSamplers: returns early when no sampler has been bound since the last call.
  • ProgramUniforms / ProgramSamplers: indexed loops over the immutable lists instead of iterators.
  • CustomUniforms.push: walks the Object2IntOpenHashMap with fastForEach so locations aren't boxed.
  • AdvancedShadowCullingFrustum: the two cross products write into the plane normal vectors, which aren't used afterwards, instead of new vectors.
  • ModelToEntityVertexSerializer: reads each vertex value once, reads the captured entity, block entity and item ids once per quad, and copies the 36-byte vertex with fixed-size loads.

Measured with the same changes applied to 1.8.0, which is still this branch's version. For example, converting 256 vertices went from about 3.9 µs to 2.6 µs, and buffer affinity lookups from about 53 ns to 24 ns with no allocation. These are per-method numbers, not frame times.

Compiles on 1.20.1-new (compileJava compileSodiumCompatibilityJava). Not tested in game on this branch.

Bons and Furious currently ships a patch for this: CurseForge · Modrinth (page still in review) · GitHub release

The shader renderer spends time organizing small pieces of data,
including lists with nothing in them. These changes reuse suitable
objects and skip unnecessary empty-list work. They reduce preparation
work and temporary memory while keeping the same shader settings and
drawing results.

Source port of a change shipped in Bons and Furious 1.0.15.
@BonsUnleashed BonsUnleashed changed the title Reduce shader-state, buffer-affinity and transparency-graph overhead Reduce allocations and redundant work in a few render paths Sep 29, 2026
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.

1 participant