-
-
Notifications
You must be signed in to change notification settings - Fork 469
/
Copy pathdx11HW.h
109 lines (83 loc) · 2.58 KB
/
dx11HW.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#pragma once
#include "xrCore/ModuleLookup.hpp"
#include "Layers/xrRender/HWCaps.h"
#include "Layers/xrRender/stats_manager.h"
#include <SDL.h>
class CHW
: public pureAppActivate,
public pureAppDeactivate
{
public:
CHW();
~CHW();
void CreateD3D();
void DestroyD3D();
void CreateDevice(SDL_Window* sdlWnd);
void DestroyDevice();
void Reset();
void SetPrimaryAttributes(u32& windowFlags);
std::pair<u32, u32> GetSurfaceSize() const;
bool CheckFormatSupport(DXGI_FORMAT format, u32 feature) const;
DXGI_FORMAT SelectFormat(D3D_FORMAT_SUPPORT feature, const DXGI_FORMAT formats[], size_t count) const;
template <size_t count>
inline DXGI_FORMAT SelectFormat(D3D_FORMAT_SUPPORT feature, const DXGI_FORMAT (&formats)[count]) const
{
return SelectFormat(feature, formats, count);
}
bool UsingFlipPresentationModel() const;
DeviceState GetDeviceState() const;
public:
void BeginScene();
void EndScene();
void Present();
public:
void OnAppActivate() override;
void OnAppDeactivate() override;
private:
bool CreateSwapChain(HWND hwnd);
bool CreateSwapChain2(HWND hwnd);
bool ThisInstanceIsGlobal() const;
public:
ICF ID3DDeviceContext* get_context(u32 context_id)
{
VERIFY(context_id < R__NUM_CONTEXTS);
return d3d_contexts_pool[context_id];
}
public:
static constexpr auto IMM_CTX_ID = R__NUM_PARALLEL_CONTEXTS;
CHWCaps Caps;
u32 BackBufferCount{};
u32 CurrentBackBuffer{};
ID3DDevice* pDevice = nullptr; // render device
D3D_DRIVER_TYPE m_DriverType;
IDXGIFactory1* m_pFactory = nullptr;
IDXGIAdapter1* m_pAdapter = nullptr; // pD3D equivalent
IDXGISwapChain* m_pSwapChain = nullptr;
D3D_FEATURE_LEVEL FeatureLevel;
bool Valid = true;
bool ComputeShadersSupported;
bool DoublePrecisionFloatShaderOps;
bool SAD4ShaderInstructions;
bool ExtendedDoublesShaderInstructions;
ID3DDeviceContext* d3d_contexts_pool[R__NUM_CONTEXTS]{};
bool DX10Only = false;
#ifdef HAS_DX11_2
IDXGISwapChain2* m_pSwapChain2 = nullptr;
#endif
#ifdef HAS_DX11_3
ID3D11Device3* pDevice3 = nullptr;
#endif
ID3D11DeviceContext1* pContext1 = nullptr;
using D3DCompileFunc = decltype(&D3DCompile);
D3DCompileFunc D3DCompile = nullptr;
#if !defined(_MAYA_EXPORT)
stats_manager stats_manager;
#endif
private:
DXGI_SWAP_CHAIN_DESC m_ChainDesc; // DevPP equivalent
XRay::Module hD3DCompiler;
XRay::Module hDXGI;
XRay::Module hD3D;
DXGI_FORMAT selectBackBufferFormat() const;
};
extern ECORE_API CHW HW;