summaryrefslogtreecommitdiff
path: root/servers/rendering/shader_language.h
diff options
context:
space:
mode:
Diffstat (limited to 'servers/rendering/shader_language.h')
-rw-r--r--servers/rendering/shader_language.h76
1 files changed, 43 insertions, 33 deletions
diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h
index de6d912a4f..d4a2e0b549 100644
--- a/servers/rendering/shader_language.h
+++ b/servers/rendering/shader_language.h
@@ -35,7 +35,7 @@
#include "core/string/string_name.h"
#include "core/string/ustring.h"
#include "core/templates/list.h"
-#include "core/templates/map.h"
+#include "core/templates/rb_map.h"
#include "core/typedefs.h"
#include "core/variant/variant.h"
@@ -525,7 +525,7 @@ public:
ConstantNode::Value value;
};
- Map<StringName, Variable> variables;
+ HashMap<StringName, Variable> variables;
List<Node *> statements;
bool single_statement = false;
bool use_comma_between_statements = false;
@@ -589,7 +589,7 @@ public:
bool is_const;
int array_size;
- Map<StringName, Set<int>> tex_argument_connect;
+ HashMap<StringName, RBSet<int>> tex_argument_connect;
};
StringName name;
@@ -622,7 +622,7 @@ public:
struct Function {
StringName name;
FunctionNode *function = nullptr;
- Set<StringName> uses_function;
+ RBSet<StringName> uses_function;
bool callable;
};
@@ -697,10 +697,10 @@ public:
}
};
- Map<StringName, Constant> constants;
- Map<StringName, Varying> varyings;
- Map<StringName, Uniform> uniforms;
- Map<StringName, Struct> structs;
+ HashMap<StringName, Constant> constants;
+ HashMap<StringName, Varying> varyings;
+ HashMap<StringName, Uniform> uniforms;
+ HashMap<StringName, Struct> structs;
Vector<StringName> render_modes;
Vector<Function> functions;
@@ -756,6 +756,7 @@ public:
static bool is_token_interpolation(TokenType p_type);
static DataInterpolation get_token_interpolation(TokenType p_type);
static bool is_token_precision(TokenType p_type);
+ static bool is_token_arg_qual(TokenType p_type);
static DataPrecision get_token_precision(TokenType p_type);
static String get_precision_name(DataPrecision p_type);
static String get_datatype_name(DataType p_type);
@@ -856,13 +857,13 @@ public:
};
struct FunctionInfo {
- Map<StringName, BuiltInInfo> built_ins;
- Map<StringName, StageFunctionInfo> stage_functions;
+ HashMap<StringName, BuiltInInfo> built_ins;
+ HashMap<StringName, StageFunctionInfo> stage_functions;
bool can_discard = false;
bool main_function = false;
};
- static bool has_builtin(const Map<StringName, ShaderLanguage::FunctionInfo> &p_functions, const StringName &p_name);
+ static bool has_builtin(const HashMap<StringName, ShaderLanguage::FunctionInfo> &p_functions, const StringName &p_name);
typedef DataType (*GlobalVariableGetTypeFunc)(const StringName &p_name);
@@ -870,15 +871,18 @@ private:
struct KeyWord {
TokenType token;
const char *text;
+ uint32_t flags;
+ const Vector<String> excluded_shader_types;
+ const Vector<String> functions;
};
static const KeyWord keyword_list[];
- GlobalVariableGetTypeFunc global_var_get_type_func;
+ GlobalVariableGetTypeFunc global_var_get_type_func = nullptr;
- bool error_set;
+ bool error_set = false;
String error_str;
- int error_line;
+ int error_line = 0;
#ifdef DEBUG_ENABLED
struct Usage {
@@ -889,20 +893,20 @@ private:
}
};
- Map<StringName, Usage> used_constants;
- Map<StringName, Usage> used_varyings;
- Map<StringName, Usage> used_uniforms;
- Map<StringName, Usage> used_functions;
- Map<StringName, Usage> used_structs;
- Map<ShaderWarning::Code, Map<StringName, Usage> *> warnings_check_map;
+ 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;
- Map<StringName, Map<StringName, Usage>> used_local_vars;
- Map<ShaderWarning::Code, Map<StringName, Map<StringName, Usage>> *> warnings_check_map2;
+ HashMap<StringName, HashMap<StringName, Usage>> used_local_vars;
+ HashMap<ShaderWarning::Code, HashMap<StringName, HashMap<StringName, Usage>> *> warnings_check_map2;
List<ShaderWarning> warnings;
bool check_warnings = false;
- uint32_t warning_flags;
+ uint32_t warning_flags = 0;
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));
@@ -917,9 +921,10 @@ private:
#endif // DEBUG_ENABLED
String code;
- int char_idx;
- int tk_line;
+ int char_idx = 0;
+ int tk_line = 0;
+ StringName shader_type_identifier;
StringName current_function;
bool last_const = false;
StringName last_name;
@@ -972,6 +977,7 @@ private:
Token _make_token(TokenType p_type, const StringName &p_text = StringName());
Token _get_token();
+ bool _lookup_next(Token &r_tk);
ShaderNode *shader = nullptr;
@@ -1020,16 +1026,20 @@ private:
};
CompletionType completion_type;
- int completion_line;
+ int completion_line = 0;
BlockNode *completion_block = nullptr;
DataType completion_base;
- bool completion_base_array;
+ bool completion_base_array = false;
SubClassTag completion_class;
StringName completion_function;
StringName completion_struct;
- int completion_argument;
+ int completion_argument = 0;
- const Map<StringName, FunctionInfo> *stages = nullptr;
+#ifdef DEBUG_ENABLED
+ uint32_t keyword_completion_context;
+#endif // DEBUG_ENABLED
+
+ const HashMap<StringName, FunctionInfo> *stages = nullptr;
bool _get_completable_identifier(BlockNode *p_block, CompletionType p_type, StringName &identifier);
static const BuiltinFuncDef builtin_func_defs[];
@@ -1058,10 +1068,10 @@ private:
Node *_parse_and_reduce_expression(BlockNode *p_block, const FunctionInfo &p_function_info);
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);
- String _get_shader_type_list(const Set<String> &p_shader_types) const;
+ String _get_shader_type_list(const RBSet<String> &p_shader_types) const;
String _get_qualifier_str(ArgumentQualifier p_qualifier) const;
- Error _parse_shader(const Map<StringName, FunctionInfo> &p_functions, const Vector<ModeInfo> &p_render_modes, const Set<String> &p_shader_types);
+ Error _parse_shader(const HashMap<StringName, FunctionInfo> &p_functions, const Vector<ModeInfo> &p_render_modes, const RBSet<String> &p_shader_types);
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);
@@ -1084,10 +1094,10 @@ public:
static String get_shader_type(const String &p_code);
struct ShaderCompileInfo {
- Map<StringName, FunctionInfo> functions;
+ HashMap<StringName, FunctionInfo> functions;
Vector<ModeInfo> render_modes;
VaryingFunctionNames varying_function_names = VaryingFunctionNames();
- Set<String> shader_types;
+ RBSet<String> shader_types;
GlobalVariableGetTypeFunc global_variable_type_func = nullptr;
};