BsASTFX.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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_Parameters,
  102. OT_Blocks,
  103. OT_Parameter,
  104. OT_Block,
  105. OT_SamplerState,
  106. OT_Code,
  107. OT_StencilRef
  108. };
  109. enum tagOptionDataType
  110. {
  111. ODT_Int,
  112. ODT_Float,
  113. ODT_Bool,
  114. ODT_String,
  115. ODT_Complex,
  116. ODT_Matrix
  117. };
  118. enum tagParamType
  119. {
  120. PT_Float, PT_Float2, PT_Float3, PT_Float4, PT_Color,
  121. PT_Mat2x2, PT_Mat2x3, PT_Mat2x4,
  122. PT_Mat3x2, PT_Mat3x3, PT_Mat3x4,
  123. PT_Mat4x2, PT_Mat4x3, PT_Mat4x4,
  124. PT_Sampler1D, PT_Sampler2D, PT_Sampler3D, PT_SamplerCUBE, PT_Sampler2DMS,
  125. PT_Texture1D, PT_Texture2D, PT_Texture3D, PT_TextureCUBE, PT_Texture2DMS,
  126. PT_ByteBuffer, PT_StructBuffer, PT_ByteBufferRW, PT_StructBufferRW,
  127. PT_TypedBufferRW, PT_AppendBuffer, PT_ConsumeBuffer,
  128. PT_Count // Keep at end
  129. };
  130. enum tagFillModeValue
  131. {
  132. FMV_Wire, FMV_Solid
  133. };
  134. enum tagCullModeValue
  135. {
  136. CMV_None, CMV_CW, CMV_CCW
  137. };
  138. enum tagCompFuncValue
  139. {
  140. CFV_Fail, CFV_Pass, CFV_LT, CFV_LTE,
  141. CFV_EQ, CFV_NEQ, CFV_GTE, CFV_GT
  142. };
  143. enum tagOpValue
  144. {
  145. OV_Keep, OV_Zero, OV_Replace, OV_Incr, OV_Decr,
  146. OV_IncrWrap, OV_DecrWrap, OV_Invert, OV_One, OV_DestColor,
  147. OV_SrcColor, OV_InvDestColor, OV_InvSrcColor, OV_DestAlpha,
  148. OV_SrcAlpha, OV_InvDestAlpha, OV_InvSrcAlpha
  149. };
  150. enum tagBlendOpValue
  151. {
  152. BOV_Add, BOV_Subtract, BOV_RevSubtract,
  153. BOV_Min, BOV_Max
  154. };
  155. enum tagAddrModeValue
  156. {
  157. AMV_Wrap, AMV_Mirror, AMV_Clamp, AMV_Border
  158. };
  159. enum tagFilterValue
  160. {
  161. FV_None, FV_Point, FV_Linear, FV_Anisotropic,
  162. FV_PointCmp, FV_LinearCmp, FV_AnisotropicCmp
  163. };
  164. enum tagBufferUsageValue
  165. {
  166. BUV_Static, BUV_Dynamic
  167. };
  168. struct tagNodeLink
  169. {
  170. ASTFXNode* node;
  171. NodeLink* next;
  172. };
  173. struct tagParseState
  174. {
  175. ASTFXNode* rootNode;
  176. ASTFXNode* topNode;
  177. void* memContext;
  178. int hasError;
  179. int errorLine;
  180. int errorColumn;
  181. const char* errorMessage;
  182. NodeLink* nodeStack;
  183. };
  184. struct tagOptionInfo
  185. {
  186. OptionType type;
  187. OptionDataType dataType;
  188. };
  189. union tagOptionData
  190. {
  191. int intValue;
  192. float floatValue;
  193. const char* strValue;
  194. float matrixValue[16];
  195. ASTFXNode* nodePtr;
  196. };
  197. struct tagNodeOption
  198. {
  199. OptionType type;
  200. OptionData value;
  201. };
  202. struct tagNodeOptions
  203. {
  204. NodeOption* entries;
  205. int count;
  206. int bufferSize;
  207. };
  208. struct tagASTFXNode
  209. {
  210. NodeType type;
  211. NodeOptions* options;
  212. };
  213. OptionInfo OPTION_LOOKUP[];
  214. NodeOptions* nodeOptionsCreate(void* context);
  215. void nodeOptionDelete(NodeOption* option);
  216. void nodeOptionsDelete(NodeOptions* options);
  217. void nodeOptionsResize(void* context, NodeOptions* options, int size);
  218. void nodeOptionsGrowIfNeeded(void* context, NodeOptions* options);
  219. void nodeOptionsAdd(void* context, NodeOptions* options, const NodeOption* option);
  220. ASTFXNode* nodeCreate(void* context, NodeType type);
  221. void nodeDelete(ASTFXNode* node);
  222. void nodePush(ParseState* parseState, ASTFXNode* node);
  223. void nodePop(ParseState* parseState);
  224. ParseState* parseStateCreate();
  225. void parseStateDelete(ParseState* parseState);
  226. #endif