gfxEnums.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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. GFXFormatD32FS8X24,
  144. // 128 bit texture formats...
  145. GFXFormatR32G32B32A32F,// first in group...
  146. // unknown size...Block compression
  147. GFXFormatBC1, //dxt1
  148. GFXFormatBC2, //dxt2/3
  149. GFXFormatBC3, //dxt4/5
  150. GFXFormatBC4, //3dc+ / ati1
  151. GFXFormatBC5, //3dc / ati2
  152. // compressed sRGB formats
  153. GFXFormatBC1_SRGB,
  154. GFXFormatBC2_SRGB,
  155. GFXFormatBC3_SRGB,
  156. GFXFormat_COUNT,
  157. GFXFormat_8BIT = GFXFormatA8,
  158. GFXFormat_16BIT = GFXFormatR5G6B5,
  159. GFXFormat_24BIT = GFXFormatR8G8B8,
  160. GFXFormat_32BIT = GFXFormatR8G8B8A8,
  161. GFXFormat_64BIT = GFXFormatR16G16B16A16,
  162. GFXFormat_128BIT = GFXFormatR32G32B32A32F,
  163. GFXFormat_UNKNOWNSIZE = GFXFormatBC1
  164. };
  165. /// Returns the byte size of the pixel for non-compressed formats.
  166. inline U32 GFXFormat_getByteSize( GFXFormat format )
  167. {
  168. AssertFatal( format < GFXFormat_UNKNOWNSIZE,
  169. "GFXDevice::formatByteSize - Cannot size a compressed format!" );
  170. if ( format < GFXFormat_16BIT )
  171. return 1;// 8 bit...
  172. else if ( format < GFXFormat_24BIT )
  173. return 2;// 16 bit...
  174. else if ( format < GFXFormat_32BIT )
  175. return 3;// 24 bit...
  176. else if ( format < GFXFormat_64BIT )
  177. return 4;// 32 bit...
  178. else if ( format < GFXFormat_128BIT )
  179. return 8;// 64 bit...
  180. // This should be 128bits... else its a DDS and
  181. // the assert should have gone off above.
  182. return 16;
  183. }
  184. enum GFXClearFlags
  185. {
  186. GFXClearTarget = 1 << 0,
  187. GFXClearZBuffer = 1 << 1,
  188. GFXClearStencil = 1 << 2,
  189. };
  190. /// The supported blend modes.
  191. enum GFXBlend
  192. {
  193. GFXBlend_FIRST = 0,
  194. GFXBlendZero = 0, /// (0, 0, 0, 0)
  195. GFXBlendOne, /// (1, 1, 1, 1)
  196. GFXBlendSrcColor, /// (Rs, Gs, Bs, As)
  197. GFXBlendInvSrcColor, /// (1 - Rs, 1 - Gs, 1 - Bs, 1 - As)
  198. GFXBlendSrcAlpha, /// (As, As, As, As)
  199. GFXBlendInvSrcAlpha, /// ( 1 - As, 1 - As, 1 - As, 1 - As)
  200. GFXBlendDestAlpha, /// (Ad Ad Ad Ad)
  201. GFXBlendInvDestAlpha, /// (1 - Ad 1 - Ad 1 - Ad 1 - Ad)
  202. GFXBlendDestColor, /// (Rd, Gd, Bd, Ad)
  203. GFXBlendInvDestColor, /// (1 - Rd, 1 - Gd, 1 - Bd, 1 - Ad)
  204. GFXBlendSrcAlphaSat, /// (f, f, f, 1) where f = min(As, 1 - Ad)
  205. GFXBlend_COUNT
  206. };
  207. /// Constants that name each GFXDevice type. Any new GFXDevice subclass must be
  208. /// added to this enum. A string representing its name must also be added to
  209. /// GFXInit::getAdapterNameFromType().
  210. enum GFXAdapterType
  211. {
  212. OpenGL = 0,
  213. Direct3D11,
  214. NullDevice,
  215. GFXAdapterType_Count
  216. };
  217. enum GFXCullMode
  218. {
  219. GFXCull_FIRST = 0,
  220. GFXCullNone = 0,
  221. GFXCullCW,
  222. GFXCullCCW,
  223. GFXCull_COUNT
  224. };
  225. enum GFXCmpFunc
  226. {
  227. GFXCmp_FIRST = 0,
  228. GFXCmpNever = 0,
  229. GFXCmpLess,
  230. GFXCmpEqual,
  231. GFXCmpLessEqual,
  232. GFXCmpGreater,
  233. GFXCmpNotEqual,
  234. GFXCmpGreaterEqual,
  235. GFXCmpAlways,
  236. GFXCmp_COUNT
  237. };
  238. enum GFXStencilOp
  239. {
  240. GFXStencilOp_FIRST = 0,
  241. GFXStencilOpKeep = 0,
  242. GFXStencilOpZero,
  243. GFXStencilOpReplace,
  244. GFXStencilOpIncrSat,
  245. GFXStencilOpDecrSat,
  246. GFXStencilOpInvert,
  247. GFXStencilOpIncr,
  248. GFXStencilOpDecr,
  249. GFXStencilOp_COUNT
  250. };
  251. enum GFXBlendOp
  252. {
  253. GFXBlendOp_FIRST = 0,
  254. GFXBlendOpAdd = 0,
  255. GFXBlendOpSubtract,
  256. GFXBlendOpRevSubtract,
  257. GFXBlendOpMin,
  258. GFXBlendOpMax,
  259. GFXBlendOp_COUNT
  260. };
  261. enum GFXMatrixType
  262. {
  263. GFXMatrixWorld = 256,
  264. GFXMatrixView = 2,
  265. GFXMatrixProjection = 3,
  266. GFXMatrixTexture = 16, // This value is texture matrix for sampler 0, can use this for offset
  267. GFXMatrixTexture0 = 16,
  268. GFXMatrixTexture1 = 17,
  269. GFXMatrixTexture2 = 18,
  270. GFXMatrixTexture3 = 19,
  271. GFXMatrixTexture4 = 20,
  272. GFXMatrixTexture5 = 21,
  273. GFXMatrixTexture6 = 22,
  274. GFXMatrixTexture7 = 23,
  275. };
  276. enum GFXShaderConstType
  277. {
  278. GFXSCT_Uknown,
  279. /// GFX"S"hader"C"onstant"T"ype
  280. GFXSCT_ConstBuffer,
  281. // Scalar
  282. GFXSCT_Float,
  283. // Vectors
  284. GFXSCT_Float2,
  285. GFXSCT_Float3,
  286. GFXSCT_Float4,
  287. // Matrices
  288. GFXSCT_Float2x2,
  289. GFXSCT_Float3x3,
  290. GFXSCT_Float3x4,
  291. GFXSCT_Float4x3,
  292. GFXSCT_Float4x4,
  293. // Scalar
  294. GFXSCT_Int,
  295. // Vectors
  296. GFXSCT_Int2,
  297. GFXSCT_Int3,
  298. GFXSCT_Int4,
  299. // Scalar
  300. GFXSCT_UInt,
  301. // Vectors
  302. GFXSCT_UInt2,
  303. GFXSCT_UInt3,
  304. GFXSCT_UInt4,
  305. // Scalar
  306. GFXSCT_Bool,
  307. // Vectors
  308. GFXSCT_Bool2,
  309. GFXSCT_Bool3,
  310. GFXSCT_Bool4,
  311. // Samplers
  312. GFXSCT_Sampler,
  313. GFXSCT_SamplerCube,
  314. GFXSCT_SamplerCubeArray,
  315. GFXSCT_SamplerTextureArray
  316. };
  317. /// Defines a vertex declaration type.
  318. /// @see GFXVertexElement
  319. /// @see GFXVertexFormat
  320. enum GFXDeclType
  321. {
  322. GFXDeclType_FIRST = 0,
  323. /// A single component F32.
  324. GFXDeclType_Float = 0,
  325. /// A two-component F32.
  326. /// @see Point2F
  327. GFXDeclType_Float2,
  328. /// A three-component F32.
  329. /// @see Point3F
  330. GFXDeclType_Float3,
  331. /// A four-component F32.
  332. /// @see Point4F
  333. GFXDeclType_Float4,
  334. /// A four-component, packed, unsigned bytes mapped to 0 to 1 range.
  335. /// @see GFXVertexColor
  336. GFXDeclType_Color,
  337. /// Four-component, packed, unsigned bytes ranged 0-255
  338. GFXDeclType_UByte4,
  339. /// The count of total GFXDeclTypes.
  340. GFXDeclType_COUNT,
  341. };
  342. #endif // _GFXENUMS_H_