Skip to content
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

Merged
merged 4 commits into from
May 12, 2021

Conversation

zadjii-msft
Copy link
Member

@zadjii-msft zadjii-msft commented May 3, 2021

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

PR Checklist

Detailed Description of the Pull Request / Additional comments

This reverts commit c113b65.

That commit reverted 30b8335

Validation Steps Performed

  • Built and ran the Terminal, it still seems to work
  • Does a TDR still work? or do we need to recreate the handle, or something.
  • Does this work on Win7? I honestly have no idea how DX compatibility works. Presumably, the WPF version uses the 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.

@zadjii-msft zadjii-msft added Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Product-Terminal The new Windows Terminal. Issue-Task It's a feature request, but it doesn't really need a major design. labels May 3, 2021
Copy link
Member

@DHowett DHowett left a 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

@ghost ghost added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels May 4, 2021
@zadjii-msft zadjii-msft requested a review from DHowett May 6, 2021 15:00
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);
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HECK YEA IT IS.

@DHowett
Copy link
Member

DHowett commented May 11, 2021

DO NOT AUTOMERGE (kills the stacked PRs)

@zadjii-msft zadjii-msft added the Needs-Second It's a PR that needs another sign-off label May 12, 2021
// actual failure from the API itself.
[[nodiscard]] HRESULT DxEngine::_CreateSurfaceHandle() noexcept
{
wil::unique_hmodule hDComp{ LoadLibraryEx(L"Dcomp.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32) };
Copy link
Member

@lhecker lhecker May 12, 2021

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 },
Copy link
Member

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.

@DHowett
Copy link
Member

DHowett commented May 12, 2021

Idle thought: should we use the APISet name for dcomp.dll? It might be more "future proof" or whatever.

@zadjii-msft zadjii-msft merged commit 9f45963 into main May 12, 2021
@zadjii-msft zadjii-msft deleted the dev/migrie/f/oop/use-dcomp-handle branch May 12, 2021 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Second It's a PR that needs another sign-off Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants