CmCommonEnums.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. #pragma once
  2. #include "CmString.h"
  3. #if defined ( CM_GCC_VISIBILITY )
  4. # pragma GCC visibility push(default)
  5. #endif
  6. #include <utility>
  7. #include <sstream>
  8. #if defined ( CM_GCC_VISIBILITY )
  9. # pragma GCC visibility pop
  10. #endif
  11. namespace BansheeEngine
  12. {
  13. /**
  14. * @brief Factors used when blending new pixels with existing pixels.
  15. */
  16. enum BlendFactor
  17. {
  18. BF_ONE, /**< Use a value of one for all pixel components. */
  19. BF_ZERO, /**< Use a value of zero for all pixel components. */
  20. BF_DEST_COLOR, /**< Use the existing pixel value. */
  21. BF_SOURCE_COLOR, /**< Use the newly generated pixel value. */
  22. BF_INV_DEST_COLOR, /**< Use the inverse of the existing value. */
  23. BF_INV_SOURCE_COLOR, /**< Use the inverse of the newly generated pixel value. */
  24. BF_DEST_ALPHA, /**< Use the existing alpha value. */
  25. BF_SOURCE_ALPHA, /**< Use the newly generated alpha value. */
  26. BF_INV_DEST_ALPHA, /**< Use the inverse of the existing alpha value. */
  27. BF_INV_SOURCE_ALPHA /**< Use the inverse of the newly generated alpha value. */
  28. };
  29. /**
  30. * @brief Operations that determines how are blending factors combined.
  31. */
  32. enum BlendOperation
  33. {
  34. BO_ADD, /**< Blend factors are added together. */
  35. BO_SUBTRACT, /**< Blend factors are subtracted in "srcFactor - dstFactor" order. */
  36. BO_REVERSE_SUBTRACT, /**< Blend factors are subtracted in "dstFactor - srcFactor" order. */
  37. BO_MIN, /**< Minimum of the two factors is chosen. */
  38. BO_MAX /**< Maximum of the two factors is chosen. */
  39. };
  40. /**
  41. * @brief Comparison functions used for the depth/stencil buffer.
  42. */
  43. enum CompareFunction
  44. {
  45. CMPF_ALWAYS_FAIL, /**< Operation will always fail. */
  46. CMPF_ALWAYS_PASS, /**< Operation will always pass. */
  47. CMPF_LESS, /**< Operation will pass if the new value is less than existing value. */
  48. CMPF_LESS_EQUAL, /**< Operation will pass if the new value is less or equal than existing value. */
  49. CMPF_EQUAL, /**< Operation will pass if the new value is equal to the existing value. */
  50. CMPF_NOT_EQUAL, /**< Operation will pass if the new value is not equal to the existing value. */
  51. CMPF_GREATER_EQUAL, /**< Operation will pass if the new value greater or equal than the existing value. */
  52. CMPF_GREATER /**< Operation will pass if the new value greater than the existing value. */
  53. };
  54. /**
  55. * @brief Types of texture addressing modes that determine what happens when texture
  56. * coordinates are outside of the valid range.
  57. */
  58. enum TextureAddressingMode
  59. {
  60. TAM_WRAP, /**< Coordinates wrap back to the valid range. */
  61. TAM_MIRROR, /**< Coordinates flip every time the size of the valid range is passed. */
  62. TAM_CLAMP, /**< Coordinates are clamped within the valid range. */
  63. TAM_BORDER /**< Coordinates outside of the valid range will return a separately set border color. */
  64. };
  65. /**
  66. * @brief Types of available filtering situations.
  67. */
  68. enum FilterType
  69. {
  70. FT_MIN, /**< The filter used when shrinking a texture. */
  71. FT_MAG, /**< The filter used when magnifying a texture. */
  72. FT_MIP /**< The filter used when filtering between mipmaps. */
  73. };
  74. /**
  75. * @brief Filtering options for textures.
  76. */
  77. enum FilterOptions
  78. {
  79. FO_NONE = 0, /**< Use no filtering. Only relevant for mipmap filtering. */
  80. FO_POINT = 1, /**< Filter using the nearest found pixel. Most basic filtering. */
  81. FO_LINEAR = 2, /**< Average a 2x2 pixel area, signifies bilinear filtering for texture, trilinear for mipmaps. */
  82. FO_ANISOTROPIC = 3, /**< More advanced filtering that improves quality when viewing textures at a steep angle */
  83. FO_USE_COMPARISON = 4 /**< Specifies that the sampled values will be compared against existing sampled data. Should be OR-ed with other filtering options. */
  84. };
  85. /**
  86. * @brief Types of frame buffers.
  87. */
  88. enum FrameBufferType
  89. {
  90. FBT_COLOR = 0x1,
  91. FBT_DEPTH = 0x2,
  92. FBT_STENCIL = 0x4
  93. };
  94. /**
  95. * @brief Types of culling that determine how (and if) hardware discards faces with certain
  96. * winding order. Winding order can be used for determining front or back facing polygons by
  97. * checking the order of its vertices from the render perspective.
  98. */
  99. enum CullingMode
  100. {
  101. CULL_NONE = 1, /**< Hardware performs no culling and renders both sides. */
  102. CULL_CLOCKWISE = 2, /**< Hardware culls faces that have a clockwise vertex ordering. */
  103. CULL_COUNTERCLOCKWISE = 3 /**< Hardware culls faces that have a counter-clockwise vertex ordering. */
  104. };
  105. /**
  106. * @brief Polygon mode to use when rasterizing.
  107. */
  108. enum PolygonMode
  109. {
  110. PM_WIREFRAME = 1, /**< Render as wireframe showing only polygon outlines. */
  111. PM_SOLID = 2 /**< Render as solid showing whole polygons. */
  112. };
  113. /**
  114. * @brief Types of action that can happen on the stencil buffer.
  115. */
  116. enum StencilOperation
  117. {
  118. SOP_KEEP, /**< Leave the stencil buffer unchanged. */
  119. SOP_ZERO, /**< Set the stencil value to zero. */
  120. SOP_REPLACE, /**< Replace the stencil value with the reference value. */
  121. SOP_INCREMENT, /**< Increase the stencil value by 1, clamping at the maximum value. */
  122. SOP_DECREMENT, /**< Decrease the stencil value by 1, clamping at 0. */
  123. SOP_INCREMENT_WRAP, /**< Increase the stencil value by 1, wrapping back to 0 when incrementing past the maximum value. */
  124. SOP_DECREMENT_WRAP, /**< Decrease the stencil value by 1, wrapping when decrementing 0. */
  125. SOP_INVERT /**< Invert the bits of the stencil buffer. */
  126. };
  127. /**
  128. * @brief These values represent a hint to the driver when locking a hardware buffer.
  129. *
  130. * GBL_WRITE_ONLY - Allows you to write to the buffer. Can cause a CPU-GPU sync point
  131. * so avoid using it often (i.e. every frame) as that might limit your performance significantly.
  132. * GBL_WRITE_ONLY_DISCARD - Allows you to write to the buffer. Tells the driver to completely discard the contents of the
  133. * buffer you are writing to. The driver will (most likely) internally allocate another buffer with same specifications
  134. * (which is fairly fast) and you will avoid CPU-GPU stalls.
  135. * GBL_WRITE_ONLY_NO_OVERWRITE - Allows you to write to the buffer. Guarantees the driver that you will not be updating any part of
  136. * the buffer that is currently used. This will also avoid CPU-GPU stalls, without requiring you to discard the entire buffer. However
  137. * it is hard to guarantee when GPU has finished using a buffer.
  138. * GBL_READ_ONLY - Allows you to read from a buffer. Be aware that reading is usually a very slow operation.
  139. * GBL_READ_WRITE - Allows you to both read and write to a buffer.
  140. */
  141. enum GpuLockOptions
  142. {
  143. GBL_READ_WRITE,
  144. GBL_WRITE_ONLY_DISCARD,
  145. GBL_READ_ONLY,
  146. GBL_WRITE_ONLY_NO_OVERWRITE,
  147. GBL_WRITE_ONLY
  148. };
  149. /**
  150. * @brief Values that represent hardware buffer usage. These usually determine in what
  151. * type of memory is buffer placed in, however that depends on rendering API.
  152. *
  153. * GBU_STATIC - Signifies that you don't plan on modifying the buffer often (or at all)
  154. * after creation. Modifying such buffer will involve a larger performance hit.
  155. * GBU_DYNAMIC - Signifies that you will modify this buffer fairly often.
  156. */
  157. enum GpuBufferUsage
  158. {
  159. GBU_STATIC = 1,
  160. GBU_DYNAMIC = 2
  161. };
  162. /**
  163. * @brief Types of generic GPU buffers that may be attached to GPU programs.
  164. *
  165. * GBT_STRUCTURED - Buffer containing an array of structures. Structure parameters
  166. * can usually be easily accessed from within the GPU program.
  167. * GBT_RAW - Buffer containing raw bytes. It is up to the user to interpret the data.
  168. * GBT_INDIRECTARGUMENT - Special type of buffer allowing you to specify arguments for
  169. * draw operations inside the buffer instead of providing them directly. Useful when you want
  170. * to control drawing directly from GPU.
  171. * GBT_APPENDCONSUME - A stack-like buffer that allows you to add or remove elements to/from the buffer
  172. * from within the GPU program.
  173. */
  174. enum GpuBufferType
  175. {
  176. GBT_STRUCTURED,
  177. GBT_RAW,
  178. GBT_INDIRECTARGUMENT,
  179. GBT_APPENDCONSUME
  180. };
  181. /**
  182. * @brief Different types of GPU views that control how GPU sees a hardware buffer.
  183. *
  184. * GVU_DEFAULT - Buffer is seen as a default shader resource, used primarily for reading. (e.g. a texture for sampling)
  185. * GVU_RENDERTARGET - Buffer is seen as a render target that color pixels will be written to after pixel shader stage.
  186. * GVU_DEPTHSTENCIL - Buffer is seen as a depth stencil target that depth and stencil information is written to.
  187. * GVU_RANDOMWRITE - Buffer that allows you to write to any part of it from within a GPU program.
  188. */
  189. enum GpuViewUsage
  190. {
  191. GVU_DEFAULT = 0x01,
  192. GVU_RENDERTARGET = 0x02,
  193. GVU_DEPTHSTENCIL = 0x04,
  194. GVU_RANDOMWRITE = 0x08
  195. };
  196. /**
  197. * @brief Type of parameter block usages. Signifies how often will parameter blocks be changed.
  198. *
  199. * GPBU_STATIC - Buffer will be rarely, if ever, updated.
  200. * GPBU_DYNAMIC - Buffer will be updated often (e.g. every frame).
  201. */
  202. enum GpuParamBlockUsage
  203. {
  204. GPBU_STATIC,
  205. GPBU_DYNAMIC
  206. };
  207. /**
  208. * @brief Type of GPU parameter.
  209. *
  210. * GPT_DATA - Raw data type like float, Vector3, Color, etc.
  211. * GPT_OBJECT - Reference to some GPU object like Texture, Sampler, etc.
  212. */
  213. enum GpuParamType
  214. {
  215. GPT_DATA,
  216. GPT_OBJECT
  217. };
  218. /**
  219. * @brief Type of GPU data parameters that can be used as inputs to a GPU program.
  220. */
  221. enum GpuParamDataType
  222. {
  223. GPDT_FLOAT1 = 1,
  224. GPDT_FLOAT2 = 2,
  225. GPDT_FLOAT3 = 3,
  226. GPDT_FLOAT4 = 4,
  227. GPDT_MATRIX_2X2 = 11,
  228. GPDT_MATRIX_2X3 = 12,
  229. GPDT_MATRIX_2X4 = 13,
  230. GPDT_MATRIX_3X2 = 14,
  231. GPDT_MATRIX_3X3 = 15,
  232. GPDT_MATRIX_3X4 = 16,
  233. GPDT_MATRIX_4X2 = 17,
  234. GPDT_MATRIX_4X3 = 18,
  235. GPDT_MATRIX_4X4 = 19,
  236. GPDT_INT1 = 20,
  237. GPDT_INT2 = 21,
  238. GPDT_INT3 = 22,
  239. GPDT_INT4 = 23,
  240. GPDT_BOOL = 24,
  241. GPDT_STRUCT = 25,
  242. GPDT_UNKNOWN = 0xffff
  243. };
  244. /**
  245. * @brief Type of GPU object parameters that can be used as inputs to a GPU program.
  246. */
  247. enum GpuParamObjectType
  248. {
  249. GPOT_SAMPLER1D = 1,
  250. GPOT_SAMPLER2D = 2,
  251. GPOT_SAMPLER3D = 3,
  252. GPOT_SAMPLERCUBE = 4,
  253. GPOT_TEXTURE1D = 11,
  254. GPOT_TEXTURE2D = 12,
  255. GPOT_TEXTURE3D = 13,
  256. GPOT_TEXTURECUBE = 14,
  257. GPOT_RWTEXTURE1D = 21,
  258. GPOT_RWTEXTURE2D = 22,
  259. GPOT_RWTEXTURE3D = 23,
  260. GPOT_BYTE_BUFFER = 32,
  261. GPOT_STRUCTURED_BUFFER = 33,
  262. GPOT_RWTYPED_BUFFER = 41,
  263. GPOT_RWBYTE_BUFFER = 42,
  264. GPOT_RWSTRUCTURED_BUFFER = 43,
  265. GPOT_RWSTRUCTURED_BUFFER_WITH_COUNTER = 44,
  266. GPOT_RWAPPEND_BUFFER = 45,
  267. GPOT_RWCONSUME_BUFFER = 46,
  268. GPOT_UNKNOWN = 0xffff
  269. };
  270. /**
  271. * @brief These values represent a hint to the driver when writing
  272. * to a GPU buffer.
  273. *
  274. * Normal - Default flag with least restrictions. Can cause a CPU-GPU sync point
  275. * so avoid using it often (i.e. every frame) as that might limit your performance significantly.
  276. * Discard - Tells the driver to completely discard the contents of the buffer you are writing
  277. * to. The driver will (most likely) internally allocate another buffer with same specifications (which is fairly fast)
  278. * and you will avoid CPU-GPU stalls.
  279. * NoOverwrite - Guarantees the driver that you will not be updating any part of the buffer that is currently used.
  280. * This will also avoid CPU-GPU stalls, without requiring you to discard the entire buffer. However it is hard to
  281. * guarantee when GPU has finished using a buffer.
  282. */
  283. enum class BufferWriteType
  284. {
  285. Normal,
  286. Discard,
  287. NoOverwrite
  288. };
  289. /**
  290. * @brief Texture addressing mode, per component.
  291. */
  292. struct UVWAddressingMode
  293. {
  294. UVWAddressingMode()
  295. :u(TAM_WRAP), v(TAM_WRAP), w(TAM_WRAP)
  296. { }
  297. TextureAddressingMode u, v, w;
  298. };
  299. typedef Map<String, String> NameValuePairList;
  300. }