diff options
author | reduz <reduzio@gmail.com> | 2022-05-13 15:04:37 +0200 |
---|---|---|
committer | RĂ©mi Verschelde <rverschelde@gmail.com> | 2022-05-16 10:37:48 +0200 |
commit | 746dddc0673d7261f19b1e056e90e6e3a49ef33a (patch) | |
tree | 434b526eb286850ebccc6d2c998a7d90fdb8b5e2 /servers/rendering | |
parent | 396def9b66c476f7834604adb7136ca903ed01be (diff) |
Replace most uses of Map by HashMap
* Map is unnecessary and inefficient in almost every case.
* Replaced by the new HashMap.
* Renamed Map to RBMap and Set to RBSet for cases that still make sense
(order matters) but use is discouraged.
There were very few cases where replacing by HashMap was undesired because
keeping the key order was intended.
I tried to keep those (as RBMap) as much as possible, but might have missed
some. Review appreciated!
Diffstat (limited to 'servers/rendering')
40 files changed, 289 insertions, 287 deletions
diff --git a/servers/rendering/renderer_canvas_cull.cpp b/servers/rendering/renderer_canvas_cull.cpp index 84ab19880c..46bc22ad54 100644 --- a/servers/rendering/renderer_canvas_cull.cpp +++ b/servers/rendering/renderer_canvas_cull.cpp @@ -1831,7 +1831,7 @@ void RendererCanvasCull::canvas_occluder_polygon_set_shape(RID p_occluder_polygo RSG::canvas_render->occluder_polygon_set_shape(occluder_poly->occluder, p_shape, p_closed); - for (Set<RendererCanvasRender::LightOccluderInstance *>::Element *E = occluder_poly->owners.front(); E; E = E->next()) { + for (RBSet<RendererCanvasRender::LightOccluderInstance *>::Element *E = occluder_poly->owners.front(); E; E = E->next()) { E->get()->aabb_cache = occluder_poly->aabb; } } @@ -1841,7 +1841,7 @@ void RendererCanvasCull::canvas_occluder_polygon_set_cull_mode(RID p_occluder_po ERR_FAIL_COND(!occluder_poly); occluder_poly->cull_mode = p_mode; RSG::canvas_render->occluder_polygon_set_cull_mode(occluder_poly->occluder, p_mode); - for (Set<RendererCanvasRender::LightOccluderInstance *>::Element *E = occluder_poly->owners.front(); E; E = E->next()) { + for (RBSet<RendererCanvasRender::LightOccluderInstance *>::Element *E = occluder_poly->owners.front(); E; E = E->next()) { E->get()->cull_cache = p_mode; } } @@ -1931,7 +1931,7 @@ bool RendererCanvasCull::free(RID p_rid) { RendererViewport::Viewport *vp = RSG::viewport->viewport_owner.get_or_null(canvas->viewports.front()->get()); ERR_FAIL_COND_V(!vp, true); - Map<RID, RendererViewport::Viewport::CanvasData>::Element *E = vp->canvas_map.find(p_rid); + HashMap<RID, RendererViewport::Viewport::CanvasData>::Iterator E = vp->canvas_map.find(p_rid); ERR_FAIL_COND_V(!E, true); vp->canvas_map.erase(p_rid); @@ -1942,11 +1942,11 @@ bool RendererCanvasCull::free(RID p_rid) { canvas->child_items[i].item->parent = RID(); } - for (Set<RendererCanvasRender::Light *>::Element *E = canvas->lights.front(); E; E = E->next()) { + for (RBSet<RendererCanvasRender::Light *>::Element *E = canvas->lights.front(); E; E = E->next()) { E->get()->canvas = RID(); } - for (Set<RendererCanvasRender::LightOccluderInstance *>::Element *E = canvas->occluders.front(); E; E = E->next()) { + for (RBSet<RendererCanvasRender::LightOccluderInstance *>::Element *E = canvas->occluders.front(); E; E = E->next()) { E->get()->canvas = RID(); } diff --git a/servers/rendering/renderer_canvas_cull.h b/servers/rendering/renderer_canvas_cull.h index 637245502d..6f3cd1d2c6 100644 --- a/servers/rendering/renderer_canvas_cull.h +++ b/servers/rendering/renderer_canvas_cull.h @@ -108,7 +108,7 @@ public: Rect2 aabb; RS::CanvasOccluderPolygonCullMode cull_mode; RID occluder; - Set<RendererCanvasRender::LightOccluderInstance *> owners; + RBSet<RendererCanvasRender::LightOccluderInstance *> owners; LightOccluderPolygon() { active = false; @@ -121,7 +121,7 @@ public: RID_Owner<RendererCanvasRender::LightOccluderInstance, true> canvas_light_occluder_owner; struct Canvas : public RendererViewport::CanvasBase { - Set<RID> viewports; + RBSet<RID> viewports; struct ChildItem { Point2 mirror; Item *item = nullptr; @@ -130,10 +130,10 @@ public: } }; - Set<RendererCanvasRender::Light *> lights; - Set<RendererCanvasRender::Light *> directional_lights; + RBSet<RendererCanvasRender::Light *> lights; + RBSet<RendererCanvasRender::Light *> directional_lights; - Set<RendererCanvasRender::LightOccluderInstance *> occluders; + RBSet<RendererCanvasRender::LightOccluderInstance *> occluders; bool children_order_dirty; Vector<ChildItem> child_items; diff --git a/servers/rendering/renderer_rd/effects_rd.h b/servers/rendering/renderer_rd/effects_rd.h index 4774864824..1963935236 100644 --- a/servers/rendering/renderer_rd/effects_rd.h +++ b/servers/rendering/renderer_rd/effects_rd.h @@ -608,10 +608,10 @@ private: RID index_buffer; RID index_array; - Map<RID, RID> texture_to_uniform_set_cache; - Map<RID, RID> input_to_uniform_set_cache; + HashMap<RID, RID> texture_to_uniform_set_cache; + HashMap<RID, RID> input_to_uniform_set_cache; - Map<RID, RID> image_to_uniform_set_cache; + HashMap<RID, RID> image_to_uniform_set_cache; struct TexturePair { RID texture1; @@ -637,11 +637,11 @@ private: } }; - Map<TexturePair, RID> texture_pair_to_uniform_set_cache; - Map<RID, RID> texture_to_compute_uniform_set_cache; - Map<TexturePair, RID> texture_pair_to_compute_uniform_set_cache; - Map<TexturePair, RID> image_pair_to_compute_uniform_set_cache; - Map<TextureSamplerPair, RID> texture_sampler_to_compute_uniform_set_cache; + RBMap<TexturePair, RID> texture_pair_to_uniform_set_cache; + RBMap<RID, RID> texture_to_compute_uniform_set_cache; + RBMap<TexturePair, RID> texture_pair_to_compute_uniform_set_cache; + RBMap<TexturePair, RID> image_pair_to_compute_uniform_set_cache; + RBMap<TextureSamplerPair, RID> texture_sampler_to_compute_uniform_set_cache; RID _get_uniform_set_from_image(RID p_texture); RID _get_uniform_set_from_texture(RID p_texture, bool p_use_mipmaps = false); diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp index 4bfaad9fe6..0eb981d51b 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp @@ -2006,14 +2006,14 @@ void RenderForwardClustered::_render_sdfgi(RID p_render_buffers, const Vector3i RID rp_uniform_set = _setup_sdfgi_render_pass_uniform_set(p_albedo_texture, p_emission_texture, p_emission_aniso_texture, p_geom_facing_texture); - Map<Size2i, RID>::Element *E = sdfgi_framebuffer_size_cache.find(fb_size); + HashMap<Size2i, RID>::Iterator E = sdfgi_framebuffer_size_cache.find(fb_size); if (!E) { RID fb = RD::get_singleton()->framebuffer_create_empty(fb_size); E = sdfgi_framebuffer_size_cache.insert(fb_size, fb); } RenderListParameters render_list_params(render_list[RENDER_LIST_SECONDARY].elements.ptr(), render_list[RENDER_LIST_SECONDARY].element_info.ptr(), render_list[RENDER_LIST_SECONDARY].elements.size(), true, pass_mode, 0, true, false, rp_uniform_set, false); - _render_list_with_threads(&render_list_params, E->get(), RD::INITIAL_ACTION_DROP, RD::FINAL_ACTION_DISCARD, RD::INITIAL_ACTION_DROP, RD::FINAL_ACTION_DISCARD, Vector<Color>(), 1.0, 0, Rect2(), sbs); + _render_list_with_threads(&render_list_params, E->value, RD::INITIAL_ACTION_DROP, RD::FINAL_ACTION_DISCARD, RD::INITIAL_ACTION_DROP, RD::FINAL_ACTION_DISCARD, Vector<Color>(), 1.0, 0, Rect2(), sbs); } RD::get_singleton()->draw_command_end_label(); @@ -3276,8 +3276,8 @@ RenderForwardClustered::~RenderForwardClustered() { memdelete_arr(scene_state.lightmap_captures); } - while (sdfgi_framebuffer_size_cache.front()) { - RD::get_singleton()->free(sdfgi_framebuffer_size_cache.front()->get()); - sdfgi_framebuffer_size_cache.erase(sdfgi_framebuffer_size_cache.front()); + while (sdfgi_framebuffer_size_cache.begin()) { + RD::get_singleton()->free(sdfgi_framebuffer_size_cache.begin()->value); + sdfgi_framebuffer_size_cache.remove(sdfgi_framebuffer_size_cache.begin()); } } diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h index 0e588aecb4..bec10f7f0e 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h @@ -106,7 +106,7 @@ class RenderForwardClustered : public RendererSceneRenderRD { RID color_only_fb; RID specular_only_fb; int width, height; - Map<uint32_t, RID> color_framebuffers; + HashMap<uint32_t, RID> color_framebuffers; uint32_t view_count; RID render_sdfgi_uniform_set; @@ -396,7 +396,7 @@ class RenderForwardClustered : public RendererSceneRenderRD { void _fill_instance_data(RenderListType p_render_list, int *p_render_info = nullptr, uint32_t p_offset = 0, int32_t p_max_elements = -1, bool p_update_buffer = true); void _fill_render_list(RenderListType p_render_list, const RenderDataRD *p_render_data, PassMode p_pass_mode, bool p_using_sdfgi = false, bool p_using_opaque_gi = false, bool p_append = false); - Map<Size2i, RID> sdfgi_framebuffer_size_cache; + HashMap<Size2i, RID> sdfgi_framebuffer_size_cache; struct GeometryInstanceData; struct GeometryInstanceForwardClustered; diff --git a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp index 036ad0f18a..bd39dd9c70 100644 --- a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp @@ -154,7 +154,7 @@ void SceneShaderForwardClustered::ShaderData::set_code(const String &p_code) { print_line(gen_code.defines[i]); } - Map<String, String>::Element *el = gen_code.code.front(); + RBMap<String, String>::Element *el = gen_code.code.front(); while (el) { print_line("\n**code " + el->key() + ":\n" + el->value()); @@ -376,14 +376,14 @@ void SceneShaderForwardClustered::ShaderData::set_default_texture_param(const St } } else { if (!default_texture_params.has(p_name)) { - default_texture_params[p_name] = Map<int, RID>(); + default_texture_params[p_name] = HashMap<int, RID>(); } default_texture_params[p_name][p_index] = p_texture; } } void SceneShaderForwardClustered::ShaderData::get_param_list(List<PropertyInfo> *p_param_list) const { - Map<int, StringName> order; + HashMap<int, StringName> order; for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) { if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) { @@ -477,7 +477,7 @@ void SceneShaderForwardClustered::MaterialData::set_next_pass(RID p_pass) { next_pass = p_pass; } -bool SceneShaderForwardClustered::MaterialData::update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) { +bool SceneShaderForwardClustered::MaterialData::update_parameters(const HashMap<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) { SceneShaderForwardClustered *shader_singleton = (SceneShaderForwardClustered *)SceneShaderForwardClustered::singleton; return update_parameters_uniform_set(p_parameters, p_uniform_dirty, p_textures_dirty, shader_data->uniforms, shader_data->ubo_offsets.ptr(), shader_data->texture_uniforms, shader_data->default_texture_params, shader_data->ubo_size, uniform_set, shader_singleton->shader.version_get_shader(shader_data->version, 0), RenderForwardClustered::MATERIAL_UNIFORM_SET, RD::BARRIER_MASK_RASTER); diff --git a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h index 0b2df983ff..c22b2f243d 100644 --- a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h +++ b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h @@ -138,14 +138,14 @@ public: String path; - Map<StringName, ShaderLanguage::ShaderNode::Uniform> uniforms; + HashMap<StringName, ShaderLanguage::ShaderNode::Uniform> uniforms; Vector<ShaderCompiler::GeneratedCode::Texture> texture_uniforms; Vector<uint32_t> ubo_offsets; uint32_t ubo_size = 0; String code; - Map<StringName, Map<int, RID>> default_texture_params; + HashMap<StringName, HashMap<int, RID>> default_texture_params; DepthDraw depth_draw; DepthTest depth_test; @@ -208,7 +208,7 @@ public: uint8_t priority; virtual void set_render_priority(int p_priority); virtual void set_next_pass(RID p_pass); - virtual bool update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty); + virtual bool update_parameters(const HashMap<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty); virtual ~MaterialData(); }; @@ -239,7 +239,7 @@ public: ShaderData *overdraw_material_shader_ptr = nullptr; Vector<RD::PipelineSpecializationConstant> default_specialization_constants; - Set<uint32_t> valid_color_pass_pipelines; + RBSet<uint32_t> valid_color_pass_pipelines; SceneShaderForwardClustered(); ~SceneShaderForwardClustered(); diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp index cdddc35579..a3cabb0693 100644 --- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp +++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp @@ -154,7 +154,7 @@ void SceneShaderForwardMobile::ShaderData::set_code(const String &p_code) { print_line(gen_code.defines[i]); } - Map<String, String>::Element * el = gen_code.code.front(); + RBMap<String, String>::Element * el = gen_code.code.front(); while (el) { print_line("\n**code " + el->key() + ":\n" + el->value()); @@ -339,14 +339,14 @@ void SceneShaderForwardMobile::ShaderData::set_default_texture_param(const Strin } } else { if (!default_texture_params.has(p_name)) { - default_texture_params[p_name] = Map<int, RID>(); + default_texture_params[p_name] = HashMap<int, RID>(); } default_texture_params[p_name][p_index] = p_texture; } } void SceneShaderForwardMobile::ShaderData::get_param_list(List<PropertyInfo> *p_param_list) const { - Map<int, StringName> order; + HashMap<int, StringName> order; for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) { if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) { @@ -440,7 +440,7 @@ void SceneShaderForwardMobile::MaterialData::set_next_pass(RID p_pass) { next_pass = p_pass; } -bool SceneShaderForwardMobile::MaterialData::update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) { +bool SceneShaderForwardMobile::MaterialData::update_parameters(const HashMap<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) { SceneShaderForwardMobile *shader_singleton = (SceneShaderForwardMobile *)SceneShaderForwardMobile::singleton; return update_parameters_uniform_set(p_parameters, p_uniform_dirty, p_textures_dirty, shader_data->uniforms, shader_data->ubo_offsets.ptr(), shader_data->texture_uniforms, shader_data->default_texture_params, shader_data->ubo_size, uniform_set, shader_singleton->shader.version_get_shader(shader_data->version, 0), RenderForwardMobile::MATERIAL_UNIFORM_SET, RD::BARRIER_MASK_RASTER); diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h index 50b5fb26ec..f325d5c0a5 100644 --- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h +++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h @@ -104,14 +104,14 @@ public: String path; - Map<StringName, ShaderLanguage::ShaderNode::Uniform> uniforms; + HashMap<StringName, ShaderLanguage::ShaderNode::Uniform> uniforms; Vector<ShaderCompiler::GeneratedCode::Texture> texture_uniforms; Vector<uint32_t> ubo_offsets; uint32_t ubo_size = 0; String code; - Map<StringName, Map<int, RID>> default_texture_params; + HashMap<StringName, HashMap<int, RID>> default_texture_params; DepthDraw depth_draw; DepthTest depth_test; @@ -171,7 +171,7 @@ public: uint8_t priority; virtual void set_render_priority(int p_priority); virtual void set_next_pass(RID p_pass); - virtual bool update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty); + virtual bool update_parameters(const HashMap<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty); virtual ~MaterialData(); }; diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp index 386bc18fcd..3c2f3f8a42 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp @@ -2160,14 +2160,14 @@ void RendererCanvasRenderRD::CanvasShaderData::set_default_texture_param(const S } } else { if (!default_texture_params.has(p_name)) { - default_texture_params[p_name] = Map<int, RID>(); + default_texture_params[p_name] = HashMap<int, RID>(); } default_texture_params[p_name][p_index] = p_texture; } } void RendererCanvasRenderRD::CanvasShaderData::get_param_list(List<PropertyInfo> *p_param_list) const { - Map<int, StringName> order; + HashMap<int, StringName> order; for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) { if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) { @@ -2246,7 +2246,7 @@ RendererRD::ShaderData *RendererCanvasRenderRD::_create_shader_func() { return shader_data; } -bool RendererCanvasRenderRD::CanvasMaterialData::update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) { +bool RendererCanvasRenderRD::CanvasMaterialData::update_parameters(const HashMap<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) { RendererCanvasRenderRD *canvas_singleton = static_cast<RendererCanvasRenderRD *>(RendererCanvasRender::singleton); return update_parameters_uniform_set(p_parameters, p_uniform_dirty, p_textures_dirty, shader_data->uniforms, shader_data->ubo_offsets.ptr(), shader_data->texture_uniforms, shader_data->default_texture_params, shader_data->ubo_size, uniform_set, canvas_singleton->shader.canvas_shader.version_get_shader(shader_data->version, 0), MATERIAL_UNIFORM_SET); diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.h b/servers/rendering/renderer_rd/renderer_canvas_render_rd.h index 06970acca6..04881ce7e6 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.h +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.h @@ -166,14 +166,14 @@ class RendererCanvasRenderRD : public RendererCanvasRender { PipelineVariants pipeline_variants; String path; - Map<StringName, ShaderLanguage::ShaderNode::Uniform> uniforms; + HashMap<StringName, ShaderLanguage::ShaderNode::Uniform> uniforms; Vector<ShaderCompiler::GeneratedCode::Texture> texture_uniforms; Vector<uint32_t> ubo_offsets; uint32_t ubo_size = 0; String code; - Map<StringName, Map<int, RID>> default_texture_params; + HashMap<StringName, HashMap<int, RID>> default_texture_params; bool uses_screen_texture = false; bool uses_sdf = false; @@ -205,7 +205,7 @@ class RendererCanvasRenderRD : public RendererCanvasRender { virtual void set_render_priority(int p_priority) {} virtual void set_next_pass(RID p_pass) {} - virtual bool update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty); + virtual bool update_parameters(const HashMap<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty); virtual ~CanvasMaterialData(); }; diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.h b/servers/rendering/renderer_rd/renderer_compositor_rd.h index 1fd6550fb8..aefc189f68 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.h +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.h @@ -90,7 +90,7 @@ protected: RID sampler; } blit; - Map<RID, RID> render_target_descriptors; + HashMap<RID, RID> render_target_descriptors; double time = 0.0; double delta = 0.0; diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp index 21b1b45802..e3bf2e3dda 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp @@ -3959,45 +3959,45 @@ void RendererSceneRenderRD::FogShaderData::set_default_texture_param(const Strin } } else { if (!default_texture_params.has(p_name)) { - default_texture_params[p_name] = Map<int, RID>(); + default_texture_params[p_name] = HashMap<int, RID>(); } default_texture_params[p_name][p_index] = p_texture; } } void RendererSceneRenderRD::FogShaderData::get_param_list(List<PropertyInfo> *p_param_list) const { - Map<int, StringName> order; + RBMap<int, StringName> order; - for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) { - if (E->get().scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_GLOBAL || E->get().scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) { + for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) { + if (E.value.scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_GLOBAL || E.value.scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) { continue; } - if (E->get().texture_order >= 0) { - order[E->get().texture_order + 100000] = E->key(); + if (E.value.texture_order >= 0) { + order[E.value.texture_order + 100000] = E.key; } else { - order[E->get().order] = E->key(); + order[E.value.order] = E.key; } } - for (Map<int, StringName>::Element *E = order.front(); E; E = E->next()) { - PropertyInfo pi = ShaderLanguage::uniform_to_property_info(uniforms[E->get()]); - pi.name = E->get(); + for (const KeyValue<int, StringName> &E : order) { + PropertyInfo pi = ShaderLanguage::uniform_to_property_info(uniforms[E.value]); + pi.name = E.value; p_param_list->push_back(pi); } } void RendererSceneRenderRD::FogShaderData::get_instance_param_list(List<RendererMaterialStorage::InstanceShaderParam> *p_param_list) const { - for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = uniforms.front(); E; E = E->next()) { - if (E->get().scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) { + for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) { + if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) { continue; } RendererMaterialStorage::InstanceShaderParam p; - p.info = ShaderLanguage::uniform_to_property_info(E->get()); - p.info.name = E->key(); //supply name - p.index = E->get().instance_index; - p.default_value = ShaderLanguage::constant_value_to_variant(E->get().default_value, E->get().type, E->get().array_size, E->get().hint); + p.info = ShaderLanguage::uniform_to_property_info(E.value); + p.info.name = E.key; //supply name + p.index = E.value.instance_index; + p.default_value = ShaderLanguage::constant_value_to_variant(E.value.default_value, E.value.type, E.value.array_size, E.value.hint); p_param_list->push_back(p); } } @@ -4045,7 +4045,7 @@ RendererSceneRenderRD::FogShaderData::~FogShaderData() { //////////////////////////////////////////////////////////////////////////////// // Fog material -bool RendererSceneRenderRD::FogMaterialData::update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) { +bool RendererSceneRenderRD::FogMaterialData::update_parameters(const HashMap<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) { RendererSceneRenderRD *scene_singleton = static_cast<RendererSceneRenderRD *>(RendererSceneRenderRD::singleton); uniform_set_updated = true; @@ -5464,7 +5464,7 @@ bool RendererSceneRenderRD::free(RID p_rid) { LightInstance *light_instance = light_instance_owner.get_or_null(p_rid); //remove from shadow atlases.. - for (Set<RID>::Element *E = light_instance->shadow_atlases.front(); E; E = E->next()) { + for (RBSet<RID>::Element *E = light_instance->shadow_atlases.front(); E; E = E->next()) { ShadowAtlas *shadow_atlas = shadow_atlas_owner.get_or_null(E->get()); ERR_CONTINUE(!shadow_atlas->shadow_owners.has(p_rid)); uint32_t key = shadow_atlas->shadow_owners[p_rid]; diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.h b/servers/rendering/renderer_rd/renderer_scene_render_rd.h index f60b7c7232..4daee17525 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.h +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.h @@ -297,7 +297,7 @@ private: RID depth; RID fb; //for copying - Map<RID, uint32_t> shadow_owners; + HashMap<RID, uint32_t> shadow_owners; }; RID_Owner<ShadowAtlas> shadow_atlas_owner; @@ -345,7 +345,7 @@ private: RID side_fb[6]; }; - Map<int, ShadowCubemap> shadow_cubemaps; + HashMap<int, ShadowCubemap> shadow_cubemaps; ShadowCubemap *_get_shadow_cubemap(int p_size); void _create_shadow_cubemaps(); @@ -387,7 +387,7 @@ private: Rect2 directional_rect; - Set<RID> shadow_atlases; //shadow atlases where this light is registered + RBSet<RID> shadow_atlases; //shadow atlases where this light is registered ForwardID forward_id = -1; @@ -921,7 +921,7 @@ private: RID version; RID pipeline; - Map<StringName, ShaderLanguage::ShaderNode::Uniform> uniforms; + HashMap<StringName, ShaderLanguage::ShaderNode::Uniform> uniforms; Vector<ShaderCompiler::GeneratedCode::Texture> texture_uniforms; Vector<uint32_t> ubo_offsets; @@ -929,7 +929,7 @@ private: String path; String code; - Map<StringName, Map<int, RID>> default_texture_params; + HashMap<StringName, HashMap<int, RID>> default_texture_params; bool uses_time = false; @@ -954,7 +954,7 @@ private: virtual void set_render_priority(int p_priority) {} virtual void set_next_pass(RID p_pass) {} - virtual bool update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty); + virtual bool update_parameters(const HashMap<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty); virtual ~FogMaterialData(); }; diff --git a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp index 4e62dee6af..14a5f02eee 100644 --- a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp @@ -151,14 +151,14 @@ void RendererSceneSkyRD::SkyShaderData::set_default_texture_param(const StringNa } } else { if (!default_texture_params.has(p_name)) { - default_texture_params[p_name] = Map<int, RID>(); + default_texture_params[p_name] = HashMap<int, RID>(); } default_texture_params[p_name][p_index] = p_texture; } } void RendererSceneSkyRD::SkyShaderData::get_param_list(List<PropertyInfo> *p_param_list) const { - Map<int, StringName> order; + HashMap<int, StringName> order; for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) { if (E.value.scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_GLOBAL || E.value.scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) { @@ -237,7 +237,7 @@ RendererSceneSkyRD::SkyShaderData::~SkyShaderData() { //////////////////////////////////////////////////////////////////////////////// // Sky material -bool RendererSceneSkyRD::SkyMaterialData::update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) { +bool RendererSceneSkyRD::SkyMaterialData::update_parameters(const HashMap<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) { RendererSceneRenderRD *scene_singleton = static_cast<RendererSceneRenderRD *>(RendererSceneRenderRD::singleton); uniform_set_updated = true; diff --git a/servers/rendering/renderer_rd/renderer_scene_sky_rd.h b/servers/rendering/renderer_rd/renderer_scene_sky_rd.h index ec225019c8..83a8fe6e77 100644 --- a/servers/rendering/renderer_rd/renderer_scene_sky_rd.h +++ b/servers/rendering/renderer_rd/renderer_scene_sky_rd.h @@ -110,7 +110,7 @@ private: RID version; PipelineCacheRD pipelines[SKY_VERSION_MAX]; - Map<StringName, ShaderLanguage::ShaderNode::Uniform> uniforms; + HashMap<StringName, ShaderLanguage::ShaderNode::Uniform> uniforms; Vector<ShaderCompiler::GeneratedCode::Texture> texture_uniforms; Vector<uint32_t> ubo_offsets; @@ -118,7 +118,7 @@ private: String path; String code; - Map<StringName, Map<int, RID>> default_texture_params; + HashMap<StringName, HashMap<int, RID>> default_texture_params; bool uses_time = false; bool uses_position = false; @@ -235,7 +235,7 @@ public: virtual void set_render_priority(int p_priority) {} virtual void set_next_pass(RID p_pass) {} - virtual bool update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty); + virtual bool update_parameters(const HashMap<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty); virtual ~SkyMaterialData(); }; diff --git a/servers/rendering/renderer_rd/shader_rd.cpp b/servers/rendering/renderer_rd/shader_rd.cpp index fdfecf2d2c..04e05380f1 100644 --- a/servers/rendering/renderer_rd/shader_rd.cpp +++ b/servers/rendering/renderer_rd/shader_rd.cpp @@ -522,7 +522,7 @@ void ShaderRD::_compile_version(Version *p_version) { p_version->valid = true; } -void ShaderRD::version_set_code(RID p_version, const Map<String, String> &p_code, const String &p_uniforms, const String &p_vertex_globals, const String &p_fragment_globals, const Vector<String> &p_custom_defines) { +void ShaderRD::version_set_code(RID p_version, const HashMap<String, String> &p_code, const String &p_uniforms, const String &p_vertex_globals, const String &p_fragment_globals, const Vector<String> &p_custom_defines) { ERR_FAIL_COND(is_compute); Version *version = version_owner.get_or_null(p_version); @@ -547,7 +547,7 @@ void ShaderRD::version_set_code(RID p_version, const Map<String, String> &p_code } } -void ShaderRD::version_set_compute_code(RID p_version, const Map<String, String> &p_code, const String &p_uniforms, const String &p_compute_globals, const Vector<String> &p_custom_defines) { +void ShaderRD::version_set_compute_code(RID p_version, const HashMap<String, String> &p_code, const String &p_uniforms, const String &p_compute_globals, const Vector<String> &p_custom_defines) { ERR_FAIL_COND(!is_compute); Version *version = version_owner.get_or_null(p_version); diff --git a/servers/rendering/renderer_rd/shader_rd.h b/servers/rendering/renderer_rd/shader_rd.h index 8e57f0d9af..40b10808c2 100644 --- a/servers/rendering/renderer_rd/shader_rd.h +++ b/servers/rendering/renderer_rd/shader_rd.h @@ -35,7 +35,7 @@ #include "core/string/string_builder.h" #include "core/templates/hash_map.h" #include "core/templates/local_vector.h" -#include "core/templates/map.h" +#include "core/templates/rb_map.h" #include "core/templates/rid_owner.h" #include "core/variant/variant.h" #include "servers/rendering_server.h" @@ -51,7 +51,7 @@ class ShaderRD { CharString vertex_globals; CharString compute_globals; CharString fragment_globals; - Map<StringName, CharString> code_sections; + HashMap<StringName, CharString> code_sections; Vector<CharString> custom_defines; Vector<uint8_t> *variant_data = nullptr; @@ -129,8 +129,8 @@ protected: public: RID version_create(); - void version_set_code(RID p_version, const Map<String, String> &p_code, const String &p_uniforms, const String &p_vertex_globals, const String &p_fragment_globals, const Vector<String> &p_custom_defines); - void version_set_compute_code(RID p_version, const Map<String, String> &p_code, const String &p_uniforms, const String &p_compute_globals, const Vector<String> &p_custom_defines); + void version_set_code(RID p_version, const HashMap<String, String> &p_code, const String &p_uniforms, const String &p_vertex_globals, const String &p_fragment_globals, const Vector<String> &p_custom_defines); + void version_set_compute_code(RID p_version, const HashMap<String, String> &p_code, const String &p_uniforms, const String &p_compute_globals, const Vector<String> &p_custom_defines); _FORCE_INLINE_ RID version_get_shader(RID p_version, int p_variant) { ERR_FAIL_INDEX_V(p_variant, variant_defines.size(), RID()); diff --git a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp index 550fc7d788..27f0c5f273 100644 --- a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp @@ -896,7 +896,7 @@ _FORCE_INLINE_ static void _fill_std140_ubo_empty(ShaderLanguage::DataType type, /////////////////////////////////////////////////////////////////////////// // MaterialData -void MaterialData::update_uniform_buffer(const Map<StringName, ShaderLanguage::ShaderNode::Uniform> &p_uniforms, const uint32_t *p_uniform_offsets, const Map<StringName, Variant> &p_parameters, uint8_t *p_buffer, uint32_t p_buffer_size, bool p_use_linear_color) { +void MaterialData::update_uniform_buffer(const HashMap<StringName, ShaderLanguage::ShaderNode::Uniform> &p_uniforms, const uint32_t *p_uniform_offsets, const HashMap<StringName, Variant> &p_parameters, uint8_t *p_buffer, uint32_t p_buffer_size, bool p_use_linear_color) { MaterialStorage *material_storage = MaterialStorage::get_singleton(); bool uses_global_buffer = false; @@ -943,11 +943,11 @@ void MaterialData::update_uniform_buffer(const Map<StringName, ShaderLanguage::S ERR_CONTINUE(offset + size > p_buffer_size); #endif uint8_t *data = &p_buffer[offset]; - const Map<StringName, Variant>::Element *V = p_parameters.find(E.key); + HashMap<StringName, Variant>::ConstIterator V = p_parameters.find(E.key); if (V) { //user provided - _fill_std140_variant_ubo_value(E.value.type, E.value.array_size, V->get(), data, p_use_linear_color); + _fill_std140_variant_ubo_value(E.value.type, E.value.array_size, V->value, data, p_use_linear_color); } else if (E.value.default_value.size()) { //default value @@ -1001,7 +1001,7 @@ MaterialData::~MaterialData() { } } -void MaterialData::update_textures(const Map<StringName, Variant> &p_parameters, const Map<StringName, Map<int, RID>> &p_default_textures, const Vector<ShaderCompiler::GeneratedCode::Texture> &p_texture_uniforms, RID *p_textures, bool p_use_linear_color) { +void MaterialData::update_textures(const HashMap<StringName, Variant> &p_parameters, const HashMap<StringName, HashMap<int, RID>> &p_default_textures, const Vector<ShaderCompiler::GeneratedCode::Texture> &p_texture_uniforms, RID *p_textures, bool p_use_linear_color) { TextureStorage *texture_storage = TextureStorage::get_singleton(); MaterialStorage *material_storage = MaterialStorage::get_singleton(); @@ -1029,12 +1029,12 @@ void MaterialData::update_textures(const Map<StringName, Variant> &p_parameters, WARN_PRINT("Shader uses global uniform texture '" + String(uniform_name) + "', but it changed type and is no longer a texture!."); } else { - Map<StringName, uint64_t>::Element *E = used_global_textures.find(uniform_name); + HashMap<StringName, uint64_t>::Iterator E = used_global_textures.find(uniform_name); if (!E) { E = used_global_textures.insert(uniform_name, global_textures_pass); v->texture_materials.insert(self); } else { - E->get() = global_textures_pass; + E->value = global_textures_pass; } textures.push_back(v->override.get_type() != Variant::NIL ? v->override : v->value); @@ -1044,10 +1044,10 @@ void MaterialData::update_textures(const Map<StringName, Variant> &p_parameters, WARN_PRINT("Shader uses global uniform texture '" + String(uniform_name) + "', but it was removed at some point. Material will not display correctly."); } } else { - const Map<StringName, Variant>::Element *V = p_parameters.find(uniform_name); + HashMap<StringName, Variant>::ConstIterator V = p_parameters.find(uniform_name); if (V) { - if (V->get().is_array()) { - Array array = (Array)V->get(); + if (V->value.is_array()) { + Array array = (Array)V->value; if (uniform_array_size > 0) { for (int j = 0; j < array.size(); j++) { textures.push_back(array[j]); @@ -1058,25 +1058,25 @@ void MaterialData::update_textures(const Map<StringName, Variant> &p_parameters, } } } else { - textures.push_back(V->get()); + textures.push_back(V->value); } } if (uniform_array_size > 0) { if (textures.size() < uniform_array_size) { - const Map<StringName, Map<int, RID>>::Element *W = p_default_textures.find(uniform_name); + HashMap<StringName, HashMap<int, RID>>::ConstIterator W = p_default_textures.find(uniform_name); for (int j = textures.size(); j < uniform_array_size; j++) { - if (W && W->get().has(j)) { - textures.push_back(W->get()[j]); + if (W && W->value.has(j)) { + textures.push_back(W->value[j]); } else { textures.push_back(RID()); } } } } else if (textures.is_empty()) { - const Map<StringName, Map<int, RID>>::Element *W = p_default_textures.find(uniform_name); - if (W && W->get().has(0)) { - textures.push_back(W->get()[0]); + HashMap<StringName, HashMap<int, RID>>::ConstIterator W = p_default_textures.find(uniform_name); + if (W && W->value.has(0)) { + textures.push_back(W->value[0]); } } } @@ -1190,12 +1190,12 @@ void MaterialData::update_textures(const Map<StringName, Variant> &p_parameters, } { //for textures no longer used, unregister them - List<Map<StringName, uint64_t>::Element *> to_delete; - for (Map<StringName, uint64_t>::Element *E = used_global_textures.front(); E; E = E->next()) { - if (E->get() != global_textures_pass) { - to_delete.push_back(E); + List<StringName> to_delete; + for (KeyValue<StringName, uint64_t> &E : used_global_textures) { + if (E.value != global_textures_pass) { + to_delete.push_back(E.key); - GlobalVariables::Variable *v = material_storage->global_variables.variables.getptr(E->key()); + GlobalVariables::Variable *v = material_storage->global_variables.variables.getptr(E.key); if (v) { v->texture_materials.erase(self); } @@ -1225,7 +1225,7 @@ void MaterialData::free_parameters_uniform_set(RID p_uniform_set) { } } -bool MaterialData::update_parameters_uniform_set(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty, const Map<StringName, ShaderLanguage::ShaderNode::Uniform> &p_uniforms, const uint32_t *p_uniform_offsets, const Vector<ShaderCompiler::GeneratedCode::Texture> &p_texture_uniforms, const Map<StringName, Map<int, RID>> &p_default_texture_params, uint32_t p_ubo_size, RID &uniform_set, RID p_shader, uint32_t p_shader_uniform_set, uint32_t p_barrier) { +bool MaterialData::update_parameters_uniform_set(const HashMap<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty, const HashMap<StringName, ShaderLanguage::ShaderNode::Uniform> &p_uniforms, const uint32_t *p_uniform_offsets, const Vector<ShaderCompiler::GeneratedCode::Texture> &p_texture_uniforms, const HashMap<StringName, HashMap<int, RID>> &p_default_texture_params, uint32_t p_ubo_size, RID &uniform_set, RID p_shader, uint32_t p_shader_uniform_set, uint32_t p_barrier) { if ((uint32_t)ubo_data.size() != p_ubo_size) { p_uniform_dirty = true; if (uniform_buffer.is_valid()) { @@ -1979,7 +1979,7 @@ void MaterialStorage::global_variable_set(const StringName &p_name, const Varian } else { //texture MaterialStorage *material_storage = MaterialStorage::get_singleton(); - for (Set<RID>::Element *E = gv.texture_materials.front(); E; E = E->next()) { + for (RBSet<RID>::Element *E = gv.texture_materials.front(); E; E = E->next()) { Material *material = material_storage->get_material(E->get()); ERR_CONTINUE(!material); material_storage->_material_queue_update(material, false, true); @@ -2011,7 +2011,7 @@ void MaterialStorage::global_variable_set_override(const StringName &p_name, con } else { //texture MaterialStorage *material_storage = MaterialStorage::get_singleton(); - for (Set<RID>::Element *E = gv.texture_materials.front(); E; E = E->next()) { + for (RBSet<RID>::Element *E = gv.texture_materials.front(); E; E = E->next()) { Material *material = material_storage->get_material(E->get()); ERR_CONTINUE(!material); material_storage->_material_queue_update(material, false, true); @@ -2305,7 +2305,7 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) { shader->data = nullptr; } - for (Set<Material *>::Element *E = shader->owners.front(); E; E = E->next()) { + for (RBSet<Material *>::Element *E = shader->owners.front(); E; E = E->next()) { Material *material = E->get(); material->shader_type = new_type; if (material->data) { @@ -2322,7 +2322,7 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) { shader->type = SHADER_TYPE_MAX; //invalid } - for (Set<Material *>::Element *E = shader->owners.front(); E; E = E->next()) { + for (RBSet<Material *>::Element *E = shader->owners.front(); E; E = E->next()) { Material *material = E->get(); if (shader->data) { material->data = material_get_data_request_function(new_type)(shader->data); @@ -2334,7 +2334,7 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) { } if (shader->data) { - for (const KeyValue<StringName, Map<int, RID>> &E : shader->default_texture_parameter) { + for (const KeyValue<StringName, HashMap<int, RID>> &E : shader->default_texture_parameter) { for (const KeyValue<int, RID> &E2 : E.value) { shader->data->set_default_texture_param(E.key, E2.value, E2.key); } @@ -2346,7 +2346,7 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) { shader->data->set_code(p_code); } - for (Set<Material *>::Element *E = shader->owners.front(); E; E = E->next()) { + for (RBSet<Material *>::Element *E = shader->owners.front(); E; E = E->next()) { Material *material = E->get(); material->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MATERIAL); _material_queue_update(material, true, true); @@ -2373,7 +2373,7 @@ void MaterialStorage::shader_set_default_texture_param(RID p_shader, const Strin if (p_texture.is_valid() && TextureStorage::get_singleton()->owns_texture(p_texture)) { if (!shader->default_texture_parameter.has(p_name)) { - shader->default_texture_parameter[p_name] = Map<int, RID>(); + shader->default_texture_parameter[p_name] = HashMap<int, RID>(); } shader->default_texture_parameter[p_name][p_index] = p_texture; } else { @@ -2388,7 +2388,7 @@ void MaterialStorage::shader_set_default_texture_param(RID p_shader, const Strin if (shader->data) { shader->data->set_default_texture_param(p_name, p_texture, p_index); } - for (Set<Material *>::Element *E = shader->owners.front(); E; E = E->next()) { + for (RBSet<Material *>::Element *E = shader->owners.front(); E; E = E->next()) { Material *material = E->get(); _material_queue_update(material, false, true); } diff --git a/servers/rendering/renderer_rd/storage_rd/material_storage.h b/servers/rendering/renderer_rd/storage_rd/material_storage.h index 0e899e37c8..7d4db49f78 100644 --- a/servers/rendering/renderer_rd/storage_rd/material_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/material_storage.h @@ -76,23 +76,23 @@ struct Shader { ShaderData *data = nullptr; String code; ShaderType type; - Map<StringName, Map<int, RID>> default_texture_parameter; - Set<Material *> owners; + HashMap<StringName, HashMap<int, RID>> default_texture_parameter; + RBSet<Material *> owners; }; /* Material structs */ struct MaterialData { - void update_uniform_buffer(const Map<StringName, ShaderLanguage::ShaderNode::Uniform> &p_uniforms, const uint32_t *p_uniform_offsets, const Map<StringName, Variant> &p_parameters, uint8_t *p_buffer, uint32_t p_buffer_size, bool p_use_linear_color); - void update_textures(const Map<StringName, Variant> &p_parameters, const Map<StringName, Map<int, RID>> &p_default_textures, const Vector<ShaderCompiler::GeneratedCode::Texture> &p_texture_uniforms, RID *p_textures, bool p_use_linear_color); + void update_uniform_buffer(const HashMap<StringName, ShaderLanguage::ShaderNode::Uniform> &p_uniforms, const uint32_t *p_uniform_offsets, const HashMap<StringName, Variant> &p_parameters, uint8_t *p_buffer, uint32_t p_buffer_size, bool p_use_linear_color); + void update_textures(const HashMap<StringName, Variant> &p_parameters, const HashMap<StringName, HashMap<int, RID>> &p_default_textures, const Vector<ShaderCompiler::GeneratedCode::Texture> &p_texture_uniforms, RID *p_textures, bool p_use_linear_color); virtual void set_render_priority(int p_priority) = 0; virtual void set_next_pass(RID p_pass) = 0; - virtual bool update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) = 0; + virtual bool update_parameters(const HashMap<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) = 0; virtual ~MaterialData(); //to be used internally by update_parameters, in the most common configuration of material parameters - bool update_parameters_uniform_set(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty, const Map<StringName, ShaderLanguage::ShaderNode::Uniform> &p_uniforms, const uint32_t *p_uniform_offsets, const Vector<ShaderCompiler::GeneratedCode::Texture> &p_texture_uniforms, const Map<StringName, Map<int, RID>> &p_default_texture_params, uint32_t p_ubo_size, RID &uniform_set, RID p_shader, uint32_t p_shader_uniform_set, uint32_t p_barrier = RD::BARRIER_MASK_ALL); + bool update_parameters_uniform_set(const HashMap<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty, const HashMap<StringName, ShaderLanguage::ShaderNode::Uniform> &p_uniforms, const uint32_t *p_uniform_offsets, const Vector<ShaderCompiler::GeneratedCode::Texture> &p_texture_uniforms, const HashMap<StringName, HashMap<int, RID>> &p_default_texture_params, uint32_t p_ubo_size, RID &uniform_set, RID p_shader, uint32_t p_shader_uniform_set, uint32_t p_barrier = RD::BARRIER_MASK_ALL); void free_parameters_uniform_set(RID p_uniform_set); private: @@ -101,7 +101,7 @@ private: List<RID>::Element *global_buffer_E = nullptr; List<RID>::Element *global_texture_E = nullptr; uint64_t global_textures_pass = 0; - Map<StringName, uint64_t> used_global_textures; + HashMap<StringName, uint64_t> used_global_textures; //internally by update_parameters_uniform_set Vector<uint8_t> ubo_data; @@ -120,7 +120,7 @@ struct Material { uint32_t shader_id = 0; bool uniform_dirty = false; bool texture_dirty = false; - Map<StringName, Variant> params; + HashMap<StringName, Variant> params; int32_t priority = 0; RID next_pass; SelfList<Material> update_element; @@ -137,7 +137,7 @@ struct GlobalVariables { BUFFER_DIRTY_REGION_SIZE = 1024 }; struct Variable { - Set<RID> texture_materials; // materials using this + RBSet<RID> texture_materials; // materials using this RS::GlobalVariableType type; Variant value; diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp index 9b7b0d2c25..fa051c92ed 100644 --- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp @@ -215,7 +215,7 @@ void MeshStorage::mesh_free(RID p_rid) { ERR_PRINT("deleting mesh with active instances"); } if (mesh->shadow_owners.size()) { - for (Set<Mesh *>::Element *E = mesh->shadow_owners.front(); E; E = E->next()) { + for (RBSet<Mesh *>::Element *E = mesh->shadow_owners.front(); E; E = E->next()) { Mesh *shadow_owner = E->get(); shadow_owner->shadow_mesh = RID(); shadow_owner->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH); @@ -431,7 +431,7 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) mesh->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH); - for (Set<Mesh *>::Element *E = mesh->shadow_owners.front(); E; E = E->next()) { + for (RBSet<Mesh *>::Element *E = mesh->shadow_owners.front(); E; E = E->next()) { Mesh *shadow_owner = E->get(); shadow_owner->shadow_mesh = RID(); shadow_owner->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH); @@ -742,7 +742,7 @@ void MeshStorage::mesh_clear(RID p_mesh) { mesh->has_bone_weights = false; mesh->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH); - for (Set<Mesh *>::Element *E = mesh->shadow_owners.front(); E; E = E->next()) { + for (RBSet<Mesh *>::Element *E = mesh->shadow_owners.front(); E; E = E->next()) { Mesh *shadow_owner = E->get(); shadow_owner->shadow_mesh = RID(); shadow_owner->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH); diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.h b/servers/rendering/renderer_rd/storage_rd/mesh_storage.h index 7d3f603afd..d90bb2f128 100644 --- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.h @@ -141,7 +141,7 @@ struct Mesh { List<MeshInstance *> instances; RID shadow_mesh; - Set<Mesh *> shadow_owners; + RBSet<Mesh *> shadow_owners; RendererStorage::Dependency dependency; }; diff --git a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp index 094120f908..1701b56b0b 100644 --- a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp @@ -838,7 +838,7 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta } uint32_t collision_3d_textures_used = 0; - for (const Set<RID>::Element *E = p_particles->collisions.front(); E; E = E->next()) { + for (const RBSet<RID>::Element *E = p_particles->collisions.front(); E; E = E->next()) { ParticlesCollisionInstance *pci = particles_collision_instance_owner.get_or_null(E->get()); if (!pci || !pci->active) { continue; @@ -1592,14 +1592,14 @@ void ParticlesStorage::ParticlesShaderData::set_default_texture_param(const Stri } } else { if (!default_texture_params.has(p_name)) { - default_texture_params[p_name] = Map<int, RID>(); + default_texture_params[p_name] = HashMap<int, RID>(); } default_texture_params[p_name][p_index] = p_texture; } } void ParticlesStorage::ParticlesShaderData::get_param_list(List<PropertyInfo> *p_param_list) const { - Map<int, StringName> order; + HashMap<int, StringName> order; for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) { if (E.value.scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_GLOBAL || E.value.scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) { @@ -1676,7 +1676,7 @@ ShaderData *ParticlesStorage::_create_particles_shader_func() { return shader_data; } -bool ParticlesStorage::ParticlesMaterialData::update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) { +bool ParticlesStorage::ParticlesMaterialData::update_parameters(const HashMap<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) { return update_parameters_uniform_set(p_parameters, p_uniform_dirty, p_textures_dirty, shader_data->uniforms, shader_data->ubo_offsets.ptr(), shader_data->texture_uniforms, shader_data->default_texture_params, shader_data->ubo_size, uniform_set, ParticlesStorage::get_singleton()->particles_shader.shader.version_get_shader(shader_data->version, 0), 3); } diff --git a/servers/rendering/renderer_rd/storage_rd/particles_storage.h b/servers/rendering/renderer_rd/storage_rd/particles_storage.h index c6480794c1..eb55db19fb 100644 --- a/servers/rendering/renderer_rd/storage_rd/particles_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/particles_storage.h @@ -224,7 +224,7 @@ struct Particles { ParticleEmissionBuffer *emission_buffer = nullptr; RID emission_storage_buffer; - Set<RID> collisions; + RBSet<RID> collisions; RendererStorage::Dependency dependency; @@ -345,7 +345,7 @@ private: RID version; bool uses_collision = false; - Map<StringName, ShaderLanguage::ShaderNode::Uniform> uniforms; + HashMap<StringName, ShaderLanguage::ShaderNode::Uniform> uniforms; Vector<ShaderCompiler::GeneratedCode::Texture> texture_uniforms; Vector<uint32_t> ubo_offsets; @@ -353,7 +353,7 @@ private: String path; String code; - Map<StringName, Map<int, RID>> default_texture_params; + HashMap<StringName, HashMap<int, RID>> default_texture_params; RID pipeline; @@ -387,7 +387,7 @@ private: virtual void set_render_priority(int p_priority) {} virtual void set_next_pass(RID p_pass) {} - virtual bool update_parameters(const Map<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty); + virtual bool update_parameters(const HashMap<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty); virtual ~ParticlesMaterialData(); }; diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.h b/servers/rendering/renderer_rd/storage_rd/texture_storage.h index a6f50803e4..029816cbda 100644 --- a/servers/rendering/renderer_rd/storage_rd/texture_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.h @@ -124,7 +124,7 @@ public: RID proxy_to; Vector<RID> proxies; - Set<RID> lightmap_users; + RBSet<RID> lightmap_users; RS::TextureDetectCallback detect_3d_callback = nullptr; void *detect_3d_callback_ud = nullptr; diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp index d85f314c5c..37bbab86ff 100644 --- a/servers/rendering/renderer_scene_cull.cpp +++ b/servers/rendering/renderer_scene_cull.cpp @@ -653,7 +653,7 @@ void RendererSceneCull::instance_set_base(RID p_instance, RID p_base) { scene_render->geometry_instance_set_lightmap_capture(geom->geometry_instance, instance->lightmap_sh.ptr()); } - for (Set<Instance *>::Element *E = instance->visibility_dependencies.front(); E; E = E->next()) { + for (RBSet<Instance *>::Element *E = instance->visibility_dependencies.front(); E; E = E->next()) { Instance *dep_instance = E->get(); ERR_CONTINUE(dep_instance->array_index == -1); ERR_CONTINUE(dep_instance->scenario->instance_data[dep_instance->array_index].parent_array_index != -1); @@ -1292,14 +1292,14 @@ void RendererSceneCull::instance_set_visibility_parent(RID p_instance, RID p_par bool RendererSceneCull::_update_instance_visibility_depth(Instance *p_instance) { bool cycle_detected = false; - Set<Instance *> traversed_nodes; + RBSet<Instance *> traversed_nodes; { Instance *instance = p_instance; while (instance) { if (!instance->visibility_dependencies.is_empty()) { uint32_t depth = 0; - for (Set<Instance *>::Element *E = instance->visibility_dependencies.front(); E; E = E->next()) { + for (RBSet<Instance *>::Element *E = instance->visibility_dependencies.front(); E; E = E->next()) { depth = MAX(depth, E->get()->visibility_dependencies_depth); } instance->visibility_dependencies_depth = depth + 1; @@ -1429,7 +1429,7 @@ void RendererSceneCull::instance_geometry_set_shader_parameter(RID p_instance, c ERR_FAIL_COND(p_value.get_type() == Variant::OBJECT); - Map<StringName, Instance::InstanceShaderParameter>::Element *E = instance->instance_shader_parameters.find(p_parameter); + HashMap<StringName, Instance::InstanceShaderParameter>::Iterator E = instance->instance_shader_parameters.find(p_parameter); if (!E) { Instance::InstanceShaderParameter isp; @@ -1438,10 +1438,10 @@ void RendererSceneCull::instance_geometry_set_shader_parameter(RID p_instance, c isp.value = p_value; instance->instance_shader_parameters[p_parameter] = isp; } else { - E->get().value = p_value; - if (E->get().index >= 0 && instance->instance_allocated_shader_parameters) { + E->value.value = p_value; + if (E->value.index >= 0 && instance->instance_allocated_shader_parameters) { //update directly - RSG::material_storage->global_variables_instance_update(p_instance, E->get().index, p_value); + RSG::material_storage->global_variables_instance_update(p_instance, E->value.index, p_value); } } } @@ -1559,7 +1559,7 @@ void RendererSceneCull::_update_instance(Instance *p_instance) { InstanceLightmapData *lightmap_data = static_cast<InstanceLightmapData *>(p_instance->base_data); //erase dependencies, since no longer a lightmap - for (Set<Instance *>::Element *E = lightmap_data->geometries.front(); E; E = E->next()) { + for (RBSet<Instance *>::Element *E = lightmap_data->geometries.front(); E; E = E->next()) { Instance *geom = E->get(); _instance_queue_update(geom, true, false); } @@ -1574,7 +1574,7 @@ void RendererSceneCull::_update_instance(Instance *p_instance) { //make sure lights are updated if it casts shadow if (geom->can_cast_shadows) { - for (Set<Instance *>::Element *E = geom->lights.front(); E; E = E->next()) { + for (RBSet<Instance *>::Element *E = geom->lights.front(); E; E = E->next()) { InstanceLightData *light = static_cast<InstanceLightData *>(E->get()->base_data); light->shadow_dirty = true; } @@ -1632,7 +1632,7 @@ void RendererSceneCull::_update_instance(Instance *p_instance) { idata.parent_array_index = p_instance->visibility_parent ? p_instance->visibility_parent->array_index : -1; idata.visibility_index = p_instance->visibility_index; - for (Set<Instance *>::Element *E = p_instance->visibility_dependencies.front(); E; E = E->next()) { + for (RBSet<Instance *>::Element *E = p_instance->visibility_dependencies.front(); E; E = E->next()) { Instance *dep_instance = E->get(); if (dep_instance->array_index != -1) { dep_instance->scenario->instance_data[dep_instance->array_index].parent_array_index = p_instance->array_index; @@ -1800,7 +1800,7 @@ void RendererSceneCull::_unpair_instance(Instance *p_instance) { swapped_instance->scenario->instance_visibility[swapped_instance->visibility_index].array_index = swapped_instance->array_index; } - for (Set<Instance *>::Element *E = swapped_instance->visibility_dependencies.front(); E; E = E->next()) { + for (RBSet<Instance *>::Element *E = swapped_instance->visibility_dependencies.front(); E; E = E->next()) { Instance *dep_instance = E->get(); if (dep_instance != p_instance && dep_instance->array_index != -1) { dep_instance->scenario->instance_data[dep_instance->array_index].parent_array_index = swapped_instance->array_index; @@ -1824,7 +1824,7 @@ void RendererSceneCull::_unpair_instance(Instance *p_instance) { scene_render->geometry_instance_pair_voxel_gi_instances(geom->geometry_instance, nullptr, 0); } - for (Set<Instance *>::Element *E = p_instance->visibility_dependencies.front(); E; E = E->next()) { + for (RBSet<Instance *>::Element *E = p_instance->visibility_dependencies.front(); E; E = E->next()) { Instance *dep_instance = E->get(); if (dep_instance->array_index != -1) { dep_instance->scenario->instance_data[dep_instance->array_index].parent_array_index = -1; @@ -1923,7 +1923,7 @@ void RendererSceneCull::_update_instance_lightmap_captures(Instance *p_instance) float accum_blend = 0.0; InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(p_instance->base_data); - for (Set<Instance *>::Element *E = geom->lightmap_captures.front(); E; E = E->next()) { + for (RBSet<Instance *>::Element *E = geom->lightmap_captures.front(); E; E = E->next()) { Instance *lightmap = E->get(); bool interior = RSG::light_storage->lightmap_is_interior(lightmap->base); @@ -2744,7 +2744,7 @@ void RendererSceneCull::_scene_cull(CullData &cull_data, InstanceCullResult &cul InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(idata.instance->base_data); uint32_t idx = 0; - for (Set<Instance *>::Element *E = geom->lights.front(); E; E = E->next()) { + for (RBSet<Instance *>::Element *E = geom->lights.front(); E; E = E->next()) { InstanceLightData *light = static_cast<InstanceLightData *>(E->get()->base_data); instance_pair_buffer[idx++] = light->instance; if (idx == MAX_INSTANCE_PAIRS) { @@ -2767,7 +2767,7 @@ void RendererSceneCull::_scene_cull(CullData &cull_data, InstanceCullResult &cul InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(idata.instance->base_data); uint32_t idx = 0; - for (Set<Instance *>::Element *E = geom->reflection_probes.front(); E; E = E->next()) { + for (RBSet<Instance *>::Element *E = geom->reflection_probes.front(); E; E = E->next()) { InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(E->get()->base_data); instance_pair_buffer[idx++] = reflection_probe->instance; @@ -2784,7 +2784,7 @@ void RendererSceneCull::_scene_cull(CullData &cull_data, InstanceCullResult &cul InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(idata.instance->base_data); uint32_t idx = 0; - for (Set<Instance *>::Element *E = geom->decals.front(); E; E = E->next()) { + for (RBSet<Instance *>::Element *E = geom->decals.front(); E; E = E->next()) { InstanceDecalData *decal = static_cast<InstanceDecalData *>(E->get()->base_data); instance_pair_buffer[idx++] = decal->instance; @@ -2799,7 +2799,7 @@ void RendererSceneCull::_scene_cull(CullData &cull_data, InstanceCullResult &cul if (idata.flags & InstanceData::FLAG_GEOM_VOXEL_GI_DIRTY) { InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(idata.instance->base_data); uint32_t idx = 0; - for (Set<Instance *>::Element *E = geom->voxel_gi_instances.front(); E; E = E->next()) { + for (RBSet<Instance *>::Element *E = geom->voxel_gi_instances.front(); E; E = E->next()) { InstanceVoxelGIData *voxel_gi = static_cast<InstanceVoxelGIData *>(E->get()->base_data); instance_pair_buffer[idx++] = voxel_gi->probe_instance; @@ -3420,7 +3420,7 @@ void RendererSceneCull::render_probes() { const RID *instance_caches = probe->light_instances.ptr(); int idx = 0; //must count visible lights - for (Set<Instance *>::Element *E = probe->lights.front(); E; E = E->next()) { + for (RBSet<Instance *>::Element *E = probe->lights.front(); E; E = E->next()) { Instance *instance = E->get(); InstanceLightData *instance_light = (InstanceLightData *)instance->base_data; if (!instance->visible) { @@ -3502,7 +3502,7 @@ void RendererSceneCull::render_probes() { RID *instance_caches = probe->light_instances.ptrw(); int idx = 0; //must count visible lights - for (Set<Instance *>::Element *E = probe->lights.front(); E; E = E->next()) { + for (RBSet<Instance *>::Element *E = probe->lights.front(); E; E = E->next()) { Instance *instance = E->get(); InstanceLightData *instance_light = (InstanceLightData *)instance->base_data; if (!instance->visible) { @@ -3557,7 +3557,7 @@ void RendererSceneCull::render_probes() { RID instance_pair_buffer[MAX_INSTANCE_PAIRS]; - for (Set<Instance *>::Element *E = probe->dynamic_geometries.front(); E; E = E->next()) { + for (RBSet<Instance *>::Element *E = probe->dynamic_geometries.front(); E; E = E->next()) { Instance *ins = E->get(); if (!ins->visible) { continue; @@ -3566,7 +3566,7 @@ void RendererSceneCull::render_probes() { if (ins->scenario && ins->array_index >= 0 && (ins->scenario->instance_data[ins->array_index].flags & InstanceData::FLAG_GEOM_VOXEL_GI_DIRTY)) { uint32_t idx = 0; - for (Set<Instance *>::Element *F = geom->voxel_gi_instances.front(); F; F = F->next()) { + for (RBSet<Instance *>::Element *F = geom->voxel_gi_instances.front(); F; F = F->next()) { InstanceVoxelGIData *voxel_gi2 = static_cast<InstanceVoxelGIData *>(F->get()->base_data); instance_pair_buffer[idx++] = voxel_gi2->probe_instance; @@ -3629,7 +3629,7 @@ void RendererSceneCull::render_particle_colliders() { } } -void RendererSceneCull::_update_instance_shader_parameters_from_material(Map<StringName, Instance::InstanceShaderParameter> &isparams, const Map<StringName, Instance::InstanceShaderParameter> &existing_isparams, RID p_material) { +void RendererSceneCull::_update_instance_shader_parameters_from_material(HashMap<StringName, Instance::InstanceShaderParameter> &isparams, const HashMap<StringName, Instance::InstanceShaderParameter> &existing_isparams, RID p_material) { List<RendererMaterialStorage::InstanceShaderParam> plist; RSG::material_storage->material_get_instance_shader_parameters(p_material, &plist); for (const RendererMaterialStorage::InstanceShaderParam &E : plist) { @@ -3700,7 +3700,7 @@ void RendererSceneCull::_update_dirty_instance(Instance *p_instance) { bool can_cast_shadows = true; bool is_animated = false; - Map<StringName, Instance::InstanceShaderParameter> isparams; + HashMap<StringName, Instance::InstanceShaderParameter> isparams; if (p_instance->cast_shadows == RS::SHADOW_CASTING_SETTING_OFF) { can_cast_shadows = false; @@ -3823,7 +3823,7 @@ void RendererSceneCull::_update_dirty_instance(Instance *p_instance) { if (can_cast_shadows != geom->can_cast_shadows) { //ability to cast shadows change, let lights now - for (Set<Instance *>::Element *E = geom->lights.front(); E; E = E->next()) { + for (RBSet<Instance *>::Element *E = geom->lights.front(); E; E = E->next()) { InstanceLightData *light = static_cast<InstanceLightData *>(E->get()->base_data); light->shadow_dirty = true; } diff --git a/servers/rendering/renderer_scene_cull.h b/servers/rendering/renderer_scene_cull.h index b5e8cf702f..c5325ef30a 100644 --- a/servers/rendering/renderer_scene_cull.h +++ b/servers/rendering/renderer_scene_cull.h @@ -324,7 +324,7 @@ public: RID reflection_probe_shadow_atlas; RID reflection_atlas; uint64_t used_viewport_visibility_bits; - Map<RID, uint64_t> viewport_visibility_masks; + HashMap<RID, uint64_t> viewport_visibility_masks; SelfList<Instance>::List instances; @@ -426,7 +426,7 @@ public: PropertyInfo info; }; - Map<StringName, InstanceShaderParameter> instance_shader_parameters; + HashMap<StringName, InstanceShaderParameter> instance_shader_parameters; bool instance_allocated_shader_parameters = false; int32_t instance_allocated_shader_parameters_offset = -1; @@ -443,7 +443,7 @@ public: float visibility_range_end_margin = 0.0f; RS::VisibilityRangeFadeMode visibility_range_fade_mode = RS::VISIBILITY_RANGE_FADE_DISABLED; Instance *visibility_parent = nullptr; - Set<Instance *> visibility_dependencies; + RBSet<Instance *> visibility_dependencies; uint32_t visibility_dependencies_depth = 0; float transparency = 0.0f; Scenario *scenario = nullptr; @@ -579,16 +579,16 @@ public: struct InstanceGeometryData : public InstanceBaseData { RendererSceneRender::GeometryInstance *geometry_instance = nullptr; - Set<Instance *> lights; + RBSet<Instance *> lights; bool can_cast_shadows; bool material_is_animated; uint32_t projector_count = 0; uint32_t softshadow_count = 0; - Set<Instance *> decals; - Set<Instance *> reflection_probes; - Set<Instance *> voxel_gi_instances; - Set<Instance *> lightmap_captures; + RBSet<Instance *> decals; + RBSet<Instance *> reflection_probes; + RBSet<Instance *> voxel_gi_instances; + RBSet<Instance *> lightmap_captures; InstanceGeometryData() { can_cast_shadows = true; @@ -599,7 +599,7 @@ public: struct InstanceReflectionProbeData : public InstanceBaseData { Instance *owner = nullptr; - Set<Instance *> geometries; + RBSet<Instance *> geometries; RID instance; SelfList<InstanceReflectionProbeData> update_list; @@ -616,7 +616,7 @@ public: Instance *owner = nullptr; RID instance; - Set<Instance *> geometries; + RBSet<Instance *> geometries; InstanceDecalData() { } @@ -654,7 +654,7 @@ public: bool uses_projector = false; bool uses_softshadow = false; - Set<Instance *> geometries; + RBSet<Instance *> geometries; Instance *baked_light = nullptr; @@ -673,10 +673,10 @@ public: struct InstanceVoxelGIData : public InstanceBaseData { Instance *owner = nullptr; - Set<Instance *> geometries; - Set<Instance *> dynamic_geometries; + RBSet<Instance *> geometries; + RBSet<Instance *> dynamic_geometries; - Set<Instance *> lights; + RBSet<Instance *> lights; struct LightCache { RS::LightType type; @@ -713,8 +713,8 @@ public: struct InstanceLightmapData : public InstanceBaseData { RID instance; - Set<Instance *> geometries; - Set<Instance *> users; + RBSet<Instance *> geometries; + RBSet<Instance *> users; InstanceLightmapData() { } @@ -779,7 +779,7 @@ public: } }; - Set<Instance *> heightfield_particle_colliders_update_list; + RBSet<Instance *> heightfield_particle_colliders_update_list; PagedArrayPool<Instance *> instance_cull_page_pool; PagedArrayPool<RendererSceneRender::GeometryInstance *> geometry_instance_cull_page_pool; @@ -964,7 +964,7 @@ public: virtual void instance_geometry_set_lightmap(RID p_instance, RID p_lightmap, const Rect2 &p_lightmap_uv_scale, int p_slice_index); virtual void instance_geometry_set_lod_bias(RID p_instance, float p_lod_bias); - void _update_instance_shader_parameters_from_material(Map<StringName, Instance::InstanceShaderParameter> &isparams, const Map<StringName, Instance::InstanceShaderParameter> &existing_isparams, RID p_material); + void _update_instance_shader_parameters_from_material(HashMap<StringName, Instance::InstanceShaderParameter> &isparams, const HashMap<StringName, Instance::InstanceShaderParameter> &existing_isparams, RID p_material); virtual void instance_geometry_set_shader_parameter(RID p_instance, const StringName &p_parameter, const Variant &p_value); virtual void instance_geometry_get_shader_parameter_list(RID p_instance, List<PropertyInfo> *p_parameters) const; diff --git a/servers/rendering/renderer_storage.h b/servers/rendering/renderer_storage.h index 7cf4fd0aff..7f35d2ca99 100644 --- a/servers/rendering/renderer_storage.h +++ b/servers/rendering/renderer_storage.h @@ -62,7 +62,7 @@ public: private: friend struct DependencyTracker; - Map<DependencyTracker *, uint32_t> instances; + HashMap<DependencyTracker *, uint32_t> instances; }; struct DependencyTracker { @@ -83,15 +83,16 @@ public: } void update_end() { //call after updating dependencies - List<Pair<Dependency *, Map<DependencyTracker *, uint32_t>::Element *>> to_clean_up; - for (Set<Dependency *>::Element *E = dependencies.front(); E; E = E->next()) { + List<Pair<Dependency *, DependencyTracker *>> to_clean_up; + + for (RBSet<Dependency *>::Element *E = dependencies.front(); E; E = E->next()) { Dependency *dep = E->get(); - Map<DependencyTracker *, uint32_t>::Element *F = dep->instances.find(this); + HashMap<DependencyTracker *, uint32_t>::Iterator F = dep->instances.find(this); ERR_CONTINUE(!F); - if (F->get() != instance_version) { - Pair<Dependency *, Map<DependencyTracker *, uint32_t>::Element *> p; + if (F->value != instance_version) { + Pair<Dependency *, DependencyTracker *> p; p.first = dep; - p.second = F; + p.second = F->key; to_clean_up.push_back(p); } } @@ -104,7 +105,7 @@ public: } void clear() { // clear all dependencies - for (Set<Dependency *>::Element *E = dependencies.front(); E; E = E->next()) { + for (RBSet<Dependency *>::Element *E = dependencies.front(); E; E = E->next()) { Dependency *dep = E->get(); dep->instances.erase(this); } @@ -116,7 +117,7 @@ public: private: friend struct Dependency; uint32_t instance_version = 0; - Set<Dependency *> dependencies; + RBSet<Dependency *> dependencies; }; virtual void base_update_dependency(RID p_base, DependencyTracker *p_instance) = 0; diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index 3ea67ae115..d612fb4aa7 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -226,7 +226,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { } if (!p_viewport->disable_2d) { - Map<Viewport::CanvasKey, Viewport::CanvasData *> canvas_map; + RBMap<Viewport::CanvasKey, Viewport::CanvasData *> canvas_map; Rect2 clip_rect(0, 0, p_viewport->size.x, p_viewport->size.y); RendererCanvasRender::Light *lights = nullptr; @@ -247,7 +247,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E.value.canvas); Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E.value, clip_rect.size); - for (Set<RendererCanvasRender::LightOccluderInstance *>::Element *F = canvas->occluders.front(); F; F = F->next()) { + for (RBSet<RendererCanvasRender::LightOccluderInstance *>::Element *F = canvas->occluders.front(); F; F = F->next()) { if (!F->get()->enabled) { continue; } @@ -281,7 +281,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { // Find lights in canvas. - for (Set<RendererCanvasRender::Light *>::Element *F = canvas->lights.front(); F; F = F->next()) { + for (RBSet<RendererCanvasRender::Light *>::Element *F = canvas->lights.front(); F; F = F->next()) { RendererCanvasRender::Light *cl = F->get(); if (cl->enabled && cl->texture.is_valid()) { //not super efficient.. @@ -313,7 +313,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { } } - for (Set<RendererCanvasRender::Light *>::Element *F = canvas->directional_lights.front(); F; F = F->next()) { + for (RBSet<RendererCanvasRender::Light *>::Element *F = canvas->directional_lights.front(); F; F = F->next()) { RendererCanvasRender::Light *cl = F->get(); if (cl->enabled) { cl->filter_next_ptr = directional_lights; @@ -349,7 +349,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E.value.canvas); Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E.value, clip_rect.size); - for (Set<RendererCanvasRender::LightOccluderInstance *>::Element *F = canvas->occluders.front(); F; F = F->next()) { + for (RBSet<RendererCanvasRender::LightOccluderInstance *>::Element *F = canvas->occluders.front(); F; F = F->next()) { if (!F->get()->enabled) { continue; } @@ -429,7 +429,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E.value.canvas); Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E.value, clip_rect.size); - for (Set<RendererCanvasRender::LightOccluderInstance *>::Element *F = canvas->occluders.front(); F; F = F->next()) { + for (RBSet<RendererCanvasRender::LightOccluderInstance *>::Element *F = canvas->occluders.front(); F; F = F->next()) { if (!F->get()->enabled) { continue; } @@ -454,7 +454,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { RENDER_TIMESTAMP("< Render DirectionalLight2D Shadows"); } - if (scenario_draw_canvas_bg && canvas_map.front() && canvas_map.front()->key().get_layer() > scenario_canvas_max_layer) { + if (scenario_draw_canvas_bg && canvas_map.begin() && canvas_map.begin()->key.get_layer() > scenario_canvas_max_layer) { if (!can_draw_3d) { RSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas); } else { @@ -547,7 +547,7 @@ void RendererViewport::draw_viewports() { //sort viewports active_viewports.sort_custom<ViewportSort>(); - Map<DisplayServer::WindowID, Vector<BlitToScreen>> blit_to_screen_list; + HashMap<DisplayServer::WindowID, Vector<BlitToScreen>> blit_to_screen_list; //draw viewports RENDER_TIMESTAMP("> Render Viewports"); @@ -1176,8 +1176,8 @@ bool RendererViewport::free(RID p_rid) { RSG::scene->free(viewport->render_buffers); } - while (viewport->canvas_map.front()) { - viewport_remove_canvas(p_rid, viewport->canvas_map.front()->key()); + while (viewport->canvas_map.begin()) { + viewport_remove_canvas(p_rid, viewport->canvas_map.begin()->key); } viewport_set_scenario(p_rid, RID()); diff --git a/servers/rendering/renderer_viewport.h b/servers/rendering/renderer_viewport.h index b6e44e8436..da8cf5396c 100644 --- a/servers/rendering/renderer_viewport.h +++ b/servers/rendering/renderer_viewport.h @@ -137,7 +137,7 @@ public: Transform2D global_transform; - Map<RID, CanvasData> canvas_map; + HashMap<RID, CanvasData> canvas_map; RendererScene::RenderInfo render_info; diff --git a/servers/rendering/rendering_device_binds.cpp b/servers/rendering/rendering_device_binds.cpp index e50ac42027..d03c4e0427 100644 --- a/servers/rendering/rendering_device_binds.cpp +++ b/servers/rendering/rendering_device_binds.cpp @@ -45,7 +45,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String }; String stage_code[RD::SHADER_STAGE_MAX]; int stages_found = 0; - Map<StringName, String> version_texts; + HashMap<StringName, String> version_texts; versions.clear(); base_error = ""; diff --git a/servers/rendering/rendering_device_binds.h b/servers/rendering/rendering_device_binds.h index ee5bf8b891..8bdd3deea1 100644 --- a/servers/rendering/rendering_device_binds.h +++ b/servers/rendering/rendering_device_binds.h @@ -329,7 +329,7 @@ protected: class RDShaderFile : public Resource { GDCLASS(RDShaderFile, Resource) - Map<StringName, Ref<RDShaderSPIRV>> versions; + HashMap<StringName, Ref<RDShaderSPIRV>> versions; String base_error; public: diff --git a/servers/rendering/shader_compiler.cpp b/servers/rendering/shader_compiler.cpp index 5669cb2054..c88d9e8222 100644 --- a/servers/rendering/shader_compiler.cpp +++ b/servers/rendering/shader_compiler.cpp @@ -289,7 +289,7 @@ String ShaderCompiler::_get_sampler_name(ShaderLanguage::TextureFilter p_filter, return actions.sampler_array_name + "[" + itos(p_filter + (p_repeat == ShaderLanguage::REPEAT_ENABLE ? ShaderLanguage::FILTER_DEFAULT : 0)) + "]"; } -void ShaderCompiler::_dump_function_deps(const SL::ShaderNode *p_node, const StringName &p_for_func, const Map<StringName, String> &p_func_code, String &r_to_add, Set<StringName> &added) { +void ShaderCompiler::_dump_function_deps(const SL::ShaderNode *p_node, const StringName &p_for_func, const HashMap<StringName, String> &p_func_code, String &r_to_add, RBSet<StringName> &added) { int fidx = -1; for (int i = 0; i < p_node->functions.size(); i++) { @@ -303,7 +303,7 @@ void ShaderCompiler::_dump_function_deps(const SL::ShaderNode *p_node, const Str Vector<StringName> uses_functions; - for (Set<StringName>::Element *E = p_node->functions[fidx].uses_function.front(); E; E = E->next()) { + for (RBSet<StringName>::Element *E = p_node->functions[fidx].uses_function.front(); E; E = E->next()) { uses_functions.push_back(E->get()); } uses_functions.sort_custom<StringName::AlphCompare>(); //ensure order is deterministic so the same shader is always produced @@ -735,7 +735,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene } } - Map<StringName, String> function_code; + HashMap<StringName, String> function_code; //code for functions for (int i = 0; i < pnode->functions.size(); i++) { @@ -748,7 +748,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene //place functions in actual code - Set<StringName> added_funcs_per_stage[STAGE_MAX]; + RBSet<StringName> added_funcs_per_stage[STAGE_MAX]; for (int i = 0; i < pnode->functions.size(); i++) { SL::FunctionNode *fnode = pnode->functions[i].function; diff --git a/servers/rendering/shader_compiler.h b/servers/rendering/shader_compiler.h index 347ecf2988..85b93c4063 100644 --- a/servers/rendering/shader_compiler.h +++ b/servers/rendering/shader_compiler.h @@ -45,14 +45,14 @@ public: }; struct IdentifierActions { - Map<StringName, Stage> entry_point_stages; + HashMap<StringName, Stage> entry_point_stages; - Map<StringName, Pair<int *, int>> render_mode_values; - Map<StringName, bool *> render_mode_flags; - Map<StringName, bool *> usage_flag_pointers; - Map<StringName, bool *> write_flag_pointers; + HashMap<StringName, Pair<int *, int>> render_mode_values; + HashMap<StringName, bool *> render_mode_flags; + HashMap<StringName, bool *> usage_flag_pointers; + HashMap<StringName, bool *> write_flag_pointers; - Map<StringName, ShaderLanguage::ShaderNode::Uniform> *uniforms; + HashMap<StringName, ShaderLanguage::ShaderNode::Uniform> *uniforms; }; struct GeneratedCode { @@ -74,7 +74,7 @@ public: String uniforms; String stage_globals[STAGE_MAX]; - Map<String, String> code; + HashMap<String, String> code; bool uses_global_textures; bool uses_fragment_time; @@ -82,10 +82,10 @@ public: }; struct DefaultIdentifierActions { - Map<StringName, String> renames; - Map<StringName, String> render_mode_defines; - Map<StringName, String> usage_defines; - Map<StringName, String> custom_samplers; + HashMap<StringName, String> renames; + HashMap<StringName, String> render_mode_defines; + HashMap<StringName, String> usage_defines; + HashMap<StringName, String> custom_samplers; ShaderLanguage::TextureFilter default_filter; ShaderLanguage::TextureRepeat default_repeat; String sampler_array_name; @@ -103,20 +103,20 @@ private: String _get_sampler_name(ShaderLanguage::TextureFilter p_filter, ShaderLanguage::TextureRepeat p_repeat); - void _dump_function_deps(const ShaderLanguage::ShaderNode *p_node, const StringName &p_for_func, const Map<StringName, String> &p_func_code, String &r_to_add, Set<StringName> &added); + void _dump_function_deps(const ShaderLanguage::ShaderNode *p_node, const StringName &p_for_func, const HashMap<StringName, String> &p_func_code, String &r_to_add, RBSet<StringName> &added); String _dump_node_code(const ShaderLanguage::Node *p_node, int p_level, GeneratedCode &r_gen_code, IdentifierActions &p_actions, const DefaultIdentifierActions &p_default_actions, bool p_assigning, bool p_scope = true); const ShaderLanguage::ShaderNode *shader = nullptr; const ShaderLanguage::FunctionNode *function = nullptr; StringName current_func_name; StringName time_name; - Set<StringName> texture_functions; + RBSet<StringName> texture_functions; - Set<StringName> used_name_defines; - Set<StringName> used_flag_pointers; - Set<StringName> used_rmode_defines; - Set<StringName> internal_functions; - Set<StringName> fragment_varyings; + RBSet<StringName> used_name_defines; + RBSet<StringName> used_flag_pointers; + RBSet<StringName> used_rmode_defines; + RBSet<StringName> internal_functions; + RBSet<StringName> fragment_varyings; DefaultIdentifierActions actions; diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 6f70a55948..8a3ab92714 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -4019,7 +4019,7 @@ uint32_t ShaderLanguage::get_datatype_size(ShaderLanguage::DataType p_type) { } void ShaderLanguage::get_keyword_list(List<String> *r_keywords) { - Set<String> kws; + RBSet<String> kws; int idx = 0; @@ -4036,7 +4036,7 @@ void ShaderLanguage::get_keyword_list(List<String> *r_keywords) { idx++; } - for (Set<String>::Element *E = kws.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = kws.front(); E; E = E->next()) { r_keywords->push_back(E->get()); } } @@ -4056,7 +4056,7 @@ bool ShaderLanguage::is_control_flow_keyword(String p_keyword) { } void ShaderLanguage::get_builtin_funcs(List<String> *r_keywords) { - Set<String> kws; + RBSet<String> kws; int idx = 0; @@ -4066,7 +4066,7 @@ void ShaderLanguage::get_builtin_funcs(List<String> *r_keywords) { idx++; } - for (Set<String>::Element *E = kws.front(); E; E = E->next()) { + for (RBSet<String>::Element *E = kws.front(); E; E = E->next()) { r_keywords->push_back(E->get()); } } @@ -4340,8 +4340,8 @@ bool ShaderLanguage::_propagate_function_call_sampler_uniform_settings(StringNam arg->tex_argument_check = true; arg->tex_argument_filter = p_filter; arg->tex_argument_repeat = p_repeat; - for (KeyValue<StringName, Set<int>> &E : arg->tex_argument_connect) { - for (Set<int>::Element *F = E.value.front(); F; F = F->next()) { + for (KeyValue<StringName, RBSet<int>> &E : arg->tex_argument_connect) { + for (RBSet<int>::Element *F = E.value.front(); F; F = F->next()) { if (!_propagate_function_call_sampler_uniform_settings(E.key, F->get(), p_filter, p_repeat)) { return false; } @@ -4374,8 +4374,8 @@ bool ShaderLanguage::_propagate_function_call_sampler_builtin_reference(StringNa arg->tex_builtin_check = true; arg->tex_builtin = p_builtin; - for (KeyValue<StringName, Set<int>> &E : arg->tex_argument_connect) { - for (Set<int>::Element *F = E.value.front(); F; F = F->next()) { + for (KeyValue<StringName, RBSet<int>> &E : arg->tex_argument_connect) { + for (RBSet<int>::Element *F = E.value.front(); F; F = F->next()) { if (!_propagate_function_call_sampler_builtin_reference(E.key, F->get(), p_builtin)) { return false; } @@ -5096,7 +5096,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons for (int j = 0; j < base_function->arguments.size(); j++) { if (base_function->arguments[j].name == varname) { if (!base_function->arguments[j].tex_argument_connect.has(call_function->name)) { - base_function->arguments.write[j].tex_argument_connect[call_function->name] = Set<int>(); + base_function->arguments.write[j].tex_argument_connect[call_function->name] = RBSet<int>(); } base_function->arguments.write[j].tex_argument_connect[call_function->name].insert(i); found = true; @@ -5419,9 +5419,9 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons StringName member_struct_name = ""; int array_size = 0; - Set<char> position_symbols; - Set<char> color_symbols; - Set<char> texture_symbols; + RBSet<char> position_symbols; + RBSet<char> color_symbols; + RBSet<char> texture_symbols; bool mix_error = false; @@ -6648,7 +6648,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun StringName func_name = parent_function->name; if (!used_local_vars.has(func_name)) { - used_local_vars.insert(func_name, Map<StringName, Usage>()); + used_local_vars.insert(func_name, HashMap<StringName, Usage>()); } used_local_vars[func_name].insert(name, Usage(tk_line)); @@ -7062,7 +7062,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun _set_tkpos(pos); continue; } else { - Set<int> constants; + RBSet<int> constants; for (int i = 0; i < switch_block->statements.size(); i++) { // Checks for duplicates. ControlFlowNode *flow = static_cast<ControlFlowNode *>(switch_block->statements[i]); if (flow) { @@ -7565,10 +7565,10 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun return OK; } -String ShaderLanguage::_get_shader_type_list(const Set<String> &p_shader_types) const { +String ShaderLanguage::_get_shader_type_list(const RBSet<String> &p_shader_types) const { // Return a list of shader types as an human-readable string String valid_types; - for (const Set<String>::Element *E = p_shader_types.front(); E; E = E->next()) { + for (const RBSet<String>::Element *E = p_shader_types.front(); E; E = E->next()) { if (!valid_types.is_empty()) { valid_types += ", "; } @@ -7639,7 +7639,7 @@ Error ShaderLanguage::_validate_datatype(DataType p_type) { return OK; } -Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_functions, const Vector<ModeInfo> &p_render_modes, const Set<String> &p_shader_types) { +Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_functions, const Vector<ModeInfo> &p_render_modes, const RBSet<String> &p_shader_types) { Token tk = _get_token(); TkPos prev_pos; Token next; @@ -7699,7 +7699,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct stages = &p_functions; const FunctionInfo &constants = p_functions.has("constants") ? p_functions["constants"] : FunctionInfo(); - Map<String, String> defined_modes; + HashMap<String, String> defined_modes; while (tk.type != TK_EOF) { switch (tk.type) { @@ -7790,7 +7790,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct st.shader_struct = st_node; int member_count = 0; - Set<String> member_names; + RBSet<String> member_names; while (true) { // variables list #ifdef DEBUG_ENABLED @@ -9234,7 +9234,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct return OK; } -bool ShaderLanguage::has_builtin(const Map<StringName, ShaderLanguage::FunctionInfo> &p_functions, const StringName &p_name) { +bool ShaderLanguage::has_builtin(const HashMap<StringName, ShaderLanguage::FunctionInfo> &p_functions, const StringName &p_name) { for (const KeyValue<StringName, ShaderLanguage::FunctionInfo> &E : p_functions) { if (E.value.built_ins.has(p_name)) { return true; @@ -9376,19 +9376,19 @@ String ShaderLanguage::get_shader_type(const String &p_code) { #ifdef DEBUG_ENABLED void ShaderLanguage::_check_warning_accums() { - for (const KeyValue<ShaderWarning::Code, Map<StringName, Map<StringName, Usage>> *> &E : warnings_check_map2) { - for (Map<StringName, Map<StringName, Usage>>::Element *T = (*E.value).front(); T; T = T->next()) { - for (const KeyValue<StringName, Usage> &U : T->get()) { + for (const KeyValue<ShaderWarning::Code, HashMap<StringName, HashMap<StringName, Usage>> *> &E : warnings_check_map2) { + for (const KeyValue<StringName, HashMap<StringName, Usage>> &T : *E.value) { + for (const KeyValue<StringName, Usage> &U : T.value) { if (!U.value.used) { _add_warning(E.key, U.value.decl_line, U.key); } } } } - for (const KeyValue<ShaderWarning::Code, Map<StringName, Usage> *> &E : warnings_check_map) { - for (const Map<StringName, Usage>::Element *U = (*E.value).front(); U; U = U->next()) { - if (!U->get().used) { - _add_warning(E.key, U->get().decl_line, U->key()); + for (const KeyValue<ShaderWarning::Code, HashMap<StringName, Usage> *> &E : warnings_check_map) { + for (const KeyValue<StringName, Usage> &U : (*E.value)) { + if (!U.value.used) { + _add_warning(E.key, U.value.decl_line, U.key); } } } @@ -9546,7 +9546,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ case COMPLETION_IDENTIFIER: case COMPLETION_FUNCTION_CALL: { bool comp_ident = completion_type == COMPLETION_IDENTIFIER; - Map<String, ScriptLanguage::CodeCompletionKind> matches; + HashMap<String, ScriptLanguage::CodeCompletionKind> matches; StringName skip_function; BlockNode *block = completion_block; @@ -9793,7 +9793,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ } int idx2 = 0; - Set<int> out_args; + RBSet<int> out_args; while (builtin_func_out_args[idx2].name != nullptr) { if (builtin_func_out_args[idx2].name == builtin_func_defs[idx].name) { for (int i = 0; i < BuiltinFuncOutArgs::MAX_ARGS; i++) { diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index 80230ed54c..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; @@ -857,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); @@ -893,15 +893,15 @@ 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; @@ -1039,7 +1039,7 @@ private: uint32_t keyword_completion_context; #endif // DEBUG_ENABLED - const Map<StringName, FunctionInfo> *stages = nullptr; + const HashMap<StringName, FunctionInfo> *stages = nullptr; bool _get_completable_identifier(BlockNode *p_block, CompletionType p_type, StringName &identifier); static const BuiltinFuncDef builtin_func_defs[]; @@ -1068,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); @@ -1094,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; }; diff --git a/servers/rendering/shader_types.cpp b/servers/rendering/shader_types.cpp index 27a69fbc2e..98c7f0d7aa 100644 --- a/servers/rendering/shader_types.cpp +++ b/servers/rendering/shader_types.cpp @@ -31,7 +31,7 @@ #include "shader_types.h" #include "core/math/math_defs.h" -const Map<StringName, ShaderLanguage::FunctionInfo> &ShaderTypes::get_functions(RS::ShaderMode p_mode) const { +const HashMap<StringName, ShaderLanguage::FunctionInfo> &ShaderTypes::get_functions(RS::ShaderMode p_mode) const { return shader_modes[p_mode].functions; } @@ -39,7 +39,7 @@ const Vector<ShaderLanguage::ModeInfo> &ShaderTypes::get_modes(RS::ShaderMode p_ return shader_modes[p_mode].modes; } -const Set<String> &ShaderTypes::get_types() const { +const RBSet<String> &ShaderTypes::get_types() const { return shader_types; } diff --git a/servers/rendering/shader_types.h b/servers/rendering/shader_types.h index 6ba05a3b43..e0fee0a822 100644 --- a/servers/rendering/shader_types.h +++ b/servers/rendering/shader_types.h @@ -31,29 +31,29 @@ #ifndef SHADERTYPES_H #define SHADERTYPES_H -#include "core/templates/map.h" +#include "core/templates/rb_map.h" #include "servers/rendering_server.h" #include "shader_language.h" class ShaderTypes { struct Type { - Map<StringName, ShaderLanguage::FunctionInfo> functions; + HashMap<StringName, ShaderLanguage::FunctionInfo> functions; Vector<ShaderLanguage::ModeInfo> modes; }; - Map<RS::ShaderMode, Type> shader_modes; + HashMap<RS::ShaderMode, Type> shader_modes; static ShaderTypes *singleton; - Set<String> shader_types; + RBSet<String> shader_types; List<String> shader_types_list; public: static ShaderTypes *get_singleton() { return singleton; } - const Map<StringName, ShaderLanguage::FunctionInfo> &get_functions(RS::ShaderMode p_mode) const; + const HashMap<StringName, ShaderLanguage::FunctionInfo> &get_functions(RS::ShaderMode p_mode) const; const Vector<ShaderLanguage::ModeInfo> &get_modes(RS::ShaderMode p_mode) const; - const Set<String> &get_types() const; + const RBSet<String> &get_types() const; const List<String> &get_types_list() const; ShaderTypes(); diff --git a/servers/rendering/shader_warnings.cpp b/servers/rendering/shader_warnings.cpp index 639b9bd165..855dc23d94 100644 --- a/servers/rendering/shader_warnings.cpp +++ b/servers/rendering/shader_warnings.cpp @@ -109,10 +109,10 @@ ShaderWarning::Code ShaderWarning::get_code_from_name(const String &p_name) { ERR_FAIL_V_MSG(WARNING_MAX, "Invalid shader warning name: " + p_name); } -static Map<int, uint32_t> *code_to_flags_map = nullptr; +static HashMap<int, uint32_t> *code_to_flags_map = nullptr; static void init_code_to_flags_map() { - code_to_flags_map = memnew((Map<int, uint32_t>)); + code_to_flags_map = memnew((HashMap<int, uint32_t>)); code_to_flags_map->insert(ShaderWarning::FLOAT_COMPARISON, ShaderWarning::FLOAT_COMPARISON_FLAG); code_to_flags_map->insert(ShaderWarning::UNUSED_CONSTANT, ShaderWarning::UNUSED_CONSTANT_FLAG); code_to_flags_map->insert(ShaderWarning::UNUSED_FUNCTION, ShaderWarning::UNUSED_FUNCTION_FLAG); @@ -124,7 +124,7 @@ static void init_code_to_flags_map() { code_to_flags_map->insert(ShaderWarning::DEVICE_LIMIT_EXCEEDED, ShaderWarning::DEVICE_LIMIT_EXCEEDED_FLAG); } -ShaderWarning::CodeFlags ShaderWarning::get_flags_from_codemap(const Map<Code, bool> &p_map) { +ShaderWarning::CodeFlags ShaderWarning::get_flags_from_codemap(const HashMap<Code, bool> &p_map) { uint32_t result = 0U; if (code_to_flags_map == nullptr) { diff --git a/servers/rendering/shader_warnings.h b/servers/rendering/shader_warnings.h index e309907181..8edf85842f 100644 --- a/servers/rendering/shader_warnings.h +++ b/servers/rendering/shader_warnings.h @@ -34,8 +34,9 @@ #ifdef DEBUG_ENABLED #include "core/string/string_name.h" +#include "core/templates/hash_map.h" #include "core/templates/list.h" -#include "core/templates/map.h" +#include "core/templates/rb_map.h" #include "core/variant/variant.h" class ShaderWarning { @@ -82,7 +83,7 @@ public: static String get_name_from_code(Code p_code); static Code get_code_from_name(const String &p_name); - static CodeFlags get_flags_from_codemap(const Map<Code, bool> &p_map); + static CodeFlags get_flags_from_codemap(const HashMap<Code, bool> &p_map); ShaderWarning(Code p_code = WARNING_MAX, int p_line = -1, const StringName &p_subject = "", const Vector<Variant> &p_extra_args = Vector<Variant>()); }; |