gfxEnums.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _GFXENUMS_H_
  23. #define _GFXENUMS_H_
  24. #include "core/util/fourcc.h"
  25. // These are for the enum translation. It will help with porting to other platforms
  26. // and API's.
  27. #define GFX_UNSUPPORTED_VAL 0xDEADBEEF
  28. #define GFX_UNINIT_VAL 0xDECAFBAD
  29. // Adjust these pools to your app's needs. Be aware dynamic vertices are much more
  30. // expensive than static vertices. These are in gfxEnums because they should be
  31. // consistant across all APIs/platforms so that the dynamic buffer performance
  32. // and behavior is also consistant. -patw
  33. #define GFX_MAX_DYNAMIC_VERTS (8192*2)
  34. #define GFX_MAX_DYNAMIC_INDICES (8192*4)
  35. #define GFX_WORLD_STACK_MAX 24
  36. #define GFX_TEXTURE_STAGE_COUNT 16
  37. enum GFXBufferType
  38. {
  39. GFXBufferTypeStatic, ///< Static vertex buffers are created and rarely updated.
  40. ///< Updating might incur a performance penalty. Resizing a static vertex buffer is not
  41. ///< allowed.
  42. GFXBufferTypeDynamic, ///< Dynamic vertex buffers are meant for vertices that can be changed
  43. ///< often. Vertices written into dynamic vertex buffers will remain valid
  44. ///< until the dynamic vertex buffer is released. Resizing a dynamic vertex buffer is not
  45. ///< allowed.
  46. GFXBufferTypeVolatile, ///< Volatile vertex or index buffers are meant for vertices or indices that are essentially
  47. ///< only used once. They can be resized without any performance penalty.
  48. GFXBufferTypeImmutable, ///< Immutable buffers must specify the data when creating the buffer. Cannot be modified.
  49. GFXBufferType_COUNT ///< Number of buffer types.
  50. };
  51. enum GFXTexCallbackCode
  52. {
  53. GFXZombify,
  54. GFXResurrect,
  55. };
  56. enum GFXPrimitiveType
  57. {
  58. GFXPT_FIRST = 0,
  59. GFXPointList = 0,
  60. GFXLineList,
  61. GFXLineStrip,
  62. GFXTriangleList,
  63. GFXTriangleStrip,
  64. GFXPT_COUNT
  65. };
  66. enum GFXBitmapFlip
  67. {
  68. GFXBitmapFlip_None = 0,
  69. GFXBitmapFlip_X = 1 << 0,
  70. GFXBitmapFlip_Y = 1 << 1,
  71. GFXBitmapFlip_XY = GFXBitmapFlip_X | GFXBitmapFlip_Y
  72. };
  73. enum GFXTextureAddressMode
  74. {
  75. GFXAddress_FIRST = 0,
  76. GFXAddressWrap = 0,
  77. GFXAddressMirror,
  78. GFXAddressClamp,
  79. GFXAddressBorder,
  80. GFXAddressMirrorOnce,
  81. GFXAddress_COUNT
  82. };
  83. enum GFXTextureFilterType
  84. {
  85. GFXTextureFilter_FIRST = 0,
  86. GFXTextureFilterNone = 0,
  87. GFXTextureFilterPoint,
  88. GFXTextureFilterLinear,
  89. GFXTextureFilterAnisotropic,
  90. GFXTextureFilter_COUNT
  91. };
  92. enum GFXFillMode
  93. {
  94. GFXFill_FIRST = 1,
  95. GFXFillPoint = 1,
  96. GFXFillWireframe,
  97. GFXFillSolid,
  98. GFXFill_COUNT
  99. };
  100. enum GFXFormat
  101. {
  102. // when adding formats make sure to place
  103. // them in the correct group!
  104. //
  105. // if displacing the first entry in the group
  106. // make sure to update the GFXFormat_xBIT entries!
  107. //
  108. GFXFormat_FIRST = 0,
  109. // 8 bit texture formats...
  110. GFXFormatA8 = 0,// first in group...
  111. GFXFormatL8,
  112. GFXFormatA4L4,
  113. // 16 bit texture formats...
  114. GFXFormatR5G6B5,// first in group...
  115. GFXFormatR5G5B5A1,
  116. GFXFormatR5G5B5X1,
  117. GFXFormatA8L8,
  118. GFXFormatL16,
  119. GFXFormatR16F,
  120. GFXFormatD16,
  121. // 24 bit texture formats...
  122. GFXFormatR8G8B8,// first in group...
  123. GFXFormatR8G8B8_SRGB,
  124. // 32 bit texture formats...
  125. GFXFormatR8G8B8A8,// first in group...
  126. GFXFormatR8G8B8X8,
  127. GFXFormatB8G8R8A8,
  128. GFXFormatR8G8B8A8_SRGB,
  129. GFXFormatR32F,
  130. GFXFormatR16G16,
  131. GFXFormatR16G16F,
  132. GFXFormatR10G10B10A2,
  133. GFXFormatR11G11B10,
  134. GFXFormatD32,
  135. GFXFormatD24X8,
  136. GFXFormatD24S8,
  137. GFXFormatD24FS8,
  138. // Guaranteed RGBA8 (for apis which really dont like bgr)
  139. GFXFormatR8G8B8A8_LINEAR_FORCE,
  140. // 64 bit texture formats...
  141. GFXFormatR16G16B16A16,// first in group...
  142. GFXFormatR16G16B16A16F,
  143. // 128 bit texture formats...
  144. GFXFormatR32G32B32A32F,// first in group...
  145. // unknown size...Block compression
  146. GFXFormatBC1, //dxt1
  147. GFXFormatBC2, //dxt2/3
  148. GFXFormatBC3, //dxt4/5
  149. GFXFormatBC4, //3dc+ / ati1
  150. GFXFormatBC5, //3dc / ati2
  151. // compressed sRGB formats
  152. GFXFormatBC1_SRGB,
  153. GFXFormatBC2_SRGB,
  154. GFXFormatBC3_SRGB,
  155. GFXFormat_COUNT,
  156. GFXFormat_8BIT = GFXFormatA8,
  157. GFXFormat_16BIT = GFXFormatR5G6B5,
  158. GFXFormat_24BIT = GFXFormatR8G8B8,
  159. GFXFormat_32BIT = GFXFormatR8G8B8A8,
  160. GFXFormat_64BIT = GFXFormatR16G16B16A16,
  161. GFXFormat_128BIT = GFXFormatR32G32B32A32F,
  162. GFXFormat_UNKNOWNSIZE = GFXFormatBC1
  163. };
  164. /// Returns the byte size of the pixel for non-compressed formats.
  165. inline U32 GFXFormat_getByteSize( GFXFormat format )
  166. {
  167. AssertFatal( format < GFXFormat_UNKNOWNSIZE,
  168. "GFXDevice::formatByteSize - Cannot size a compressed format!" );
  169. if ( format < GFXFormat_16BIT )
  170. return 1;// 8 bit...
  171. else if ( format < GFXFormat_24BIT )
  172. return 2;// 16 bit...
  173. else if ( format < GFXFormat_32BIT )
  174. return 3;// 24 bit...
  175. else if ( format < GFXFormat_64BIT )
  176. return 4;// 32 bit...
  177. else if ( format < GFXFormat_128BIT )
  178. return 8;// 64 bit...
  179. // This should be 128bits... else its a DDS and
  180. // the assert should have gone off above.
  181. return 16;
  182. }
  183. enum GFXClearFlags
  184. {
  185. GFXClearTarget = 1 << 0,
  186. GFXClearZBuffer = 1 << 1,
  187. GFXClearStencil = 1 << 2,
  188. };
  189. /// The supported blend modes.
  190. enum GFXBlend
  191. {
  192. GFXBlend_FIRST = 0,
  193. GFXBlendZero = 0, /// (0, 0, 0, 0)
  194. GFXBlendOne, /// (1, 1, 1, 1)
  195. GFXBlendSrcColor, /// (Rs, Gs, Bs, As)
  196. GFXBlendInvSrcColor, /// (1 - Rs, 1 - Gs, 1 - Bs, 1 - As)
  197. GFXBlendSrcAlpha, /// (As, As, As, As)
  198. GFXBlendInvSrcAlpha, /// ( 1 - As, 1 - As, 1 - As, 1 - As)
  199. GFXBlendDestAlpha, /// (Ad Ad Ad Ad)
  200. GFXBlendInvDestAlpha, /// (1 - Ad 1 - Ad 1 - Ad 1 - Ad)
  201. GFXBlendDestColor, /// (Rd, Gd, Bd, Ad)
  202. GFXBlendInvDestColor, /// (1 - Rd, 1 - Gd, 1 - Bd, 1 - Ad)
  203. GFXBlendSrcAlphaSat, /// (f, f, f, 1) where f = min(As, 1 - Ad)
  204. GFXBlend_COUNT
  205. };
  206. /// Constants that name each GFXDevice type. Any new GFXDevice subclass must be
  207. /// added to this enum. A string representing its name must also be added to
  208. /// GFXInit::getAdapterNameFromType().
  209. enum GFXAdapterType
  210. {
  211. OpenGL = 0,
  212. Direct3D11,
  213. NullDevice,
  214. GFXAdapterType_Count
  215. };
  216. enum GFXCullMode
  217. {
  218. GFXCull_FIRST = 0,
  219. GFXCullNone = 0,
  220. GFXCullCW,
  221. GFXCullCCW,
  222. GFXCull_COUNT
  223. };
  224. enum GFXCmpFunc
  225. {
  226. GFXCmp_FIRST = 0,
  227. GFXCmpNever = 0,
  228. GFXCmpLess,
  229. GFXCmpEqual,
  230. GFXCmpLessEqual,
  231. GFXCmpGreater,
  232. GFXCmpNotEqual,
  233. GFXCmpGreaterEqual,
  234. GFXCmpAlways,
  235. GFXCmp_COUNT
  236. };
  237. enum GFXStencilOp
  238. {
  239. GFXStencilOp_FIRST = 0,
  240. GFXStencilOpKeep = 0,
  241. GFXStencilOpZero,
  242. GFXStencilOpReplace,
  243. GFXStencilOpIncrSat,
  244. GFXStencilOpDecrSat,
  245. GFXStencilOpInvert,
  246. GFXStencilOpIncr,
  247. GFXStencilOpDecr,
  248. GFXStencilOp_COUNT
  249. };
  250. enum GFXBlendOp
  251. {
  252. GFXBlendOp_FIRST = 0,
  253. GFXBlendOpAdd = 0,
  254. GFXBlendOpSubtract,
  255. GFXBlendOpRevSubtract,
  256. GFXBlendOpMin,
  257. GFXBlendOpMax,
  258. GFXBlendOp_COUNT
  259. };
  260. enum GFXMatrixType
  261. {
  262. GFXMatrixWorld = 256,
  263. GFXMatrixView = 2,
  264. GFXMatrixProjection = 3,
  265. GFXMatrixTexture = 16, // This value is texture matrix for sampler 0, can use this for offset
  266. GFXMatrixTexture0 = 16,
  267. GFXMatrixTexture1 = 17,
  268. GFXMatrixTexture2 = 18,
  269. GFXMatrixTexture3 = 19,
  270. GFXMatrixTexture4 = 20,
  271. GFXMatrixTexture5 = 21,
  272. GFXMatrixTexture6 = 22,
  273. GFXMatrixTexture7 = 23,
  274. };
  275. enum GFXShaderConstType
  276. {
  277. /// GFX"S"hader"C"onstant"T"ype
  278. // Scalar
  279. GFXSCT_Float,
  280. // Vectors
  281. GFXSCT_Float2,
  282. GFXSCT_Float3,
  283. GFXSCT_Float4,
  284. // Matrices
  285. GFXSCT_Float2x2,
  286. GFXSCT_Float3x3,
  287. GFXSCT_Float3x4,
  288. GFXSCT_Float4x3,
  289. GFXSCT_Float4x4,
  290. // Scalar
  291. GFXSCT_Int,
  292. // Vectors
  293. GFXSCT_Int2,
  294. GFXSCT_Int3,
  295. GFXSCT_Int4,
  296. // Samplers
  297. GFXSCT_Sampler,
  298. GFXSCT_SamplerCube,
  299. GFXSCT_SamplerCubeArray,
  300. GFXSCT_SamplerTextureArray
  301. };
  302. /// Defines a vertex declaration type.
  303. /// @see GFXVertexElement
  304. /// @see GFXVertexFormat
  305. enum GFXDeclType
  306. {
  307. GFXDeclType_FIRST = 0,
  308. /// A single component F32.
  309. GFXDeclType_Float = 0,
  310. /// A two-component F32.
  311. /// @see Point2F
  312. GFXDeclType_Float2,
  313. /// A three-component F32.
  314. /// @see Point3F
  315. GFXDeclType_Float3,
  316. /// A four-component F32.
  317. /// @see Point4F
  318. GFXDeclType_Float4,
  319. /// A four-component, packed, unsigned bytes mapped to 0 to 1 range.
  320. /// @see GFXVertexColor
  321. GFXDeclType_Color,
  322. /// Four-component, packed, unsigned bytes ranged 0-255
  323. GFXDeclType_UByte4,
  324. /// The count of total GFXDeclTypes.
  325. GFXDeclType_COUNT,
  326. };
  327. #endif // _GFXENUMS_H_