Skip to content

feat(d3d11): implement SwapDeviceContextState#172

Open
WIndFate wants to merge 1 commit into
3Shain:mainfrom
WIndFate:feat/swap-device-context-state
Open

feat(d3d11): implement SwapDeviceContextState#172
WIndFate wants to merge 1 commit into
3Shain:mainfrom
WIndFate:feat/swap-device-context-state

Conversation

@WIndFate

Copy link
Copy Markdown

Summary

SwapDeviceContextState was UNIMPLEMENTED. 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 first Clear).

DXMT already has the pieces needed: a single D3D11ContextState struct, the context's state_, ResetEncodingContextState() and InvalidateRenderPipeline(). This change:

  • adds a D3D11ContextState saved_state slot to MTLD3D11DeviceContextState
  • saves the current state_ into the returned previous-state token
  • activates the incoming token's saved state
  • resets encoding state and invalidates the render pipeline so the Metal side follows the new state

Testing

Verified on macOS with a CrossOver/Wine runtime on an Apple M-series GPU. Together with the IDXGISurface change (#171), a Wine Direct2D render loop (BeginDraw → Clear → draw → EndDraw) runs ~150 frames with EndDraw returning S_OK and no errors in the log.

Notes

Builds on the existing context-state machinery rather than introducing new state tracking.

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.
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