summaryrefslogtreecommitdiff
path: root/Runtime/GfxDevice/d3d11/D3D11Context.h
blob: 16134cea9b8932772a4de231b6c4d987a936a014 (plain)
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
#pragma once

#include "D3D11Includes.h"

#if UNITY_METRO
#include <windows.ui.xaml.media.dxinterop.h>
#endif

struct D3D11Compiler;

bool InitializeD3D11();
void CleanupD3D11();
#if UNITY_WP8
HRESULT UpdateD3D11Device(ID3D11Device1* device, ID3D11DeviceContext1* deviceContext, ID3D11RenderTargetView* renderTargetView, int& width, int& height);
void ActivateD3D11BackBuffer(class GfxDevice* device);
#elif UNITY_METRO
IDXGISwapChain1* CreateSwapChainForXAML(ISwapChainBackgroundPanelNative* panel, int width, int height);
#if UNITY_METRO_VS2013
IDXGIDevice3* GetIDXGIDevice3();
#endif
IDXGISwapChain1* CreateSwapChainForD3D(IUnknown* coreWindow, int width, int height);
bool InitializeOrResetD3D11SwapChain(
	class GfxDevice* device,
	IDXGISwapChain1* chain, int width, int height, int vsynccount,
	int& outBackbufferBPP, int& outFrontbufferBPP, int& outDepthBPP, int& outFSAA);
void ActivateD3D11BackBuffer(class GfxDevice* device);
#else
bool InitializeOrResetD3D11SwapChain(
	class GfxDevice* device,
	HWND window, int width, int height,
	int refreshRate, bool fullscreen, int vsynccount, int fsaa,
	int& outBackbufferBPP, int& outFrontbufferBPP, int& outDepthBPP, int& outFSAA);
void ResizeSwapD3D11SwapChain (class GfxDevice* device, HWND window, int width, int height);

#endif

typedef std::vector<D3D_FEATURE_LEVEL> SupportedFeatureLevels;
SupportedFeatureLevels GetSupportedFeatureLevels();

void DestroyD3D11Device();

ID3D11Device* GetD3D11Device();
ID3D11Device1* GetD3D11_1Device();
ID3D11DeviceContext* GetD3D11Context(bool expectNull = false);

IDXGIFactory* GetDXGIFactory();
IDXGISwapChain* GetD3D11SwapChain();
int GetD3D11SyncInterval();

#if ENABLE_DX11_FRAME_LATENCY_WAITABLE_OBJECT
HANDLE GetFrameLatencyWaitableObject();
void WaitOnSwapChain();
#endif

extern ID3D11RenderTargetView* g_D3D11CurrRT;
extern ID3D11DepthStencilView* g_D3D11CurrDS;
struct RenderColorSurfaceD3D11;
struct RenderDepthSurfaceD3D11;
extern RenderColorSurfaceD3D11* g_D3D11CurrColorRT;
extern RenderDepthSurfaceD3D11* g_D3D11CurrDepthRT;

typedef int (WINAPI* D3D11PERF_BeginEventFunc)(DWORD, LPCWSTR);
typedef int (WINAPI* D3D11PERF_EndEventFunc)();
extern D3D11PERF_BeginEventFunc g_D3D11BeginEventFunc;
extern D3D11PERF_EndEventFunc g_D3D11EndEventFunc;