diff options
Diffstat (limited to 'servers')
-rw-r--r-- | servers/visual/shader_language.cpp | 12 | ||||
-rw-r--r-- | servers/visual/shader_language.h | 6 | ||||
-rw-r--r-- | servers/visual/shader_types.cpp | 83 | ||||
-rw-r--r-- | servers/visual/shader_types.h | 6 |
4 files changed, 55 insertions, 52 deletions
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index 2069e64c43..346b04f070 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -3583,7 +3583,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui return OK; } -Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_functions, const Set<String> &p_render_modes, const Set<String> &p_shader_types) { +Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types) { Token tk = _get_token(); @@ -3642,7 +3642,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct return ERR_PARSE_ERROR; } - if (!p_render_modes.has(mode)) { + if (p_render_modes.find(mode) == -1) { _set_error("Invalid render mode: '" + String(mode) + "'"); return ERR_PARSE_ERROR; } @@ -4097,7 +4097,7 @@ String ShaderLanguage::get_shader_type(const String &p_code) { return String(); } -Error ShaderLanguage::compile(const String &p_code, const Map<StringName, FunctionInfo> &p_functions, const Set<String> &p_render_modes, const Set<String> &p_shader_types) { +Error ShaderLanguage::compile(const String &p_code, const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types) { clear(); @@ -4114,7 +4114,7 @@ Error ShaderLanguage::compile(const String &p_code, const Map<StringName, Functi return OK; } -Error ShaderLanguage::complete(const String &p_code, const Map<StringName, FunctionInfo> &p_functions, const Set<String> &p_render_modes, const Set<String> &p_shader_types, List<String> *r_options, String &r_call_hint) { +Error ShaderLanguage::complete(const String &p_code, const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types, List<String> *r_options, String &r_call_hint) { clear(); @@ -4134,9 +4134,9 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct return ERR_PARSE_ERROR; } break; case COMPLETION_RENDER_MODE: { - for (const Set<String>::Element *E = p_render_modes.front(); E; E = E->next()) { + for (int i = 0; i < p_render_modes.size(); i++) { - r_options->push_back(E->get()); + r_options->push_back(p_render_modes[i]); } return OK; diff --git a/servers/visual/shader_language.h b/servers/visual/shader_language.h index 720511e18d..9b84c5f195 100644 --- a/servers/visual/shader_language.h +++ b/servers/visual/shader_language.h @@ -650,7 +650,7 @@ private: Error _parse_block(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types, bool p_just_one = false, bool p_can_break = false, bool p_can_continue = false); - Error _parse_shader(const Map<StringName, FunctionInfo> &p_functions, const Set<String> &p_render_modes, const Set<String> &p_shader_types); + Error _parse_shader(const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types); public: //static void get_keyword_list(ShaderType p_type,List<String> *p_keywords); @@ -658,8 +658,8 @@ public: void clear(); static String get_shader_type(const String &p_code); - Error compile(const String &p_code, const Map<StringName, FunctionInfo> &p_functions, const Set<String> &p_render_modes, const Set<String> &p_shader_types); - Error complete(const String &p_code, const Map<StringName, FunctionInfo> &p_functions, const Set<String> &p_render_modes, const Set<String> &p_shader_types, List<String> *r_options, String &r_call_hint); + Error compile(const String &p_code, const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types); + Error complete(const String &p_code, const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types, List<String> *r_options, String &r_call_hint); String get_error_text(); int get_error_line(); diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp index a92e1b06d2..92786ea740 100644 --- a/servers/visual/shader_types.cpp +++ b/servers/visual/shader_types.cpp @@ -35,7 +35,7 @@ const Map<StringName, ShaderLanguage::FunctionInfo> &ShaderTypes::get_functions( return shader_modes[p_mode].functions; } -const Set<String> &ShaderTypes::get_modes(VS::ShaderMode p_mode) { +const Vector<StringName> &ShaderTypes::get_modes(VS::ShaderMode p_mode) { return shader_modes[p_mode].modes; } @@ -140,43 +140,44 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_SPATIAL].functions["light"].can_discard = true; - shader_modes[VS::SHADER_SPATIAL].modes.insert("blend_mix"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("blend_add"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("blend_sub"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("blend_mul"); + //order used puts first enum mode (default) first + shader_modes[VS::SHADER_SPATIAL].modes.push_back("blend_mix"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("blend_add"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("blend_sub"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("blend_mul"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("depth_draw_opaque"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("depth_draw_always"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("depth_draw_never"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("depth_draw_alpha_prepass"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("depth_draw_opaque"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("depth_draw_always"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("depth_draw_never"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("depth_draw_alpha_prepass"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("depth_test_disable"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("depth_test_disable"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("cull_front"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("cull_back"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("cull_disabled"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("cull_back"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("cull_front"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("cull_disabled"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("unshaded"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("unshaded"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_lambert"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_lambert_wrap"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_oren_nayar"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_burley"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_toon"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("diffuse_lambert"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("diffuse_lambert_wrap"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("diffuse_oren_nayar"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("diffuse_burley"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("diffuse_toon"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("specular_schlick_ggx"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("specular_blinn"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("specular_phong"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("specular_toon"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("specular_disabled"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("specular_schlick_ggx"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("specular_blinn"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("specular_phong"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("specular_toon"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("specular_disabled"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("skip_vertex_transform"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("world_vertex_coords"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("ensure_correct_normals"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("skip_vertex_transform"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("world_vertex_coords"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("ensure_correct_normals"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("shadows_disabled"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("shadows_disabled"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("vertex_lighting"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("vertex_lighting"); /************ CANVAS ITEM **************************/ @@ -227,17 +228,17 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].can_discard = true; - shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("skip_vertex_transform"); + shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("skip_vertex_transform"); - shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("blend_mix"); - shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("blend_add"); - shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("blend_sub"); - shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("blend_mul"); - shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("blend_premul_alpha"); - shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("blend_disabled"); + shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("blend_mix"); + shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("blend_add"); + shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("blend_sub"); + shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("blend_mul"); + shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("blend_premul_alpha"); + shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("blend_disabled"); - shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("unshaded"); - shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("light_only"); + shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("unshaded"); + shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("light_only"); /************ PARTICLES **************************/ @@ -257,9 +258,9 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["RANDOM_SEED"] = constt(ShaderLanguage::TYPE_UINT); shader_modes[VS::SHADER_PARTICLES].functions["vertex"].can_discard = false; - shader_modes[VS::SHADER_PARTICLES].modes.insert("disable_force"); - shader_modes[VS::SHADER_PARTICLES].modes.insert("disable_velocity"); - shader_modes[VS::SHADER_PARTICLES].modes.insert("keep_data"); + shader_modes[VS::SHADER_PARTICLES].modes.push_back("disable_force"); + shader_modes[VS::SHADER_PARTICLES].modes.push_back("disable_velocity"); + shader_modes[VS::SHADER_PARTICLES].modes.push_back("keep_data"); shader_types.insert("spatial"); shader_types.insert("canvas_item"); diff --git a/servers/visual/shader_types.h b/servers/visual/shader_types.h index 1f43ff9c92..0680ec8242 100644 --- a/servers/visual/shader_types.h +++ b/servers/visual/shader_types.h @@ -31,14 +31,16 @@ #ifndef SHADERTYPES_H #define SHADERTYPES_H +#include "ordered_hash_map.h" #include "servers/visual_server.h" #include "shader_language.h" + class ShaderTypes { struct Type { Map<StringName, ShaderLanguage::FunctionInfo> functions; - Set<String> modes; + Vector<StringName> modes; }; Map<VS::ShaderMode, Type> shader_modes; @@ -51,7 +53,7 @@ public: static ShaderTypes *get_singleton() { return singleton; } const Map<StringName, ShaderLanguage::FunctionInfo> &get_functions(VS::ShaderMode p_mode); - const Set<String> &get_modes(VS::ShaderMode p_mode); + const Vector<StringName> &get_modes(VS::ShaderMode p_mode); const Set<String> &get_types(); ShaderTypes(); |