Skip to content

Publish replacement textures within the frame budget - #323

Open
CharlieMacnamara wants to merge 2 commits into
encounter:mainfrom
CharlieMacnamara:texture-replacement-publish-budget
Open

CharlieMacnamara wants to merge 2 commits into
encounter:mainfrom
CharlieMacnamara:texture-replacement-publish-budget

Conversation

@CharlieMacnamara

Copy link
Copy Markdown

A decoded replacement is uploaded in one frame on the presenting thread. publish_fits_budget exempts the first publish of a frame from the limit, so a single large chain goes up whole: 4096x4096 BC7 replacement textures stalled for 2 to 3 s each with a 4K texture pack.

A publish now spends at most ReplacementPublishBudgetBytes per frame, a row range at a time, and its handle reaches the replacement cache only after the last row, so a draw never samples a partly written texture. The rows still to write are kept for the next frame, and a publish whose entry stops being selected is dropped.

With the pack: worst publish 0.1 MB in 2.2 ms, no multi-second frame. The first commit adds write_texture_rows so a range of a mip level goes through the same upload path as a whole level.

write_texture writes whole mip levels. Uploading a decoded replacement texture over several frames
needs to write any row range of any level, with the same layout and upload path so that the result is
identical.

The row range loop moves into a shared helper; write_texture calls it with the whole level.
A decoded replacement goes up in one frame on the presenting thread. publish_fits_budget exempts the
first publish of a frame from the limit, so a single large chain is uploaded whole: 4096x4096 BC7
textures in a texture pack stalled for 2 to 3 s each.

A publish now spends at most ReplacementPublishBudgetBytes per frame, a row range at a time, and the
handle reaches the replacement cache only after the last row arrives, so a draw never samples a
partly written texture. Rows still to write are kept across frames; a publishing entry that is no
longer selected is dropped.

s_readyPublishes becomes a deque because publishes are consumed from the front one at a time.
@CharlieMacnamara
CharlieMacnamara force-pushed the texture-replacement-publish-budget branch from 056d5ad to 5e2dff2 Compare November 19, 2026 01:15
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