-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use DComp surface handle for Swap Chain management #10023
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking for the dcomp discussion
wil::unique_hmodule hDComp{ LoadLibraryEx(L"Dcomp.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32) }; | ||
RETURN_LAST_ERROR_IF(hDComp.get() == nullptr); | ||
|
||
auto fn = GetProcAddressByFunctionDeclaration(hDComp.get(), DCompositionCreateSurfaceHandle); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WHAT?? THIS IS SO COOL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HECK YEA IT IS.
DO NOT AUTOMERGE (kills the stacked PRs) |
// actual failure from the API itself. | ||
[[nodiscard]] HRESULT DxEngine::_CreateSurfaceHandle() noexcept | ||
{ | ||
wil::unique_hmodule hDComp{ LoadLibraryEx(L"Dcomp.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The library is technically called dcomp.dll
. I know that Microsoft's prior file systems are all case insensitive unfortunately, but... you know... It might be a good idea to fix the name.
Assuming that this function is only called from the main thread you can also write:
(Removed, as making code more complex really isn't that useful...)
@@ -79,6 +79,7 @@ DxEngine::DxEngine() : | |||
_backgroundColor{ 0 }, | |||
_selectionBackground{}, | |||
_haveDeviceResources{ false }, | |||
_swapChainHandle{ INVALID_HANDLE_VALUE }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wil::unique_*
types have default constructors and you don't need to initialize them here.
Idle thought: should we use the APISet name for dcomp.dll? It might be more "future proof" or whatever. |
Summary of the Pull Request
This PR changes the DxEngine to create a swapchain HANDLE, then have the TermControl attach that handle to the SwapChainPanel, rather than returning the swapchain via a
IDXGISwapChain1
.I didn't write this code originally, @miniksa helped me out. The original commit was so succinct that I didn't think there was anything else to add or take away.
I'm going to need this for tear-out (#1256), so that I can have the content process create swap chain handles, then duplicate those handles out to the window process that will end up embedding the content.
References
DCompositionCreateSurfaceHandle
CreateSwapChainForCompositionSurfaceHandle
CreateSwapChainForComposition
PR Checklist
Detailed Description of the Pull Request / Additional comments
This reverts commit c113b65.
That commit reverted 30b8335
Validation Steps Performed
ForHwnd
path, so this will still work, but I don't know if this will suddenly fail to launch on Win7 or something. Tagging in @miniksa.