BsASTFX.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #ifndef __ASTFX_H__
  4. #define __ASTFX_H__
  5. #include <stdlib.h>
  6. #include <string.h>
  7. typedef enum tagNodeType NodeType;
  8. typedef enum tagOptionType OptionType;
  9. typedef enum tagOptionDataType OptionDataType;
  10. typedef enum tagParamType ParamType;
  11. typedef struct tagParseState ParseState;
  12. typedef struct tagOptionInfo OptionInfo;
  13. typedef union tagOptionData OptionData;
  14. typedef struct tagNodeOptions NodeOptions;
  15. typedef struct tagNodeOption NodeOption;
  16. typedef struct tagASTFXNode ASTFXNode;
  17. typedef struct tagNodeLink NodeLink;
  18. typedef enum tagFillModeValue FillModeValue;
  19. typedef enum tagCullModeValue CullModeValue;
  20. typedef enum tagCompFuncValue CompFuncValue;
  21. typedef enum tagOpValue OpValue;
  22. typedef enum tagBlendOpValue BlendOpValue;
  23. typedef enum tagAddrModeValue AddrModeValue;
  24. typedef enum tagFilterValue FilterValue;
  25. typedef enum tagBufferUsageValue BufferUsageValue;
  26. enum tagNodeType
  27. {
  28. NT_Shader,
  29. NT_Technique,
  30. NT_Parameters,
  31. NT_Blocks,
  32. NT_Pass,
  33. NT_StencilOp,
  34. NT_Target,
  35. NT_BlendDef,
  36. NT_SamplerState,
  37. NT_AddrMode,
  38. NT_Parameter,
  39. NT_Block,
  40. NT_Code
  41. };
  42. enum tagOptionType
  43. {
  44. OT_None = 0,
  45. OT_Separable,
  46. OT_Priority,
  47. OT_Queue,
  48. OT_Transparent,
  49. OT_Technique,
  50. OT_Renderer,
  51. OT_Language,
  52. OT_Include,
  53. OT_Pass,
  54. OT_FillMode,
  55. OT_CullMode,
  56. OT_DepthBias,
  57. OT_SDepthBias,
  58. OT_DepthClip,
  59. OT_Scissor,
  60. OT_Multisample,
  61. OT_AALine,
  62. OT_DepthRead,
  63. OT_DepthWrite,
  64. OT_CompareFunc,
  65. OT_Stencil,
  66. OT_StencilReadMask,
  67. OT_StencilWriteMask,
  68. OT_StencilOpFront,
  69. OT_StencilOpBack,
  70. OT_PassOp,
  71. OT_Fail,
  72. OT_ZFail,
  73. OT_AlphaToCoverage,
  74. OT_IndependantBlend,
  75. OT_Target,
  76. OT_Index,
  77. OT_Blend,
  78. OT_Color,
  79. OT_Alpha,
  80. OT_WriteMask,
  81. OT_Source,
  82. OT_Dest,
  83. OT_Op,
  84. OT_AddrMode,
  85. OT_MinFilter,
  86. OT_MagFilter,
  87. OT_MipFilter,
  88. OT_MaxAniso,
  89. OT_MipBias,
  90. OT_MipMin,
  91. OT_MipMax,
  92. OT_BorderColor,
  93. OT_U,
  94. OT_V,
  95. OT_W,
  96. OT_Alias,
  97. OT_Auto,
  98. OT_Shared,
  99. OT_Usage,
  100. OT_ParamType,
  101. OT_Identifier,
  102. OT_ParamValue,
  103. OT_ParamStrValue,
  104. OT_Parameters,
  105. OT_Blocks,
  106. OT_Parameter,
  107. OT_Block,
  108. OT_SamplerState,
  109. OT_Code,
  110. OT_StencilRef
  111. };
  112. enum tagOptionDataType
  113. {
  114. ODT_Int,
  115. ODT_Float,
  116. ODT_Bool,
  117. ODT_String,
  118. ODT_Complex,
  119. ODT_Matrix
  120. };
  121. enum tagParamType
  122. {
  123. PT_Float, PT_Float2, PT_Float3, PT_Float4,
  124. PT_Int, PT_Int2, PT_Int3, PT_Int4, PT_Color,
  125. PT_Mat2x2, PT_Mat2x3, PT_Mat2x4,
  126. PT_Mat3x2, PT_Mat3x3, PT_Mat3x4,
  127. PT_Mat4x2, PT_Mat4x3, PT_Mat4x4,
  128. PT_Sampler1D, PT_Sampler2D, PT_Sampler3D, PT_SamplerCUBE, PT_Sampler2DMS,
  129. PT_Texture1D, PT_Texture2D, PT_Texture3D, PT_TextureCUBE, PT_Texture2DMS,
  130. PT_ByteBuffer, PT_StructBuffer, PT_ByteBufferRW, PT_StructBufferRW,
  131. PT_TypedBufferRW, PT_AppendBuffer, PT_ConsumeBuffer,
  132. PT_Count // Keep at end
  133. };
  134. enum tagFillModeValue
  135. {
  136. FMV_Wire, FMV_Solid
  137. };
  138. enum tagCullModeValue
  139. {
  140. CMV_None, CMV_CW, CMV_CCW
  141. };
  142. enum tagCompFuncValue
  143. {
  144. CFV_Fail, CFV_Pass, CFV_LT, CFV_LTE,
  145. CFV_EQ, CFV_NEQ, CFV_GTE, CFV_GT
  146. };
  147. enum tagOpValue
  148. {
  149. OV_Keep, OV_Zero, OV_Replace, OV_Incr, OV_Decr,
  150. OV_IncrWrap, OV_DecrWrap, OV_Invert, OV_One, OV_DestColor,
  151. OV_SrcColor, OV_InvDestColor, OV_InvSrcColor, OV_DestAlpha,
  152. OV_SrcAlpha, OV_InvDestAlpha, OV_InvSrcAlpha
  153. };
  154. enum tagBlendOpValue
  155. {
  156. BOV_Add, BOV_Subtract, BOV_RevSubtract,
  157. BOV_Min, BOV_Max
  158. };
  159. enum tagAddrModeValue
  160. {
  161. AMV_Wrap, AMV_Mirror, AMV_Clamp, AMV_Border
  162. };
  163. enum tagFilterValue
  164. {
  165. FV_None, FV_Point, FV_Linear, FV_Anisotropic,
  166. FV_PointCmp, FV_LinearCmp, FV_AnisotropicCmp
  167. };
  168. enum tagBufferUsageValue
  169. {
  170. BUV_Static, BUV_Dynamic
  171. };
  172. struct tagNodeLink
  173. {
  174. ASTFXNode* node;
  175. NodeLink* next;
  176. };
  177. struct tagParseState
  178. {
  179. ASTFXNode* rootNode;
  180. ASTFXNode* topNode;
  181. void* memContext;
  182. int hasError;
  183. int errorLine;
  184. int errorColumn;
  185. const char* errorMessage;
  186. NodeLink* nodeStack;
  187. };
  188. struct tagOptionInfo
  189. {
  190. OptionType type;
  191. OptionDataType dataType;
  192. };
  193. union tagOptionData
  194. {
  195. int intValue;
  196. float floatValue;
  197. const char* strValue;
  198. float matrixValue[16];
  199. int intVectorValue[4];
  200. ASTFXNode* nodePtr;
  201. };
  202. struct tagNodeOption
  203. {
  204. OptionType type;
  205. OptionData value;
  206. };
  207. struct tagNodeOptions
  208. {
  209. NodeOption* entries;
  210. int count;
  211. int bufferSize;
  212. };
  213. struct tagASTFXNode
  214. {
  215. NodeType type;
  216. NodeOptions* options;
  217. };
  218. OptionInfo OPTION_LOOKUP[];
  219. NodeOptions* nodeOptionsCreate(void* context);
  220. void nodeOptionDelete(NodeOption* option);
  221. void nodeOptionsDelete(NodeOptions* options);
  222. void nodeOptionsResize(void* context, NodeOptions* options, int size);
  223. void nodeOptionsGrowIfNeeded(void* context, NodeOptions* options);
  224. void nodeOptionsAdd(void* context, NodeOptions* options, const NodeOption* option);
  225. ASTFXNode* nodeCreate(void* context, NodeType type);
  226. void nodeDelete(ASTFXNode* node);
  227. void nodePush(ParseState* parseState, ASTFXNode* node);
  228. void nodePop(ParseState* parseState);
  229. ParseState* parseStateCreate();
  230. void parseStateDelete(ParseState* parseState);
  231. #endif