Repository navigation
app,internal/d3d11: [Windows] present with the flip model - #4
Merged
Merged
Conversation
The swap chain used the old blit model with one buffer, which adds a copy and a frame of queueing between a keystroke and the screen. Create a FLIP_DISCARD chain of two buffers instead and set the maximum frame latency to 1, falling back to the previous DISCARD chain where a flip chain cannot be created. Flip-model buffers cannot have an _SRGB format, so the buffers are UNORM and the render target view carries the sRGB format. ResizeBuffers now runs with the view unbound and its deferred destruction flushed, and Release clears and flushes the context, since a window holds one flip chain and a new one after a lost device would otherwise fail. The first frame of a new size presents with sync interval 0, replacing any queued frame so the window does not show an older one stretched.
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.
Summary
Windows presented through the blit model (
DXGI_SWAP_EFFECT_DISCARD, one buffer). This moves the swap chain to the flip model to cut typing latency, and makes a resize present its new-size frame at once.CreateSwapChaintriesFLIP_DISCARDwith 2 UNORM buffers, then falls back to the previousDISCARDchain with its_SRGBbuffer.IDXGIDevice1::SetMaximumFrameLatency(1)on the device, best effort. No waitable object.R8G8B8A8_UNORM_SRGB, valid over both buffer formats, so Gio's linear output stays sRGB encoded.Refreshunbinds the view and flushes beforeResizeBuffers.Lockalready rebinds it every frame, afterPresentunbinds it.Releaseclears and flushes the context so a new flip chain can be created on the same window after a lost device.Presentafter a size change uses sync interval 0, which replaces any queued frame.Buffer contents after
Presentare not read: Direct3D has noBufferAge, so every frame is drawn whole, and the window clears at the start of each frame.Test plan
go test ./internal/d3d11/ ./gpu/on Linux: pass, including the new config and fallback testsGOOS=windows go build ./...: cleanGOOS=windows go vet ./app/... ./internal/d3d11/... ./gpu/...: no finding in changed codeFLIP_DISCARDchain with 2 UNORM buffers, set the frame latency, resized, bound the sRGB view, presented at intervals 0 and 1, and created a second chain on the same window after release: passnative/against this branch through a localreplace:go build ./...andgo vet ./...on Linux clean