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
Родитель 69f22a7113
Коммит c113b65d9b
8 изменённых файлов: 20 добавлений и 31 удалений

Просмотреть файл

@ -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)

Просмотреть файл

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

Просмотреть файл

@ -572,14 +572,14 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// This event is only registered during terminal initialization,
// so we don't need to check _initializedTerminal.
// 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() };
co_await winrt::resume_foreground(Dispatcher());
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>();
nativePanel->SetSwapChainHandle(swapChainHandle);
auto nativePanel = SwapChainPanel().as<ISwapChainPanelNative>();
nativePanel->SetSwapChain(swapChain);
}
bool TermControl::_InitializeTerminal()
@ -667,7 +667,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}
_interactivity->Initialize();
_AttachDxgiSwapChainToXaml(_core->GetSwapChainHandle());
_AttachDxgiSwapChainToXaml(_core->GetSwapChain());
// 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

Просмотреть файл

@ -66,8 +66,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void ToggleShaderEffects();
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);
void _RenderRetryButton_Click(IInspectable const& button, IInspectable const& args);
winrt::fire_and_forget _RendererWarning(const IInspectable& sender,
const Control::RendererWarningArgs& args);

Просмотреть файл

@ -13,7 +13,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<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>
</ItemDefinitionGroup>

Просмотреть файл

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

Просмотреть файл

@ -70,7 +70,7 @@ namespace Microsoft::Console::Render
void SetSoftwareRendering(bool enable) noexcept;
HANDLE GetSwapChainHandle();
::Microsoft::WRL::ComPtr<IDXGISwapChain1> GetSwapChain();
// IRenderEngine Members
[[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<IDXGIFactory2> _dxgiFactory2;
::Microsoft::WRL::ComPtr<IDXGIFactoryMedia> _dxgiFactoryMedia;
::Microsoft::WRL::ComPtr<IDXGIDevice> _dxgiDevice;
::Microsoft::WRL::ComPtr<IDXGISurface> _dxgiSurface;

Просмотреть файл

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