feat(d3d11): implement SwapDeviceContextState#172
Open
WIndFate wants to merge 1 commit into
Open
Conversation
SwapDeviceContextState was UNIMPLEMENTED. Callers such as Direct2D interop use it to swap their own pipeline state in and the application's state out around a render pass, so any such render loop aborted at the first call. MTLD3D11DeviceContextState gains a D3D11ContextState saved_state slot. The swap saves the current state_ into the returned previous-state token, activates the incoming token's saved state, then resets encoding state and invalidates the render pipeline so the Metal side follows the new state. With this, a Direct2D render loop (BeginDraw/Clear/draw/EndDraw) runs cleanly with EndDraw returning S_OK.
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
SwapDeviceContextStatewasUNIMPLEMENTED. Callers such as Direct2D interop use it to swap their own pipeline state in and the application's state out around each render pass, so any such render loop aborts at the first call (e.g. Wine's Direct2D at the firstClear).DXMT already has the pieces needed: a single
D3D11ContextStatestruct, the context'sstate_,ResetEncodingContextState()andInvalidateRenderPipeline(). This change:D3D11ContextState saved_stateslot toMTLD3D11DeviceContextStatestate_into the returned previous-state tokenTesting
Verified on macOS with a CrossOver/Wine runtime on an Apple M-series GPU. Together with the
IDXGISurfacechange (#171), a Wine Direct2D render loop (BeginDraw → Clear → draw → EndDraw) runs ~150 frames withEndDrawreturningS_OKand no errors in the log.Notes
Builds on the existing context-state machinery rather than introducing new state tracking.