2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
11 #include "DeviceResources.h"
12 #include "rendering/RenderSystem.h"
13 #include "threads/Condition.h"
14 #include "threads/CriticalSection.h"
15 #include "threads/SystemClock.h"
16 #include "utils/ColorUtils.h"
18 #include <wrl/client.h>
25 class CRenderSystemDX
: public CRenderSystemBase
, DX::IDeviceNotify
29 virtual ~CRenderSystemDX();
31 // CRenderBase overrides
32 bool InitRenderSystem() override
;
33 bool DestroyRenderSystem() override
;
34 bool BeginRender() override
;
35 bool EndRender() override
;
36 void PresentRender(bool rendered
, bool videoLayer
) override
;
37 bool ClearBuffers(UTILS::COLOR::Color color
) override
;
38 void SetViewPort(const CRect
& viewPort
) override
;
39 void GetViewPort(CRect
& viewPort
) override
;
40 void RestoreViewPort() override
;
41 CRect
ClipRectToScissorRect(const CRect
&rect
) override
;
42 bool ScissorsCanEffectClipping() override
;
43 void SetScissors(const CRect
&rect
) override
;
44 void ResetScissors() override
;
45 void CaptureStateBlock() override
;
46 void ApplyStateBlock() override
;
47 void SetCameraPosition(const CPoint
&camera
, int screenWidth
, int screenHeight
, float stereoFactor
= 0.f
) override
;
48 void SetStereoMode(RENDER_STEREO_MODE mode
, RENDER_STEREO_VIEW view
) override
;
49 bool SupportsStereo(RENDER_STEREO_MODE mode
) const override
;
50 void Project(float &x
, float &y
, float &z
) override
;
51 bool SupportsNPOT(bool dxt
) const override
;
53 // IDeviceNotify overrides
54 void OnDXDeviceLost() override
;
55 void OnDXDeviceRestored() override
;
57 // CRenderSystemDX methods
58 CGUIShaderDX
* GetGUIShader() const { return m_pGUIShader
; }
59 bool IsFormatSupport(DXGI_FORMAT format
, unsigned int usage
) const;
60 CRect
GetBackBufferRect();
61 CD3DTexture
& GetBackBuffer();
63 void FlushGPU() const;
64 void RequestDecodingTime();
65 void ReleaseDecodingTime();
66 void SetAlphaBlendEnable(bool enable
);
69 bool IsExtSupported(const char* extension
) const override
{ return false; }
70 bool ResetRenderSystem(int width
, int height
) override
{ return true; }
73 virtual void PresentRenderImpl(bool rendered
) = 0;
78 void CheckInterlacedStereoView(void);
79 void CheckDeviceCaps();
81 CCriticalSection m_resourceSection
;
82 CCriticalSection m_decoderSection
;
84 // our adapter could change as we go
85 bool m_inScene
{ false }; ///< True if we're in a BeginScene()/EndScene() block
86 bool m_BlendEnabled
{ false };
87 bool m_ScissorsEnabled
{ false };
88 D3D11_VIEWPORT m_viewPort
;
90 CGUIShaderDX
* m_pGUIShader
{ nullptr };
91 Microsoft::WRL::ComPtr
<ID3D11DepthStencilState
> m_depthStencilState
;
92 Microsoft::WRL::ComPtr
<ID3D11BlendState
> m_BlendEnableState
;
93 Microsoft::WRL::ComPtr
<ID3D11BlendState
> m_BlendDisableState
;
94 Microsoft::WRL::ComPtr
<ID3D11RasterizerState
> m_RSScissorDisable
;
95 Microsoft::WRL::ComPtr
<ID3D11RasterizerState
> m_RSScissorEnable
;
96 // stereo interlaced/checkerboard intermediate target
97 CD3DTexture m_rightEyeTex
;
99 XbmcThreads::EndTime
<> m_decodingTimer
;
100 XbmcThreads::ConditionVariable m_decodingEvent
;
102 std::shared_ptr
<DX::DeviceResources
> m_deviceResources
;