Skip to content

perf(screenshot): Avoid redundant buffers and copies in screenshot uploads - #635

Open
tintinhamans wants to merge 1 commit into
GeneralsOnlineDevelopmentTeam:mainfrom
tintinhamans:arctic/go/perf/screenshot-probe-buffers
Open

tintinhamans wants to merge 1 commit into
GeneralsOnlineDevelopmentTeam:mainfrom
tintinhamans:arctic/go/perf/screenshot-probe-buffers

Conversation

@tintinhamans

@tintinhamans tintinhamans commented Oct 9, 2026 •

Copy link
Copy Markdown

CaptureScreenshot created a display-sized image surface and read the whole front buffer into it on every capture, then never used it: the pixels come from the back buffer copy. That is a full GPU to CPU readback and a 29 MB surface at 5120x1440 per capture, and the capture also failed whenever GetFrontBuffer did. This removes it.

The worker thread now packs BGRA to RGB in place in the buffer it already owns instead of allocating a second full-size image, keeps the resized image in a vector and frees the full-size capture once it is resized, and reserves the JPEG output buffer up front. The encoded bytes are moved instead of copied through the match-start cache, the pending upload list (whose loop copied every entry each tick) and into the S3 PUT request.

It also drops an Unlock() on the back buffer, which is never locked. UnlockRect fails on it with D3DERR_INVALIDCALL, which DX8_ErrorCode turns into a WWASSERT(0), so debug builds asserted on every capture.

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