
What this is
A small client mod that fixes two depth-buffer defects in Iris, both of which come from the same place: Iris does not own a depth buffer for the world, it borrows Minecraft's — and it decides when to re-borrow it from a counter that cannot answer the question being asked.
Minecraft 1.21.1 / NeoForge 21.1.x. Nothing is written to your world.
Fix 1 — Distant Horizons dies after you resize the window
No render-scaling mod required. This one affects plain Iris + Distant Horizons.
Drag the edge of the game window, or go in or out of fullscreen, and Distant Horizons stops drawing. It stays broken until you reload the world.
The cause: when Iris resizes its render targets it walks every framebuffer it owns and hangs Minecraft's depth texture on each — and the Distant Horizons framebuffers are on that list, though they must keep DH's own depth. The reconnect that would put it back is guarded by a check on the texture's id, and DH's id never changed. Only the attachment did. So nothing ever restores it.
This mod clears the remembered id at the head of that reconnect, so Iris's own code re-attaches normally.
Fix 2 — the world's depth does not follow a replaced render target
If you use anything that renders the world at a resolution other than the window's — a render scaler, a dynamic resolution mod — Iris ends up drawing into colour buffers of one size against a depth buffer of another. Distant Horizons LODs draw on top of everything, and the world can come out stretched or doubled.
The cause, read out of Iris's compiled code:
// RenderTargets.resizeIfNeeded and DHCompatInternal.reconnectDHTextures
if (depthBufferVersion != cachedDepthBufferVersion) { /* only here is a new depth taken */ }
That counter answers "has this target recreated its buffers?" It cannot answer "is this a different target now?" — which is exactly what happens when another mod hands Minecraft a different main render target.
The advice usually given for the symptom is "resize the game window until it fixes itself". That works precisely because resizing makes Minecraft recreate its target, which bumps the counter.
This mod compares the depth texture's id, and the Distant Horizons texture's size, instead of the counter. In ordinary play that is one integer comparison per frame.
What is proven and what is not
Both defects are read directly from Iris 1.8.14's bytecode, and fix 1 is confirmed in play: with the mod installed the log shows the DH depth texture being re-attached as the world resolution changes, and DH keeps rendering.
What has not been done is a controlled before/after against the open upstream report whose symptoms match fix 2 (RenderScale#59). The mechanism is proven; the claim "this fixes that issue" is not made here. During development, one picture defect that looked exactly like it turned out to have a completely unrelated cause — another mod leaking a viewport in the middle of the frame.
Requirements
Minecraft 1.21.1, NeoForge 21.1.x, Iris. Distant Horizons optional — without it, fix 1 simply has nothing to act on.
License
MIT.

