Repository navigation
Fix: Clear stale Skyboxify sky layers to avoid frametime spikes (#108) - #109
Open
gnilobaiter wants to merge 1 commit into
Open
gnilobaiter wants to merge 1 commit into
gnilobaiter wants to merge 1 commit into
Conversation
…101#108) Skyboxify queues its sky layers every frame and only clears the queue when the vanilla sky pass renders. When the sky pass is skipped (e.g. underwater) the queue grows by a few layers per frame and is drawn all at once when the sky returns. With custom sky packs and a high render scale this shows up as a large frametime spike when surfacing. Clear the queue after the level has rendered via a reflective, optional compat hook. It is a no-op when Skyboxify is absent or the queue is already empty.
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.
Clear stale Skyboxify sky layers (optional compat fix)
Refs #108, related to #90.
This is an optional compat workaround. Feel free to drop it. If it looks useful, it could go into a future release as a fix for a mod whose source is closed, so it can't be fixed upstream.
The problem
With RenderScale + Skyboxify + a custom sky pack (Dramatic Skys), there is a large frametime spike (~200-600 ms in my logs) when leaving water after ~10-20 seconds underwater. The spike gets worse as the render scale goes up (none at 100%, small at 105%, bigger at 150%, worst at 200%).
Cause
Skyboxify adds its sky layers to an internal queue (
FeatureRenderer.submits) every frame during extraction, but only clears it inendFrame, which runs when the vanilla sky pass renders. Vanilla skips the sky pass in some situations (it happens underwater), so the queue is never cleared and grows by a few layers per frame. When the sky pass runs again, every queued layer is drawn in one frame.I logged the queue size while underwater: it grew linearly, 180 -> 7260 in ~6 seconds, and dropped back to 4 as soon as I surfaced. In that same frame
Dynamic Transforms UBOresized from 32 up to 2048+ (16384 and 32768 after longer dives) and the frame took 200+ ms. All of these are full-screen layers, so the cost scales with the render target size, which is why it shows up with RenderScale.What this changes
SkyboxifyCompat: afterrenderLevelfinishes, it calls the publicFeatureRenderer.clear()on Skyboxify's queue.MixinGameRenderer.handBackcalls it once per frame.In a normal frame the queue is already empty after
endFrame, so this is a no-op. When the sky pass was skipped, it drops the layers that would otherwise pile up.Implementation notes
skyboxify$skyFeatureRendereronSkyRenderer,FeatureRenderer#clear).Testing
26.3-fabriconly. I have not built the other version targets, but the change is pure reflection plus one call, so it shouldn't affect them.Dynamic Transforms UBOno longer grows after diving.