shader_compiler.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*************************************************************************/
  2. /* shader_compiler.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
  9. /* */
  10. /* Permission is hereby granted, free of charge, to any person obtaining */
  11. /* a copy of this software and associated documentation files (the */
  12. /* "Software"), to deal in the Software without restriction, including */
  13. /* without limitation the rights to use, copy, modify, merge, publish, */
  14. /* distribute, sublicense, and/or sell copies of the Software, and to */
  15. /* permit persons to whom the Software is furnished to do so, subject to */
  16. /* the following conditions: */
  17. /* */
  18. /* The above copyright notice and this permission notice shall be */
  19. /* included in all copies or substantial portions of the Software. */
  20. /* */
  21. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  22. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  23. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  24. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  25. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  26. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  27. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  28. /*************************************************************************/
  29. #ifndef SHADER_COMPILER_H
  30. #define SHADER_COMPILER_H
  31. #include "map.h"
  32. #include "list.h"
  33. #include "vector.h"
  34. #if 0
  35. class ShaderSyntax {
  36. public:
  37. enum DataType {
  38. TYPE_BOOL,
  39. TYPE_FLOAT,
  40. TYPE_VEC3,
  41. TYPE_TRANSFORM,
  42. TYPE_TEXTURE
  43. };
  44. enum Operator {
  45. OP_ASSIGN,
  46. OP_ADD,
  47. OP_SUB,
  48. OP_MUL,
  49. OP_DIV,
  50. OP_NEG,
  51. OP_CMP_EQ,
  52. OP_CMP_NEQ,
  53. OP_CMP_LEQ,
  54. OP_CMP_GEQ,
  55. OP_CMP_OR,
  56. OP_CMP_AND,
  57. OP_CALL
  58. };
  59. struct Node {
  60. enum Type {
  61. TYPE_PROGRAM,
  62. TYPE_FUNCTION,
  63. TYPE_BLOCK,
  64. TYPE_VARIABLE,
  65. TYPE_OPERATOR,
  66. TYPE_IF,
  67. };
  68. Node * parent;
  69. Type type;
  70. virtual ~Node() {}
  71. };
  72. struct OperatorNode : public Node {
  73. Operator op;
  74. Vector<Node*> arguments;
  75. OperatorNode() { type=TYPE_OPERATOR; }
  76. };
  77. struct VariableNode : public Node {
  78. StringName variable;
  79. VariableNode() { type=TYPE_VARIABLE; }
  80. };
  81. struct BlockNode : public Node {
  82. Map<StringName,DataType> variables;
  83. List<Node*> subnodes;
  84. BlockNode() { type=TYPE_BLOCK; }
  85. };
  86. struct ConditionalNode : public Node {
  87. Node *test;
  88. Node *do_if;
  89. Node *do_else;
  90. ConditionalNode() { type=TYPE_CONDITIONAL; }
  91. };
  92. struct FunctionNode : public Node {
  93. struct Argument {
  94. StringName name;
  95. DataType type;
  96. };
  97. Vector<Argument> arguments;
  98. Node *body;
  99. FunctionNode() { type=TYPE_FUNCTION; }
  100. };
  101. struct ProgramNode : public Node {
  102. Vector<FunctionNode*> functions;
  103. Node *body;
  104. ProgramNode() { type=TYPE_PROGRAM; }
  105. };
  106. ShaderCompiler();
  107. };
  108. #endif // SHADER_COMPILER_H
  109. #endif