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;
    77     void GetCachedOutputAndDesc(IDXGIOutput** output, DXGI_OUTPUT_DESC* outputDesc) 
const;
    78     DXGI_ADAPTER_DESC GetAdapterDesc() 
const;
    79     void GetDisplayMode(DXGI_MODE_DESC *mode) 
const;
    81     D3D11_VIEWPORT GetScreenViewport()
 const { 
return m_screenViewport; }
    82     void SetViewPort(D3D11_VIEWPORT& viewPort) 
const;
    84     void ReleaseBackBuffer();
    85     void CreateBackBuffer();
    91     void ApplyDisplaySettings();
    94     HDR_STATUS ToggleHDR();
    95     void SetHdrMetaData(DXGI_HDR_METADATA_HDR10& hdr10) 
const;
    96     void SetHdrColorSpace(
const DXGI_COLOR_SPACE_TYPE colorSpace);
    97     bool IsHDROutput()
 const { 
return m_IsHDROutput; }
    98     bool IsTransferPQ()
 const { 
return m_IsTransferPQ; }
   104     void FinishCommandList(
bool bExecute = 
true) 
const;
   105     void ClearDepthStencil() 
const;
   106     void ClearRenderTarget(ID3D11RenderTargetView* pRTView, 
float color[4]) 
const;
   107     void RegisterDeviceNotify(IDeviceNotify* deviceNotify);
   109     bool IsStereoAvailable() 
const;
   110     bool IsStereoEnabled()
 const { 
return m_stereoEnabled; }
   111     void SetStereoIdx(byte idx) { m_backBufferTex.SetViewIdx(idx); }
   113     void SetMonitor(HMONITOR monitor);
   114     HMONITOR GetMonitor() 
const;
   115 #if defined(TARGET_WINDOWS_DESKTOP)   116     void SetWindow(HWND window);
   117 #elif defined(TARGET_WINDOWS_STORE)   119     void SetWindow(
const winrt::Windows::UI::Core::CoreWindow& window);
   120     void SetWindowPos(winrt::Windows::Foundation::Rect rect);
   121 #endif // TARGET_WINDOWS_STORE   122     bool IsNV12SharedTexturesSupported()
 const { 
return m_NV12SharedTexturesSupport; }
   123     bool IsDXVA2SharedDecoderSurfaces()
 const { 
return m_DXVA2SharedDecoderSurfaces; }
   124     bool IsSuperResolutionSupported()
 const { 
return m_DXVASuperResolutionSupport; }
   125     bool UseFence()
 const { 
return m_DXVA2UseFence; }
   129     std::vector<DXGI_COLOR_SPACE_TYPE> GetSwapChainColorSpaces() 
const;
   130     bool SetMultithreadProtected(
bool enabled) 
const;
   131     bool IsGCNOrOlder() 
const;
   138       void SetViewIdx(
unsigned idx) { m_viewIdx = idx; }
   139       bool Acquire(ID3D11Texture2D* pTexture);
   142     HRESULT CreateSwapChain(DXGI_SWAP_CHAIN_DESC1 &desc, DXGI_SWAP_CHAIN_FULLSCREEN_DESC &fsDesc, IDXGISwapChain1 **ppSwapChain) 
const;
   143     void DestroySwapChain();
   144     void CreateDeviceIndependentResources();
   145     void CreateDeviceResources();
   146     void CreateWindowSizeDependentResources();
   147     void UpdateRenderTargetSize();
   148     void OnDeviceLost(
bool removed);
   149     void OnDeviceRestored();
   150     void HandleOutputChange(
const std::function<
bool(DXGI_OUTPUT_DESC)>& cmpFunc);
   151     bool CreateFactory();
   152     void CheckNV12SharedTexturesSupport();
   154     void CheckDXVA2SharedDecoderSurfaces();
   156     HWND m_window{ 
nullptr };
   157 #if defined(TARGET_WINDOWS_STORE)   158     winrt::Windows::UI::Core::CoreWindow m_coreWindow = 
nullptr;
   160     Microsoft::WRL::ComPtr<IDXGIFactory2> m_dxgiFactory;
   161     Microsoft::WRL::ComPtr<IDXGIAdapter1> m_adapter;
   162     Microsoft::WRL::ComPtr<IDXGIOutput1> m_output;
   163     DXGI_OUTPUT_DESC m_outputDesc{};
   165     Microsoft::WRL::ComPtr<ID3D11Device1> m_d3dDevice;
   166     Microsoft::WRL::ComPtr<ID3D11DeviceContext1> m_d3dContext;
   167     Microsoft::WRL::ComPtr<ID3D11DeviceContext1> m_deferrContext;
   168     Microsoft::WRL::ComPtr<IDXGISwapChain1> m_swapChain;
   170     Microsoft::WRL::ComPtr<ID3D11Debug> m_d3dDebug;
   173     CBackBuffer m_backBufferTex;
   174     Microsoft::WRL::ComPtr<ID3D11DepthStencilView> m_d3dDepthStencilView;
   175     D3D11_VIEWPORT m_screenViewport;
   178     D3D_FEATURE_LEVEL m_d3dFeatureLevel;
   179     winrt::Windows::Foundation::Size m_outputSize;
   180     winrt::Windows::Foundation::Size m_logicalSize;
   184     float m_effectiveDpi;
   186     IDeviceNotify* m_deviceNotify;
   189     Concurrency::critical_section m_criticalSection;
   190     Concurrency::critical_section m_resourceSection;
   191     std::vector<ID3DResource*> m_resources;
   193     bool m_stereoEnabled;
   194     bool m_bDeviceCreated;
   197     bool m_NV12SharedTexturesSupport{
false};
   198     bool m_DXVA2SharedDecoderSurfaces{
false};
   199     bool m_DXVASuperResolutionSupport{
false};
   200     bool m_DXVA2UseFence{
false};
 Definition: D3DResource.h:90
Definition: DeviceResources.h:27
Provide info of a resolution. 
Definition: Resolution.h:66
Definition: DebugInfo.h:30
Definition: D3DResource.h:36
Definition: DeviceResources.h:36
Definition: WIN32Util.h:23