| 
									
										
										
										
											2023-01-05 13:25:55 +01:00
										 |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /*  shader_language.h                                                     */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /*                         This file is part of:                          */ | 
					
						
							|  |  |  | /*                             GODOT ENGINE                               */ | 
					
						
							|  |  |  | /*                        https://godotengine.org                         */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | 
					
						
							|  |  |  | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */ | 
					
						
							|  |  |  | /*                                                                        */ | 
					
						
							|  |  |  | /* Permission is hereby granted, free of charge, to any person obtaining  */ | 
					
						
							|  |  |  | /* a copy of this software and associated documentation files (the        */ | 
					
						
							|  |  |  | /* "Software"), to deal in the Software without restriction, including    */ | 
					
						
							|  |  |  | /* without limitation the rights to use, copy, modify, merge, publish,    */ | 
					
						
							|  |  |  | /* distribute, sublicense, and/or sell copies of the Software, and to     */ | 
					
						
							|  |  |  | /* permit persons to whom the Software is furnished to do so, subject to  */ | 
					
						
							|  |  |  | /* the following conditions:                                              */ | 
					
						
							|  |  |  | /*                                                                        */ | 
					
						
							|  |  |  | /* The above copyright notice and this permission notice shall be         */ | 
					
						
							|  |  |  | /* included in all copies or substantial portions of the Software.        */ | 
					
						
							|  |  |  | /*                                                                        */ | 
					
						
							|  |  |  | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */ | 
					
						
							|  |  |  | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */ | 
					
						
							|  |  |  | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | 
					
						
							|  |  |  | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */ | 
					
						
							|  |  |  | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */ | 
					
						
							|  |  |  | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */ | 
					
						
							|  |  |  | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							| 
									
										
										
										
											2018-01-05 00:50:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-01 10:33:58 -06:00
										 |  |  | #pragma once
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-07 19:33:38 -03:00
										 |  |  | #include "core/object/script_language.h"
 | 
					
						
							|  |  |  | #include "core/string/string_name.h"
 | 
					
						
							|  |  |  | #include "core/string/ustring.h"
 | 
					
						
							|  |  |  | #include "core/templates/list.h"
 | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | #include "core/templates/rb_map.h"
 | 
					
						
							| 
									
										
										
										
											2024-11-26 11:59:52 +03:00
										 |  |  | #include "core/templates/safe_refcount.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-11 18:13:45 +02:00
										 |  |  | #include "core/typedefs.h"
 | 
					
						
							| 
									
										
										
										
											2020-11-07 19:33:38 -03:00
										 |  |  | #include "core/variant/variant.h"
 | 
					
						
							| 
									
										
										
										
											2022-03-08 13:39:16 +03:00
										 |  |  | #include "scene/resources/shader_include.h"
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-01 18:04:47 +03:00
										 |  |  | #ifdef DEBUG_ENABLED
 | 
					
						
							|  |  |  | #include "shader_warnings.h"
 | 
					
						
							|  |  |  | #endif // DEBUG_ENABLED
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | class ShaderLanguage { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2020-12-26 14:26:19 +03:00
										 |  |  | 	struct TkPos { | 
					
						
							|  |  |  | 		int char_idx; | 
					
						
							|  |  |  | 		int tk_line; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-17 23:23:42 -03:00
										 |  |  | 	enum TokenType { | 
					
						
							|  |  |  | 		TK_EMPTY, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TK_IDENTIFIER, | 
					
						
							| 
									
										
										
										
											2014-09-17 23:23:42 -03:00
										 |  |  | 		TK_TRUE, | 
					
						
							|  |  |  | 		TK_FALSE, | 
					
						
							| 
									
										
										
										
											2020-12-04 09:25:14 -03:00
										 |  |  | 		TK_FLOAT_CONSTANT, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TK_INT_CONSTANT, | 
					
						
							| 
									
										
										
										
											2021-12-03 22:05:23 +03:00
										 |  |  | 		TK_UINT_CONSTANT, | 
					
						
							| 
									
										
										
										
											2024-07-13 14:30:08 -04:00
										 |  |  | 		TK_STRING_CONSTANT, | 
					
						
							| 
									
										
										
										
											2014-09-17 23:23:42 -03:00
										 |  |  | 		TK_TYPE_VOID, | 
					
						
							|  |  |  | 		TK_TYPE_BOOL, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TK_TYPE_BVEC2, | 
					
						
							|  |  |  | 		TK_TYPE_BVEC3, | 
					
						
							|  |  |  | 		TK_TYPE_BVEC4, | 
					
						
							|  |  |  | 		TK_TYPE_INT, | 
					
						
							|  |  |  | 		TK_TYPE_IVEC2, | 
					
						
							|  |  |  | 		TK_TYPE_IVEC3, | 
					
						
							|  |  |  | 		TK_TYPE_IVEC4, | 
					
						
							|  |  |  | 		TK_TYPE_UINT, | 
					
						
							|  |  |  | 		TK_TYPE_UVEC2, | 
					
						
							|  |  |  | 		TK_TYPE_UVEC3, | 
					
						
							|  |  |  | 		TK_TYPE_UVEC4, | 
					
						
							| 
									
										
										
										
											2014-09-17 23:23:42 -03:00
										 |  |  | 		TK_TYPE_FLOAT, | 
					
						
							|  |  |  | 		TK_TYPE_VEC2, | 
					
						
							|  |  |  | 		TK_TYPE_VEC3, | 
					
						
							|  |  |  | 		TK_TYPE_VEC4, | 
					
						
							| 
									
										
										
										
											2015-03-10 00:53:09 -03:00
										 |  |  | 		TK_TYPE_MAT2, | 
					
						
							| 
									
										
										
										
											2014-09-17 23:23:42 -03:00
										 |  |  | 		TK_TYPE_MAT3, | 
					
						
							|  |  |  | 		TK_TYPE_MAT4, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TK_TYPE_SAMPLER2D, | 
					
						
							|  |  |  | 		TK_TYPE_ISAMPLER2D, | 
					
						
							|  |  |  | 		TK_TYPE_USAMPLER2D, | 
					
						
							| 
									
										
										
										
											2018-06-26 13:59:26 +02:00
										 |  |  | 		TK_TYPE_SAMPLER2DARRAY, | 
					
						
							|  |  |  | 		TK_TYPE_ISAMPLER2DARRAY, | 
					
						
							|  |  |  | 		TK_TYPE_USAMPLER2DARRAY, | 
					
						
							|  |  |  | 		TK_TYPE_SAMPLER3D, | 
					
						
							|  |  |  | 		TK_TYPE_ISAMPLER3D, | 
					
						
							|  |  |  | 		TK_TYPE_USAMPLER3D, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TK_TYPE_SAMPLERCUBE, | 
					
						
							| 
									
										
										
										
											2020-05-01 09:34:23 -03:00
										 |  |  | 		TK_TYPE_SAMPLERCUBEARRAY, | 
					
						
							| 
									
										
										
										
											2023-10-14 03:58:59 -07:00
										 |  |  | 		TK_TYPE_SAMPLEREXT, | 
					
						
							| 
									
										
										
										
											2017-11-27 16:47:46 +01:00
										 |  |  | 		TK_INTERPOLATION_FLAT, | 
					
						
							|  |  |  | 		TK_INTERPOLATION_SMOOTH, | 
					
						
							| 
									
										
										
										
											2019-05-30 17:19:24 +03:00
										 |  |  | 		TK_CONST, | 
					
						
							| 
									
										
										
										
											2020-01-17 22:35:22 +03:00
										 |  |  | 		TK_STRUCT, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TK_PRECISION_LOW, | 
					
						
							|  |  |  | 		TK_PRECISION_MID, | 
					
						
							|  |  |  | 		TK_PRECISION_HIGH, | 
					
						
							| 
									
										
										
										
											2014-09-17 23:23:42 -03:00
										 |  |  | 		TK_OP_EQUAL, | 
					
						
							|  |  |  | 		TK_OP_NOT_EQUAL, | 
					
						
							|  |  |  | 		TK_OP_LESS, | 
					
						
							|  |  |  | 		TK_OP_LESS_EQUAL, | 
					
						
							|  |  |  | 		TK_OP_GREATER, | 
					
						
							|  |  |  | 		TK_OP_GREATER_EQUAL, | 
					
						
							|  |  |  | 		TK_OP_AND, | 
					
						
							|  |  |  | 		TK_OP_OR, | 
					
						
							|  |  |  | 		TK_OP_NOT, | 
					
						
							|  |  |  | 		TK_OP_ADD, | 
					
						
							|  |  |  | 		TK_OP_SUB, | 
					
						
							|  |  |  | 		TK_OP_MUL, | 
					
						
							|  |  |  | 		TK_OP_DIV, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TK_OP_MOD, | 
					
						
							|  |  |  | 		TK_OP_SHIFT_LEFT, | 
					
						
							|  |  |  | 		TK_OP_SHIFT_RIGHT, | 
					
						
							| 
									
										
										
										
											2014-09-17 23:23:42 -03:00
										 |  |  | 		TK_OP_ASSIGN, | 
					
						
							|  |  |  | 		TK_OP_ASSIGN_ADD, | 
					
						
							|  |  |  | 		TK_OP_ASSIGN_SUB, | 
					
						
							|  |  |  | 		TK_OP_ASSIGN_MUL, | 
					
						
							|  |  |  | 		TK_OP_ASSIGN_DIV, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TK_OP_ASSIGN_MOD, | 
					
						
							|  |  |  | 		TK_OP_ASSIGN_SHIFT_LEFT, | 
					
						
							|  |  |  | 		TK_OP_ASSIGN_SHIFT_RIGHT, | 
					
						
							|  |  |  | 		TK_OP_ASSIGN_BIT_AND, | 
					
						
							|  |  |  | 		TK_OP_ASSIGN_BIT_OR, | 
					
						
							|  |  |  | 		TK_OP_ASSIGN_BIT_XOR, | 
					
						
							|  |  |  | 		TK_OP_BIT_AND, | 
					
						
							|  |  |  | 		TK_OP_BIT_OR, | 
					
						
							|  |  |  | 		TK_OP_BIT_XOR, | 
					
						
							|  |  |  | 		TK_OP_BIT_INVERT, | 
					
						
							|  |  |  | 		TK_OP_INCREMENT, | 
					
						
							|  |  |  | 		TK_OP_DECREMENT, | 
					
						
							| 
									
										
										
										
											2014-09-17 23:23:42 -03:00
										 |  |  | 		TK_CF_IF, | 
					
						
							|  |  |  | 		TK_CF_ELSE, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TK_CF_FOR, | 
					
						
							|  |  |  | 		TK_CF_WHILE, | 
					
						
							|  |  |  | 		TK_CF_DO, | 
					
						
							|  |  |  | 		TK_CF_SWITCH, | 
					
						
							|  |  |  | 		TK_CF_CASE, | 
					
						
							| 
									
										
										
										
											2019-08-14 14:22:25 +03:00
										 |  |  | 		TK_CF_DEFAULT, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TK_CF_BREAK, | 
					
						
							|  |  |  | 		TK_CF_CONTINUE, | 
					
						
							| 
									
										
										
										
											2014-09-17 23:23:42 -03:00
										 |  |  | 		TK_CF_RETURN, | 
					
						
							| 
									
										
										
										
											2017-08-29 10:14:07 -03:00
										 |  |  | 		TK_CF_DISCARD, | 
					
						
							| 
									
										
										
										
											2014-09-17 23:23:42 -03:00
										 |  |  | 		TK_BRACKET_OPEN, | 
					
						
							|  |  |  | 		TK_BRACKET_CLOSE, | 
					
						
							|  |  |  | 		TK_CURLY_BRACKET_OPEN, | 
					
						
							|  |  |  | 		TK_CURLY_BRACKET_CLOSE, | 
					
						
							|  |  |  | 		TK_PARENTHESIS_OPEN, | 
					
						
							|  |  |  | 		TK_PARENTHESIS_CLOSE, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TK_QUESTION, | 
					
						
							| 
									
										
										
										
											2014-09-17 23:23:42 -03:00
										 |  |  | 		TK_COMMA, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TK_COLON, | 
					
						
							| 
									
										
										
										
											2014-09-17 23:23:42 -03:00
										 |  |  | 		TK_SEMICOLON, | 
					
						
							|  |  |  | 		TK_PERIOD, | 
					
						
							|  |  |  | 		TK_UNIFORM, | 
					
						
							| 
									
										
										
										
											2022-07-13 11:31:27 +03:00
										 |  |  | 		TK_UNIFORM_GROUP, | 
					
						
							| 
									
										
										
										
											2020-04-16 23:52:00 -03:00
										 |  |  | 		TK_INSTANCE, | 
					
						
							|  |  |  | 		TK_GLOBAL, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TK_VARYING, | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 		TK_ARG_IN, | 
					
						
							|  |  |  | 		TK_ARG_OUT, | 
					
						
							|  |  |  | 		TK_ARG_INOUT, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TK_RENDER_MODE, | 
					
						
							| 
									
										
										
										
											2023-02-17 15:20:26 -06:00
										 |  |  | 		TK_STENCIL_MODE, | 
					
						
							| 
									
										
										
										
											2022-05-05 21:23:40 +03:00
										 |  |  | 		TK_HINT_DEFAULT_WHITE_TEXTURE, | 
					
						
							|  |  |  | 		TK_HINT_DEFAULT_BLACK_TEXTURE, | 
					
						
							| 
									
										
										
										
											2021-08-14 18:29:52 +02:00
										 |  |  | 		TK_HINT_DEFAULT_TRANSPARENT_TEXTURE, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TK_HINT_NORMAL_TEXTURE, | 
					
						
							| 
									
										
										
										
											2019-09-14 00:37:42 -03:00
										 |  |  | 		TK_HINT_ROUGHNESS_NORMAL_TEXTURE, | 
					
						
							|  |  |  | 		TK_HINT_ROUGHNESS_R, | 
					
						
							|  |  |  | 		TK_HINT_ROUGHNESS_G, | 
					
						
							|  |  |  | 		TK_HINT_ROUGHNESS_B, | 
					
						
							|  |  |  | 		TK_HINT_ROUGHNESS_A, | 
					
						
							|  |  |  | 		TK_HINT_ROUGHNESS_GRAY, | 
					
						
							| 
									
										
										
										
											2021-12-09 20:29:06 +01:00
										 |  |  | 		TK_HINT_ANISOTROPY_TEXTURE, | 
					
						
							| 
									
										
										
										
											2022-05-05 21:23:40 +03:00
										 |  |  | 		TK_HINT_SOURCE_COLOR, | 
					
						
							| 
									
										
										
										
											2024-10-04 00:29:28 -07:00
										 |  |  | 		TK_HINT_COLOR_CONVERSION_DISABLED, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TK_HINT_RANGE, | 
					
						
							| 
									
										
										
										
											2024-07-13 14:30:08 -04:00
										 |  |  | 		TK_HINT_ENUM, | 
					
						
							| 
									
										
										
										
											2020-04-16 23:52:00 -03:00
										 |  |  | 		TK_HINT_INSTANCE_INDEX, | 
					
						
							| 
									
										
										
										
											2022-08-09 12:29:49 -04:00
										 |  |  | 		TK_HINT_SCREEN_TEXTURE, | 
					
						
							|  |  |  | 		TK_HINT_NORMAL_ROUGHNESS_TEXTURE, | 
					
						
							|  |  |  | 		TK_HINT_DEPTH_TEXTURE, | 
					
						
							| 
									
										
										
										
											2019-07-21 11:31:30 -03:00
										 |  |  | 		TK_FILTER_NEAREST, | 
					
						
							|  |  |  | 		TK_FILTER_LINEAR, | 
					
						
							|  |  |  | 		TK_FILTER_NEAREST_MIPMAP, | 
					
						
							|  |  |  | 		TK_FILTER_LINEAR_MIPMAP, | 
					
						
							| 
									
										
										
										
											2021-12-15 22:12:38 +03:00
										 |  |  | 		TK_FILTER_NEAREST_MIPMAP_ANISOTROPIC, | 
					
						
							|  |  |  | 		TK_FILTER_LINEAR_MIPMAP_ANISOTROPIC, | 
					
						
							| 
									
										
										
										
											2019-07-21 11:31:30 -03:00
										 |  |  | 		TK_REPEAT_ENABLE, | 
					
						
							|  |  |  | 		TK_REPEAT_DISABLE, | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 		TK_SHADER_TYPE, | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 		TK_CURSOR, | 
					
						
							| 
									
										
										
										
											2014-09-17 23:23:42 -03:00
										 |  |  | 		TK_ERROR, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TK_EOF, | 
					
						
							| 
									
										
										
										
											2014-09-17 23:23:42 -03:00
										 |  |  | 		TK_MAX | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | /* COMPILER */ | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | // lame work around to Apple defining this as a macro in 10.12 SDK
 | 
					
						
							|  |  |  | #ifdef TYPE_BOOL
 | 
					
						
							|  |  |  | #undef TYPE_BOOL
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-01-04 21:56:56 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	enum DataType { | 
					
						
							|  |  |  | 		TYPE_VOID, | 
					
						
							|  |  |  | 		TYPE_BOOL, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TYPE_BVEC2, | 
					
						
							|  |  |  | 		TYPE_BVEC3, | 
					
						
							|  |  |  | 		TYPE_BVEC4, | 
					
						
							|  |  |  | 		TYPE_INT, | 
					
						
							|  |  |  | 		TYPE_IVEC2, | 
					
						
							|  |  |  | 		TYPE_IVEC3, | 
					
						
							|  |  |  | 		TYPE_IVEC4, | 
					
						
							|  |  |  | 		TYPE_UINT, | 
					
						
							|  |  |  | 		TYPE_UVEC2, | 
					
						
							|  |  |  | 		TYPE_UVEC3, | 
					
						
							|  |  |  | 		TYPE_UVEC4, | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		TYPE_FLOAT, | 
					
						
							|  |  |  | 		TYPE_VEC2, | 
					
						
							|  |  |  | 		TYPE_VEC3, | 
					
						
							|  |  |  | 		TYPE_VEC4, | 
					
						
							| 
									
										
										
										
											2015-03-10 00:53:09 -03:00
										 |  |  | 		TYPE_MAT2, | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		TYPE_MAT3, | 
					
						
							|  |  |  | 		TYPE_MAT4, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TYPE_SAMPLER2D, | 
					
						
							|  |  |  | 		TYPE_ISAMPLER2D, | 
					
						
							|  |  |  | 		TYPE_USAMPLER2D, | 
					
						
							| 
									
										
										
										
											2018-06-26 13:59:26 +02:00
										 |  |  | 		TYPE_SAMPLER2DARRAY, | 
					
						
							|  |  |  | 		TYPE_ISAMPLER2DARRAY, | 
					
						
							|  |  |  | 		TYPE_USAMPLER2DARRAY, | 
					
						
							|  |  |  | 		TYPE_SAMPLER3D, | 
					
						
							|  |  |  | 		TYPE_ISAMPLER3D, | 
					
						
							|  |  |  | 		TYPE_USAMPLER3D, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		TYPE_SAMPLERCUBE, | 
					
						
							| 
									
										
										
										
											2020-05-01 09:34:23 -03:00
										 |  |  | 		TYPE_SAMPLERCUBEARRAY, | 
					
						
							| 
									
										
										
										
											2023-10-14 03:58:59 -07:00
										 |  |  | 		TYPE_SAMPLEREXT, | 
					
						
							| 
									
										
										
										
											2020-01-17 22:35:22 +03:00
										 |  |  | 		TYPE_STRUCT, | 
					
						
							| 
									
										
										
										
											2020-04-16 23:52:00 -03:00
										 |  |  | 		TYPE_MAX | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	enum DataPrecision { | 
					
						
							|  |  |  | 		PRECISION_LOWP, | 
					
						
							|  |  |  | 		PRECISION_MEDIUMP, | 
					
						
							|  |  |  | 		PRECISION_HIGHP, | 
					
						
							|  |  |  | 		PRECISION_DEFAULT, | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-27 16:47:46 +01:00
										 |  |  | 	enum DataInterpolation { | 
					
						
							|  |  |  | 		INTERPOLATION_FLAT, | 
					
						
							|  |  |  | 		INTERPOLATION_SMOOTH, | 
					
						
							| 
									
										
										
										
											2022-12-22 23:19:30 +03:00
										 |  |  | 		INTERPOLATION_DEFAULT, | 
					
						
							| 
									
										
										
										
											2017-11-27 16:47:46 +01:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	enum Operator { | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		OP_EQUAL, | 
					
						
							|  |  |  | 		OP_NOT_EQUAL, | 
					
						
							|  |  |  | 		OP_LESS, | 
					
						
							|  |  |  | 		OP_LESS_EQUAL, | 
					
						
							|  |  |  | 		OP_GREATER, | 
					
						
							|  |  |  | 		OP_GREATER_EQUAL, | 
					
						
							|  |  |  | 		OP_AND, | 
					
						
							|  |  |  | 		OP_OR, | 
					
						
							|  |  |  | 		OP_NOT, | 
					
						
							|  |  |  | 		OP_NEGATE, | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		OP_ADD, | 
					
						
							|  |  |  | 		OP_SUB, | 
					
						
							|  |  |  | 		OP_MUL, | 
					
						
							|  |  |  | 		OP_DIV, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		OP_MOD, | 
					
						
							|  |  |  | 		OP_SHIFT_LEFT, | 
					
						
							|  |  |  | 		OP_SHIFT_RIGHT, | 
					
						
							|  |  |  | 		OP_ASSIGN, | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		OP_ASSIGN_ADD, | 
					
						
							|  |  |  | 		OP_ASSIGN_SUB, | 
					
						
							|  |  |  | 		OP_ASSIGN_MUL, | 
					
						
							|  |  |  | 		OP_ASSIGN_DIV, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		OP_ASSIGN_MOD, | 
					
						
							|  |  |  | 		OP_ASSIGN_SHIFT_LEFT, | 
					
						
							|  |  |  | 		OP_ASSIGN_SHIFT_RIGHT, | 
					
						
							|  |  |  | 		OP_ASSIGN_BIT_AND, | 
					
						
							|  |  |  | 		OP_ASSIGN_BIT_OR, | 
					
						
							|  |  |  | 		OP_ASSIGN_BIT_XOR, | 
					
						
							|  |  |  | 		OP_BIT_AND, | 
					
						
							|  |  |  | 		OP_BIT_OR, | 
					
						
							|  |  |  | 		OP_BIT_XOR, | 
					
						
							|  |  |  | 		OP_BIT_INVERT, | 
					
						
							|  |  |  | 		OP_INCREMENT, | 
					
						
							|  |  |  | 		OP_DECREMENT, | 
					
						
							|  |  |  | 		OP_SELECT_IF, | 
					
						
							|  |  |  | 		OP_SELECT_ELSE, //used only internally, then only IF appears with 3 arguments
 | 
					
						
							|  |  |  | 		OP_POST_INCREMENT, | 
					
						
							|  |  |  | 		OP_POST_DECREMENT, | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		OP_CALL, | 
					
						
							|  |  |  | 		OP_CONSTRUCT, | 
					
						
							| 
									
										
										
										
											2020-01-17 22:35:22 +03:00
										 |  |  | 		OP_STRUCT, | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 		OP_INDEX, | 
					
						
							| 
									
										
										
										
											2021-11-30 23:28:35 +03:00
										 |  |  | 		OP_EMPTY, | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		OP_MAX | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	enum FlowOperation { | 
					
						
							|  |  |  | 		FLOW_OP_IF, | 
					
						
							|  |  |  | 		FLOW_OP_RETURN, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		FLOW_OP_FOR, | 
					
						
							|  |  |  | 		FLOW_OP_WHILE, | 
					
						
							|  |  |  | 		FLOW_OP_DO, | 
					
						
							|  |  |  | 		FLOW_OP_BREAK, | 
					
						
							|  |  |  | 		FLOW_OP_SWITCH, | 
					
						
							| 
									
										
										
										
											2019-08-14 14:22:25 +03:00
										 |  |  | 		FLOW_OP_CASE, | 
					
						
							|  |  |  | 		FLOW_OP_DEFAULT, | 
					
						
							| 
									
										
										
										
											2017-08-29 10:14:07 -03:00
										 |  |  | 		FLOW_OP_CONTINUE, | 
					
						
							|  |  |  | 		FLOW_OP_DISCARD | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 	enum ArgumentQualifier { | 
					
						
							|  |  |  | 		ARGUMENT_QUALIFIER_IN, | 
					
						
							|  |  |  | 		ARGUMENT_QUALIFIER_OUT, | 
					
						
							|  |  |  | 		ARGUMENT_QUALIFIER_INOUT, | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 14:50:11 +03:00
										 |  |  | 	enum SubClassTag { | 
					
						
							|  |  |  | 		TAG_GLOBAL, | 
					
						
							|  |  |  | 		TAG_ARRAY, | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-21 11:31:30 -03:00
										 |  |  | 	enum TextureFilter { | 
					
						
							|  |  |  | 		FILTER_NEAREST, | 
					
						
							|  |  |  | 		FILTER_LINEAR, | 
					
						
							|  |  |  | 		FILTER_NEAREST_MIPMAP, | 
					
						
							|  |  |  | 		FILTER_LINEAR_MIPMAP, | 
					
						
							| 
									
										
										
										
											2021-12-15 22:12:38 +03:00
										 |  |  | 		FILTER_NEAREST_MIPMAP_ANISOTROPIC, | 
					
						
							|  |  |  | 		FILTER_LINEAR_MIPMAP_ANISOTROPIC, | 
					
						
							| 
									
										
										
										
											2019-07-21 11:31:30 -03:00
										 |  |  | 		FILTER_DEFAULT, | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	enum TextureRepeat { | 
					
						
							|  |  |  | 		REPEAT_DISABLE, | 
					
						
							|  |  |  | 		REPEAT_ENABLE, | 
					
						
							|  |  |  | 		REPEAT_DEFAULT, | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-16 23:52:00 -03:00
										 |  |  | 	enum { | 
					
						
							|  |  |  | 		MAX_INSTANCE_UNIFORM_INDICES = 16 | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-13 17:01:43 -03:00
										 |  |  | 	struct VaryingFunctionNames { | 
					
						
							|  |  |  | 		StringName fragment; | 
					
						
							|  |  |  | 		StringName vertex; | 
					
						
							|  |  |  | 		StringName light; | 
					
						
							|  |  |  | 		VaryingFunctionNames() { | 
					
						
							|  |  |  | 			fragment = "fragment"; | 
					
						
							|  |  |  | 			vertex = "vertex"; | 
					
						
							|  |  |  | 			light = "light"; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-01 16:39:49 +03:00
										 |  |  | 	union Scalar { | 
					
						
							|  |  |  | 		bool boolean = false; | 
					
						
							|  |  |  | 		float real; | 
					
						
							|  |  |  | 		int32_t sint; | 
					
						
							|  |  |  | 		uint32_t uint; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	struct Node { | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		Node *next = nullptr; | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		enum Type { | 
					
						
							| 
									
										
										
										
											2023-05-11 12:32:23 +02:00
										 |  |  | 			NODE_TYPE_SHADER, | 
					
						
							|  |  |  | 			NODE_TYPE_FUNCTION, | 
					
						
							|  |  |  | 			NODE_TYPE_BLOCK, | 
					
						
							|  |  |  | 			NODE_TYPE_VARIABLE, | 
					
						
							|  |  |  | 			NODE_TYPE_VARIABLE_DECLARATION, | 
					
						
							|  |  |  | 			NODE_TYPE_CONSTANT, | 
					
						
							|  |  |  | 			NODE_TYPE_OPERATOR, | 
					
						
							|  |  |  | 			NODE_TYPE_CONTROL_FLOW, | 
					
						
							|  |  |  | 			NODE_TYPE_MEMBER, | 
					
						
							|  |  |  | 			NODE_TYPE_ARRAY, | 
					
						
							|  |  |  | 			NODE_TYPE_ARRAY_CONSTRUCT, | 
					
						
							|  |  |  | 			NODE_TYPE_STRUCT, | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		Type type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		virtual DataType get_datatype() const { return TYPE_VOID; } | 
					
						
							| 
									
										
										
										
											2020-01-17 22:35:22 +03:00
										 |  |  | 		virtual String get_datatype_name() const { return ""; } | 
					
						
							| 
									
										
										
										
											2021-05-21 19:16:23 +03:00
										 |  |  | 		virtual int get_array_size() const { return 0; } | 
					
						
							|  |  |  | 		virtual bool is_indexed() const { return false; } | 
					
						
							| 
									
										
										
										
											2024-07-01 16:39:49 +03:00
										 |  |  | 		virtual Vector<Scalar> get_values() const { return Vector<Scalar>(); } | 
					
						
							| 
									
										
										
										
											2020-01-17 22:35:22 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-30 02:12:41 +01:00
										 |  |  | 		Node(Type t) : | 
					
						
							|  |  |  | 				type(t) {} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		virtual ~Node() {} | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-07 20:29:49 -06:00
										 |  |  | 	template <typename T> | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	T *alloc_node() { | 
					
						
							|  |  |  | 		T *node = memnew(T); | 
					
						
							|  |  |  | 		node->next = nodes; | 
					
						
							|  |  |  | 		nodes = node; | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		return node; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 	Node *nodes = nullptr; | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	struct OperatorNode : public Node { | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		DataType return_cache = TYPE_VOID; | 
					
						
							|  |  |  | 		DataPrecision return_precision_cache = PRECISION_DEFAULT; | 
					
						
							| 
									
										
										
										
											2021-05-21 19:16:23 +03:00
										 |  |  | 		int return_array_size = 0; | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		Operator op = OP_EQUAL; | 
					
						
							| 
									
										
										
										
											2020-01-17 22:35:22 +03:00
										 |  |  | 		StringName struct_name; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		Vector<Node *> arguments; | 
					
						
							| 
									
										
										
										
											2024-07-01 16:39:49 +03:00
										 |  |  | 		Vector<Scalar> values; | 
					
						
							| 
									
										
										
										
											2021-05-21 19:16:23 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		virtual DataType get_datatype() const override { return return_cache; } | 
					
						
							|  |  |  | 		virtual String get_datatype_name() const override { return String(struct_name); } | 
					
						
							|  |  |  | 		virtual int get_array_size() const override { return return_array_size; } | 
					
						
							|  |  |  | 		virtual bool is_indexed() const override { return op == OP_INDEX; } | 
					
						
							| 
									
										
										
										
											2024-07-01 16:39:49 +03:00
										 |  |  | 		virtual Vector<Scalar> get_values() const override { return values; } | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-30 02:12:41 +01:00
										 |  |  | 		OperatorNode() : | 
					
						
							| 
									
										
										
										
											2023-05-11 12:32:23 +02:00
										 |  |  | 				Node(NODE_TYPE_OPERATOR) {} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	struct VariableNode : public Node { | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		DataType datatype_cache = TYPE_VOID; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		StringName name; | 
					
						
							| 
									
										
										
										
											2024-05-27 22:16:54 +03:00
										 |  |  | 		StringName rname; | 
					
						
							| 
									
										
										
										
											2020-01-17 22:35:22 +03:00
										 |  |  | 		StringName struct_name; | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		bool is_const = false; | 
					
						
							| 
									
										
										
										
											2021-08-13 08:12:04 +03:00
										 |  |  | 		bool is_local = false; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-21 19:16:23 +03:00
										 |  |  | 		virtual DataType get_datatype() const override { return datatype_cache; } | 
					
						
							|  |  |  | 		virtual String get_datatype_name() const override { return String(struct_name); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-30 02:12:41 +01:00
										 |  |  | 		VariableNode() : | 
					
						
							| 
									
										
										
										
											2023-05-11 12:32:23 +02:00
										 |  |  | 				Node(NODE_TYPE_VARIABLE) {} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-05 15:22:33 -03:00
										 |  |  | 	struct VariableDeclarationNode : public Node { | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		DataPrecision precision = PRECISION_DEFAULT; | 
					
						
							|  |  |  | 		DataType datatype = TYPE_VOID; | 
					
						
							| 
									
										
										
										
											2020-01-17 22:35:22 +03:00
										 |  |  | 		String struct_name; | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		bool is_const = false; | 
					
						
							| 
									
										
										
										
											2017-09-05 15:22:33 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		struct Declaration { | 
					
						
							|  |  |  | 			StringName name; | 
					
						
							| 
									
										
										
										
											2022-01-18 10:40:41 +03:00
										 |  |  | 			uint32_t size = 0U; | 
					
						
							|  |  |  | 			Node *size_expression = nullptr; | 
					
						
							|  |  |  | 			Vector<Node *> initializer; | 
					
						
							|  |  |  | 			bool single_expression = false; | 
					
						
							| 
									
										
										
										
											2017-09-05 15:22:33 -03:00
										 |  |  | 		}; | 
					
						
							|  |  |  | 		Vector<Declaration> declarations; | 
					
						
							| 
									
										
										
										
											2021-05-21 19:16:23 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		virtual DataType get_datatype() const override { return datatype; } | 
					
						
							| 
									
										
										
										
											2017-09-05 15:22:33 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-30 02:12:41 +01:00
										 |  |  | 		VariableDeclarationNode() : | 
					
						
							| 
									
										
										
										
											2023-05-11 12:32:23 +02:00
										 |  |  | 				Node(NODE_TYPE_VARIABLE_DECLARATION) {} | 
					
						
							| 
									
										
										
										
											2017-09-05 15:22:33 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-10 19:52:50 +03:00
										 |  |  | 	struct ArrayNode : public Node { | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		DataType datatype_cache = TYPE_VOID; | 
					
						
							| 
									
										
										
										
											2020-01-17 22:35:22 +03:00
										 |  |  | 		StringName struct_name; | 
					
						
							| 
									
										
										
										
											2019-07-10 19:52:50 +03:00
										 |  |  | 		StringName name; | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		Node *index_expression = nullptr; | 
					
						
							|  |  |  | 		Node *call_expression = nullptr; | 
					
						
							| 
									
										
										
										
											2020-12-26 21:13:24 +03:00
										 |  |  | 		Node *assign_expression = nullptr; | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		bool is_const = false; | 
					
						
							| 
									
										
										
										
											2021-05-21 19:16:23 +03:00
										 |  |  | 		int array_size = 0; | 
					
						
							| 
									
										
										
										
											2021-08-13 08:12:04 +03:00
										 |  |  | 		bool is_local = false; | 
					
						
							| 
									
										
										
										
											2019-07-10 19:52:50 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-03 09:52:41 +03:00
										 |  |  | 		virtual DataType get_datatype() const override { return call_expression ? call_expression->get_datatype() : datatype_cache; } | 
					
						
							|  |  |  | 		virtual String get_datatype_name() const override { return call_expression ? call_expression->get_datatype_name() : String(struct_name); } | 
					
						
							| 
									
										
										
										
											2021-06-09 13:12:55 +03:00
										 |  |  | 		virtual int get_array_size() const override { return (index_expression || call_expression) ? 0 : array_size; } | 
					
						
							| 
									
										
										
										
											2021-05-21 19:16:23 +03:00
										 |  |  | 		virtual bool is_indexed() const override { return index_expression != nullptr; } | 
					
						
							| 
									
										
										
										
											2019-07-10 19:52:50 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		ArrayNode() : | 
					
						
							| 
									
										
										
										
											2023-05-11 12:32:23 +02:00
										 |  |  | 				Node(NODE_TYPE_ARRAY) {} | 
					
						
							| 
									
										
										
										
											2019-07-10 19:52:50 +03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-11 22:03:04 +03:00
										 |  |  | 	struct ArrayConstructNode : public Node { | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		DataType datatype = TYPE_VOID; | 
					
						
							| 
									
										
										
										
											2020-02-11 22:03:04 +03:00
										 |  |  | 		String struct_name; | 
					
						
							|  |  |  | 		Vector<Node *> initializer; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-21 19:16:23 +03:00
										 |  |  | 		virtual DataType get_datatype() const override { return datatype; } | 
					
						
							|  |  |  | 		virtual String get_datatype_name() const override { return struct_name; } | 
					
						
							|  |  |  | 		virtual int get_array_size() const override { return initializer.size(); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-11 22:03:04 +03:00
										 |  |  | 		ArrayConstructNode() : | 
					
						
							| 
									
										
										
										
											2023-05-11 12:32:23 +02:00
										 |  |  | 				Node(NODE_TYPE_ARRAY_CONSTRUCT) {} | 
					
						
							| 
									
										
										
										
											2020-02-11 22:03:04 +03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	struct ConstantNode : public Node { | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		DataType datatype = TYPE_VOID; | 
					
						
							| 
									
										
										
										
											2019-10-11 20:43:42 +03:00
										 |  |  | 		String struct_name = ""; | 
					
						
							|  |  |  | 		int array_size = 0; | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-01 16:39:49 +03:00
										 |  |  | 		Vector<Scalar> values; | 
					
						
							| 
									
										
										
										
											2022-01-18 10:40:41 +03:00
										 |  |  | 		Vector<VariableDeclarationNode::Declaration> array_declarations; | 
					
						
							| 
									
										
										
										
											2021-05-21 19:16:23 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		virtual DataType get_datatype() const override { return datatype; } | 
					
						
							|  |  |  | 		virtual String get_datatype_name() const override { return struct_name; } | 
					
						
							|  |  |  | 		virtual int get_array_size() const override { return array_size; } | 
					
						
							| 
									
										
										
										
											2024-07-01 16:39:49 +03:00
										 |  |  | 		virtual Vector<Scalar> get_values() const override { | 
					
						
							|  |  |  | 			return values; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-30 02:12:41 +01:00
										 |  |  | 		ConstantNode() : | 
					
						
							| 
									
										
										
										
											2023-05-11 12:32:23 +02:00
										 |  |  | 				Node(NODE_TYPE_CONSTANT) {} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	struct FunctionNode; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	struct BlockNode : public Node { | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		FunctionNode *parent_function = nullptr; | 
					
						
							|  |  |  | 		BlockNode *parent_block = nullptr; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-14 14:22:25 +03:00
										 |  |  | 		enum BlockType { | 
					
						
							| 
									
										
										
										
											2022-05-20 18:38:06 +03:00
										 |  |  | 			BLOCK_TYPE_STANDARD, | 
					
						
							| 
									
										
										
										
											2022-02-03 11:13:20 +03:00
										 |  |  | 			BLOCK_TYPE_FOR_INIT, | 
					
						
							|  |  |  | 			BLOCK_TYPE_FOR_CONDITION, | 
					
						
							|  |  |  | 			BLOCK_TYPE_FOR_EXPRESSION, | 
					
						
							| 
									
										
										
										
											2019-08-14 14:22:25 +03:00
										 |  |  | 			BLOCK_TYPE_SWITCH, | 
					
						
							|  |  |  | 			BLOCK_TYPE_CASE, | 
					
						
							|  |  |  | 			BLOCK_TYPE_DEFAULT, | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-20 18:38:06 +03:00
										 |  |  | 		int block_type = BLOCK_TYPE_STANDARD; | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		SubClassTag block_tag = SubClassTag::TAG_GLOBAL; | 
					
						
							| 
									
										
										
										
											2019-08-14 14:22:25 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		struct Variable { | 
					
						
							|  |  |  | 			DataType type; | 
					
						
							| 
									
										
										
										
											2020-01-17 22:35:22 +03:00
										 |  |  | 			StringName struct_name; | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 			DataPrecision precision; | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 			int line; //for completion
 | 
					
						
							| 
									
										
										
										
											2019-07-10 19:52:50 +03:00
										 |  |  | 			int array_size; | 
					
						
							| 
									
										
										
										
											2019-08-05 10:35:53 +03:00
										 |  |  | 			bool is_const; | 
					
						
							| 
									
										
										
										
											2024-07-01 16:39:49 +03:00
										 |  |  | 			Vector<Scalar> values; | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 		HashMap<StringName, Variable> variables; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		List<Node *> statements; | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		bool single_statement = false; | 
					
						
							| 
									
										
										
										
											2022-02-03 11:13:20 +03:00
										 |  |  | 		bool use_comma_between_statements = false; | 
					
						
							| 
									
										
										
										
											2024-07-01 16:39:49 +03:00
										 |  |  | 		bool use_op_eval = true; | 
					
						
							| 
									
										
										
										
											2019-01-30 02:12:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-13 11:38:41 +03:00
										 |  |  | 		DataType expected_type = TYPE_VOID; | 
					
						
							|  |  |  | 		HashSet<int> constants; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-30 02:12:41 +01:00
										 |  |  | 		BlockNode() : | 
					
						
							| 
									
										
										
										
											2023-05-11 12:32:23 +02:00
										 |  |  | 				Node(NODE_TYPE_BLOCK) {} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	struct ControlFlowNode : public Node { | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		FlowOperation flow_op = FLOW_OP_IF; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		Vector<Node *> expressions; | 
					
						
							|  |  |  | 		Vector<BlockNode *> blocks; | 
					
						
							| 
									
										
										
										
											2019-01-30 02:12:41 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		ControlFlowNode() : | 
					
						
							| 
									
										
										
										
											2023-05-11 12:32:23 +02:00
										 |  |  | 				Node(NODE_TYPE_CONTROL_FLOW) {} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	struct MemberNode : public Node { | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		DataType basetype = TYPE_VOID; | 
					
						
							|  |  |  | 		bool basetype_const = false; | 
					
						
							| 
									
										
										
										
											2020-01-17 22:35:22 +03:00
										 |  |  | 		StringName base_struct_name; | 
					
						
							| 
									
										
										
										
											2020-12-08 20:58:49 +02:00
										 |  |  | 		DataPrecision precision = PRECISION_DEFAULT; | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		DataType datatype = TYPE_VOID; | 
					
						
							|  |  |  | 		int array_size = 0; | 
					
						
							| 
									
										
										
										
											2020-01-17 22:35:22 +03:00
										 |  |  | 		StringName struct_name; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		StringName name; | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		Node *owner = nullptr; | 
					
						
							|  |  |  | 		Node *index_expression = nullptr; | 
					
						
							| 
									
										
										
										
											2020-12-26 21:13:24 +03:00
										 |  |  | 		Node *assign_expression = nullptr; | 
					
						
							| 
									
										
										
										
											2021-05-19 21:50:11 +03:00
										 |  |  | 		Node *call_expression = nullptr; | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		bool has_swizzling_duplicates = false; | 
					
						
							| 
									
										
										
										
											2019-01-30 02:12:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-03 09:52:41 +03:00
										 |  |  | 		virtual DataType get_datatype() const override { return call_expression ? call_expression->get_datatype() : datatype; } | 
					
						
							|  |  |  | 		virtual String get_datatype_name() const override { return call_expression ? call_expression->get_datatype_name() : String(struct_name); } | 
					
						
							| 
									
										
										
										
											2021-12-13 21:19:13 +03:00
										 |  |  | 		virtual int get_array_size() const override { return (index_expression || call_expression) ? 0 : array_size; } | 
					
						
							| 
									
										
										
										
											2021-05-21 19:16:23 +03:00
										 |  |  | 		virtual bool is_indexed() const override { return index_expression != nullptr || call_expression != nullptr; } | 
					
						
							| 
									
										
										
										
											2019-01-30 02:12:41 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		MemberNode() : | 
					
						
							| 
									
										
										
										
											2023-05-11 12:32:23 +02:00
										 |  |  | 				Node(NODE_TYPE_MEMBER) {} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-17 22:35:22 +03:00
										 |  |  | 	struct StructNode : public Node { | 
					
						
							|  |  |  | 		List<MemberNode *> members; | 
					
						
							|  |  |  | 		StructNode() : | 
					
						
							| 
									
										
										
										
											2023-05-11 12:32:23 +02:00
										 |  |  | 				Node(NODE_TYPE_STRUCT) {} | 
					
						
							| 
									
										
										
										
											2020-01-17 22:35:22 +03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	struct ShaderNode : public Node { | 
					
						
							| 
									
										
										
										
											2019-05-30 17:19:24 +03:00
										 |  |  | 		struct Constant { | 
					
						
							| 
									
										
										
										
											2020-04-11 12:40:17 +03:00
										 |  |  | 			StringName name; | 
					
						
							| 
									
										
										
										
											2019-05-30 17:19:24 +03:00
										 |  |  | 			DataType type; | 
					
						
							| 
									
										
										
										
											2024-05-28 12:13:25 +03:00
										 |  |  | 			StringName struct_name; | 
					
						
							| 
									
										
										
										
											2019-05-30 17:19:24 +03:00
										 |  |  | 			DataPrecision precision; | 
					
						
							| 
									
										
										
										
											2024-06-22 16:15:40 +03:00
										 |  |  | 			Node *initializer = nullptr; | 
					
						
							| 
									
										
										
										
											2019-10-11 20:43:42 +03:00
										 |  |  | 			int array_size; | 
					
						
							| 
									
										
										
										
											2019-05-30 17:19:24 +03:00
										 |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		struct Function { | 
					
						
							|  |  |  | 			StringName name; | 
					
						
							| 
									
										
										
										
											2024-05-27 22:16:54 +03:00
										 |  |  | 			StringName rname; | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 			FunctionNode *function = nullptr; | 
					
						
							| 
									
										
										
										
											2022-05-19 17:00:06 +02:00
										 |  |  | 			HashSet<StringName> uses_function; | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 			bool callable; | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-17 22:35:22 +03:00
										 |  |  | 		struct Struct { | 
					
						
							|  |  |  | 			StringName name; | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 			StructNode *shader_struct = nullptr; | 
					
						
							| 
									
										
										
										
											2020-01-17 22:35:22 +03:00
										 |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		struct Varying { | 
					
						
							| 
									
										
										
										
											2020-12-26 14:26:19 +03:00
										 |  |  | 			enum Stage { | 
					
						
							|  |  |  | 				STAGE_UNKNOWN, | 
					
						
							| 
									
										
										
										
											2024-08-18 10:19:16 +03:00
										 |  |  | 				STAGE_VERTEX, | 
					
						
							|  |  |  | 				STAGE_FRAGMENT, | 
					
						
							| 
									
										
										
										
											2020-12-26 14:26:19 +03:00
										 |  |  | 			}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			Stage stage = STAGE_UNKNOWN; | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 			DataType type = TYPE_VOID; | 
					
						
							|  |  |  | 			DataInterpolation interpolation = INTERPOLATION_FLAT; | 
					
						
							|  |  |  | 			DataPrecision precision = PRECISION_DEFAULT; | 
					
						
							|  |  |  | 			int array_size = 0; | 
					
						
							| 
									
										
										
										
											2020-12-26 14:26:19 +03:00
										 |  |  | 			TkPos tkpos; | 
					
						
							| 
									
										
										
										
											2019-01-30 02:12:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-12 16:12:46 -08:00
										 |  |  | 			uint32_t get_size() const { | 
					
						
							|  |  |  | 				uint32_t size = 1; | 
					
						
							|  |  |  | 				if (array_size > 0) { | 
					
						
							|  |  |  | 					size = (uint32_t)array_size; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				switch (type) { | 
					
						
							|  |  |  | 					case TYPE_MAT2: | 
					
						
							|  |  |  | 						size *= 2; | 
					
						
							|  |  |  | 						break; | 
					
						
							|  |  |  | 					case TYPE_MAT3: | 
					
						
							|  |  |  | 						size *= 3; | 
					
						
							|  |  |  | 						break; | 
					
						
							|  |  |  | 					case TYPE_MAT4: | 
					
						
							|  |  |  | 						size *= 4; | 
					
						
							|  |  |  | 						break; | 
					
						
							|  |  |  | 					default: | 
					
						
							|  |  |  | 						break; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				return size; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 			Varying() {} | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		struct Uniform { | 
					
						
							|  |  |  | 			enum Hint { | 
					
						
							|  |  |  | 				HINT_NONE, | 
					
						
							|  |  |  | 				HINT_RANGE, | 
					
						
							| 
									
										
										
										
											2024-07-13 14:30:08 -04:00
										 |  |  | 				HINT_ENUM, | 
					
						
							| 
									
										
										
										
											2022-05-05 21:23:40 +03:00
										 |  |  | 				HINT_SOURCE_COLOR, | 
					
						
							| 
									
										
										
										
											2024-10-04 00:29:28 -07:00
										 |  |  | 				HINT_COLOR_CONVERSION_DISABLED, | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 				HINT_NORMAL, | 
					
						
							| 
									
										
										
										
											2019-09-14 00:37:42 -03:00
										 |  |  | 				HINT_ROUGHNESS_NORMAL, | 
					
						
							|  |  |  | 				HINT_ROUGHNESS_R, | 
					
						
							|  |  |  | 				HINT_ROUGHNESS_G, | 
					
						
							|  |  |  | 				HINT_ROUGHNESS_B, | 
					
						
							|  |  |  | 				HINT_ROUGHNESS_A, | 
					
						
							|  |  |  | 				HINT_ROUGHNESS_GRAY, | 
					
						
							| 
									
										
										
										
											2022-05-05 21:23:40 +03:00
										 |  |  | 				HINT_DEFAULT_BLACK, | 
					
						
							|  |  |  | 				HINT_DEFAULT_WHITE, | 
					
						
							| 
									
										
										
										
											2021-08-14 18:29:52 +02:00
										 |  |  | 				HINT_DEFAULT_TRANSPARENT, | 
					
						
							| 
									
										
										
										
											2021-12-09 20:29:06 +01:00
										 |  |  | 				HINT_ANISOTROPY, | 
					
						
							| 
									
										
										
										
											2022-08-09 12:29:49 -04:00
										 |  |  | 				HINT_SCREEN_TEXTURE, | 
					
						
							|  |  |  | 				HINT_NORMAL_ROUGHNESS_TEXTURE, | 
					
						
							|  |  |  | 				HINT_DEPTH_TEXTURE, | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 				HINT_MAX | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 			}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-16 23:52:00 -03:00
										 |  |  | 			enum Scope { | 
					
						
							|  |  |  | 				SCOPE_LOCAL, | 
					
						
							|  |  |  | 				SCOPE_INSTANCE, | 
					
						
							|  |  |  | 				SCOPE_GLOBAL, | 
					
						
							|  |  |  | 			}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 			int order = 0; | 
					
						
							| 
									
										
										
										
											2024-07-26 12:19:13 +03:00
										 |  |  | 			int prop_order = 0; | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 			int texture_order = 0; | 
					
						
							| 
									
										
										
										
											2021-06-09 12:33:41 +03:00
										 |  |  | 			int texture_binding = 0; | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 			DataType type = TYPE_VOID; | 
					
						
							|  |  |  | 			DataPrecision precision = PRECISION_DEFAULT; | 
					
						
							| 
									
										
										
										
											2021-06-09 12:33:41 +03:00
										 |  |  | 			int array_size = 0; | 
					
						
							| 
									
										
										
										
											2024-07-01 16:39:49 +03:00
										 |  |  | 			Vector<Scalar> default_value; | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 			Scope scope = SCOPE_LOCAL; | 
					
						
							|  |  |  | 			Hint hint = HINT_NONE; | 
					
						
							| 
									
										
										
										
											2022-05-31 11:44:44 +03:00
										 |  |  | 			bool use_color = false; | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 			TextureFilter filter = FILTER_DEFAULT; | 
					
						
							|  |  |  | 			TextureRepeat repeat = REPEAT_DEFAULT; | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 			float hint_range[3]; | 
					
						
							| 
									
										
										
										
											2024-07-13 14:30:08 -04:00
										 |  |  | 			PackedStringArray hint_enum_names; | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 			int instance_index = 0; | 
					
						
							| 
									
										
										
										
											2022-07-13 11:31:27 +03:00
										 |  |  | 			String group; | 
					
						
							|  |  |  | 			String subgroup; | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-26 12:19:13 +03:00
										 |  |  | 			_FORCE_INLINE_ bool is_texture() const { | 
					
						
							|  |  |  | 				// Order is assigned to -1 for texture uniforms.
 | 
					
						
							|  |  |  | 				return order < 0; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 			Uniform() { | 
					
						
							| 
									
										
										
										
											2019-01-30 02:12:41 +01:00
										 |  |  | 				hint_range[0] = 0.0f; | 
					
						
							|  |  |  | 				hint_range[1] = 1.0f; | 
					
						
							|  |  |  | 				hint_range[2] = 0.001f; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 		HashMap<StringName, Constant> constants; | 
					
						
							|  |  |  | 		HashMap<StringName, Varying> varyings; | 
					
						
							|  |  |  | 		HashMap<StringName, Uniform> uniforms; | 
					
						
							|  |  |  | 		HashMap<StringName, Struct> structs; | 
					
						
							| 
									
										
										
										
											2023-09-13 19:11:12 +03:00
										 |  |  | 		HashMap<StringName, Function> functions; | 
					
						
							| 
									
										
										
										
											2016-10-10 18:31:01 -03:00
										 |  |  | 		Vector<StringName> render_modes; | 
					
						
							| 
									
										
										
										
											2023-02-17 15:20:26 -06:00
										 |  |  | 		Vector<StringName> stencil_modes; | 
					
						
							|  |  |  | 		int stencil_reference = -1; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-13 19:11:12 +03:00
										 |  |  | 		Vector<Function> vfunctions; | 
					
						
							| 
									
										
										
										
											2020-04-11 12:40:17 +03:00
										 |  |  | 		Vector<Constant> vconstants; | 
					
						
							| 
									
										
										
										
											2020-01-17 22:35:22 +03:00
										 |  |  | 		Vector<Struct> vstructs; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-30 02:12:41 +01:00
										 |  |  | 		ShaderNode() : | 
					
						
							| 
									
										
										
										
											2023-05-11 12:32:23 +02:00
										 |  |  | 				Node(NODE_TYPE_SHADER) {} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-26 10:45:36 -07:00
										 |  |  | 	struct FunctionNode : public Node { | 
					
						
							|  |  |  | 		struct Argument { | 
					
						
							|  |  |  | 			ArgumentQualifier qualifier; | 
					
						
							|  |  |  | 			StringName name; | 
					
						
							|  |  |  | 			DataType type; | 
					
						
							|  |  |  | 			StringName struct_name; | 
					
						
							|  |  |  | 			DataPrecision precision; | 
					
						
							|  |  |  | 			//for passing textures as arguments
 | 
					
						
							|  |  |  | 			bool tex_argument_check; | 
					
						
							|  |  |  | 			TextureFilter tex_argument_filter; | 
					
						
							|  |  |  | 			TextureRepeat tex_argument_repeat; | 
					
						
							|  |  |  | 			bool tex_builtin_check; | 
					
						
							|  |  |  | 			StringName tex_builtin; | 
					
						
							|  |  |  | 			ShaderNode::Uniform::Hint tex_hint; | 
					
						
							|  |  |  | 			bool is_const; | 
					
						
							|  |  |  | 			int array_size; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			HashMap<StringName, HashSet<int>> tex_argument_connect; | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		StringName name; | 
					
						
							| 
									
										
										
										
											2024-05-27 22:16:54 +03:00
										 |  |  | 		StringName rname; | 
					
						
							| 
									
										
										
										
											2024-07-26 10:45:36 -07:00
										 |  |  | 		DataType return_type = TYPE_VOID; | 
					
						
							|  |  |  | 		StringName return_struct_name; | 
					
						
							|  |  |  | 		DataPrecision return_precision = PRECISION_DEFAULT; | 
					
						
							|  |  |  | 		int return_array_size = 0; | 
					
						
							|  |  |  | 		Vector<Argument> arguments; | 
					
						
							|  |  |  | 		BlockNode *body = nullptr; | 
					
						
							|  |  |  | 		bool can_discard = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		virtual DataType get_datatype() const override { return return_type; } | 
					
						
							|  |  |  | 		virtual String get_datatype_name() const override { return String(return_struct_name); } | 
					
						
							|  |  |  | 		virtual int get_array_size() const override { return return_array_size; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		FunctionNode() : | 
					
						
							|  |  |  | 				Node(NODE_TYPE_FUNCTION) {} | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-13 15:39:53 +03:00
										 |  |  | 	struct UniformOrderComparator { | 
					
						
							|  |  |  | 		_FORCE_INLINE_ bool operator()(const Pair<StringName, int> &A, const Pair<StringName, int> &B) const { | 
					
						
							|  |  |  | 			return A.second < B.second; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-17 23:23:42 -03:00
										 |  |  | 	struct Expression { | 
					
						
							|  |  |  | 		bool is_op; | 
					
						
							|  |  |  | 		union { | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 			Operator op; | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 			Node *node = nullptr; | 
					
						
							| 
									
										
										
										
											2014-09-17 23:23:42 -03:00
										 |  |  | 		}; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-14 18:08:05 +03:00
										 |  |  | 	struct ExpressionInfo { | 
					
						
							|  |  |  | 		Vector<Expression> *expression = nullptr; | 
					
						
							|  |  |  | 		TokenType tt_break = TK_EMPTY; | 
					
						
							|  |  |  | 		bool is_last_expr = false; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	struct VarInfo { | 
					
						
							|  |  |  | 		StringName name; | 
					
						
							|  |  |  | 		DataType type; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	enum CompletionType { | 
					
						
							|  |  |  | 		COMPLETION_NONE, | 
					
						
							| 
									
										
										
										
											2022-01-13 18:00:59 +03:00
										 |  |  | 		COMPLETION_SHADER_TYPE, | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 		COMPLETION_RENDER_MODE, | 
					
						
							| 
									
										
										
										
											2023-02-17 15:20:26 -06:00
										 |  |  | 		COMPLETION_STENCIL_MODE, | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 		COMPLETION_MAIN_FUNCTION, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		COMPLETION_IDENTIFIER, | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 		COMPLETION_FUNCTION_CALL, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		COMPLETION_CALL_ARGUMENTS, | 
					
						
							|  |  |  | 		COMPLETION_INDEX, | 
					
						
							| 
									
										
										
										
											2020-01-17 22:35:22 +03:00
										 |  |  | 		COMPLETION_STRUCT, | 
					
						
							| 
									
										
										
										
											2021-12-09 20:29:23 +03:00
										 |  |  | 		COMPLETION_HINT, | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	struct Token { | 
					
						
							|  |  |  | 		TokenType type; | 
					
						
							|  |  |  | 		StringName text; | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 		double constant; | 
					
						
							|  |  |  | 		uint16_t line; | 
					
						
							| 
									
										
										
										
											2021-12-03 22:05:23 +03:00
										 |  |  | 		bool is_integer_constant() const { | 
					
						
							|  |  |  | 			return type == TK_INT_CONSTANT || type == TK_UINT_CONSTANT; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 	static String get_operator_text(Operator p_op); | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	static String get_token_text(Token p_token); | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	static bool is_token_datatype(TokenType p_type); | 
					
						
							| 
									
										
										
										
											2018-11-12 08:36:26 -03:00
										 |  |  | 	static bool is_token_variable_datatype(TokenType p_type); | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	static DataType get_token_datatype(TokenType p_type); | 
					
						
							| 
									
										
										
										
											2017-11-27 16:47:46 +01:00
										 |  |  | 	static bool is_token_interpolation(TokenType p_type); | 
					
						
							|  |  |  | 	static DataInterpolation get_token_interpolation(TokenType p_type); | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	static bool is_token_precision(TokenType p_type); | 
					
						
							| 
									
										
										
										
											2022-04-27 14:18:32 +03:00
										 |  |  | 	static bool is_token_arg_qual(TokenType p_type); | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	static DataPrecision get_token_precision(TokenType p_type); | 
					
						
							| 
									
										
										
										
											2019-07-15 18:47:22 +03:00
										 |  |  | 	static String get_precision_name(DataPrecision p_type); | 
					
						
							| 
									
										
										
										
											2022-12-22 23:19:30 +03:00
										 |  |  | 	static String get_interpolation_name(DataInterpolation p_interpolation); | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	static String get_datatype_name(DataType p_type); | 
					
						
							| 
									
										
										
										
											2022-05-31 11:44:44 +03:00
										 |  |  | 	static String get_uniform_hint_name(ShaderNode::Uniform::Hint p_hint); | 
					
						
							|  |  |  | 	static String get_texture_filter_name(TextureFilter p_filter); | 
					
						
							|  |  |  | 	static String get_texture_repeat_name(TextureRepeat p_repeat); | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	static bool is_token_nonvoid_datatype(TokenType p_type); | 
					
						
							|  |  |  | 	static bool is_token_operator(TokenType p_type); | 
					
						
							| 
									
										
										
										
											2021-07-26 14:38:33 +03:00
										 |  |  | 	static bool is_token_operator_assign(TokenType p_type); | 
					
						
							| 
									
										
										
										
											2021-12-09 20:29:23 +03:00
										 |  |  | 	static bool is_token_hint(TokenType p_type); | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-01 16:39:49 +03:00
										 |  |  | 	static bool convert_constant(ConstantNode *p_constant, DataType p_to_type, Scalar *p_value = nullptr); | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 	static DataType get_scalar_type(DataType p_type); | 
					
						
							| 
									
										
										
										
											2018-04-29 20:58:42 +02:00
										 |  |  | 	static int get_cardinality(DataType p_type); | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 	static bool is_scalar_type(DataType p_type); | 
					
						
							| 
									
										
										
										
											2021-08-18 12:18:50 -03:00
										 |  |  | 	static bool is_float_type(DataType p_type); | 
					
						
							| 
									
										
										
										
											2016-10-10 18:31:01 -03:00
										 |  |  | 	static bool is_sampler_type(DataType p_type); | 
					
						
							| 
									
										
										
										
											2024-10-04 00:29:28 -07:00
										 |  |  | 	static bool is_hint_color(ShaderNode::Uniform::Hint p_hint); | 
					
						
							| 
									
										
										
										
											2024-07-01 16:39:49 +03:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2024-08-16 12:21:32 +03:00
										 |  |  | 	static Variant get_default_datatype_value(DataType p_type, int p_array_size, ShaderLanguage::ShaderNode::Uniform::Hint p_hint); | 
					
						
							| 
									
										
										
										
											2019-07-21 11:31:30 -03:00
										 |  |  | 	static PropertyInfo uniform_to_property_info(const ShaderNode::Uniform &p_uniform); | 
					
						
							| 
									
										
										
										
											2021-12-22 10:15:12 +03:00
										 |  |  | 	static uint32_t get_datatype_size(DataType p_type); | 
					
						
							| 
									
										
										
										
											2024-07-01 16:39:49 +03:00
										 |  |  | 	static uint32_t get_datatype_component_count(DataType p_type); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 	static void get_keyword_list(List<String> *r_keywords); | 
					
						
							| 
									
										
										
										
											2021-04-08 16:12:22 +02:00
										 |  |  | 	static bool is_control_flow_keyword(String p_keyword); | 
					
						
							| 
									
										
										
										
											2016-10-10 18:31:01 -03:00
										 |  |  | 	static void get_builtin_funcs(List<String> *r_keywords); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-26 11:59:52 +03:00
										 |  |  | 	static SafeNumeric<int> instance_counter; | 
					
						
							| 
									
										
										
										
											2024-07-02 18:16:04 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-15 18:23:16 -03:00
										 |  |  | 	struct BuiltInInfo { | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		DataType type = TYPE_VOID; | 
					
						
							|  |  |  | 		bool constant = false; | 
					
						
							| 
									
										
										
										
											2025-02-01 17:01:44 +03:00
										 |  |  | 		Vector<Scalar> values; | 
					
						
							| 
									
										
										
										
											2019-01-30 02:12:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-12 17:01:17 +02:00
										 |  |  | 		BuiltInInfo() {} | 
					
						
							| 
									
										
										
										
											2019-01-30 02:12:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-01 17:01:44 +03:00
										 |  |  | 		BuiltInInfo(DataType p_type, bool p_constant = false, const Vector<Scalar> &p_values = {}) : | 
					
						
							| 
									
										
										
										
											2019-01-30 02:12:41 +01:00
										 |  |  | 				type(p_type), | 
					
						
							| 
									
										
										
										
											2025-02-01 17:01:44 +03:00
										 |  |  | 				constant(p_constant), | 
					
						
							|  |  |  | 				values(p_values) {} | 
					
						
							| 
									
										
										
										
											2017-12-15 18:23:16 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-06 09:18:10 -03:00
										 |  |  | 	struct StageFunctionInfo { | 
					
						
							|  |  |  | 		struct Argument { | 
					
						
							|  |  |  | 			StringName name; | 
					
						
							|  |  |  | 			DataType type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			Argument(const StringName &p_name = StringName(), DataType p_type = TYPE_VOID) { | 
					
						
							|  |  |  | 				name = p_name; | 
					
						
							|  |  |  | 				type = p_type; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		Vector<Argument> arguments; | 
					
						
							|  |  |  | 		DataType return_type = TYPE_VOID; | 
					
						
							| 
									
										
										
										
											2024-06-27 10:18:44 +03:00
										 |  |  | 		String skip_function; | 
					
						
							| 
									
										
										
										
											2020-09-06 09:18:10 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-21 17:21:55 +03:00
										 |  |  | 	struct ModeInfo { | 
					
						
							|  |  |  | 		StringName name; | 
					
						
							|  |  |  | 		Vector<StringName> options; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		ModeInfo() {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		ModeInfo(const StringName &p_name) : | 
					
						
							|  |  |  | 				name(p_name) { | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		ModeInfo(const StringName &p_name, const StringName &p_arg1, const StringName &p_arg2) : | 
					
						
							|  |  |  | 				name(p_name) { | 
					
						
							|  |  |  | 			options.push_back(p_arg1); | 
					
						
							|  |  |  | 			options.push_back(p_arg2); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		ModeInfo(const StringName &p_name, const StringName &p_arg1, const StringName &p_arg2, const StringName &p_arg3) : | 
					
						
							|  |  |  | 				name(p_name) { | 
					
						
							|  |  |  | 			options.push_back(p_arg1); | 
					
						
							|  |  |  | 			options.push_back(p_arg2); | 
					
						
							|  |  |  | 			options.push_back(p_arg3); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		ModeInfo(const StringName &p_name, const StringName &p_arg1, const StringName &p_arg2, const StringName &p_arg3, const StringName &p_arg4) : | 
					
						
							|  |  |  | 				name(p_name) { | 
					
						
							|  |  |  | 			options.push_back(p_arg1); | 
					
						
							|  |  |  | 			options.push_back(p_arg2); | 
					
						
							|  |  |  | 			options.push_back(p_arg3); | 
					
						
							|  |  |  | 			options.push_back(p_arg4); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		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) : | 
					
						
							|  |  |  | 				name(p_name) { | 
					
						
							|  |  |  | 			options.push_back(p_arg1); | 
					
						
							|  |  |  | 			options.push_back(p_arg2); | 
					
						
							|  |  |  | 			options.push_back(p_arg3); | 
					
						
							|  |  |  | 			options.push_back(p_arg4); | 
					
						
							|  |  |  | 			options.push_back(p_arg5); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		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) : | 
					
						
							|  |  |  | 				name(p_name) { | 
					
						
							|  |  |  | 			options.push_back(p_arg1); | 
					
						
							|  |  |  | 			options.push_back(p_arg2); | 
					
						
							|  |  |  | 			options.push_back(p_arg3); | 
					
						
							|  |  |  | 			options.push_back(p_arg4); | 
					
						
							|  |  |  | 			options.push_back(p_arg5); | 
					
						
							|  |  |  | 			options.push_back(p_arg6); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2023-09-10 02:06:38 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		ModeInfo(const StringName &p_name, std::initializer_list<StringName> p_args) : | 
					
						
							|  |  |  | 				name(p_name) { | 
					
						
							|  |  |  | 			for (const StringName &arg : p_args) { | 
					
						
							|  |  |  | 				options.push_back(arg); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2021-12-21 17:21:55 +03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-29 10:14:07 -03:00
										 |  |  | 	struct FunctionInfo { | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 		HashMap<StringName, BuiltInInfo> built_ins; | 
					
						
							|  |  |  | 		HashMap<StringName, StageFunctionInfo> stage_functions; | 
					
						
							| 
									
										
										
										
											2020-09-06 09:18:10 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-13 17:01:43 -03:00
										 |  |  | 		bool can_discard = false; | 
					
						
							|  |  |  | 		bool main_function = false; | 
					
						
							| 
									
										
										
										
											2017-08-29 10:14:07 -03:00
										 |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2024-05-30 21:15:21 +03:00
										 |  |  | 	static bool has_builtin(const HashMap<StringName, ShaderLanguage::FunctionInfo> &p_functions, const StringName &p_name, bool p_check_global_funcs = false); | 
					
						
							| 
									
										
										
										
											2017-08-29 10:14:07 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-03 18:56:43 +02:00
										 |  |  | 	typedef DataType (*GlobalShaderUniformGetTypeFunc)(const StringName &p_name); | 
					
						
							| 
									
										
										
										
											2020-04-16 23:52:00 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-29 11:31:18 +02:00
										 |  |  | 	struct FilePosition { | 
					
						
							|  |  |  | 		String file; | 
					
						
							|  |  |  | 		int line = 0; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | private: | 
					
						
							|  |  |  | 	struct KeyWord { | 
					
						
							|  |  |  | 		TokenType token; | 
					
						
							|  |  |  | 		const char *text; | 
					
						
							| 
									
										
										
										
											2022-04-27 14:18:32 +03:00
										 |  |  | 		uint32_t flags; | 
					
						
							|  |  |  | 		const Vector<String> excluded_shader_types; | 
					
						
							| 
									
										
										
										
											2024-06-25 15:39:21 +03:00
										 |  |  | 		const Vector<String> excluded_functions; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2019-01-30 02:12:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 	static const KeyWord keyword_list[]; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-03 18:56:43 +02:00
										 |  |  | 	GlobalShaderUniformGetTypeFunc global_shader_uniform_get_type_func = nullptr; | 
					
						
							| 
									
										
										
										
											2020-04-16 23:52:00 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-02 16:28:25 +02:00
										 |  |  | 	bool error_set = false; | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	String error_str; | 
					
						
							| 
									
										
										
										
											2022-05-02 16:28:25 +02:00
										 |  |  | 	int error_line = 0; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-29 11:31:18 +02:00
										 |  |  | 	Vector<FilePosition> include_positions; | 
					
						
							| 
									
										
										
										
											2023-09-04 14:51:04 +03:00
										 |  |  | 	HashSet<String> include_markers_handled; | 
					
						
							| 
									
										
										
										
											2024-05-27 22:16:54 +03:00
										 |  |  | 	HashMap<StringName, int> function_overload_count; | 
					
						
							| 
									
										
										
										
											2022-06-29 11:31:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-19 18:38:51 +03:00
										 |  |  | 	// Additional function information (eg. call hierarchy). No need to expose it to compiler.
 | 
					
						
							|  |  |  | 	struct CallInfo { | 
					
						
							| 
									
										
										
										
											2024-07-23 21:07:33 +03:00
										 |  |  | 		struct Item { | 
					
						
							|  |  |  | 			enum ItemType { | 
					
						
							|  |  |  | 				ITEM_TYPE_BUILTIN, | 
					
						
							|  |  |  | 				ITEM_TYPE_VARYING, | 
					
						
							|  |  |  | 			} type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			TkPos pos; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			Item() {} | 
					
						
							|  |  |  | 			Item(ItemType p_type, TkPos p_pos) : | 
					
						
							|  |  |  | 					type(p_type), pos(p_pos) {} | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-19 18:38:51 +03:00
										 |  |  | 		StringName name; | 
					
						
							| 
									
										
										
										
											2024-07-23 21:07:33 +03:00
										 |  |  | 		List<Pair<StringName, Item>> uses_restricted_items; | 
					
						
							| 
									
										
										
										
											2024-06-19 18:38:51 +03:00
										 |  |  | 		List<CallInfo *> calls; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	RBMap<StringName, CallInfo> calls_info; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-01 18:04:47 +03:00
										 |  |  | #ifdef DEBUG_ENABLED
 | 
					
						
							|  |  |  | 	struct Usage { | 
					
						
							|  |  |  | 		int decl_line; | 
					
						
							|  |  |  | 		bool used = false; | 
					
						
							|  |  |  | 		Usage(int p_decl_line = -1) { | 
					
						
							|  |  |  | 			decl_line = p_decl_line; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 	HashMap<StringName, Usage> used_constants; | 
					
						
							|  |  |  | 	HashMap<StringName, Usage> used_varyings; | 
					
						
							|  |  |  | 	HashMap<StringName, Usage> used_uniforms; | 
					
						
							|  |  |  | 	HashMap<StringName, Usage> used_functions; | 
					
						
							|  |  |  | 	HashMap<StringName, Usage> used_structs; | 
					
						
							|  |  |  | 	HashMap<ShaderWarning::Code, HashMap<StringName, Usage> *> warnings_check_map; | 
					
						
							| 
									
										
										
										
											2021-01-01 18:04:47 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 	HashMap<StringName, HashMap<StringName, Usage>> used_local_vars; | 
					
						
							|  |  |  | 	HashMap<ShaderWarning::Code, HashMap<StringName, HashMap<StringName, Usage>> *> warnings_check_map2; | 
					
						
							| 
									
										
										
										
											2021-06-29 14:34:54 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-01 18:04:47 +03:00
										 |  |  | 	List<ShaderWarning> warnings; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	bool check_warnings = false; | 
					
						
							| 
									
										
										
										
											2022-05-02 16:28:25 +02:00
										 |  |  | 	uint32_t warning_flags = 0; | 
					
						
							| 
									
										
										
										
											2021-01-01 18:04:47 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-22 10:15:12 +03:00
										 |  |  | 	void _add_line_warning(ShaderWarning::Code p_code, const StringName &p_subject = "", const Vector<Variant> &p_extra_args = Vector<Variant>()) { | 
					
						
							|  |  |  | 		warnings.push_back(ShaderWarning(p_code, tk_line, p_subject, p_extra_args)); | 
					
						
							| 
									
										
										
										
											2021-01-01 18:04:47 +03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-12-22 10:15:12 +03:00
										 |  |  | 	void _add_global_warning(ShaderWarning::Code p_code, const StringName &p_subject = "", const Vector<Variant> &p_extra_args = Vector<Variant>()) { | 
					
						
							|  |  |  | 		warnings.push_back(ShaderWarning(p_code, -1, p_subject, p_extra_args)); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	void _add_warning(ShaderWarning::Code p_code, int p_line, const StringName &p_subject = "", const Vector<Variant> &p_extra_args = Vector<Variant>()) { | 
					
						
							|  |  |  | 		warnings.push_back(ShaderWarning(p_code, p_line, p_subject, p_extra_args)); | 
					
						
							| 
									
										
										
										
											2021-01-01 18:04:47 +03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	void _check_warning_accums(); | 
					
						
							|  |  |  | #endif // DEBUG_ENABLED
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	String code; | 
					
						
							| 
									
										
										
										
											2022-05-02 16:28:25 +02:00
										 |  |  | 	int char_idx = 0; | 
					
						
							|  |  |  | 	int tk_line = 0; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-27 14:18:32 +03:00
										 |  |  | 	StringName shader_type_identifier; | 
					
						
							| 
									
										
										
										
											2016-10-10 18:31:01 -03:00
										 |  |  | 	StringName current_function; | 
					
						
							| 
									
										
										
										
											2023-02-01 09:04:10 +03:00
										 |  |  | 	bool is_const_decl = false; | 
					
						
							| 
									
										
										
										
											2021-01-01 18:04:47 +03:00
										 |  |  | 	StringName last_name; | 
					
						
							| 
									
										
										
										
											2022-07-25 08:19:48 +03:00
										 |  |  | 	bool is_shader_inc = false; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-13 11:31:27 +03:00
										 |  |  | 	String current_uniform_group_name; | 
					
						
							|  |  |  | 	String current_uniform_subgroup_name; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-13 17:01:43 -03:00
										 |  |  | 	VaryingFunctionNames varying_function_names; | 
					
						
							| 
									
										
										
										
											2025-02-12 16:12:46 -08:00
										 |  |  | 	uint32_t base_varying_index = 0; | 
					
						
							| 
									
										
										
										
											2021-04-13 17:01:43 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 	TkPos _get_tkpos() { | 
					
						
							|  |  |  | 		TkPos tkp; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		tkp.char_idx = char_idx; | 
					
						
							|  |  |  | 		tkp.tk_line = tk_line; | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 		return tkp; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 	void _set_tkpos(TkPos p_pos) { | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		char_idx = p_pos.char_idx; | 
					
						
							|  |  |  | 		tk_line = p_pos.tk_line; | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	void _set_error(const String &p_str) { | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		if (error_set) { | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 			return; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		error_line = tk_line; | 
					
						
							|  |  |  | 		error_set = true; | 
					
						
							|  |  |  | 		error_str = p_str; | 
					
						
							| 
									
										
										
										
											2022-06-29 11:31:18 +02:00
										 |  |  | 		include_positions.write[include_positions.size() - 1].line = tk_line; | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 15:00:11 +03:00
										 |  |  | 	void _set_expected_error(const String &p_what) { | 
					
						
							|  |  |  | 		_set_error(vformat(RTR("Expected a '%s'."), p_what)); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _set_expected_error(const String &p_first, const String p_second) { | 
					
						
							|  |  |  | 		_set_error(vformat(RTR("Expected a '%s' or '%s'."), p_first, p_second)); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _set_expected_after_error(const String &p_what, const String &p_after) { | 
					
						
							|  |  |  | 		_set_error(vformat(RTR("Expected a '%s' after '%s'."), p_what, p_after)); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _set_redefinition_error(const String &p_what) { | 
					
						
							|  |  |  | 		_set_error(vformat(RTR("Redefinition of '%s'."), p_what)); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void _set_parsing_error() { | 
					
						
							|  |  |  | 		_set_error("Parser bug."); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	static const char *token_names[TK_MAX]; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	Token _make_token(TokenType p_type, const StringName &p_text = StringName()); | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	Token _get_token(); | 
					
						
							| 
									
										
										
										
											2022-04-27 14:18:32 +03:00
										 |  |  | 	bool _lookup_next(Token &r_tk); | 
					
						
							| 
									
										
										
										
											2024-08-10 11:07:53 +03:00
										 |  |  | 	Token _peek(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 	ShaderNode *shader = nullptr; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	enum IdentifierType { | 
					
						
							|  |  |  | 		IDENTIFIER_FUNCTION, | 
					
						
							|  |  |  | 		IDENTIFIER_UNIFORM, | 
					
						
							|  |  |  | 		IDENTIFIER_VARYING, | 
					
						
							|  |  |  | 		IDENTIFIER_FUNCTION_ARGUMENT, | 
					
						
							|  |  |  | 		IDENTIFIER_LOCAL_VAR, | 
					
						
							|  |  |  | 		IDENTIFIER_BUILTIN_VAR, | 
					
						
							| 
									
										
										
										
											2019-05-30 17:19:24 +03:00
										 |  |  | 		IDENTIFIER_CONSTANT, | 
					
						
							| 
									
										
										
										
											2021-01-01 18:04:47 +03:00
										 |  |  | 		IDENTIFIER_MAX, | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-01 18:04:47 +03:00
										 |  |  | 	IdentifierType last_type = IDENTIFIER_MAX; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-01 16:39:49 +03:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2021-01-01 18:04:47 +03:00
										 |  |  | #ifdef DEBUG_ENABLED
 | 
					
						
							| 
									
										
										
										
											2021-06-29 14:34:54 +03:00
										 |  |  | 	void _parse_used_identifier(const StringName &p_identifier, IdentifierType p_type, const StringName &p_function); | 
					
						
							| 
									
										
										
										
											2021-01-01 18:04:47 +03:00
										 |  |  | #endif // DEBUG_ENABLED
 | 
					
						
							| 
									
										
										
										
											2017-12-15 18:23:16 -03:00
										 |  |  | 	bool _is_operator_assign(Operator p_op) const; | 
					
						
							| 
									
										
										
										
											2020-09-06 09:18:10 -03:00
										 |  |  | 	bool _validate_assign(Node *p_node, const FunctionInfo &p_function_info, String *r_message = nullptr); | 
					
						
							| 
									
										
										
										
											2025-02-01 17:01:44 +03:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2024-07-01 16:39:49 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-01 17:01:44 +03:00
										 |  |  | 	Vector<Scalar> _get_node_values(const BlockNode *p_block, const FunctionInfo &p_function_info, Node *p_node); | 
					
						
							|  |  |  | 	bool _eval_operator(const BlockNode *p_block, const FunctionInfo &p_function_info, OperatorNode *p_op); | 
					
						
							| 
									
										
										
										
											2024-07-01 16:39:49 +03:00
										 |  |  | 	Scalar _eval_unary_scalar(const Scalar &p_a, Operator p_op, DataType p_ret_type); | 
					
						
							|  |  |  | 	Scalar _eval_scalar(const Scalar &p_a, const Scalar &p_b, Operator p_op, DataType p_ret_type, bool &r_is_valid); | 
					
						
							|  |  |  | 	Vector<Scalar> _eval_unary_vector(const Vector<Scalar> &p_va, DataType p_ret_type, Operator p_op); | 
					
						
							|  |  |  | 	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); | 
					
						
							|  |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-19 18:38:51 +03:00
										 |  |  | 	struct BuiltinEntry { | 
					
						
							|  |  |  | 		const char *name; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 	struct BuiltinFuncDef { | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		enum { MAX_ARGS = 5 }; | 
					
						
							|  |  |  | 		const char *name; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		DataType rettype; | 
					
						
							|  |  |  | 		const DataType args[MAX_ARGS]; | 
					
						
							| 
									
										
										
										
											2021-08-08 14:49:59 +03:00
										 |  |  | 		const char *args_names[MAX_ARGS]; | 
					
						
							| 
									
										
										
										
											2019-07-10 19:52:50 +03:00
										 |  |  | 		SubClassTag tag; | 
					
						
							| 
									
										
										
										
											2019-10-30 12:38:35 +03:00
										 |  |  | 		bool high_end; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-13 09:23:29 +01:00
										 |  |  | 	struct BuiltinFuncOutArgs { //arguments used as out in built in functions
 | 
					
						
							| 
									
										
										
										
											2021-10-13 12:49:57 +03:00
										 |  |  | 		enum { MAX_ARGS = 2 }; | 
					
						
							| 
									
										
										
										
											2018-11-14 18:55:38 -03:00
										 |  |  | 		const char *name; | 
					
						
							| 
									
										
										
										
											2021-10-13 12:49:57 +03:00
										 |  |  | 		const int arguments[MAX_ARGS]; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	struct BuiltinFuncConstArgs { | 
					
						
							|  |  |  | 		const char *name; | 
					
						
							|  |  |  | 		int arg; | 
					
						
							|  |  |  | 		int min; | 
					
						
							|  |  |  | 		int max; | 
					
						
							| 
									
										
										
										
											2018-11-14 18:55:38 -03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 	CompletionType completion_type; | 
					
						
							| 
									
										
										
										
											2022-09-11 14:49:19 +03:00
										 |  |  | 	ShaderNode::Uniform::Hint current_uniform_hint = ShaderNode::Uniform::HINT_NONE; | 
					
						
							|  |  |  | 	TextureFilter current_uniform_filter = FILTER_DEFAULT; | 
					
						
							|  |  |  | 	TextureRepeat current_uniform_repeat = REPEAT_DEFAULT; | 
					
						
							|  |  |  | 	bool current_uniform_instance_index_defined = false; | 
					
						
							| 
									
										
										
										
											2022-05-02 16:28:25 +02:00
										 |  |  | 	int completion_line = 0; | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 	BlockNode *completion_block = nullptr; | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 	DataType completion_base; | 
					
						
							| 
									
										
										
										
											2022-05-02 16:28:25 +02:00
										 |  |  | 	bool completion_base_array = false; | 
					
						
							| 
									
										
										
										
											2019-07-10 19:52:50 +03:00
										 |  |  | 	SubClassTag completion_class; | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 	StringName completion_function; | 
					
						
							| 
									
										
										
										
											2020-01-17 22:35:22 +03:00
										 |  |  | 	StringName completion_struct; | 
					
						
							| 
									
										
										
										
											2022-05-02 16:28:25 +02:00
										 |  |  | 	int completion_argument = 0; | 
					
						
							| 
									
										
										
										
											2021-12-09 20:29:23 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-27 14:18:32 +03:00
										 |  |  | #ifdef DEBUG_ENABLED
 | 
					
						
							|  |  |  | 	uint32_t keyword_completion_context; | 
					
						
							|  |  |  | #endif // DEBUG_ENABLED
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 	const HashMap<StringName, FunctionInfo> *stages = nullptr; | 
					
						
							| 
									
										
										
										
											2024-06-19 18:38:51 +03:00
										 |  |  | 	bool is_supported_frag_only_funcs = false; | 
					
						
							| 
									
										
										
										
											2024-06-25 15:39:21 +03:00
										 |  |  | 	bool is_discard_supported = false; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	bool _get_completable_identifier(BlockNode *p_block, CompletionType p_type, StringName &identifier); | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 	static const BuiltinFuncDef builtin_func_defs[]; | 
					
						
							| 
									
										
										
										
											2018-11-14 18:55:38 -03:00
										 |  |  | 	static const BuiltinFuncOutArgs builtin_func_out_args[]; | 
					
						
							| 
									
										
										
										
											2021-10-13 12:49:57 +03:00
										 |  |  | 	static const BuiltinFuncConstArgs builtin_func_const_args[]; | 
					
						
							| 
									
										
										
										
											2024-06-19 18:38:51 +03:00
										 |  |  | 	static const BuiltinEntry frag_only_func_defs[]; | 
					
						
							| 
									
										
										
										
											2015-01-11 11:43:31 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-03 22:05:23 +03:00
										 |  |  | 	static bool is_const_suffix_lut_initialized; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-26 11:46:06 +03:00
										 |  |  | 	Error _validate_precision(DataType p_type, DataPrecision p_precision); | 
					
						
							| 
									
										
										
										
											2021-05-21 19:16:23 +03:00
										 |  |  | 	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); | 
					
						
							|  |  |  | 	bool _compare_datatypes_in_nodes(Node *a, Node *b); | 
					
						
							| 
									
										
										
										
											2019-11-03 13:28:29 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-29 12:14:22 +03:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2020-09-06 09:18:10 -03:00
										 |  |  | 	bool _parse_function_arguments(BlockNode *p_block, const FunctionInfo &p_function_info, OperatorNode *p_func, int *r_complete_arg = nullptr); | 
					
						
							| 
									
										
										
										
											2024-07-28 22:31:57 -07:00
										 |  |  | 	ShaderNode::Uniform::Hint _sanitize_hint(ShaderNode::Uniform::Hint p_hint); | 
					
						
							| 
									
										
										
										
											2024-07-26 10:45:36 -07:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2021-08-01 16:47:20 -03:00
										 |  |  | 	bool _propagate_function_call_sampler_builtin_reference(const StringName &p_name, int p_argument, const StringName &p_builtin); | 
					
						
							| 
									
										
										
										
											2020-12-26 14:26:19 +03:00
										 |  |  | 	bool _validate_varying_assign(ShaderNode::Varying &p_varying, String *r_message); | 
					
						
							| 
									
										
										
										
											2021-04-27 14:58:32 +03:00
										 |  |  | 	bool _check_node_constness(const Node *p_node) const; | 
					
						
							| 
									
										
										
										
											2015-01-11 11:43:31 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-19 18:38:51 +03:00
										 |  |  | 	bool _check_restricted_func(const StringName &p_name, const StringName &p_current_function) const; | 
					
						
							|  |  |  | 	bool _validate_restricted_func(const StringName &p_call_name, const CallInfo *p_func_info, bool p_is_builtin_hint = false); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-14 18:08:05 +03:00
										 |  |  | 	Node *_parse_expression(BlockNode *p_block, const FunctionInfo &p_function_info, const ExpressionInfo *p_previous_expression_info = nullptr); | 
					
						
							| 
									
										
										
										
											2022-01-15 12:10:26 +03:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2021-05-21 19:16:23 +03:00
										 |  |  | 	Node *_parse_array_constructor(BlockNode *p_block, const FunctionInfo &p_function_info); | 
					
						
							| 
									
										
										
										
											2020-12-26 21:13:24 +03:00
										 |  |  | 	Node *_parse_array_constructor(BlockNode *p_block, const FunctionInfo &p_function_info, DataType p_type, const StringName &p_struct_name, int p_array_size); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	ShaderLanguage::Node *_reduce_expression(BlockNode *p_block, ShaderLanguage::Node *p_node); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-14 18:08:05 +03:00
										 |  |  | 	Node *_parse_and_reduce_expression(BlockNode *p_block, const FunctionInfo &p_function_info, const ExpressionInfo *p_previous_expression_info = nullptr); | 
					
						
							| 
									
										
										
										
											2020-09-06 09:18:10 -03:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2022-05-19 17:00:06 +02:00
										 |  |  | 	String _get_shader_type_list(const HashSet<String> &p_shader_types) const; | 
					
						
							| 
									
										
										
										
											2020-02-12 23:16:47 +03:00
										 |  |  | 	String _get_qualifier_str(ArgumentQualifier p_qualifier) const; | 
					
						
							| 
									
										
										
										
											2019-10-26 17:41:47 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-01 17:01:44 +03:00
										 |  |  | 	bool _parse_numeric_constant_expression(const FunctionInfo &p_function_info, float &r_constant); | 
					
						
							| 
									
										
										
										
											2023-02-17 15:20:26 -06:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-23 15:40:42 +03:00
										 |  |  | 	Error _find_last_flow_op_in_block(BlockNode *p_block, FlowOperation p_op); | 
					
						
							|  |  |  | 	Error _find_last_flow_op_in_op(ControlFlowNode *p_flow, FlowOperation p_op); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-17 15:20:26 -06:00
										 |  |  | 	Error _parse_shader_mode(bool p_is_stencil, const Vector<ModeInfo> &p_modes, HashMap<String, String> &r_defined_modes); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2021-01-01 18:04:47 +03:00
										 |  |  | #ifdef DEBUG_ENABLED
 | 
					
						
							|  |  |  | 	List<ShaderWarning>::Element *get_warnings_ptr(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void enable_warning_checking(bool p_enabled); | 
					
						
							|  |  |  | 	bool is_warning_checking_enabled() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void set_warning_flags(uint32_t p_flags); | 
					
						
							|  |  |  | 	uint32_t get_warning_flags() const; | 
					
						
							|  |  |  | #endif // DEBUG_ENABLED
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-14 12:26:56 +01:00
										 |  |  | 	//static void get_keyword_list(ShaderType p_type,List<String> *p_keywords);
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	void clear(); | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	static String get_shader_type(const String &p_code); | 
					
						
							| 
									
										
										
										
											2022-11-14 11:11:33 +03:00
										 |  |  | 	static bool is_builtin_func_out_parameter(const String &p_name, int p_param); | 
					
						
							| 
									
										
										
										
											2021-08-08 08:04:20 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	struct ShaderCompileInfo { | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 		HashMap<StringName, FunctionInfo> functions; | 
					
						
							| 
									
										
										
										
											2021-12-21 17:21:55 +03:00
										 |  |  | 		Vector<ModeInfo> render_modes; | 
					
						
							| 
									
										
										
										
											2023-02-17 15:20:26 -06:00
										 |  |  | 		Vector<ModeInfo> stencil_modes; | 
					
						
							| 
									
										
										
										
											2024-06-21 11:19:04 -05:00
										 |  |  | 		VaryingFunctionNames varying_function_names; | 
					
						
							| 
									
										
										
										
											2022-05-19 17:00:06 +02:00
										 |  |  | 		HashSet<String> shader_types; | 
					
						
							| 
									
										
										
										
											2022-04-03 18:56:43 +02:00
										 |  |  | 		GlobalShaderUniformGetTypeFunc global_shader_uniform_type_func = nullptr; | 
					
						
							| 
									
										
										
										
											2022-03-08 13:39:16 +03:00
										 |  |  | 		bool is_include = false; | 
					
						
							| 
									
										
										
										
											2025-02-12 16:12:46 -08:00
										 |  |  | 		uint32_t base_varying_index = 0; | 
					
						
							| 
									
										
										
										
											2021-08-08 08:04:20 +03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Error compile(const String &p_code, const ShaderCompileInfo &p_info); | 
					
						
							| 
									
										
										
										
											2022-03-26 16:48:43 +01:00
										 |  |  | 	Error complete(const String &p_code, const ShaderCompileInfo &p_info, List<ScriptLanguage::CodeCompletionOption> *r_options, String &r_call_hint); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	String get_error_text(); | 
					
						
							| 
									
										
										
										
											2022-06-29 11:31:18 +02:00
										 |  |  | 	Vector<FilePosition> get_include_positions(); | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	int get_error_line(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-07 11:31:18 -03:00
										 |  |  | 	ShaderNode *get_shader(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	String token_debug(const String &p_code); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 	ShaderLanguage(); | 
					
						
							|  |  |  | 	~ShaderLanguage(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | }; |