Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/d3d11/d3d11_context_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1884,7 +1884,26 @@ template <typename ContextInternalState> class MTLD3D11DeviceContextImplBase : p
void
STDMETHODCALLTYPE
SwapDeviceContextState(ID3DDeviceContextState *pState, ID3DDeviceContextState **ppPreviousState) override {
UNIMPLEMENTED("SwapDeviceContextState");
// Callers (e.g. Direct2D interop) swap their own pipeline state in and the
// application's state out around a render pass. Save the current pipeline
// state into the returned previous-state token, then activate the incoming
// token's saved state.
if (!pState) {
if (ppPreviousState)
*ppPreviousState = nullptr;
return;
}
std::lock_guard<mutex_t> lock(mutex);
auto incoming = static_cast<MTLD3D11DeviceContextState *>(pState);
if (ppPreviousState) {
auto previous = new MTLD3D11DeviceContextState(device);
previous->saved_state = std::move(state_);
*ppPreviousState = ref(previous);
}
state_ = std::move(incoming->saved_state);
incoming->saved_state = {};
ResetEncodingContextState();
InvalidateRenderPipeline();
}

void
Expand Down
5 changes: 5 additions & 0 deletions src/d3d11/d3d11_context_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ class MTLD3D11DeviceContextState

return E_NOINTERFACE;
}

// Saved pipeline state for SwapDeviceContextState. A newly created token
// carries default (empty) state, giving the caller a clean context to render
// into; swapping back restores the previously saved state.
D3D11ContextState saved_state = {};
};

} // namespace dxmt