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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
|
// 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 (C) 2012, 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.
#pragma once
/*===========================================================================
GFSDK_Common.h
GFSDK_Common defines common macros, types and structs used generally by
all NVIDIA TECH Libraries. You won't find anything particularly interesting
here.
For any issues with this particular header please contact:
[email protected]
For any issues with the specific FX library you are using, see the header
file for that library for contact information.
===========================================================================*/
#pragma pack(push,8) // Make sure we have consistent structure packings
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================
AUTO CONFIG
===========================================================================*/
#ifndef __GFSDK_COMMON_AUTOCONFIG
#define __GFSDK_COMMON_AUTOCONFIG
#ifdef __GNUC__
#define __GFSDK_CC_GNU__ 1
#define __GFSDK_CC_MSVC__ 0
#else
#define __GFSDK_CC_GNU__ 0
#define __GFSDK_CC_MSVC__ 1
#endif
#endif
/*===========================================================================
FORWARD DECLARATIONS
===========================================================================*/
#ifndef __GFSDK_COMMON_FORWARDDECLS
#define __GFSDK_COMMON_FORWARDDECLS
#if defined ( __GFSDK_GL__ )
// $ TODO Add common fwd decls for OGL
#elif defined ( __GFSDK_DX11__ )
// $ TODO Add common fwd decls for D3D11
#endif
#endif // __GFSDK_COMMON_FORWARDDECLS
/*===========================================================================
TYPES
===========================================================================*/
#ifndef __GFSDK_COMMON_TYPES
#define __GFSDK_COMMON_TYPES
typedef unsigned char gfsdk_U8;
typedef unsigned short gfsdk_U16;
typedef signed int gfsdk_S32;
typedef signed long long gfsdk_S64;
typedef unsigned int gfsdk_U32;
typedef unsigned long long gfsdk_U64;
typedef float gfsdk_F32;
typedef struct {
gfsdk_F32 x;
gfsdk_F32 y;
} gfsdk_float2;
typedef struct {
gfsdk_F32 x;
gfsdk_F32 y;
gfsdk_F32 z;
} gfsdk_float3;
typedef struct {
gfsdk_F32 x;
gfsdk_F32 y;
gfsdk_F32 z;
gfsdk_F32 w;
} gfsdk_float4;
// implicit row major
typedef struct {
gfsdk_F32 _11, _12, _13, _14;
gfsdk_F32 _21, _22, _23, _24;
gfsdk_F32 _31, _32, _33, _34;
gfsdk_F32 _41, _42, _43, _44;
} gfsdk_float4x4;
typedef bool gfsdk_bool;
typedef char gfsdk_char;
typedef const gfsdk_char* gfsdk_cstr;
typedef double gfsdk_F64;
#endif // __GFSDK_COMMON_TYPES
/*=========================================================================
Useful default matrices/vectors
===========================================================================*/
static gfsdk_float4x4 GFSDK_Identity_Matrix = { 1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1 };
static gfsdk_float2 GFSDK_Zero_Vector2 = { 0, 0 };
static gfsdk_float2 GFSDK_One_Vector2 = { 1, 1 };
static gfsdk_float3 GFSDK_Zero_Vector3 = { 0, 0, 0 };
static gfsdk_float3 GFSDK_One_Vector3 = { 1, 1, 1 };
/*===========================================================================
MACROS
===========================================================================*/
#ifndef __GFSDK_COMMON_MACROS
#define __GFSDK_COMMON_MACROS
// GNU
#if __GFSDK_CC_GNU__
#define __GFSDK_ALIGN__(bytes) __attribute__((aligned (bytes)))
#define __GFSDK_EXPECT__(exp,tf) __builtin_expect(exp, tf)
#define __GFSDK_INLINE__ __attribute__((always_inline))
#define __GFSDK_NOLINE__ __attribute__((noinline))
#define __GFSDK_RESTRICT__ __restrict
/*-------------------------------------------------------------------------*/
#define __GFSDK_CDECL__
#define __GFSDK_IMPORT__
#define __GFSDK_EXPORT__
#define __GFSDK_STDCALL__
#endif
// MSVC
#if __GFSDK_CC_MSVC__
#define __GFSDK_ALIGN__(bytes) __declspec(align(bytes))
#define __GFSDK_EXPECT__(exp, tf) (exp)
#define __GFSDK_INLINE__ __forceinline
#define __GFSDK_NOINLINE__
#define __GFSDK_RESTRICT__ __restrict
/*-------------------------------------------------------------------------*/
#define __GFSDK_CDECL__ __cdecl
#define __GFSDK_IMPORT__ __declspec(dllimport)
#define __GFSDK_EXPORT__ __declspec(dllexport)
#define __GFSDK_STDCALL__ __stdcall
#endif
#endif // __GFSDK_COMMON_MACROS
/*===========================================================================
RETURN CODES
===========================================================================*/
#ifndef __GFSDK_COMMON_RETURNCODES
#define __GFSDK_COMMON_RETURNCODES
#define GFSDK_RETURN_OK 0
#define GFSDK_RETURN_FAIL 1
#define GFSDK_RETURN_EMULATION 2
#endif // __GFSDK_COMMON_RETURNCODES
/*===========================================================================
CUSTOM HEAP
===========================================================================*/
#ifndef __GFSDK_COMMON_CUSTOMHEAP
#define __GFSDK_COMMON_CUSTOMHEAP
typedef struct {
void* (*new_)(size_t);
void (*delete_)(void*);
} gfsdk_new_delete_t;
#endif // __GFSDK_COMMON_CUSTOMHEAP
/*===========================================================================
HANDLE DECLARATION
===========================================================================*/
#ifndef __GFSDK_COMMON_DECLHANDLE
#define __GFSDK_COMMON_DECLHANDLE
#define GFSDK_DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
#endif // __GFSDK_COMMON_DECLHANDLE
/*===========================================================================
Forward Declarations
===========================================================================*/
// Shadow buffer handle
struct GFSDK_ShadowLib_Buffer;
// Shadow map handle
struct GFSDK_ShadowLib_Map;
/*===========================================================================
Resource Structure Declarations (different for each platform)
===========================================================================*/
struct GFSDK_ShadowLib_DeviceContext
{
#if defined ( __GFSDK_DX11__ )
ID3D11Device* pD3DDevice;
ID3D11DeviceContext* pDeviceContext;
GFSDK_ShadowLib_DeviceContext()
{
pD3DDevice = NULL;
pDeviceContext = NULL;
}
#elif defined ( __GFSDK_GL__ )
// $ TO implement
#endif
};
struct GFSDK_ShadowLib_RenderTargetView
{
#if defined ( __GFSDK_DX11__ )
ID3D11RenderTargetView* pRTV;
GFSDK_ShadowLib_RenderTargetView()
{
pRTV = NULL;
}
#elif defined ( __GFSDK_GL__ )
GLuint FBO;
GFSDK_ShadowLib_RenderTargetView()
{
FBO = 0;
}
#endif
};
struct GFSDK_ShadowLib_ShaderResourceView
{
#if defined ( __GFSDK_DX11__ )
ID3D11ShaderResourceView* pSRV;
GFSDK_ShadowLib_ShaderResourceView()
{
pSRV = NULL;
}
#elif defined ( __GFSDK_GL__ )
GLuint Texture;
GFSDK_ShadowLib_ShaderResourceView()
{
Texture = 0;
}
#endif
};
struct GFSDK_ShadowLib_DepthStencilView
{
#if defined ( __GFSDK_DX11__ )
ID3D11DepthStencilView* pDSV;
GFSDK_ShadowLib_DepthStencilView()
{
pDSV = NULL;
}
#elif defined ( __GFSDK_GL__ )
GLuint Texture;
GFSDK_ShadowLib_DepthStencilView()
{
Texture = 0;
}
#endif
};
struct GFSDK_ShadowLib_ScissorRect
{
#if defined ( __GFSDK_DX11__ )
D3D11_RECT* pSR;
GFSDK_ShadowLib_ScissorRect()
{
pSR = NULL;
}
#elif defined ( __GFSDK_GL__ )
// $ TO implement
#endif
};
struct GFSDK_ShadowLib_Texture2D
{
gfsdk_U32 uWidth;
gfsdk_U32 uHeight;
gfsdk_U32 uSampleCount;
#if defined ( __GFSDK_DX11__ )
DXGI_FORMAT Format;
ID3D11Texture2D* pTexture;
ID3D11ShaderResourceView* pSRV;
ID3D11RenderTargetView* pRTV;
#elif defined ( __GFSDK_GL__ )
GLenum Type;
GLenum InternalFormat;
GLenum Format;
GLuint Texture;
GLuint FBO;
#endif
GFSDK_ShadowLib_Texture2D()
{
uWidth = 0;
uHeight = 0;
uSampleCount = 1;
#if defined ( __GFSDK_DX11__ )
Format = DXGI_FORMAT_UNKNOWN;
pTexture = NULL;
pSRV = NULL;
pRTV = NULL;
#elif defined ( __GFSDK_GL__ )
Type = 0;
InternalFormat = 0;
Format = 0;
Texture = 0;
FBO = 0;
#endif
}
};
/*===========================================================================
Interface defines
===========================================================================*/
#define __GFSDK_SHADOWLIB_INTERFACE__ GFSDK_ShadowLib_Status __GFSDK_CDECL__
#ifdef __DLL_GFSDK_SHADOWLIB_EXPORTS__
#define __GFSDK_SHADOWLIB_EXTERN_INTERFACE__ __GFSDK_EXPORT__ __GFSDK_SHADOWLIB_INTERFACE__
#else
#define __GFSDK_SHADOWLIB_EXTERN_INTERFACE__ __GFSDK_IMPORT__ __GFSDK_SHADOWLIB_INTERFACE__
#endif
#define GFSDK_ShadowLib_FunctionPointer (void(*)(void*,gfsdk_float4x4*))
#ifdef __cplusplus
}; //extern "C" {
#endif
#pragma pack(pop)
/*===========================================================================
EOF
===========================================================================*/
|