11 #include "DirectXHelper.h" 12 #include "HDRStatus.h" 13 #include "guilib/D3DResource.h" 21 #include <wrl/client.h> 29 interface IDeviceNotify
31 virtual void OnDXDeviceLost() = 0;
32 virtual void OnDXDeviceRestored() = 0;
39 static std::shared_ptr<DX::DeviceResources> Get();
45 void ValidateDevice();
46 void HandleDeviceLost(
bool removed);
51 winrt::Windows::Foundation::Size GetOutputSize()
const {
return m_outputSize; }
53 winrt::Windows::Foundation::Size GetLogicalSize()
const {
return m_logicalSize; }
54 void SetLogicalSize(
float width,
float height);
55 float GetDpi()
const {
return m_effectiveDpi; }
56 void SetDpi(
float dpi);
59 bool HasValidDevice()
const {
return m_bDeviceCreated; }
60 ID3D11Device1* GetD3DDevice()
const {
return m_d3dDevice.Get(); }
61 ID3D11DeviceContext1* GetD3DContext()
const {
return m_deferrContext.Get(); }
62 ID3D11DeviceContext1* GetImmediateContext()
const {
return m_d3dContext.Get(); }
63 IDXGISwapChain1* GetSwapChain()
const {
return m_swapChain.Get(); }
64 IDXGIFactory2* GetIDXGIFactory2()
const {
return m_dxgiFactory.Get(); }
65 IDXGIAdapter1* GetAdapter()
const {
return m_adapter.Get(); }
66 ID3D11DepthStencilView* GetDSV()
const {
return m_d3dDepthStencilView.Get(); }
67 D3D_FEATURE_LEVEL GetDeviceFeatureLevel()
const {
return m_d3dFeatureLevel; }
68 CD3DTexture& GetBackBuffer() {
return m_backBufferTex; }
70 void GetOutput(IDXGIOutput** ppOutput)
const;
71 void GetAdapterDesc(DXGI_ADAPTER_DESC *desc)
const;
72 void GetDisplayMode(DXGI_MODE_DESC *mode)
const;
74 D3D11_VIEWPORT GetScreenViewport()
const {
return m_screenViewport; }
75 void SetViewPort(D3D11_VIEWPORT& viewPort)
const;
77 void ReleaseBackBuffer();
78 void CreateBackBuffer();
84 void ApplyDisplaySettings();
87 HDR_STATUS ToggleHDR();
88 void SetHdrMetaData(DXGI_HDR_METADATA_HDR10& hdr10)
const;
89 void SetHdrColorSpace(
const DXGI_COLOR_SPACE_TYPE colorSpace);
90 bool IsHDROutput()
const {
return m_IsHDROutput; }
91 bool IsTransferPQ()
const {
return m_IsTransferPQ; }
97 void FinishCommandList(
bool bExecute =
true)
const;
98 void ClearDepthStencil()
const;
99 void ClearRenderTarget(ID3D11RenderTargetView* pRTView,
float color[4])
const;
100 void RegisterDeviceNotify(IDeviceNotify* deviceNotify);
102 bool IsStereoAvailable()
const;
103 bool IsStereoEnabled()
const {
return m_stereoEnabled; }
104 void SetStereoIdx(byte idx) { m_backBufferTex.SetViewIdx(idx); }
106 void SetMonitor(HMONITOR monitor);
107 HMONITOR GetMonitor()
const;
108 #if defined(TARGET_WINDOWS_DESKTOP) 109 void SetWindow(HWND window);
110 #elif defined(TARGET_WINDOWS_STORE) 112 void SetWindow(
const winrt::Windows::UI::Core::CoreWindow& window);
113 void SetWindowPos(winrt::Windows::Foundation::Rect rect);
114 #endif // TARGET_WINDOWS_STORE 115 bool IsNV12SharedTexturesSupported()
const {
return m_NV12SharedTexturesSupport; }
116 bool IsDXVA2SharedDecoderSurfaces()
const {
return m_DXVA2SharedDecoderSurfaces; }
126 void SetViewIdx(
unsigned idx) { m_viewIdx = idx; }
127 bool Acquire(ID3D11Texture2D* pTexture);
130 HRESULT CreateSwapChain(DXGI_SWAP_CHAIN_DESC1 &desc, DXGI_SWAP_CHAIN_FULLSCREEN_DESC &fsDesc, IDXGISwapChain1 **ppSwapChain)
const;
131 void DestroySwapChain();
132 void CreateDeviceIndependentResources();
133 void CreateDeviceResources();
134 void CreateWindowSizeDependentResources();
135 void UpdateRenderTargetSize();
136 void OnDeviceLost(
bool removed);
137 void OnDeviceRestored();
138 void HandleOutputChange(
const std::function<
bool(DXGI_OUTPUT_DESC)>& cmpFunc);
139 bool CreateFactory();
140 void CheckNV12SharedTexturesSupport();
142 void CheckDXVA2SharedDecoderSurfaces();
144 HWND m_window{
nullptr };
145 #if defined(TARGET_WINDOWS_STORE) 146 winrt::Windows::UI::Core::CoreWindow m_coreWindow =
nullptr;
148 Microsoft::WRL::ComPtr<IDXGIFactory2> m_dxgiFactory;
149 Microsoft::WRL::ComPtr<IDXGIAdapter1> m_adapter;
150 Microsoft::WRL::ComPtr<IDXGIOutput1> m_output;
152 Microsoft::WRL::ComPtr<ID3D11Device1> m_d3dDevice;
153 Microsoft::WRL::ComPtr<ID3D11DeviceContext1> m_d3dContext;
154 Microsoft::WRL::ComPtr<ID3D11DeviceContext1> m_deferrContext;
155 Microsoft::WRL::ComPtr<IDXGISwapChain1> m_swapChain;
157 Microsoft::WRL::ComPtr<ID3D11Debug> m_d3dDebug;
160 CBackBuffer m_backBufferTex;
161 Microsoft::WRL::ComPtr<ID3D11DepthStencilView> m_d3dDepthStencilView;
162 D3D11_VIEWPORT m_screenViewport;
165 D3D_FEATURE_LEVEL m_d3dFeatureLevel;
166 winrt::Windows::Foundation::Size m_outputSize;
167 winrt::Windows::Foundation::Size m_logicalSize;
171 float m_effectiveDpi;
173 IDeviceNotify* m_deviceNotify;
176 Concurrency::critical_section m_criticalSection;
177 Concurrency::critical_section m_resourceSection;
178 std::vector<ID3DResource*> m_resources;
180 bool m_stereoEnabled;
181 bool m_bDeviceCreated;
184 bool m_NV12SharedTexturesSupport{
false};
185 bool m_DXVA2SharedDecoderSurfaces{
false};
Definition: D3DResource.h:90
Definition: DeviceResources.h:27
Provide info of a resolution.
Definition: Resolution.h:66
Definition: DebugInfo.h:29
Definition: D3DResource.h:36
Definition: DeviceResources.h:36
Definition: WIN32Util.h:23