Revert "Use DComp surface handle for Swap Chain management."

This reverts commit 30b8335479.
This commit is contained in:
Mike Griese
2021-04-20 12:16:31 -05:00
parent 69f22a7113
commit c113b65d9b
8 changed files with 20 additions and 31 deletions

View File

@@ -1192,9 +1192,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
} }
} }
HANDLE ControlCore::GetSwapChainHandle() const IDXGISwapChain1* ControlCore::GetSwapChain() const
{ {
return _renderEngine->GetSwapChainHandle(); return _renderEngine->GetSwapChain().Get();
} }
void ControlCore::_rendererWarning(const HRESULT hr) void ControlCore::_rendererWarning(const HRESULT hr)

View File

@@ -49,7 +49,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void UpdateAppearance(IControlAppearance newAppearance); void UpdateAppearance(IControlAppearance newAppearance);
void SizeChanged(const double width, const double height); void SizeChanged(const double width, const double height);
void ScaleChanged(const double scaleX, const double scaleY); void ScaleChanged(const double scaleX, const double scaleY);
HANDLE GetSwapChainHandle() const; IDXGISwapChain1* GetSwapChain() const;
void AdjustFontSize(int fontSizeDelta); void AdjustFontSize(int fontSizeDelta);
void ResetFontSize(); void ResetFontSize();

View File

@@ -572,14 +572,14 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// This event is only registered during terminal initialization, // This event is only registered during terminal initialization,
// so we don't need to check _initializedTerminal. // so we don't need to check _initializedTerminal.
// We also don't lock for things that come back from the renderer. // We also don't lock for things that come back from the renderer.
auto chainHandle = _core->GetSwapChainHandle(); auto chain = _core->GetSwapChain();
auto weakThis{ get_weak() }; auto weakThis{ get_weak() };
co_await winrt::resume_foreground(Dispatcher()); co_await winrt::resume_foreground(Dispatcher());
if (auto control{ weakThis.get() }) if (auto control{ weakThis.get() })
{ {
_AttachDxgiSwapChainToXaml(chainHandle); _AttachDxgiSwapChainToXaml(chain);
} }
} }
@@ -625,10 +625,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation
} }
} }
void TermControl::_AttachDxgiSwapChainToXaml(HANDLE swapChainHandle) void TermControl::_AttachDxgiSwapChainToXaml(IDXGISwapChain1* swapChain)
{ {
auto nativePanel = SwapChainPanel().as<ISwapChainPanelNative2>(); auto nativePanel = SwapChainPanel().as<ISwapChainPanelNative>();
nativePanel->SetSwapChainHandle(swapChainHandle); nativePanel->SetSwapChain(swapChain);
} }
bool TermControl::_InitializeTerminal() bool TermControl::_InitializeTerminal()
@@ -667,7 +667,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
} }
_interactivity->Initialize(); _interactivity->Initialize();
_AttachDxgiSwapChainToXaml(_core->GetSwapChainHandle()); _AttachDxgiSwapChainToXaml(_core->GetSwapChain());
// Tell the DX Engine to notify us when the swap chain changes. We do // Tell the DX Engine to notify us when the swap chain changes. We do
// this after we initially set the swapchain so as to avoid unnecessary // this after we initially set the swapchain so as to avoid unnecessary

View File

@@ -66,8 +66,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void ToggleShaderEffects(); void ToggleShaderEffects();
winrt::fire_and_forget RenderEngineSwapChainChanged(const IInspectable& sender, const IInspectable& args); winrt::fire_and_forget RenderEngineSwapChainChanged(const IInspectable& sender, const IInspectable& args);
void _AttachDxgiSwapChainToXaml(HANDLE swapChainHandle); void _AttachDxgiSwapChainToXaml(IDXGISwapChain1* swapChain);
winrt::fire_and_forget _RendererEnteredErrorState(const IInspectable& sender, const IInspectable& args); winrt::fire_and_forget _RendererEnteredErrorState(const IInspectable& sender, const IInspectable& args);
void _RenderRetryButton_Click(IInspectable const& button, IInspectable const& args); void _RenderRetryButton_Click(IInspectable const& button, IInspectable const& args);
winrt::fire_and_forget _RendererWarning(const IInspectable& sender, winrt::fire_and_forget _RendererWarning(const IInspectable& sender,
const Control::RendererWarningArgs& args); const Control::RendererWarningArgs& args);

View File

@@ -13,7 +13,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>onecoreuap_apiset.lib;d3dcompiler.lib;dwmapi.lib;uxtheme.lib;shlwapi.lib;ntdll.lib;dcomp.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>onecoreuap_apiset.lib;d3dcompiler.lib;dwmapi.lib;uxtheme.lib;shlwapi.lib;ntdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>

View File

