Debian Codegraph @

servers/rendering/shader_language.h

raw symbols SCIP
1 /**************************************************************************/
2 /* shader_language.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "core/object/script_language.h"
34 #include "core/string/string_name.h"
35 #include "core/string/ustring.h"
36 #include "core/templates/list.h"
37 #include "core/templates/rb_map.h"
38 #include "core/templates/safe_refcount.h"
39 #include "core/typedefs.h"
40 #include "core/variant/variant.h"
41 #include "scene/resources/shader_include.h"
42
43 #ifdef DEBUG_ENABLED
44 #include "shader_warnings.h"
45 #endif // DEBUG_ENABLED
46
47 class ShaderLanguage {
48 public:
49 struct TkPos {
50 int char_idx;
51 int tk_line;
52 };
53
54 enum TokenType {
55 TK_EMPTY,
56 TK_IDENTIFIER,
57 TK_TRUE,
58 TK_FALSE,
59 TK_FLOAT_CONSTANT,
60 TK_INT_CONSTANT,
61 TK_UINT_CONSTANT,
62 TK_STRING_CONSTANT,
63 TK_TYPE_VOID,
64 TK_TYPE_BOOL,
65 TK_TYPE_BVEC2,
66 TK_TYPE_BVEC3,
67 TK_TYPE_BVEC4,
68 TK_TYPE_INT,
69 TK_TYPE_IVEC2,
70 TK_TYPE_IVEC3,
71 TK_TYPE_IVEC4,
72 TK_TYPE_UINT,
73 TK_TYPE_UVEC2,
74 TK_TYPE_UVEC3,
75 TK_TYPE_UVEC4,
76 TK_TYPE_FLOAT,
77 TK_TYPE_VEC2,
78 TK_TYPE_VEC3,
79 TK_TYPE_VEC4,
80 TK_TYPE_MAT2,
81 TK_TYPE_MAT3,
82 TK_TYPE_MAT4,
83 TK_TYPE_SAMPLER2D,
84 TK_TYPE_ISAMPLER2D,
85 TK_TYPE_USAMPLER2D,
86 TK_TYPE_SAMPLER2DARRAY,
87 TK_TYPE_ISAMPLER2DARRAY,
88 TK_TYPE_USAMPLER2DARRAY,
89 TK_TYPE_SAMPLER3D,
90 TK_TYPE_ISAMPLER3D,
91 TK_TYPE_USAMPLER3D,
92 TK_TYPE_SAMPLERCUBE,
93 TK_TYPE_SAMPLERCUBEARRAY,
94 TK_TYPE_SAMPLEREXT,
95 TK_INTERPOLATION_FLAT,
96 TK_INTERPOLATION_SMOOTH,
97 TK_CONST,
98 TK_STRUCT,
99 TK_PRECISION_LOW,
100 TK_PRECISION_MID,
101 TK_PRECISION_HIGH,
102 TK_OP_EQUAL,
103 TK_OP_NOT_EQUAL,
104 TK_OP_LESS,
105 TK_OP_LESS_EQUAL,
106 TK_OP_GREATER,
107 TK_OP_GREATER_EQUAL,
108 TK_OP_AND,
109 TK_OP_OR,
110 TK_OP_NOT,
111 TK_OP_ADD,
112 TK_OP_SUB,
113 TK_OP_MUL,
114 TK_OP_DIV,
115 TK_OP_MOD,
116 TK_OP_SHIFT_LEFT,
117 TK_OP_SHIFT_RIGHT,
118 TK_OP_ASSIGN,
119 TK_OP_ASSIGN_ADD,
120 TK_OP_ASSIGN_SUB,
121 TK_OP_ASSIGN_MUL,
122 TK_OP_ASSIGN_DIV,
123 TK_OP_ASSIGN_MOD,
124 TK_OP_ASSIGN_SHIFT_LEFT,
125 TK_OP_ASSIGN_SHIFT_RIGHT,
126 TK_OP_ASSIGN_BIT_AND,
127 TK_OP_ASSIGN_BIT_OR,
128 TK_OP_ASSIGN_BIT_XOR,
129 TK_OP_BIT_AND,
130 TK_OP_BIT_OR,
131 TK_OP_BIT_XOR,
132 TK_OP_BIT_INVERT,
133 TK_OP_INCREMENT,
134 TK_OP_DECREMENT,
135 TK_CF_IF,
136 TK_CF_ELSE,
137 TK_CF_FOR,
138 TK_CF_WHILE,
139 TK_CF_DO,
140 TK_CF_SWITCH,
141 TK_CF_CASE,
142 TK_CF_DEFAULT,
143 TK_CF_BREAK,
144 TK_CF_CONTINUE,
145 TK_CF_RETURN,
146 TK_CF_DISCARD,
147 TK_BRACKET_OPEN,
148 TK_BRACKET_CLOSE,
149 TK_CURLY_BRACKET_OPEN,
150 TK_CURLY_BRACKET_CLOSE,
151 TK_PARENTHESIS_OPEN,
152 TK_PARENTHESIS_CLOSE,
153 TK_QUESTION,
154 TK_COMMA,
155 TK_COLON,
156 TK_SEMICOLON,
157 TK_PERIOD,
158 TK_UNIFORM,
159 TK_UNIFORM_GROUP,
160 TK_INSTANCE,
161 TK_GLOBAL,
162 TK_VARYING,
163 TK_ARG_IN,
164 TK_ARG_OUT,
165 TK_ARG_INOUT,
166 TK_RENDER_MODE,
167 TK_STENCIL_MODE,
168 TK_HINT_DEFAULT_WHITE_TEXTURE,
169 TK_HINT_DEFAULT_BLACK_TEXTURE,
170 TK_HINT_DEFAULT_TRANSPARENT_TEXTURE,
171 TK_HINT_NORMAL_TEXTURE,
172 TK_HINT_ROUGHNESS_NORMAL_TEXTURE,
173 TK_HINT_ROUGHNESS_R,
174 TK_HINT_ROUGHNESS_G,
175 TK_HINT_ROUGHNESS_B,
176 TK_HINT_ROUGHNESS_A,
177 TK_HINT_ROUGHNESS_GRAY,
178 TK_HINT_ANISOTROPY_TEXTURE,
179 TK_HINT_SOURCE_COLOR,
180 TK_HINT_COLOR_CONVERSION_DISABLED,
181 TK_HINT_RANGE,
182 TK_HINT_ENUM,
183 TK_HINT_INSTANCE_INDEX,
184 TK_HINT_SCREEN_TEXTURE,
185 TK_HINT_NORMAL_ROUGHNESS_TEXTURE,
186 TK_HINT_DEPTH_TEXTURE,
187 TK_FILTER_NEAREST,
188 TK_FILTER_LINEAR,
189 TK_FILTER_NEAREST_MIPMAP,
190 TK_FILTER_LINEAR_MIPMAP,
191 TK_FILTER_NEAREST_MIPMAP_ANISOTROPIC,
192 TK_FILTER_LINEAR_MIPMAP_ANISOTROPIC,
193 TK_REPEAT_ENABLE,
194 TK_REPEAT_DISABLE,
195 TK_SHADER_TYPE,
196 TK_CURSOR,
197 TK_ERROR,
198 TK_EOF,
199 TK_MAX
200 };
201
202 /* COMPILER */
203
204 // lame work around to Apple defining this as a macro in 10.12 SDK
205 #ifdef TYPE_BOOL
206 #undef TYPE_BOOL
207 #endif
208
209 enum DataType {
210 TYPE_VOID,
211 TYPE_BOOL,
212 TYPE_BVEC2,
213 TYPE_BVEC3,
214 TYPE_BVEC4,
215 TYPE_INT,
216 TYPE_IVEC2,
217 TYPE_IVEC3,
218 TYPE_IVEC4,
219 TYPE_UINT,
220 TYPE_UVEC2,
221 TYPE_UVEC3,
222 TYPE_UVEC4,
223 TYPE_FLOAT,
224 TYPE_VEC2,
225 TYPE_VEC3,
226 TYPE_VEC4,
227 TYPE_MAT2,
228 TYPE_MAT3,
229 TYPE_MAT4,
230 TYPE_SAMPLER2D,
231 TYPE_ISAMPLER2D,
232 TYPE_USAMPLER2D,
233 TYPE_SAMPLER2DARRAY,
234 TYPE_ISAMPLER2DARRAY,
235 TYPE_USAMPLER2DARRAY,
236 TYPE_SAMPLER3D,
237 TYPE_ISAMPLER3D,
238 TYPE_USAMPLER3D,
239 TYPE_SAMPLERCUBE,
240 TYPE_SAMPLERCUBEARRAY,
241 TYPE_SAMPLEREXT,
242 TYPE_STRUCT,
243 TYPE_MAX
244 };
245
246 enum DataPrecision {
247 PRECISION_LOWP,
248 PRECISION_MEDIUMP,
249 PRECISION_HIGHP,
250 PRECISION_DEFAULT,
251 };
252
253 enum DataInterpolation {
254 INTERPOLATION_FLAT,
255 INTERPOLATION_SMOOTH,
256 INTERPOLATION_DEFAULT,
257 };
258
259 enum Operator {
260 OP_EQUAL,
261 OP_NOT_EQUAL,
262 OP_LESS,
263 OP_LESS_EQUAL,
264 OP_GREATER,
265 OP_GREATER_EQUAL,
266 OP_AND,
267 OP_OR,
268 OP_NOT,
269 OP_NEGATE,
270 OP_ADD,
271 OP_SUB,
272 OP_MUL,
273 OP_DIV,
274 OP_MOD,
275 OP_SHIFT_LEFT,
276 OP_SHIFT_RIGHT,
277 OP_ASSIGN,
278 OP_ASSIGN_ADD,
279 OP_ASSIGN_SUB,
280 OP_ASSIGN_MUL,
281 OP_ASSIGN_DIV,
282 OP_ASSIGN_MOD,
283 OP_ASSIGN_SHIFT_LEFT,
284 OP_ASSIGN_SHIFT_RIGHT,
285 OP_ASSIGN_BIT_AND,
286 OP_ASSIGN_BIT_OR,
287 OP_ASSIGN_BIT_XOR,
288 OP_BIT_AND,
289 OP_BIT_OR,
290 OP_BIT_XOR,
291 OP_BIT_INVERT,
292 OP_INCREMENT,
293 OP_DECREMENT,
294 OP_SELECT_IF,
295 OP_SELECT_ELSE, //used only internally, then only IF appears with 3 arguments
296 OP_POST_INCREMENT,
297 OP_POST_DECREMENT,
298 OP_CALL,
299 OP_CONSTRUCT,
300 OP_STRUCT,
301 OP_INDEX,
302 OP_EMPTY,
303 OP_MAX
304 };
305
306 enum FlowOperation {
307 FLOW_OP_IF,
308 FLOW_OP_RETURN,
309 FLOW_OP_FOR,
310 FLOW_OP_WHILE,
311 FLOW_OP_DO,
312 FLOW_OP_BREAK,
313 FLOW_OP_SWITCH,
314 FLOW_OP_CASE,
315 FLOW_OP_DEFAULT,
316 FLOW_OP_CONTINUE,
317 FLOW_OP_DISCARD
318 };
319
320 enum ArgumentQualifier {
321 ARGUMENT_QUALIFIER_IN,
322 ARGUMENT_QUALIFIER_OUT,
323 ARGUMENT_QUALIFIER_INOUT,
324 };
325
326 enum SubClassTag {
327 TAG_GLOBAL,
328 TAG_ARRAY,
329 };
330
331 enum TextureFilter {
332 FILTER_NEAREST,
333 FILTER_LINEAR,
334 FILTER_NEAREST_MIPMAP,
335 FILTER_LINEAR_MIPMAP,
336 FILTER_NEAREST_MIPMAP_ANISOTROPIC,
337 FILTER_LINEAR_MIPMAP_ANISOTROPIC,
338 FILTER_DEFAULT,
339 };
340
341 enum TextureRepeat {
342 REPEAT_DISABLE,
343 REPEAT_ENABLE,
344 REPEAT_DEFAULT,
345 };
346
347 enum {
348 MAX_INSTANCE_UNIFORM_INDICES = 16
349 };
350
351 struct VaryingFunctionNames {
352 StringName fragment;
353 StringName vertex;
354 StringName light;
355 VaryingFunctionNames() {
356 fragment = "fragment";
357 vertex = "vertex";
358 light = "light";
359 }
360 };
361
362 union Scalar {
363 bool boolean = false;
364 float real;
365 int32_t sint;
366 uint32_t uint;
367 };
368
369 struct Node {
370 Node *next = nullptr;
371
372 enum Type {
373 NODE_TYPE_SHADER,
374 NODE_TYPE_FUNCTION,
375 NODE_TYPE_BLOCK,
376 NODE_TYPE_VARIABLE,
377 NODE_TYPE_VARIABLE_DECLARATION,
378 NODE_TYPE_CONSTANT,
379 NODE_TYPE_OPERATOR,
380 NODE_TYPE_CONTROL_FLOW,
381 NODE_TYPE_MEMBER,
382 NODE_TYPE_ARRAY,
383 NODE_TYPE_ARRAY_CONSTRUCT,
384 NODE_TYPE_STRUCT,
385 };
386
387 Type type;
388
389 virtual DataType get_datatype() const { return TYPE_VOID; }
390 virtual String get_datatype_name() const { return ""; }
391 virtual int get_array_size() const { return 0; }
392 virtual bool is_indexed() const { return false; }
393 virtual Vector<Scalar> get_values() const { return Vector<Scalar>(); }
394
395 Node(Type t) :
396 type(t) {}
397 virtual ~Node() {}
398 };
399
400 template <typename T>
401 T *alloc_node() {
402 T *node = memnew(T);
403 node->next = nodes;
404 nodes = node;
405 return node;
406 }
407
408 Node *nodes = nullptr;
409
410 struct OperatorNode : public Node {
411 DataType return_cache = TYPE_VOID;
412 DataPrecision return_precision_cache = PRECISION_DEFAULT;
413 int return_array_size = 0;
414 Operator op = OP_EQUAL;
415 StringName struct_name;
416 Vector<Node *> arguments;
417 Vector<Scalar> values;
418
419 virtual DataType get_datatype() const override { return return_cache; }
420 virtual String get_datatype_name() const override { return String(struct_name); }
421 virtual int get_array_size() const override { return return_array_size; }
422 virtual bool is_indexed() const override { return op == OP_INDEX; }
423 virtual Vector<Scalar> get_values() const override { return values; }
424
425 OperatorNode() :
426 Node(NODE_TYPE_OPERATOR) {}
427 };
428
429 struct VariableNode : public Node {
430 DataType datatype_cache = TYPE_VOID;
431 StringName name;
432 StringName rname;
433 StringName struct_name;
434 bool is_const = false;
435 bool is_local = false;
436
437 virtual DataType get_datatype() const override { return datatype_cache; }
438 virtual String get_datatype_name() const override { return String(struct_name); }
439
440 VariableNode() :
441 Node(NODE_TYPE_VARIABLE) {}
442 };
443
444 struct VariableDeclarationNode : public Node {
445 DataPrecision precision = PRECISION_DEFAULT;
446 DataType datatype = TYPE_VOID;
447 String struct_name;
448 bool is_const = false;
449
450 struct Declaration {
451 StringName name;
452 uint32_t size = 0U;
453 Node *size_expression = nullptr;
454 Vector<Node *> initializer;
455 bool single_expression = false;
456 };
457 Vector<Declaration> declarations;
458
459 virtual DataType get_datatype() const override { return datatype; }
460
461 VariableDeclarationNode() :
462 Node(NODE_TYPE_VARIABLE_DECLARATION) {}
463 };
464
465 struct ArrayNode : public Node {
466 DataType datatype_cache = TYPE_VOID;
467 StringName struct_name;
468 StringName name;
469 Node *index_expression = nullptr;
470 Node *call_expression = nullptr;
471 Node *assign_expression = nullptr;
472 bool is_const = false;
473 int array_size = 0;
474 bool is_local = false;
475
476 virtual DataType get_datatype() const override { return call_expression ? call_expression->get_datatype() : datatype_cache; }
477 virtual String get_datatype_name() const override { return call_expression ? call_expression->get_datatype_name() : String(struct_name); }
478 virtual int get_array_size() const override { return (index_expression || call_expression) ? 0 : array_size; }
479 virtual bool is_indexed() const override { return index_expression != nullptr; }
480
481 ArrayNode() :
482 Node(NODE_TYPE_ARRAY) {}
483 };
484
485 struct ArrayConstructNode : public Node {
486 DataType datatype = TYPE_VOID;
487 String struct_name;
488 Vector<Node *> initializer;
489
490 virtual DataType get_datatype() const override { return datatype; }
491 virtual String get_datatype_name() const override { return struct_name; }
492 virtual int get_array_size() const override { return initializer.size(); }
493
494 ArrayConstructNode() :
495 Node(NODE_TYPE_ARRAY_CONSTRUCT) {}
496 };
497
498 struct ConstantNode : public Node {
499 DataType datatype = TYPE_VOID;
500 String struct_name = "";
501 int array_size = 0;
502
503 Vector<Scalar> values;
504 Vector<VariableDeclarationNode::Declaration> array_declarations;
505
506 virtual DataType get_datatype() const override { return datatype; }
507 virtual String get_datatype_name() const override { return struct_name; }
508 virtual int get_array_size() const override { return array_size; }
509 virtual Vector<Scalar> get_values() const override {
510 return values;
511 }
512
513 ConstantNode() :
514 Node(NODE_TYPE_CONSTANT) {}
515 };
516
517 struct FunctionNode;
518
519 struct BlockNode : public Node {
520 FunctionNode *parent_function = nullptr;
521 BlockNode *parent_block = nullptr;
522
523 enum BlockType {
524 BLOCK_TYPE_STANDARD,
525 BLOCK_TYPE_FOR_INIT,
526 BLOCK_TYPE_FOR_CONDITION,
527 BLOCK_TYPE_FOR_EXPRESSION,
528 BLOCK_TYPE_SWITCH,
529 BLOCK_TYPE_CASE,
530 BLOCK_TYPE_DEFAULT,
531 };
532
533 int block_type = BLOCK_TYPE_STANDARD;
534 SubClassTag block_tag = SubClassTag::TAG_GLOBAL;
535
536 struct Variable {
537 DataType type;
538 StringName struct_name;
539 DataPrecision precision;
540 int line; //for completion
541 int array_size;
542 bool is_const;
543 Vector<Scalar> values;
544 };
545
546 HashMap<StringName, Variable> variables;
547 List<Node *> statements;
548 bool single_statement = false;
549 bool use_comma_between_statements = false;
550 bool use_op_eval = true;
551
552 DataType expected_type = TYPE_VOID;
553 HashSet<int> constants;
554
555 BlockNode() :
556 Node(NODE_TYPE_BLOCK) {}
557 };
558
559 struct ControlFlowNode : public Node {
560 FlowOperation flow_op = FLOW_OP_IF;
561 Vector<Node *> expressions;
562 Vector<BlockNode *> blocks;
563
564 ControlFlowNode() :
565 Node(NODE_TYPE_CONTROL_FLOW) {}
566 };
567
568 struct MemberNode : public Node {
569 DataType basetype = TYPE_VOID;
570 bool basetype_const = false;
571 StringName base_struct_name;
572 DataPrecision precision = PRECISION_DEFAULT;
573 DataType datatype = TYPE_VOID;
574 int array_size = 0;
575 StringName struct_name;
576 StringName name;
577 Node *owner = nullptr;
578 Node *index_expression = nullptr;
579 Node *assign_expression = nullptr;
580 Node *call_expression = nullptr;
581 bool has_swizzling_duplicates = false;
582
583 virtual DataType get_datatype() const override { return call_expression ? call_expression->get_datatype() : datatype; }
584 virtual String get_datatype_name() const override { return call_expression ? call_expression->get_datatype_name() : String(struct_name); }
585 virtual int get_array_size() const override { return (index_expression || call_expression) ? 0 : array_size; }
586 virtual bool is_indexed() const override { return index_expression != nullptr || call_expression != nullptr; }
587
588 MemberNode() :
589 Node(NODE_TYPE_MEMBER) {}
590 };
591
592 struct StructNode : public Node {
593 List<MemberNode *> members;
594 StructNode() :
595 Node(NODE_TYPE_STRUCT) {}
596 };
597
598 struct ShaderNode : public Node {
599 struct Constant {
600 StringName name;
601 DataType type;
602 StringName struct_name;
603 DataPrecision precision;
604 Node *initializer = nullptr;
605 int array_size;
606 };
607
608 struct Function {
609 StringName name;
610 StringName rname;
611 FunctionNode *function = nullptr;
612 HashSet<StringName> uses_function;
613 bool callable;
614 };
615
616 struct Struct {
617 StringName name;
618 StructNode *shader_struct = nullptr;
619 };
620
621 struct Varying {
622 enum Stage {
623 STAGE_UNKNOWN,
624 STAGE_VERTEX,
625 STAGE_FRAGMENT,
626 };
627
628 Stage stage = STAGE_UNKNOWN;
629 DataType type = TYPE_VOID;
630 DataInterpolation interpolation = INTERPOLATION_FLAT;
631 DataPrecision precision = PRECISION_DEFAULT;
632 int array_size = 0;
633 TkPos tkpos;
634
635 uint32_t get_size() const {
636 uint32_t size = 1;
637 if (array_size > 0) {
638 size = (uint32_t)array_size;
639 }
640
641 switch (type) {
642 case TYPE_MAT2:
643 size *= 2;
644 break;
645 case TYPE_MAT3:
646 size *= 3;
647 break;
648 case TYPE_MAT4:
649 size *= 4;
650 break;
651 default:
652 break;
653 }
654 return size;
655 }
656
657 Varying() {}
658 };
659
660 struct Uniform {
661 enum Hint {
662 HINT_NONE,
663 HINT_RANGE,
664 HINT_ENUM,
665 HINT_SOURCE_COLOR,
666 HINT_COLOR_CONVERSION_DISABLED,
667 HINT_NORMAL,
668 HINT_ROUGHNESS_NORMAL,
669 HINT_ROUGHNESS_R,
670 HINT_ROUGHNESS_G,
671 HINT_ROUGHNESS_B,
672 HINT_ROUGHNESS_A,
673 HINT_ROUGHNESS_GRAY,
674 HINT_DEFAULT_BLACK,
675 HINT_DEFAULT_WHITE,
676 HINT_DEFAULT_TRANSPARENT,
677 HINT_ANISOTROPY,
678 HINT_SCREEN_TEXTURE,
679 HINT_NORMAL_ROUGHNESS_TEXTURE,
680 HINT_DEPTH_TEXTURE,
681 HINT_MAX
682 };
683
684 enum Scope {
685 SCOPE_LOCAL,
686 SCOPE_INSTANCE,
687 SCOPE_GLOBAL,
688 };
689
690 int order = 0;
691 int prop_order = 0;
692 int texture_order = 0;
693 int texture_binding = 0;
694 DataType type = TYPE_VOID;
695 DataPrecision precision = PRECISION_DEFAULT;
696 int array_size = 0;
697 Vector<Scalar> default_value;
698 Scope scope = SCOPE_LOCAL;
699 Hint hint = HINT_NONE;
700 bool use_color = false;
701 TextureFilter filter = FILTER_DEFAULT;
702 TextureRepeat repeat = REPEAT_DEFAULT;
703 float hint_range[3];
704 PackedStringArray hint_enum_names;
705 int instance_index = 0;
706 String group;
707 String subgroup;
708
709 _FORCE_INLINE_ bool is_texture() const {
710 // Order is assigned to -1 for texture uniforms.
711 return order < 0;
712 }
713
714 Uniform() {
715 hint_range[0] = 0.0f;
716 hint_range[1] = 1.0f;
717 hint_range[2] = 0.001f;
718 }
719 };
720
721 HashMap<StringName, Constant> constants;
722 HashMap<StringName, Varying> varyings;
723 HashMap<StringName, Uniform> uniforms;
724 HashMap<StringName, Struct> structs;
725 HashMap<StringName, Function> functions;
726 Vector<StringName> render_modes;
727 Vector<StringName> stencil_modes;
728 int stencil_reference = -1;
729
730 Vector<Function> vfunctions;
731 Vector<Constant> vconstants;
732 Vector<Struct> vstructs;
733
734 ShaderNode() :
735 Node(NODE_TYPE_SHADER) {}
736 };
737
738 struct FunctionNode : public Node {
739 struct Argument {
740 ArgumentQualifier qualifier;
741 StringName name;
742 DataType type;
743 StringName struct_name;
744 DataPrecision precision;
745 //for passing textures as arguments
746 bool tex_argument_check;
747 TextureFilter tex_argument_filter;
748 TextureRepeat tex_argument_repeat;
749 bool tex_builtin_check;
750 StringName tex_builtin;
751 ShaderNode::Uniform::Hint tex_hint;
752 bool is_const;
753 int array_size;
754
755 HashMap<StringName, HashSet<int>> tex_argument_connect;
756 };
757
758 StringName name;
759 StringName rname;
760 DataType return_type = TYPE_VOID;
761 StringName return_struct_name;
762 DataPrecision return_precision = PRECISION_DEFAULT;
763 int return_array_size = 0;
764 Vector<Argument> arguments;
765 BlockNode *body = nullptr;
766 bool can_discard = false;
767
768 virtual DataType get_datatype() const override { return return_type; }
769 virtual String get_datatype_name() const override { return String(return_struct_name); }
770 virtual int get_array_size() const override { return return_array_size; }
771
772 FunctionNode() :
773 Node(NODE_TYPE_FUNCTION) {}
774 };
775
776 struct UniformOrderComparator {
777 _FORCE_INLINE_ bool operator()(const Pair<StringName, int> &A, const Pair<StringName, int> &B) const {
778 return A.second < B.second;
779 }
780 };
781
782 struct Expression {
783 bool is_op;
784 union {
785 Operator op;
786 Node *node = nullptr;
787 };
788 };
789
790 struct ExpressionInfo {
791 Vector<Expression> *expression = nullptr;
792 TokenType tt_break = TK_EMPTY;
793 bool is_last_expr = false;
794 };
795
796 struct VarInfo {
797 StringName name;
798 DataType type;
799 };
800
801 enum CompletionType {
802 COMPLETION_NONE,
803 COMPLETION_SHADER_TYPE,
804 COMPLETION_RENDER_MODE,
805 COMPLETION_STENCIL_MODE,
806 COMPLETION_MAIN_FUNCTION,
807 COMPLETION_IDENTIFIER,
808 COMPLETION_FUNCTION_CALL,
809 COMPLETION_CALL_ARGUMENTS,
810 COMPLETION_INDEX,
811 COMPLETION_STRUCT,
812 COMPLETION_HINT,
813 };
814
815 struct Token {
816 TokenType type;
817 StringName text;
818 double constant;
819 uint16_t line;
820 bool is_integer_constant() const {
821 return type == TK_INT_CONSTANT || type == TK_UINT_CONSTANT;
822 }
823 };
824
825 static String get_operator_text(Operator p_op);
826 static String get_token_text(Token p_token);
827
828 static bool is_token_datatype(TokenType p_type);
829 static bool is_token_variable_datatype(TokenType p_type);
830 static DataType get_token_datatype(TokenType p_type);
831 static bool is_token_interpolation(TokenType p_type);
832 static DataInterpolation get_token_interpolation(TokenType p_type);
833 static bool is_token_precision(TokenType p_type);
834 static bool is_token_arg_qual(TokenType p_type);
835 static DataPrecision get_token_precision(TokenType p_type);
836 static String get_precision_name(DataPrecision p_type);
837 static String get_interpolation_name(DataInterpolation p_interpolation);
838 static String get_datatype_name(DataType p_type);
839 static String get_uniform_hint_name(ShaderNode::Uniform::Hint p_hint);
840 static String get_texture_filter_name(TextureFilter p_filter);
841 static String get_texture_repeat_name(TextureRepeat p_repeat);
842 static bool is_token_nonvoid_datatype(TokenType p_type);
843 static bool is_token_operator(TokenType p_type);
844 static bool is_token_operator_assign(TokenType p_type);
845 static bool is_token_hint(TokenType p_type);
846
847 static bool convert_constant(ConstantNode *p_constant, DataType p_to_type, Scalar *p_value = nullptr);
848 static DataType get_scalar_type(DataType p_type);
849 static int get_cardinality(DataType p_type);
850 static bool is_scalar_type(DataType p_type);
851 static bool is_float_type(DataType p_type);
852 static bool is_sampler_type(DataType p_type);
853 static bool is_hint_color(ShaderNode::Uniform::Hint p_hint);
854 static Variant constant_value_to_variant(const Vector<Scalar> &p_value, DataType p_type, int p_array_size, ShaderLanguage::ShaderNode::Uniform::Hint p_hint = ShaderLanguage::ShaderNode::Uniform::HINT_NONE);
855 static Variant get_default_datatype_value(DataType p_type, int p_array_size, ShaderLanguage::ShaderNode::Uniform::Hint p_hint);
856 static PropertyInfo uniform_to_property_info(const ShaderNode::Uniform &p_uniform);
857 static uint32_t get_datatype_size(DataType p_type);
858 static uint32_t get_datatype_component_count(DataType p_type);
859
860 static void get_keyword_list(List<String> *r_keywords);
861 static bool is_control_flow_keyword(String p_keyword);
862 static void get_builtin_funcs(List<String> *r_keywords);
863
864 static SafeNumeric<int> instance_counter;
865
866 struct BuiltInInfo {
867 DataType type = TYPE_VOID;
868 bool constant = false;
869 Vector<Scalar> values;
870
871 BuiltInInfo() {}
872
873 BuiltInInfo(DataType p_type, bool p_constant = false, const Vector<Scalar> &p_values = {}) :
874 type(p_type),
875 constant(p_constant),
876 values(p_values) {}
877 };
878
879 struct StageFunctionInfo {
880 struct Argument {
881 StringName name;
882 DataType type;
883
884 Argument(const StringName &p_name = StringName(), DataType p_type = TYPE_VOID) {
885 name = p_name;
886 type = p_type;
887 }
888 };
889
890 Vector<Argument> arguments;
891 DataType return_type = TYPE_VOID;
892 String skip_function;
893 };
894
895 struct ModeInfo {
896 StringName name;
897 Vector<StringName> options;
898
899 ModeInfo() {}
900
901 ModeInfo(const StringName &p_name) :
902 name(p_name) {
903 }
904
905 ModeInfo(const StringName &p_name, const StringName &p_arg1, const StringName &p_arg2) :
906 name(p_name) {
907 options.push_back(p_arg1);
908 options.push_back(p_arg2);
909 }
910
911 ModeInfo(const StringName &p_name, const StringName &p_arg1, const StringName &p_arg2, const StringName &p_arg3) :
912 name(p_name) {
913 options.push_back(p_arg1);
914 options.push_back(p_arg2);
915 options.push_back(p_arg3);
916 }
917
918 ModeInfo(const StringName &p_name, const StringName &p_arg1, const StringName &p_arg2, const StringName &p_arg3, const StringName &p_arg4) :
919 name(p_name) {
920 options.push_back(p_arg1);
921 options.push_back(p_arg2);
922 options.push_back(p_arg3);
923 options.push_back(p_arg4);
924 }
925
926 ModeInfo(const StringName &p_name, const StringName &p_arg1, const StringName &p_arg2, const StringName &p_arg3, const StringName &p_arg4, const StringName &p_arg5) :
927 name(p_name) {
928 options.push_back(p_arg1);
929 options.push_back(p_arg2);
930 options.push_back(p_arg3);
931 options.push_back(p_arg4);
932 options.push_back(p_arg5);
933 }
934
935 ModeInfo(const StringName &p_name, const StringName &p_arg1, const StringName &p_arg2, const StringName &p_arg3, const StringName &p_arg4, const StringName &p_arg5, const StringName &p_arg6) :
936 name(p_name) {
937 options.push_back(p_arg1);
938 options.push_back(p_arg2);
939 options.push_back(p_arg3);
940 options.push_back(p_arg4);
941 options.push_back(p_arg5);
942 options.push_back(p_arg6);
943 }
944
945 ModeInfo(const StringName &p_name, std::initializer_list<StringName> p_args) :
946 name(p_name) {
947 for (const StringName &arg : p_args) {
948 options.push_back(arg);
949 }
950 }
951 };
952
953 struct FunctionInfo {
954 HashMap<StringName, BuiltInInfo> built_ins;
955 HashMap<StringName, StageFunctionInfo> stage_functions;
956
957 bool can_discard = false;
958 bool main_function = false;
959 };
960 static bool has_builtin(const HashMap<StringName, ShaderLanguage::FunctionInfo> &p_functions, const StringName &p_name, bool p_check_global_funcs = false);
961
962 typedef DataType (*GlobalShaderUniformGetTypeFunc)(const StringName &p_name);
963
964 struct FilePosition {
965 String file;
966 int line = 0;
967 };
968
969 private:
970 struct KeyWord {
971 TokenType token;
972 const char *text;
973 uint32_t flags;
974 const Vector<String> excluded_shader_types;
975 const Vector<String> excluded_functions;
976 };
977
978 static const KeyWord keyword_list[];
979
980 GlobalShaderUniformGetTypeFunc global_shader_uniform_get_type_func = nullptr;
981
982 bool error_set = false;
983 String error_str;
984 int error_line = 0;
985
986 Vector<FilePosition> include_positions;
987 HashSet<String> include_markers_handled;
988 HashMap<StringName, int> function_overload_count;
989
990 // Additional function information (eg. call hierarchy). No need to expose it to compiler.
991 struct CallInfo {
992 struct Item {
993 enum ItemType {
994 ITEM_TYPE_BUILTIN,
995 ITEM_TYPE_VARYING,
996 } type;
997
998 TkPos pos;
999
1000 Item() {}
1001 Item(ItemType p_type, TkPos p_pos) :
1002 type(p_type), pos(p_pos) {}
1003 };
1004
1005 StringName name;
1006 List<Pair<StringName, Item>> uses_restricted_items;
1007 List<CallInfo *> calls;
1008 };
1009
1010 RBMap<StringName, CallInfo> calls_info;
1011
1012 #ifdef DEBUG_ENABLED
1013 struct Usage {
1014 int decl_line;
1015 bool used = false;
1016 Usage(int p_decl_line = -1) {
1017 decl_line = p_decl_line;
1018 }
1019 };
1020
1021 HashMap<StringName, Usage> used_constants;
1022 HashMap<StringName, Usage> used_varyings;
1023 HashMap<StringName, Usage> used_uniforms;
1024 HashMap<StringName, Usage> used_functions;
1025 HashMap<StringName, Usage> used_structs;
1026 HashMap<ShaderWarning::Code, HashMap<StringName, Usage> *> warnings_check_map;
1027
1028 HashMap<StringName, HashMap<StringName, Usage>> used_local_vars;
1029 HashMap<ShaderWarning::Code, HashMap<StringName, HashMap<StringName, Usage>> *> warnings_check_map2;
1030
1031 List<ShaderWarning> warnings;
1032
1033 bool check_warnings = false;
1034 uint32_t warning_flags = 0;
1035
1036 void _add_line_warning(ShaderWarning::Code p_code, const StringName &p_subject = "", const Vector<Variant> &p_extra_args = Vector<Variant>()) {
1037 warnings.push_back(ShaderWarning(p_code, tk_line, p_subject, p_extra_args));
1038 }
1039 void _add_global_warning(ShaderWarning::Code p_code, const StringName &p_subject = "", const Vector<Variant> &p_extra_args = Vector<Variant>()) {
1040 warnings.push_back(ShaderWarning(p_code, -1, p_subject, p_extra_args));
1041 }
1042 void _add_warning(ShaderWarning::Code p_code, int p_line, const StringName &p_subject = "", const Vector<Variant> &p_extra_args = Vector<Variant>()) {
1043 warnings.push_back(ShaderWarning(p_code, p_line, p_subject, p_extra_args));
1044 }
1045 void _check_warning_accums();
1046 #endif // DEBUG_ENABLED
1047
1048 String code;
1049 int char_idx = 0;
1050 int tk_line = 0;
1051
1052 StringName shader_type_identifier;
1053 StringName current_function;
1054 bool is_const_decl = false;
1055 StringName last_name;
1056 bool is_shader_inc = false;
1057
1058 String current_uniform_group_name;
1059 String current_uniform_subgroup_name;
1060
1061 VaryingFunctionNames varying_function_names;
1062 uint32_t base_varying_index = 0;
1063
1064 TkPos _get_tkpos() {
1065 TkPos tkp;
1066 tkp.char_idx = char_idx;
1067 tkp.tk_line = tk_line;
1068 return tkp;
1069 }
1070
1071 void _set_tkpos(TkPos p_pos) {
1072 char_idx = p_pos.char_idx;
1073 tk_line = p_pos.tk_line;
1074 }
1075
1076 void _set_error(const String &p_str) {
1077 if (error_set) {
1078 return;
1079 }
1080
1081 error_line = tk_line;
1082 error_set = true;
1083 error_str = p_str;
1084 include_positions.write[include_positions.size() - 1].line = tk_line;
1085 }
1086
1087 void _set_expected_error(const String &p_what) {
1088 _set_error(vformat(RTR("Expected a '%s'."), p_what));
1089 }
1090
1091 void _set_expected_error(const String &p_first, const String p_second) {
1092 _set_error(vformat(RTR("Expected a '%s' or '%s'."), p_first, p_second));
1093 }
1094
1095 void _set_expected_after_error(const String &p_what, const String &p_after) {
1096 _set_error(vformat(RTR("Expected a '%s' after '%s'."), p_what, p_after));
1097 }
1098
1099 void _set_redefinition_error(const String &p_what) {
1100 _set_error(vformat(RTR("Redefinition of '%s'."), p_what));
1101 }
1102
1103 void _set_parsing_error() {
1104 _set_error("Parser bug.");
1105 }
1106
1107 static const char *token_names[TK_MAX];
1108
1109 Token _make_token(TokenType p_type, const StringName &p_text = StringName());
1110 Token _get_token();
1111 bool _lookup_next(Token &r_tk);
1112 Token _peek();
1113
1114 ShaderNode *shader = nullptr;
1115
1116 enum IdentifierType {
1117 IDENTIFIER_FUNCTION,
1118 IDENTIFIER_UNIFORM,
1119 IDENTIFIER_VARYING,
1120 IDENTIFIER_FUNCTION_ARGUMENT,
1121 IDENTIFIER_LOCAL_VAR,
1122 IDENTIFIER_BUILTIN_VAR,
1123 IDENTIFIER_CONSTANT,
1124 IDENTIFIER_MAX,
1125 };
1126
1127 IdentifierType last_type = IDENTIFIER_MAX;
1128
1129 bool _find_identifier(const BlockNode *p_block, bool p_allow_reassign, const FunctionInfo &p_function_info, const StringName &p_identifier, DataType *r_data_type = nullptr, IdentifierType *r_type = nullptr, bool *r_is_const = nullptr, int *r_array_size = nullptr, StringName *r_struct_name = nullptr, Vector<Scalar> *r_constant_values = nullptr);
1130 #ifdef DEBUG_ENABLED
1131 void _parse_used_identifier(const StringName &p_identifier, IdentifierType p_type, const StringName &p_function);
1132 #endif // DEBUG_ENABLED
1133 bool _is_operator_assign(Operator p_op) const;
1134 bool _validate_assign(Node *p_node, const FunctionInfo &p_function_info, String *r_message = nullptr);
1135 bool _validate_operator(const BlockNode *p_block, const FunctionInfo &p_function_info, OperatorNode *p_op, DataType *r_ret_type = nullptr, int *r_ret_size = nullptr, StringName *r_ret_struct_name = nullptr);
1136
1137 Vector<Scalar> _get_node_values(const BlockNode *p_block, const FunctionInfo &p_function_info, Node *p_node);
1138 bool _eval_operator(const BlockNode *p_block, const FunctionInfo &p_function_info, OperatorNode *p_op);
1139 Scalar _eval_unary_scalar(const Scalar &p_a, Operator p_op, DataType p_ret_type);
1140 Scalar _eval_scalar(const Scalar &p_a, const Scalar &p_b, Operator p_op, DataType p_ret_type, bool &r_is_valid);
1141 Vector<Scalar> _eval_unary_vector(const Vector<Scalar> &p_va, DataType p_ret_type, Operator p_op);
1142 Vector<Scalar> _eval_vector(const Vector<Scalar> &p_va, const Vector<Scalar> &p_vb, DataType p_left_type, DataType p_right_type, DataType p_ret_type, Operator p_op, bool &r_is_valid);
1143 Vector<Scalar> _eval_vector_transform(const Vector<Scalar> &p_va, const Vector<Scalar> &p_vb, DataType p_left_type, DataType p_right_type, DataType p_ret_type);
1144
1145 struct BuiltinEntry {
1146 const char *name;
1147 };
1148
1149 struct BuiltinFuncDef {
1150 enum { MAX_ARGS = 5 };
1151 const char *name;
1152 DataType rettype;
1153 const DataType args[MAX_ARGS];
1154 const char *args_names[MAX_ARGS];
1155 SubClassTag tag;
1156 bool high_end;
1157 };
1158
1159 struct BuiltinFuncOutArgs { //arguments used as out in built in functions
1160 enum { MAX_ARGS = 2 };
1161 const char *name;
1162 const int arguments[MAX_ARGS];
1163 };
1164
1165 struct BuiltinFuncConstArgs {
1166 const char *name;
1167 int arg;
1168 int min;
1169 int max;
1170 };
1171
1172 CompletionType completion_type;
1173 ShaderNode::Uniform::Hint current_uniform_hint = ShaderNode::Uniform::HINT_NONE;
1174 TextureFilter current_uniform_filter = FILTER_DEFAULT;
1175 TextureRepeat current_uniform_repeat = REPEAT_DEFAULT;
1176 bool current_uniform_instance_index_defined = false;
1177 int completion_line = 0;
1178 BlockNode *completion_block = nullptr;
1179 DataType completion_base;
1180 bool completion_base_array = false;
1181 SubClassTag completion_class;
1182 StringName completion_function;
1183 StringName completion_struct;
1184 int completion_argument = 0;
1185
1186 #ifdef DEBUG_ENABLED
1187 uint32_t keyword_completion_context;
1188 #endif // DEBUG_ENABLED
1189
1190 const HashMap<StringName, FunctionInfo> *stages = nullptr;
1191 bool is_supported_frag_only_funcs = false;
1192 bool is_discard_supported = false;
1193
1194 bool _get_completable_identifier(BlockNode *p_block, CompletionType p_type, StringName &identifier);
1195 static const BuiltinFuncDef builtin_func_defs[];
1196 static const BuiltinFuncOutArgs builtin_func_out_args[];
1197 static const BuiltinFuncConstArgs builtin_func_const_args[];
1198 static const BuiltinEntry frag_only_func_defs[];
1199
1200 static bool is_const_suffix_lut_initialized;
1201
1202 Error _validate_precision(DataType p_type, DataPrecision p_precision);
1203 bool _compare_datatypes(DataType p_datatype_a, String p_datatype_name_a, int p_array_size_a, DataType p_datatype_b, String p_datatype_name_b, int p_array_size_b);
1204 bool _compare_datatypes_in_nodes(Node *a, Node *b);
1205
1206 bool _validate_function_call(BlockNode *p_block, const FunctionInfo &p_function_info, OperatorNode *p_func, DataType *r_ret_type, StringName *r_ret_type_str, bool *r_is_custom_function = nullptr);
1207 bool _parse_function_arguments(BlockNode *p_block, const FunctionInfo &p_function_info, OperatorNode *p_func, int *r_complete_arg = nullptr);
1208 ShaderNode::Uniform::Hint _sanitize_hint(ShaderNode::Uniform::Hint p_hint);
1209 bool _propagate_function_call_sampler_uniform_settings(const StringName &p_name, int p_argument, TextureFilter p_filter, TextureRepeat p_repeat, ShaderNode::Uniform::Hint p_hint);
1210 bool _propagate_function_call_sampler_builtin_reference(const StringName &p_name, int p_argument, const StringName &p_builtin);
1211 bool _validate_varying_assign(ShaderNode::Varying &p_varying, String *r_message);
1212 bool _check_node_constness(const Node *p_node) const;
1213
1214 bool _check_restricted_func(const StringName &p_name, const StringName &p_current_function) const;
1215 bool _validate_restricted_func(const StringName &p_call_name, const CallInfo *p_func_info, bool p_is_builtin_hint = false);
1216
1217 Node *_parse_expression(BlockNode *p_block, const FunctionInfo &p_function_info, const ExpressionInfo *p_previous_expression_info = nullptr);
1218 Error _parse_array_size(BlockNode *p_block, const FunctionInfo &p_function_info, bool p_forbid_unknown_size, Node **r_size_expression, int *r_array_size, bool *r_unknown_size);
1219 Node *_parse_array_constructor(BlockNode *p_block, const FunctionInfo &p_function_info);
1220 Node *_parse_array_constructor(BlockNode *p_block, const FunctionInfo &p_function_info, DataType p_type, const StringName &p_struct_name, int p_array_size);
1221 ShaderLanguage::Node *_reduce_expression(BlockNode *p_block, ShaderLanguage::Node *p_node);
1222
1223 Node *_parse_and_reduce_expression(BlockNode *p_block, const FunctionInfo &p_function_info, const ExpressionInfo *p_previous_expression_info = nullptr);
1224 Error _parse_block(BlockNode *p_block, const FunctionInfo &p_function_info, bool p_just_one = false, bool p_can_break = false, bool p_can_continue = false);
1225 String _get_shader_type_list(const HashSet<String> &p_shader_types) const;
1226 String _get_qualifier_str(ArgumentQualifier p_qualifier) const;
1227
1228 bool _parse_numeric_constant_expression(const FunctionInfo &p_function_info, float &r_constant);
1229 Error _parse_shader(const HashMap<StringName, FunctionInfo> &p_functions, const Vector<ModeInfo> &p_render_modes, const Vector<ModeInfo> &p_stencil_modes, const HashSet<String> &p_shader_types);
1230
1231 Error _find_last_flow_op_in_block(BlockNode *p_block, FlowOperation p_op);
1232 Error _find_last_flow_op_in_op(ControlFlowNode *p_flow, FlowOperation p_op);
1233
1234 Error _parse_shader_mode(bool p_is_stencil, const Vector<ModeInfo> &p_modes, HashMap<String, String> &r_defined_modes);
1235
1236 public:
1237 #ifdef DEBUG_ENABLED
1238 List<ShaderWarning>::Element *get_warnings_ptr();
1239
1240 void enable_warning_checking(bool p_enabled);
1241 bool is_warning_checking_enabled() const;
1242
1243 void set_warning_flags(uint32_t p_flags);
1244 uint32_t get_warning_flags() const;
1245 #endif // DEBUG_ENABLED
1246
1247 //static void get_keyword_list(ShaderType p_type,List<String> *p_keywords);
1248
1249 void clear();
1250
1251 static String get_shader_type(const String &p_code);
1252 static bool is_builtin_func_out_parameter(const String &p_name, int p_param);
1253
1254 struct ShaderCompileInfo {
1255 HashMap<StringName, FunctionInfo> functions;
1256 Vector<ModeInfo> render_modes;
1257 Vector<ModeInfo> stencil_modes;
1258 VaryingFunctionNames varying_function_names;
1259 HashSet<String> shader_types;
1260 GlobalShaderUniformGetTypeFunc global_shader_uniform_type_func = nullptr;
1261 bool is_include = false;
1262 uint32_t base_varying_index = 0;
1263 };
1264
1265 Error compile(const String &p_code, const ShaderCompileInfo &p_info);
1266 Error complete(const String &p_code, const ShaderCompileInfo &p_info, List<ScriptLanguage::CodeCompletionOption> *r_options, String &r_call_hint);
1267
1268 String get_error_text();
1269 Vector<FilePosition> get_include_positions();
1270 CompletionType get_completion_type() const { return completion_type; }
1271 int get_error_line();
1272
1273 ShaderNode *get_shader();
1274
1275 String token_debug(const String &p_code);
1276
1277 ShaderLanguage();
1278 ~ShaderLanguage();
1279 };