summaryrefslogtreecommitdiff
path: root/src/GFX_Timer_impl.h
blob: eeb00934e64f81fd8c6abb7a0190bead7ca4d3dc (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
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
110
111
112
// This code contains NVIDIA Confidential Information and is disclosed 
// under the Mutual Non-Disclosure Agreement. 
// 
// Notice 
// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES 
// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO 
// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, 
// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. 
// 
// NVIDIA Corporation assumes no responsibility for the consequences of use of such 
// information or for any infringement of patents or other rights of third parties that may 
// result from its use. No license is granted by implication or otherwise under any patent 
// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless 
// expressly authorized by NVIDIA.  Details are subject to change without notice. 
// This code supersedes and replaces all information previously supplied. 
// NVIDIA Corporation products are not authorized for use as critical 
// components in life support devices or systems without express written approval of 
// NVIDIA Corporation. 
// 
// Copyright � 2008- 2013 NVIDIA Corporation. All rights reserved.
//
// NVIDIA Corporation and its licensors retain all intellectual property and proprietary
// rights in and to this software and related documentation and any modifications thereto.
// Any use, reproduction, disclosure or distribution of this software and related
// documentation without an express license agreement from NVIDIA Corporation is
// strictly prohibited.
//

#ifndef _NVWAVEWORKS_GFX_TIMER_IMPL_H
#define _NVWAVEWORKS_GFX_TIMER_IMPL_H

class GFSDK_WaveWorks_GFX_DisjointQuery_Pool_Impl;
class GFSDK_WaveWorks_GFX_TimerQuery_Pool_Impl;

class NVWaveWorks_GFX_Timer_Impl
{
public:

	NVWaveWorks_GFX_Timer_Impl();
	~NVWaveWorks_GFX_Timer_Impl();

	HRESULT initD3D11(ID3D11Device* pD3DDevice);
	HRESULT initGnm();
	HRESULT initGL2(void* pGLContext);

	// Timer queries wrapper
	HRESULT issueTimerQuery(Graphics_Context* pGC, int& ix);
	void releaseTimerQuery(int ix);
	HRESULT waitTimerQuery(Graphics_Context* pGC, int ix, UINT64& t);
	HRESULT getTimerQuery(Graphics_Context* pGC, int ix, UINT64& t);

	// Pair-wise get/wait
	HRESULT getTimerQueries(Graphics_Context* pGC, int ix1, int ix2, UINT64& tdiff);
	HRESULT waitTimerQueries(Graphics_Context* pGC, int ix1, int ix2, UINT64& tdiff);

	// Disjoint queries wrapper
	HRESULT beginDisjoint(Graphics_Context* pGC);
	HRESULT endDisjoint(Graphics_Context* pGC);
	int getCurrentDisjointQuery();
	void releaseDisjointQuery(int ix);
	HRESULT waitDisjointQuery(Graphics_Context* pGC, int ix, UINT64& f);
	HRESULT getDisjointQuery(Graphics_Context* pGC, int ix, UINT64& f);

	enum { InvalidQueryIndex = -1 };

private:

	HRESULT allocateAllResources();
	void releaseAllResources();
	void releaseAll();

	GFSDK_WaveWorks_GFX_DisjointQuery_Pool_Impl* m_pDisjointTimersPool;
	int m_CurrentDisjointTimerQuery;

	GFSDK_WaveWorks_GFX_TimerQuery_Pool_Impl* m_pTimersPool;

	// D3D API handling
	nv_water_d3d_api m_d3dAPI;

#if WAVEWORKS_ENABLE_D3D11
    struct D3D11Objects
    {
		ID3D11Device* m_pd3d11Device;
	};
#endif

#if WAVEWORKS_ENABLE_GNM
	struct GnmObjects
	{
	};
#endif
#if WAVEWORKS_ENABLE_GL
	struct GL2Objects
	{
		void* m_pGLContext;
	};
#endif
	union
    {
#if WAVEWORKS_ENABLE_D3D11
		D3D11Objects _11;
#endif
#if WAVEWORKS_ENABLE_GNM
		GnmObjects _gnm;
#endif
#if WAVEWORKS_ENABLE_GL
		GL2Objects _GL2;
#endif
    } m_d3d;
};

#endif	// _NVWAVEWORKS_GFX_TIMER_IMPL_H