BsASTFX.h 4.9 KB

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