aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Samples/SampleFramework/renderer/include/RendererConfig.h
blob: aeefada1124ea39e0b89ca351ec90e2831513d5d (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
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
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//  * Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
//  * Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
//  * Neither the name of NVIDIA CORPORATION nor the names of its
//    contributors may be used to endorse or promote products derived
//    from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.

#ifndef RENDERER_CONFIG_H
#define RENDERER_CONFIG_H

#include <RendererFoundation.h>
#include <assert.h>

#define RENDERER_TEXT(_foo)   #_foo
#define RENDERER_TEXT2(_foo)  RENDERER_TEXT(_foo)

// number of lights required before it switches from forward rendering to deferred rendering.
#define RENDERER_DEFERRED_THRESHOLD  0x7FFFFFFF // set to a big number just to disable it for now...

// Enables/Disables support for dresscode in the renderer...
#define RENDERER_ENABLE_DRESSCODE 0

// If turned on, asserts get compiled in as print statements in release mode.
#define RENDERER_ENABLE_CHECKED_RELEASE 0

// If enabled, all lights will be bound in a single pass. Requires appropriate shader support.
#define RENDERER_ENABLE_SINGLE_PASS_LIGHTING 0

// maximum number of bones per-drawcall allowed.
#define RENDERER_MAX_BONES 60

#define RENDERER_TANGENT_CHANNEL            5
#define RENDERER_BONEINDEX_CHANNEL          6
#define RENDERER_BONEWEIGHT_CHANNEL         7
#define RENDERER_INSTANCE_POSITION_CHANNEL  8
#define RENDERER_INSTANCE_NORMALX_CHANNEL   9
#define RENDERER_INSTANCE_NORMALY_CHANNEL  10
#define RENDERER_INSTANCE_NORMALZ_CHANNEL  11
#define RENDERER_INSTANCE_VEL_LIFE_CHANNEL 12
#define RENDERER_INSTANCE_DENSITY_CHANNEL  13

#define RENDERER_INSTANCE_UV_CHANNEL       12
#define RENDERER_INSTANCE_LOCAL_CHANNEL    13

#define RENDERER_DISPLACEMENT_CHANNEL      14
#define RENDERER_X_DISPLACEMENT_CHANNEL    13
#define RENDERER_Y_DISPLACEMENT_CHANNEL    14
#define RENDERER_Z_DISPLACEMENT_CHANNEL    15
#define RENDERER_DISPLACEMENT_FLAGS_CHANNEL 15

// Compiler specific configuration...
#if defined(_MSC_VER)
#define RENDERER_VISUALSTUDIO
#pragma warning(disable : 4127) // conditional expression is constant
#pragma warning(disable : 4100) // unreferenced formal parameter

#elif defined(__ghs__)
	#define RENDERER_GHS
#elif defined(__GNUC__)
	#define RENDERER_GCC
#else
#error Unknown Compiler!

#endif

#if PX_PS4
#pragma clang diagnostic push
// variadic macros are incompatible with C++98
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
#endif

// Platform specific configuration...
#if defined(WIN32) || defined(WIN64) || defined(_M_ARM) || PX_XBOXONE
	#define RENDERER_WINDOWS
#if !PX_XBOXONE
	#define RENDERER_ENABLE_DIRECT3D9
#endif
	#define RENDERER_ENABLE_DIRECT3D11
	#define RENDERER_ENABLE_NVPERFHUD
	#define RENDERER_ENABLE_TGA_SUPPORT
	#if !defined(RENDERER_PVD) && !PX_XBOXONE && PX_SUPPORT_GPU_PHYSX
		//Removed this to get PhysX distro working without shipping CUDA.
		//#define RENDERER_ENABLE_CUDA_INTEROP 
	#endif
	#define	DIRECT3D9_SUPPORT_D3DUSAGE_DYNAMIC
	#if defined(WIN64)
		#define RENDERER_64BIT
	#endif
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#define NOMINMAX
#include <windows.h>
#elif defined(__APPLE__) && !defined(__arm__) && !defined(__arm64__)
#define RENDERER_MACOSX
#define RENDERER_ENABLE_OPENGL
#define RENDERER_ENABLE_CG
#if !PX_PPC
#define RENDERER_ENABLE_TGA_SUPPORT
#endif

#elif defined(_XBOX) && _XBOX_VER == 200
#define RENDERER_XBOX360
#define RENDERER_ENABLE_DIRECT3D9
#define NOMINMAX
#define RENDERER_ENABLE_TGA_SUPPORT
#define RENDERER_BIG_ENDIAN

#elif PX_PS4
	#define RENDERER_PS4
	#define RENDERER_ENABLE_LIBGNM
	#define RENDERER_ENABLE_CG
	#define RENDERER_ENABLE_TGA_SUPPORT

#elif defined(__CYGWIN__)
#define RENDERER_LINUX
#define RENDERER_ENABLE_OPENGL
#define RENDERER_ENABLE_CG
#define RENDERER_ENABLE_TGA_SUPPORT

#elif defined(ANDROID)
	#define RENDERER_DEBUG
	#define RENDERER_ANDROID
	#define RENDERER_TABLET
	#define RENDERER_ENABLE_GLES2
	#define RENDERER_ENABLE_TGA_SUPPORT

#elif defined(__linux__)
	#define RENDERER_LINUX
	#define RENDERER_ENABLE_OPENGL
	#define RENDERER_ENABLE_CG
	#define RENDERER_ENABLE_TGA_SUPPORT

#elif defined(__APPLE__) && (defined(__arm__) || defined(__arm64__))
	#define RENDERER_DEBUG
	#define RENDERER_IOS
	#define RENDERER_TABLET
	#define RENDERER_ENABLE_GLES2
	#define RENDERER_ENABLE_TGA_SUPPORT
	#define RENDERER_ENABLE_PVR_SUPPORT

#elif defined(RENDERER_GHS)
	#define RENDERER_WIIU
	#define RENDERER_ENABLE_GX2
	#define RENDERER_ENABLE_TGA_SUPPORT
	#define RENDERER_BIG_ENDIAN

#else
#error "Unknown Platform!"

#endif

#if PX_DEBUG
#define RENDERER_DEBUG
#endif


#if defined(RENDERER_DEBUG)
	#if defined(RENDERER_WINDOWS) && !PX_XBOXONE
		#define RENDERER_ASSERT(_exp, _msg)                     \
		    if(!(_exp))                                         \
		    {                                                   \
		        MessageBoxA(0, _msg, "Renderer Assert", MB_OK); \
		        __debugbreak();                                 \
		    }
	#elif defined(RENDERER_ANDROID)
	#include <android/log.h>
	#define RENDERER_ASSERT(_exp, _msg)													\
		if(!(_exp))																		\
			__android_log_print(ANDROID_LOG_INFO, _msg, "RENDERER_ASSERT: %s\n", #_exp);\
		assert(_exp && (_msg));
	#else
		#define RENDERER_ASSERT(_exp, _msg) assert(_exp && (_msg));
	#endif
#elif RENDERER_ENABLE_CHECKED_RELEASE
#if defined(RENDERER_VISUALSTUDIO)
#define RENDERER_ASSERT(_exp, _msg)                                          \
	if(!(_exp))                                                              \
	{                                                                        \
		OutputDebugStringA("*** (" __FILE__":"RENDERER_TEXT2(__LINE__)") "); \
		OutputDebugStringA(_msg);                                            \
		OutputDebugStringA(" ***\n");                                        \
	}
#else
#define RENDERER_ASSERT(_exp, _msg) if(!(_exp)) shdfnd::printFormatted("*** (" __FILE__ ":" RENDERER_TEXT2(__LINE__)") %s ***\n", _msg);
#endif
#else
#define RENDERER_ASSERT(_exp, _msg)
#endif

#define RENDERER_OUTPUT_MESSAGE(_rendererPtr, _msg) \
	if((_rendererPtr) && (_rendererPtr)->getErrorCallback()) \
	{ \
		(_rendererPtr)->getErrorCallback()->reportError(PxErrorCode::eDEBUG_INFO, (_msg), __FILE__, __LINE__); \
	}


#if defined(RENDERER_ANDROID)
	#include <android/log.h>
	#define LOG_INFO(title, ...) ((void)__android_log_print(ANDROID_LOG_INFO, title, __VA_ARGS__))
#else

#if 0
	#include <stdio.h>
	#include <stdarg.h>

	static void printInfo(const char* title, const char* message, ...)
	{
		char buff[4096];
		
		shdfnd::printFormatted("%s ", title);
		va_list va;
		va_start(va, message);
		vsprintf(buff, message, va);
		va_end(va);
		if (strlen(buff)>=4096)
			assert(!"buffer overflow!!");
		
		shdfnd::printFormatted("%s\n", buff);
	}

	#define LOG_INFO(title, ...) (printInfo(title, __VA_ARGS__))
#else
	#define LOG_INFO(title, ...)
#endif

#endif

#if defined(RENDERER_XBOX360)
#define RENDERER_INSTANCING 0
#else
#define RENDERER_INSTANCING 1
#endif

namespace SampleRenderer
{
	// 2D and 3D Textures have identical external interfaces
	//    Using a typedef provides compatibility with legacy code that used only 2D textures
	class RendererTexture;
	class RendererTextureDesc;
	typedef RendererTexture     RendererTexture2D;
	typedef RendererTextureDesc RendererTexture2DDesc;
	typedef RendererTexture     RendererTexture3D;
	typedef RendererTextureDesc RendererTexture3DDesc;
}
#if defined(RENDERER_ANDROID) && !defined(LOGI)
#	include <android/log.h>
#	define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "RendererConfig", __VA_ARGS__))
#else
#	define LOGI(...) LOG_INFO("LOGI: ", __VA_ARGS__)
#endif

#if PX_PS4
#pragma clang diagnostic pop
#endif

#endif