@@ -79,7 +79,6 @@ DxEngine::DxEngine() :
_backgroundColor{ 0 }, _backgroundColor{ 0 },
_selectionBackground{}, _selectionBackground{},
_haveDeviceResources{ false }, _haveDeviceResources{ false },
_swapChainHandle{ INVALID_HANDLE_VALUE },
_swapChainDesc{ 0 }, _swapChainDesc{ 0 },
_swapChainFrameLatencyWaitableObject{ INVALID_HANDLE_VALUE }, _swapChainFrameLatencyWaitableObject{ INVALID_HANDLE_VALUE },
_recreateDeviceRequested{ false }, _recreateDeviceRequested{ false },
@@ -619,13 +618,6 @@ try
} }
case SwapChainMode::ForComposition: case SwapChainMode::ForComposition:
{ {
if (!_swapChainHandle)
{
RETURN_IF_FAILED(DCompositionCreateSurfaceHandle(GENERIC_ALL, nullptr, &_swapChainHandle));
}
RETURN_IF_FAILED(_dxgiFactory2.As(&_dxgiFactoryMedia));
// Use the given target size for compositions. // Use the given target size for compositions.
_swapChainDesc.Width = _displaySizePixels.width<UINT>(); _swapChainDesc.Width = _displaySizePixels.width<UINT>();
_swapChainDesc.Height = _displaySizePixels.height<UINT>(); _swapChainDesc.Height = _displaySizePixels.height<UINT>();
@@ -635,8 +627,7 @@ try
// It's 100% required to use scaling mode stretch for composition. There is no other choice. // It's 100% required to use scaling mode stretch for composition. There is no other choice.
_swapChainDesc.Scaling = DXGI_SCALING_STRETCH; _swapChainDesc.Scaling = DXGI_SCALING_STRETCH;
RETURN_IF_FAILED(_dxgiFactoryMedia->CreateSwapChainForCompositionSurfaceHandle(_d3dDevice.Get(), RETURN_IF_FAILED(_dxgiFactory2->CreateSwapChainForComposition(_d3dDevice.Get(),
_swapChainHandle.get(),
&_swapChainDesc, &_swapChainDesc,
nullptr, nullptr,
&_dxgiSwapChain)); &_dxgiSwapChain));
@@ -1012,14 +1003,14 @@ try
} }
CATCH_LOG() CATCH_LOG()
HANDLE DxEngine::GetSwapChainHandle() Microsoft::WRL::ComPtr<IDXGISwapChain1> DxEngine::GetSwapChain()
{ {
if (!_swapChainHandle) if (_dxgiSwapChain.Get() == nullptr)
{ {
THROW_IF_FAILED(_CreateDeviceResources(true)); THROW_IF_FAILED(_CreateDeviceResources(true));
} }
return _swapChainHandle.get(); return _dxgiSwapChain;
} }
void DxEngine::_InvalidateRectangle(const til::rectangle& rc) void DxEngine::_InvalidateRectangle(const til::rectangle& rc)

View File

@@ -70,7 +70,7 @@ namespace Microsoft::Console::Render
void SetSoftwareRendering(bool enable) noexcept; void SetSoftwareRendering(bool enable) noexcept;
HANDLE GetSwapChainHandle(); ::Microsoft::WRL::ComPtr<IDXGISwapChain1> GetSwapChain();
// IRenderEngine Members // IRenderEngine Members
[[nodiscard]] HRESULT Invalidate(const SMALL_RECT* const psrRegion) noexcept override; [[nodiscard]] HRESULT Invalidate(const SMALL_RECT* const psrRegion) noexcept override;
@@ -212,7 +212,6 @@ namespace Microsoft::Console::Render
::Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> _d2dBrushBackground; ::Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> _d2dBrushBackground;
::Microsoft::WRL::ComPtr<IDXGIFactory2> _dxgiFactory2; ::Microsoft::WRL::ComPtr<IDXGIFactory2> _dxgiFactory2;
::Microsoft::WRL::ComPtr<IDXGIFactoryMedia> _dxgiFactoryMedia;
::Microsoft::WRL::ComPtr<IDXGIDevice> _dxgiDevice; ::Microsoft::WRL::ComPtr<IDXGIDevice> _dxgiDevice;
::Microsoft::WRL::ComPtr<IDXGISurface> _dxgiSurface; ::Microsoft::WRL::ComPtr<IDXGISurface> _dxgiSurface;

View File

@@ -21,8 +21,6 @@
#include <typeinfo> #include <typeinfo>
#include <stdexcept> #include <stdexcept>
#include <dcomp.h>
#include <dxgi.h> #include <dxgi.h>
#include <dxgi1_2.h> #include <dxgi1_2.h>
#include <dxgi1_3.h> #include <dxgi1_3.h>