-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommonTypes.h
148 lines (123 loc) · 4.78 KB
/
CommonTypes.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#pragma once
//TODO(fran): clean includes
#include <windows.h>
#include <d3d11.h>
#include <dxgi1_2.h>
#include <sal.h>
#include <new>
//#include <warning.h>
#include <DirectXMath.h>
#include "PixelShader.h"
#include "VertexShader.h"
#ifdef _DEBUG
//Used to debug directx components of the application, ID3D11Devices should not be destroyed to allow debugging after destructors have been called, at least for now
//#define _DX_DEBUG_LAYER
#endif
#ifdef _DX_DEBUG_LAYER
#include <dxgidebug.h>
#pragma comment( lib, "dxguid.lib") //_WKPDID_D3DDebugObjectName
#endif
//extern bool TEST_draw; //TODO(fran): REMOVE (and from cpp)
#define NUMVERTICES 6
#define BPP 4
//#define OCCLUSION_STATUS_MSG (WM_USER+5000)
// Below are lists of errors expect from Dxgi API calls when a transition event like mode change, PnpStop, PnpStart
// desktop switch, TDR or session disconnect/reconnect. In all these cases we want the application to clean up the threads that process
// the desktop updates and attempt to recreate them.
// If we get an error that is not on the appropriate list then we exit the application
// These are the errors we expect from general Dxgi API due to a transition
constexpr HRESULT SystemTransitionsExpectedErrors[] = {
DXGI_ERROR_DEVICE_REMOVED,
DXGI_ERROR_ACCESS_LOST,
static_cast<HRESULT>(WAIT_ABANDONED),
S_OK // Terminate list with zero valued HRESULT
};
// These are the errors we expect from IDXGIOutput1::DuplicateOutput due to a transition
constexpr HRESULT CreateDuplicationExpectedErrors[] = {
DXGI_ERROR_DEVICE_REMOVED,
static_cast<HRESULT>(E_ACCESSDENIED),
DXGI_ERROR_UNSUPPORTED,
DXGI_ERROR_SESSION_DISCONNECTED,
S_OK // Terminate list with zero valued HRESULT
};
// These are the errors we expect from IDXGIOutputDuplication methods due to a transition
constexpr HRESULT FrameInfoExpectedErrors[] = {
DXGI_ERROR_DEVICE_REMOVED,
DXGI_ERROR_ACCESS_LOST,
S_OK // Terminate list with zero valued HRESULT
};
// These are the errors we expect from IDXGIAdapter::EnumOutputs methods due to outputs becoming stale during a transition
constexpr HRESULT EnumOutputsExpectedErrors[] = {
DXGI_ERROR_NOT_FOUND,
S_OK // Terminate list with zero valued HRESULT
};
typedef _Return_type_success_(return == DUPL_RETURN_SUCCESS) enum
{
DUPL_RETURN_SUCCESS = 0,
DUPL_RETURN_ERROR_EXPECTED = 1,
DUPL_RETURN_ERROR_UNEXPECTED = 2
}DUPL_RETURN;
_Post_satisfies_(return != DUPL_RETURN_SUCCESS)
DUPL_RETURN ProcessFailure(_In_opt_ ID3D11Device* Device, _In_ LPCWSTR Str, _In_ LPCWSTR Title, HRESULT hr, _In_opt_z_ const HRESULT* ExpectedErrors = nullptr);
//
// Holds info about the pointer/cursor
//
typedef struct _PTR_INFO
{
_Field_size_bytes_(BufferSize) BYTE* PtrShapeBuffer;
DXGI_OUTDUPL_POINTER_SHAPE_INFO ShapeInfo;
POINT Position;
bool Visible;
UINT BufferSize;
UINT WhoUpdatedPositionLast;
LARGE_INTEGER LastTimeStamp;
} PTR_INFO;
//
// Structure that holds D3D resources not directly tied to any one thread
//
typedef struct _DX_RESOURCES
{
ID3D11Device* Device;
ID3D11DeviceContext* Context;
ID3D11VertexShader* VertexShader;
ID3D11PixelShader* PixelShader;
ID3D11InputLayout* InputLayout;
ID3D11SamplerState* SamplerLinear;
} DX_RESOURCES;
//
// Structure to pass to a new thread
//
typedef struct _THREAD_DATA
{
// Used to indicate abnormal error condition
bool* UnexpectedErrorEvent; //TODO(fran): I can just make this bool and pass the pointer to thread data struct, so everyone has the same bool
// Used to indicate a transition event occurred e.g. PnpStop, PnpStart, mode change, TDR, desktop switch and the application needs to recreate the duplication interface
bool* ExpectedErrorEvent;
// Used by WinProc to signal to threads to exit
bool* TerminateThreadsEvent;
HANDLE TexSharedHandle;
UINT Output;
INT OffsetX;
INT OffsetY;
PTR_INFO* PtrInfo;
DX_RESOURCES DxRes;
} THREAD_DATA;
//
// FRAME_DATA holds information about an acquired frame
//
typedef struct _FRAME_DATA
{
ID3D11Texture2D* Frame;
DXGI_OUTDUPL_FRAME_INFO FrameInfo;
_Field_size_bytes_((MoveCount * sizeof(DXGI_OUTDUPL_MOVE_RECT)) + (DirtyCount * sizeof(RECT))) BYTE* MetaData;
UINT DirtyCount;
UINT MoveCount;
} FRAME_DATA;
//
// A vertex with a position and texture coordinate
//
typedef struct _VERTEX
{
DirectX::XMFLOAT3 Pos;
DirectX::XMFLOAT2 TexCoord;
} VERTEX;