Repository navigation
Streamer: compute the dynamic buffer offset after "Grow" - #326
Merged
Merged
Conversation
StreamBufferData and StreamTextureData computed the frame base with the per-frame size from before Grow(). After a grow in frame slot >= 1 the data landed outside the current frame slot of the new buffer, where the next frames overwrote it while it could still be in flight. Add the frame base after Grow().
Collaborator
|
It's a bomb. Thanks. Merged! |
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.
StreamBufferDataandStreamTextureDatacompute the returned offset asm_FrameIndex * m_DynamicBufferSizePerFrame + m_DynamicBufferOffsetbefore callingGrow(). IfGrow()raises the per-frame size and replaces the buffer whilem_FrameIndex >= 1, the offset still uses the old per-frame size. The data is then written and returned outside the current frame's slot of the new buffer, partly or fully inside another frame's slot. The next frames stream into that slot while the GPU may still read the previous frame's data, for example dynamic vertices or indices, ImGui geometry, or a texture copy source.This change keeps the in-frame offset and adds the frame base after
Grow(). The same fix is applied to both functions.Repro
The repo has no test directory, so I used a small standalone program. It links the static library (NONE backend) and constructs
StreamerImplthe way the backends do. The NONE core interface is passed in with buffer create/map/destroy redirected to host memory, so the streamed bytes can be checked. Setup:queuedFrameNum = 2,dynamicBufferDesc.size = 64 KB.StreamBufferData100 KBStreamTextureDataBC7 1024x1024 mip 1 (256 KB)I checked this in Debug and Release builds, and both gave the same output. I also timed a loop of 10^6
StreamBufferDatacalls (256 B each) in Release, alternating before/after runs, on a busy machine. The two sets of runs didn't agree on a direction:The change only moves the frame-base add to after
Grow(); it doesn't add any work.Testing
This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.