summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/src/nvapi.h
blob: adb11bab44ad28f7bbc9264bd73fcac693374a05 (plain) (blame)
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
/*
 * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
 * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
 */

#ifndef BGFX_NVAPI_H_HEADER_GUARD
#define BGFX_NVAPI_H_HEADER_GUARD

struct ID3D11Device;
struct ID3D11DeviceContext;
struct ID3D11Buffer;
struct ID3D12Device;
struct ID3D12CommandList;

namespace bgfx
{
	struct NvPhysicalGpuHandle;
	struct NvAftermathContextHandle;

	struct NvAftermathDeviceStatus
	{
		enum Enum
		{
			Active,
			Timeout,
			OutOfMemory,
			PageFault,
			Unknown,
			NotInitialized
		};
	};

	typedef void (*PFN_NVAPI_MULTIDRAWINDIRECT)(ID3D11DeviceContext* _deviceCtx, uint32_t _numDrawIndirect, ID3D11Buffer* _ptr, uint32_t _offset, uint32_t _stride);

	///
	struct NvApi
	{
		///
		NvApi();

		///
		void init();

		///
		void shutdown();

		///
		bool isInitialized() const { return NULL != m_nvGpu; }

		///
		void getMemoryInfo(int64_t& _gpuMemoryUsed, int64_t& _gpuMemoryMax);

		///
		bool loadAftermath();

		///
		bool initAftermath(const ID3D11Device* _device, const ID3D11DeviceContext* _deviceCtx);

		///
		bool initAftermath(const ID3D12Device* _device, const ID3D12CommandList* _commandList);

		///
		NvAftermathDeviceStatus::Enum getDeviceStatus() const;

		///
		void shutdownAftermath();

		///
		void setMarker(const bx::StringView& _marker);

		///
		void* m_nvApiDll;
		NvPhysicalGpuHandle* m_nvGpu;

		void* m_nvAftermathDll;
		NvAftermathContextHandle* m_aftermathHandle;

		PFN_NVAPI_MULTIDRAWINDIRECT nvApiD3D11MultiDrawInstancedIndirect;
		PFN_NVAPI_MULTIDRAWINDIRECT nvApiD3D11MultiDrawIndexedInstancedIndirect;
	};

} // namespace bgfx

#endif // BGFX_NVAPI_H_HEADER_GUARD