From e8a457ba898ffde5dbc02d573103f00d626f3a5b Mon Sep 17 00:00:00 2001 From: Yuri Roubinsky Date: Tue, 21 Dec 2021 17:21:55 +0300 Subject: Refactor render_mode in shaders, forbid declaring duplicates --- servers/rendering/shader_language.h | 55 +++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) (limited to 'servers/rendering/shader_language.h') diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index 8502a250b6..0ed3d9fabf 100644 --- a/servers/rendering/shader_language.h +++ b/servers/rendering/shader_language.h @@ -819,6 +819,57 @@ public: DataType return_type = TYPE_VOID; }; + struct ModeInfo { + StringName name; + Vector 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); + } + }; + struct FunctionInfo { Map built_ins; Map stage_functions; @@ -1013,7 +1064,7 @@ private: String _get_shader_type_list(const Set &p_shader_types) const; String _get_qualifier_str(ArgumentQualifier p_qualifier) const; - Error _parse_shader(const Map &p_functions, const Vector &p_render_modes, const Set &p_shader_types); + Error _parse_shader(const Map &p_functions, const Vector &p_render_modes, const Set &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); @@ -1037,7 +1088,7 @@ public: struct ShaderCompileInfo { Map functions; - Vector render_modes; + Vector render_modes; VaryingFunctionNames varying_function_names = VaryingFunctionNames(); Set shader_types; GlobalVariableGetTypeFunc global_variable_type_func = nullptr; -- cgit v1.2.3