BsASTFX.h 4.6 KB

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