config.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. /*
  2. * Copyright 2011-2021 Branimir Karadzic. All rights reserved.
  3. * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
  4. */
  5. #ifndef BGFX_CONFIG_H_HEADER_GUARD
  6. #define BGFX_CONFIG_H_HEADER_GUARD
  7. #include <bx/bx.h>
  8. // # Configuration options for bgfx.
  9. //
  10. // Any of `BGFX_CONFIG_*` options that's inside `#ifndef` block can be configured externally
  11. // via compiler options.
  12. //
  13. // When selecting rendering backends select all backends you want to include in the build.
  14. #ifndef BGFX_CONFIG_DEBUG
  15. # define BGFX_CONFIG_DEBUG 0
  16. #endif // BGFX_CONFIG_DEBUG
  17. #if !defined(BGFX_CONFIG_RENDERER_DIRECT3D9) \
  18. && !defined(BGFX_CONFIG_RENDERER_DIRECT3D11) \
  19. && !defined(BGFX_CONFIG_RENDERER_DIRECT3D12) \
  20. && !defined(BGFX_CONFIG_RENDERER_GNM) \
  21. && !defined(BGFX_CONFIG_RENDERER_METAL) \
  22. && !defined(BGFX_CONFIG_RENDERER_NVN) \
  23. && !defined(BGFX_CONFIG_RENDERER_OPENGL) \
  24. && !defined(BGFX_CONFIG_RENDERER_OPENGLES) \
  25. && !defined(BGFX_CONFIG_RENDERER_VULKAN) \
  26. && !defined(BGFX_CONFIG_RENDERER_WEBGPU)
  27. # ifndef BGFX_CONFIG_RENDERER_DIRECT3D9
  28. # define BGFX_CONFIG_RENDERER_DIRECT3D9 (0 \
  29. || BX_PLATFORM_WINDOWS \
  30. ? 1 : 0)
  31. # endif // BGFX_CONFIG_RENDERER_DIRECT3D9
  32. # ifndef BGFX_CONFIG_RENDERER_DIRECT3D11
  33. # define BGFX_CONFIG_RENDERER_DIRECT3D11 (0 \
  34. || BX_PLATFORM_WINDOWS \
  35. || BX_PLATFORM_WINRT \
  36. || BX_PLATFORM_XBOXONE \
  37. ? 1 : 0)
  38. # endif // BGFX_CONFIG_RENDERER_DIRECT3D11
  39. # ifndef BGFX_CONFIG_RENDERER_DIRECT3D12
  40. # define BGFX_CONFIG_RENDERER_DIRECT3D12 (0 \
  41. || BX_PLATFORM_WINDOWS \
  42. || BX_PLATFORM_WINRT \
  43. || BX_PLATFORM_XBOXONE \
  44. ? 1 : 0)
  45. # endif // BGFX_CONFIG_RENDERER_DIRECT3D12
  46. # ifndef BGFX_CONFIG_RENDERER_GNM
  47. # define BGFX_CONFIG_RENDERER_GNM (0 \
  48. || BX_PLATFORM_PS4 \
  49. ? 1 : 0)
  50. # endif // BGFX_CONFIG_RENDERER_GNM
  51. # ifndef BGFX_CONFIG_RENDERER_METAL
  52. # define BGFX_CONFIG_RENDERER_METAL (0 \
  53. || (BX_PLATFORM_IOS && BX_CPU_ARM) \
  54. || (BX_PLATFORM_IOS && BX_CPU_X86) \
  55. || (BX_PLATFORM_OSX >= 101100) \
  56. ? 1 : 0)
  57. # endif // BGFX_CONFIG_RENDERER_METAL
  58. # ifndef BGFX_CONFIG_RENDERER_NVN
  59. # define BGFX_CONFIG_RENDERER_NVN (0 \
  60. || BX_PLATFORM_NX \
  61. ? 1 : 0)
  62. # endif // BGFX_CONFIG_RENDERER_NVN
  63. # ifndef BGFX_CONFIG_RENDERER_OPENGL_MIN_VERSION
  64. # define BGFX_CONFIG_RENDERER_OPENGL_MIN_VERSION 1
  65. # endif // BGFX_CONFIG_RENDERER_OPENGL_MIN_VERSION
  66. # ifndef BGFX_CONFIG_RENDERER_OPENGL
  67. # define BGFX_CONFIG_RENDERER_OPENGL (0 \
  68. || BX_PLATFORM_BSD \
  69. || BX_PLATFORM_LINUX \
  70. || BX_PLATFORM_OSX \
  71. || BX_PLATFORM_WINDOWS \
  72. ? BGFX_CONFIG_RENDERER_OPENGL_MIN_VERSION : 0)
  73. # endif // BGFX_CONFIG_RENDERER_OPENGL
  74. # ifndef BGFX_CONFIG_RENDERER_OPENGLES_MIN_VERSION
  75. # define BGFX_CONFIG_RENDERER_OPENGLES_MIN_VERSION 1
  76. # endif // BGFX_CONFIG_RENDERER_OPENGLES_MIN_VERSION
  77. # ifndef BGFX_CONFIG_RENDERER_OPENGLES
  78. # define BGFX_CONFIG_RENDERER_OPENGLES (0 \
  79. || BX_PLATFORM_ANDROID \
  80. || BX_PLATFORM_EMSCRIPTEN \
  81. || BX_PLATFORM_IOS \
  82. || BX_PLATFORM_RPI \
  83. || BX_PLATFORM_NX \
  84. ? BGFX_CONFIG_RENDERER_OPENGLES_MIN_VERSION : 0)
  85. # endif // BGFX_CONFIG_RENDERER_OPENGLES
  86. # ifndef BGFX_CONFIG_RENDERER_VULKAN
  87. # define BGFX_CONFIG_RENDERER_VULKAN (0 \
  88. || BX_PLATFORM_ANDROID \
  89. || BX_PLATFORM_LINUX \
  90. || BX_PLATFORM_WINDOWS \
  91. || BX_PLATFORM_NX \
  92. || BX_PLATFORM_OSX \
  93. ? 1 : 0)
  94. # endif // BGFX_CONFIG_RENDERER_VULKAN
  95. # ifndef BGFX_CONFIG_RENDERER_WEBGPU
  96. # define BGFX_CONFIG_RENDERER_WEBGPU 0
  97. # endif // BGFX_CONFIG_RENDERER_WEBGPU
  98. #else
  99. # ifndef BGFX_CONFIG_RENDERER_DIRECT3D9
  100. # define BGFX_CONFIG_RENDERER_DIRECT3D9 0
  101. # endif // BGFX_CONFIG_RENDERER_DIRECT3D9
  102. # ifndef BGFX_CONFIG_RENDERER_DIRECT3D11
  103. # define BGFX_CONFIG_RENDERER_DIRECT3D11 0
  104. # endif // BGFX_CONFIG_RENDERER_DIRECT3D11
  105. # ifndef BGFX_CONFIG_RENDERER_DIRECT3D12
  106. # define BGFX_CONFIG_RENDERER_DIRECT3D12 0
  107. # endif // BGFX_CONFIG_RENDERER_DIRECT3D12
  108. # ifndef BGFX_CONFIG_RENDERER_GNM
  109. # define BGFX_CONFIG_RENDERER_GNM 0
  110. # endif // BGFX_CONFIG_RENDERER_GNM
  111. # ifndef BGFX_CONFIG_RENDERER_METAL
  112. # define BGFX_CONFIG_RENDERER_METAL 0
  113. # endif // BGFX_CONFIG_RENDERER_METAL
  114. # ifndef BGFX_CONFIG_RENDERER_NVN
  115. # define BGFX_CONFIG_RENDERER_NVN 0
  116. # endif // BGFX_CONFIG_RENDERER_NVN
  117. # ifndef BGFX_CONFIG_RENDERER_OPENGL
  118. # define BGFX_CONFIG_RENDERER_OPENGL 0
  119. # endif // BGFX_CONFIG_RENDERER_OPENGL
  120. # ifndef BGFX_CONFIG_RENDERER_OPENGLES
  121. # define BGFX_CONFIG_RENDERER_OPENGLES 0
  122. # endif // BGFX_CONFIG_RENDERER_OPENGLES
  123. # ifndef BGFX_CONFIG_RENDERER_VULKAN
  124. # define BGFX_CONFIG_RENDERER_VULKAN 0
  125. # endif // BGFX_CONFIG_RENDERER_VULKAN
  126. # ifndef BGFX_CONFIG_RENDERER_WEBGPU
  127. # define BGFX_CONFIG_RENDERER_WEBGPU 0
  128. # endif // BGFX_CONFIG_RENDERER_VULKAN
  129. #endif // !defined...
  130. #if BGFX_CONFIG_RENDERER_OPENGL && BGFX_CONFIG_RENDERER_OPENGL < 21
  131. # undef BGFX_CONFIG_RENDERER_OPENGL
  132. # define BGFX_CONFIG_RENDERER_OPENGL 21
  133. #endif // BGFX_CONFIG_RENDERER_OPENGL && BGFX_CONFIG_RENDERER_OPENGL < 21
  134. #if BGFX_CONFIG_RENDERER_OPENGLES && BGFX_CONFIG_RENDERER_OPENGLES < 20
  135. # undef BGFX_CONFIG_RENDERER_OPENGLES
  136. # define BGFX_CONFIG_RENDERER_OPENGLES 20
  137. #endif // BGFX_CONFIG_RENDERER_OPENGLES && BGFX_CONFIG_RENDERER_OPENGLES < 20
  138. #if BGFX_CONFIG_RENDERER_OPENGL && BGFX_CONFIG_RENDERER_OPENGLES
  139. # error "Can't define both BGFX_CONFIG_RENDERER_OPENGL and BGFX_CONFIG_RENDERER_OPENGLES"
  140. #endif // BGFX_CONFIG_RENDERER_OPENGL && BGFX_CONFIG_RENDERER_OPENGLES
  141. /// Enable use of extensions.
  142. #ifndef BGFX_CONFIG_RENDERER_USE_EXTENSIONS
  143. # define BGFX_CONFIG_RENDERER_USE_EXTENSIONS 1
  144. #endif // BGFX_CONFIG_RENDERER_USE_EXTENSIONS
  145. /// Enable use of tinystl.
  146. #ifndef BGFX_CONFIG_USE_TINYSTL
  147. # define BGFX_CONFIG_USE_TINYSTL 1
  148. #endif // BGFX_CONFIG_USE_TINYSTL
  149. /// Enable nVidia PerfHUD integration.
  150. #ifndef BGFX_CONFIG_DEBUG_PERFHUD
  151. # define BGFX_CONFIG_DEBUG_PERFHUD 0
  152. #endif // BGFX_CONFIG_DEBUG_NVPERFHUD
  153. /// Enable annotation for graphics debuggers.
  154. #ifndef BGFX_CONFIG_DEBUG_ANNOTATION
  155. # define BGFX_CONFIG_DEBUG_ANNOTATION BGFX_CONFIG_DEBUG
  156. #endif // BGFX_CONFIG_DEBUG_ANNOTATION
  157. /// Enable DX11 object names.
  158. #ifndef BGFX_CONFIG_DEBUG_OBJECT_NAME
  159. # define BGFX_CONFIG_DEBUG_OBJECT_NAME BGFX_CONFIG_DEBUG_ANNOTATION
  160. #endif // BGFX_CONFIG_DEBUG_OBJECT_NAME
  161. /// Enable uniform debug checks.
  162. #ifndef BGFX_CONFIG_DEBUG_UNIFORM
  163. # define BGFX_CONFIG_DEBUG_UNIFORM BGFX_CONFIG_DEBUG
  164. #endif // BGFX_CONFIG_DEBUG_UNIFORM
  165. /// Enable occlusion debug checks.
  166. #ifndef BGFX_CONFIG_DEBUG_OCCLUSION
  167. # define BGFX_CONFIG_DEBUG_OCCLUSION BGFX_CONFIG_DEBUG
  168. #endif // BGFX_CONFIG_DEBUG_OCCLUSION
  169. #ifndef BGFX_CONFIG_MULTITHREADED
  170. # define BGFX_CONFIG_MULTITHREADED ( (0 == BX_PLATFORM_EMSCRIPTEN) ? 1 : 0)
  171. #endif // BGFX_CONFIG_MULTITHREADED
  172. #ifndef BGFX_CONFIG_MAX_DRAW_CALLS
  173. # define BGFX_CONFIG_MAX_DRAW_CALLS ( (64<<10)-1)
  174. #endif // BGFX_CONFIG_MAX_DRAW_CALLS
  175. #ifndef BGFX_CONFIG_MAX_BLIT_ITEMS
  176. # define BGFX_CONFIG_MAX_BLIT_ITEMS (1<<10)
  177. #endif // BGFX_CONFIG_MAX_BLIT_ITEMS
  178. #ifndef BGFX_CONFIG_MAX_MATRIX_CACHE
  179. # define BGFX_CONFIG_MAX_MATRIX_CACHE (BGFX_CONFIG_MAX_DRAW_CALLS+1)
  180. #endif // BGFX_CONFIG_MAX_MATRIX_CACHE
  181. #ifndef BGFX_CONFIG_MAX_RECT_CACHE
  182. # define BGFX_CONFIG_MAX_RECT_CACHE (4<<10)
  183. #endif // BGFX_CONFIG_MAX_RECT_CACHE
  184. #ifndef BGFX_CONFIG_SORT_KEY_NUM_BITS_DEPTH
  185. # define BGFX_CONFIG_SORT_KEY_NUM_BITS_DEPTH 32
  186. #endif // BGFX_CONFIG_SORT_KEY_NUM_BITS_DEPTH
  187. #ifndef BGFX_CONFIG_SORT_KEY_NUM_BITS_SEQ
  188. # define BGFX_CONFIG_SORT_KEY_NUM_BITS_SEQ 20
  189. #endif // BGFX_CONFIG_SORT_KEY_NUM_BITS_SEQ
  190. #ifndef BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM
  191. # define BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM 9
  192. #endif // BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM
  193. // Cannot be configured via compiler options.
  194. #define BGFX_CONFIG_MAX_PROGRAMS (1<<BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM)
  195. BX_STATIC_ASSERT(bx::isPowerOf2(BGFX_CONFIG_MAX_PROGRAMS), "BGFX_CONFIG_MAX_PROGRAMS must be power of 2.");
  196. #ifndef BGFX_CONFIG_MAX_VIEWS
  197. # define BGFX_CONFIG_MAX_VIEWS 256
  198. #endif // BGFX_CONFIG_MAX_VIEWS
  199. BX_STATIC_ASSERT(bx::isPowerOf2(BGFX_CONFIG_MAX_VIEWS), "BGFX_CONFIG_MAX_VIEWS must be power of 2.");
  200. #define BGFX_CONFIG_MAX_VIEW_NAME_RESERVED 6
  201. #ifndef BGFX_CONFIG_MAX_VIEW_NAME
  202. # define BGFX_CONFIG_MAX_VIEW_NAME 256
  203. #endif // BGFX_CONFIG_MAX_VIEW_NAME
  204. #ifndef BGFX_CONFIG_MAX_VERTEX_LAYOUTS
  205. # define BGFX_CONFIG_MAX_VERTEX_LAYOUTS 64
  206. #endif // BGFX_CONFIG_MAX_VERTEX_LAYOUTS
  207. #ifndef BGFX_CONFIG_MAX_INDEX_BUFFERS
  208. # define BGFX_CONFIG_MAX_INDEX_BUFFERS (4<<10)
  209. #endif // BGFX_CONFIG_MAX_INDEX_BUFFERS
  210. #ifndef BGFX_CONFIG_MAX_VERTEX_BUFFERS
  211. # define BGFX_CONFIG_MAX_VERTEX_BUFFERS (4<<10)
  212. #endif // BGFX_CONFIG_MAX_VERTEX_BUFFERS
  213. #ifndef BGFX_CONFIG_MAX_VERTEX_STREAMS
  214. # define BGFX_CONFIG_MAX_VERTEX_STREAMS 4
  215. #endif // BGFX_CONFIG_MAX_VERTEX_STREAMS
  216. #ifndef BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS
  217. # define BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS (4<<10)
  218. #endif // BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS
  219. #ifndef BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS
  220. # define BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS (4<<10)
  221. #endif // BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS
  222. #ifndef BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE
  223. # define BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE (1<<20)
  224. #endif // BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE
  225. #ifndef BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE
  226. # define BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE (3<<20)
  227. #endif // BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE
  228. #ifndef BGFX_CONFIG_MAX_SHADERS
  229. # define BGFX_CONFIG_MAX_SHADERS 512
  230. #endif // BGFX_CONFIG_MAX_FRAGMENT_SHADERS
  231. #ifndef BGFX_CONFIG_MAX_TEXTURES
  232. # define BGFX_CONFIG_MAX_TEXTURES (4<<10)
  233. #endif // BGFX_CONFIG_MAX_TEXTURES
  234. #ifndef BGFX_CONFIG_MAX_TEXTURE_SAMPLERS
  235. # define BGFX_CONFIG_MAX_TEXTURE_SAMPLERS 16
  236. #endif // BGFX_CONFIG_MAX_TEXTURE_SAMPLERS
  237. #ifndef BGFX_CONFIG_MAX_FRAME_BUFFERS
  238. # define BGFX_CONFIG_MAX_FRAME_BUFFERS 128
  239. #endif // BGFX_CONFIG_MAX_FRAME_BUFFERS
  240. #ifndef BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS
  241. # define BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS 8
  242. #endif // BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS
  243. #ifndef BGFX_CONFIG_MAX_UNIFORMS
  244. # define BGFX_CONFIG_MAX_UNIFORMS 512
  245. #endif // BGFX_CONFIG_MAX_UNIFORMS
  246. #ifndef BGFX_CONFIG_MAX_OCCLUSION_QUERIES
  247. # define BGFX_CONFIG_MAX_OCCLUSION_QUERIES 256
  248. #endif // BGFX_CONFIG_MAX_OCCLUSION_QUERIES
  249. #ifndef BGFX_CONFIG_MIN_RESOURCE_COMMAND_BUFFER_SIZE
  250. # define BGFX_CONFIG_MIN_RESOURCE_COMMAND_BUFFER_SIZE (64<<10)
  251. #endif // BGFX_CONFIG_MIN_RESOURCE_COMMAND_BUFFER_SIZE
  252. #ifndef BGFX_CONFIG_TRANSIENT_VERTEX_BUFFER_SIZE
  253. # define BGFX_CONFIG_TRANSIENT_VERTEX_BUFFER_SIZE (6<<20)
  254. #endif // BGFX_CONFIG_TRANSIENT_VERTEX_BUFFER_SIZE
  255. #ifndef BGFX_CONFIG_TRANSIENT_INDEX_BUFFER_SIZE
  256. # define BGFX_CONFIG_TRANSIENT_INDEX_BUFFER_SIZE (2<<20)
  257. #endif // BGFX_CONFIG_TRANSIENT_INDEX_BUFFER_SIZE
  258. #ifndef BGFX_CONFIG_MAX_INSTANCE_DATA_COUNT
  259. # define BGFX_CONFIG_MAX_INSTANCE_DATA_COUNT 5
  260. #endif // BGFX_CONFIG_MAX_INSTANCE_DATA_COUNT
  261. #ifndef BGFX_CONFIG_MAX_COLOR_PALETTE
  262. # define BGFX_CONFIG_MAX_COLOR_PALETTE 16
  263. #endif // BGFX_CONFIG_MAX_COLOR_PALETTE
  264. #define BGFX_CONFIG_DRAW_INDIRECT_STRIDE 32
  265. #ifndef BGFX_CONFIG_PROFILER
  266. # define BGFX_CONFIG_PROFILER 0
  267. #endif // BGFX_CONFIG_PROFILER
  268. #ifndef BGFX_CONFIG_RENDERDOC_LOG_FILEPATH
  269. # define BGFX_CONFIG_RENDERDOC_LOG_FILEPATH "temp/bgfx"
  270. #endif // BGFX_CONFIG_RENDERDOC_LOG_FILEPATH
  271. #ifndef BGFX_CONFIG_RENDERDOC_CAPTURE_KEYS
  272. # define BGFX_CONFIG_RENDERDOC_CAPTURE_KEYS { eRENDERDOC_Key_F11 }
  273. #endif // BGFX_CONFIG_RENDERDOC_CAPTURE_KEYS
  274. #ifndef BGFX_CONFIG_API_SEMAPHORE_TIMEOUT
  275. # define BGFX_CONFIG_API_SEMAPHORE_TIMEOUT (5000)
  276. #endif // BGFX_CONFIG_API_SEMAPHORE_TIMEOUT
  277. #ifndef BGFX_CONFIG_MIP_LOD_BIAS
  278. # define BGFX_CONFIG_MIP_LOD_BIAS 0
  279. #endif // BGFX_CONFIG_MIP_LOD_BIAS
  280. #ifndef BGFX_CONFIG_DEFAULT_MAX_ENCODERS
  281. # define BGFX_CONFIG_DEFAULT_MAX_ENCODERS ( (0 != BGFX_CONFIG_MULTITHREADED) ? 8 : 1)
  282. #endif // BGFX_CONFIG_DEFAULT_MAX_ENCODERS
  283. #ifndef BGFX_CONFIG_MAX_BACK_BUFFERS
  284. # define BGFX_CONFIG_MAX_BACK_BUFFERS 4
  285. #endif // BGFX_CONFIG_MAX_BACK_BUFFERS
  286. #ifndef BGFX_CONFIG_MAX_FRAME_LATENCY
  287. # define BGFX_CONFIG_MAX_FRAME_LATENCY 3
  288. #endif // BGFX_CONFIG_MAX_FRAME_LATENCY
  289. #ifndef BGFX_CONFIG_PREFER_DISCRETE_GPU
  290. // On laptops with integrated and discrete GPU, prefer selection of discrete GPU.
  291. // nVidia and AMD, on Windows only.
  292. # define BGFX_CONFIG_PREFER_DISCRETE_GPU BX_PLATFORM_WINDOWS
  293. #endif // BGFX_CONFIG_PREFER_DISCRETE_GPU
  294. #ifndef BGFX_CONFIG_MAX_SCREENSHOTS
  295. # define BGFX_CONFIG_MAX_SCREENSHOTS 4
  296. #endif // BGFX_CONFIG_MAX_SCREENSHOTS
  297. #endif // BGFX_CONFIG_H_HEADER_GUARD