diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-09-30 23:52:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-30 23:52:46 +0200 |
commit | 77721b35ba21f2e7e8bb42cf415fccb018517843 (patch) | |
tree | 96b8f7532ae5d923b75bfbac8d6763015b6646bb /servers/rendering | |
parent | 3e1b6304613855cad56938e8a58848f09363a298 (diff) | |
parent | c63b18507d21b8a213c073bced9057b571cdcd7a (diff) |
Merge pull request #51409 from LightningAA/use-map-iterators
Use range iterators for `Map` in most cases
Diffstat (limited to 'servers/rendering')
-rw-r--r-- | servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp | 28 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp | 28 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp | 28 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/renderer_scene_render_rd.cpp | 8 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp | 28 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/renderer_storage_rd.cpp | 70 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/shader_compiler_rd.cpp | 14 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/shader_rd.cpp | 16 | ||||
-rw-r--r-- | servers/rendering/renderer_scene_cull.cpp | 10 | ||||
-rw-r--r-- | servers/rendering/renderer_storage.cpp | 20 | ||||
-rw-r--r-- | servers/rendering/renderer_viewport.cpp | 42 | ||||
-rw-r--r-- | servers/rendering/rendering_device_binds.cpp | 6 | ||||
-rw-r--r-- | servers/rendering/rendering_device_binds.h | 10 | ||||
-rw-r--r-- | servers/rendering/shader_language.cpp | 92 | ||||
-rw-r--r-- | servers/rendering/shader_warnings.cpp | 8 |
15 files changed, 204 insertions, 204 deletions
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 1947680a7a..0416b06d0d 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 @@ -344,36 +344,36 @@ void SceneShaderForwardClustered::ShaderData::set_default_texture_param(const St void SceneShaderForwardClustered::ShaderData::get_param_list(List<PropertyInfo> *p_param_list) const { Map<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_LOCAL) { + for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) { + if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) { 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 SceneShaderForwardClustered::ShaderData::get_instance_param_list(List<RendererStorage::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; } RendererStorage::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().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.hint); p_param_list->push_back(p); } } 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 cd314d8c56..4118735cf2 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 @@ -336,36 +336,36 @@ void SceneShaderForwardMobile::ShaderData::set_default_texture_param(const Strin void SceneShaderForwardMobile::ShaderData::get_param_list(List<PropertyInfo> *p_param_list) const { Map<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_LOCAL) { + for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) { + if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) { 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 SceneShaderForwardMobile::ShaderData::get_instance_param_list(List<RendererStorage::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; } RendererStorage::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().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.hint); p_param_list->push_back(p); } } diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp index 673df00c18..b792ec9971 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp @@ -2133,35 +2133,35 @@ void RendererCanvasRenderRD::ShaderData::set_default_texture_param(const StringN void RendererCanvasRenderRD::ShaderData::get_param_list(List<PropertyInfo> *p_param_list) const { Map<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_LOCAL) { + for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : uniforms) { + if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) { 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 RendererCanvasRenderRD::ShaderData::get_instance_param_list(List<RendererStorage::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; } RendererStorage::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().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.hint); p_param_list->push_back(p); } } diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp index e7156accfa..a1c2f4f49c 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp @@ -850,8 +850,8 @@ void RendererSceneRenderRD::shadow_atlas_set_size(RID p_atlas, int p_size, bool } //erase shadow atlas reference from lights - for (Map<RID, uint32_t>::Element *E = shadow_atlas->shadow_owners.front(); E; E = E->next()) { - LightInstance *li = light_instance_owner.get_or_null(E->key()); + for (const KeyValue<RID, uint32_t> &E : shadow_atlas->shadow_owners) { + LightInstance *li = light_instance_owner.get_or_null(E.key); ERR_CONTINUE(!li); li->shadow_atlases.erase(p_atlas); } @@ -4801,8 +4801,8 @@ void RendererSceneRenderRD::init() { } RendererSceneRenderRD::~RendererSceneRenderRD() { - for (Map<int, ShadowCubemap>::Element *E = shadow_cubemaps.front(); E; E = E->next()) { - RD::get_singleton()->free(E->get().cubemap); + for (const KeyValue<int, ShadowCubemap> &E : shadow_cubemaps) { + RD::get_singleton()->free(E.value.cubemap); } if (sky.sky_scene_state.uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(sky.sky_scene_state.uniform_set)) { diff --git a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp index 14a4111038..830b0e7bae 100644 --- a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp @@ -148,36 +148,36 @@ void RendererSceneSkyRD::SkyShaderData::set_default_texture_param(const StringNa void RendererSceneSkyRD::SkyShaderData::get_param_list(List<PropertyInfo> *p_param_list) const { Map<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 RendererSceneSkyRD::SkyShaderData::get_instance_param_list(List<RendererStorage::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; } RendererStorage::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().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.hint); p_param_list->push_back(p); } } diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp index a0751d3689..5ef1f46742 100644 --- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp @@ -1438,8 +1438,8 @@ void RendererStorageRD::shader_set_code(RID p_shader, const String &p_code) { } if (shader->data) { - for (Map<StringName, RID>::Element *E = shader->default_texture_parameter.front(); E; E = E->next()) { - shader->data->set_default_texture_param(E->key(), E->get()); + for (const KeyValue<StringName, RID> &E : shader->default_texture_parameter) { + shader->data->set_default_texture_param(E.key, E.value); } } } @@ -2136,28 +2136,28 @@ _FORCE_INLINE_ static void _fill_std140_ubo_empty(ShaderLanguage::DataType type, void RendererStorageRD::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) { bool uses_global_buffer = false; - for (Map<StringName, ShaderLanguage::ShaderNode::Uniform>::Element *E = p_uniforms.front(); E; E = E->next()) { - if (E->get().order < 0) { + for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : p_uniforms) { + if (E.value.order < 0) { continue; // texture, does not go here } - if (E->get().scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) { + if (E.value.scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_INSTANCE) { continue; //instance uniforms don't appear in the bufferr } - if (E->get().scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_GLOBAL) { + if (E.value.scope == ShaderLanguage::ShaderNode::Uniform::SCOPE_GLOBAL) { //this is a global variable, get the index to it RendererStorageRD *rs = base_singleton; - GlobalVariables::Variable *gv = rs->global_variables.variables.getptr(E->key()); + GlobalVariables::Variable *gv = rs->global_variables.variables.getptr(E.key); uint32_t index = 0; if (gv) { index = gv->buffer_index; } else { - WARN_PRINT("Shader uses global uniform '" + E->key() + "', but it was removed at some point. Material will not display correctly."); + WARN_PRINT("Shader uses global uniform '" + E.key + "', but it was removed at some point. Material will not display correctly."); } - uint32_t offset = p_uniform_offsets[E->get().order]; + uint32_t offset = p_uniform_offsets[E.value.order]; uint32_t *intptr = (uint32_t *)&p_buffer[offset]; *intptr = index; uses_global_buffer = true; @@ -2165,30 +2165,30 @@ void RendererStorageRD::MaterialData::update_uniform_buffer(const Map<StringName } //regular uniform - uint32_t offset = p_uniform_offsets[E->get().order]; + uint32_t offset = p_uniform_offsets[E.value.order]; #ifdef DEBUG_ENABLED - uint32_t size = ShaderLanguage::get_type_size(E->get().type); + uint32_t size = ShaderLanguage::get_type_size(E.value.type); 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()); + const Map<StringName, Variant>::Element *V = p_parameters.find(E.key); if (V) { //user provided - _fill_std140_variant_ubo_value(E->get().type, V->get(), data, p_use_linear_color); + _fill_std140_variant_ubo_value(E.value.type, V->get(), data, p_use_linear_color); - } else if (E->get().default_value.size()) { + } else if (E.value.default_value.size()) { //default value - _fill_std140_ubo_value(E->get().type, E->get().default_value, data); - //value=E->get().default_value; + _fill_std140_ubo_value(E.value.type, E.value.default_value, data); + //value=E.value.default_value; } else { //zero because it was not provided - if (E->get().type == ShaderLanguage::TYPE_VEC4 && E->get().hint == ShaderLanguage::ShaderNode::Uniform::HINT_COLOR) { + if (E.value.type == ShaderLanguage::TYPE_VEC4 && E.value.hint == ShaderLanguage::ShaderNode::Uniform::HINT_COLOR) { //colors must be set as black, with alpha as 1.0 - _fill_std140_variant_ubo_value(E->get().type, Color(0, 0, 0, 1), data, p_use_linear_color); + _fill_std140_variant_ubo_value(E.value.type, Color(0, 0, 0, 1), data, p_use_linear_color); } else { //else just zero it out - _fill_std140_ubo_empty(E->get().type, data); + _fill_std140_ubo_empty(E.value.type, data); } } } @@ -2215,8 +2215,8 @@ RendererStorageRD::MaterialData::~MaterialData() { //unregister global textures RendererStorageRD *rs = base_singleton; - for (Map<StringName, uint64_t>::Element *E = used_global_textures.front(); E; E = E->next()) { - GlobalVariables::Variable *v = rs->global_variables.variables.getptr(E->key()); + for (const KeyValue<StringName, uint64_t> &E : used_global_textures) { + GlobalVariables::Variable *v = rs->global_variables.variables.getptr(E.key); if (v) { v->texture_materials.erase(self); } @@ -5298,36 +5298,36 @@ void RendererStorageRD::ParticlesShaderData::set_default_texture_param(const Str void RendererStorageRD::ParticlesShaderData::get_param_list(List<PropertyInfo> *p_param_list) const { Map<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 RendererStorageRD::ParticlesShaderData::get_instance_param_list(List<RendererStorage::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; } RendererStorage::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().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.hint); p_param_list->push_back(p); } } diff --git a/servers/rendering/renderer_rd/shader_compiler_rd.cpp b/servers/rendering/renderer_rd/shader_compiler_rd.cpp index b95d4b642c..cddb679eba 100644 --- a/servers/rendering/renderer_rd/shader_compiler_rd.cpp +++ b/servers/rendering/renderer_rd/shader_compiler_rd.cpp @@ -566,11 +566,11 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge int max_texture_uniforms = 0; int max_uniforms = 0; - for (Map<StringName, SL::ShaderNode::Uniform>::Element *E = pnode->uniforms.front(); E; E = E->next()) { - if (SL::is_sampler_type(E->get().type)) { + for (const KeyValue<StringName, SL::ShaderNode::Uniform> &E : pnode->uniforms) { + if (SL::is_sampler_type(E.value.type)) { max_texture_uniforms++; } else { - if (E->get().scope == SL::ShaderNode::Uniform::SCOPE_INSTANCE) { + if (E.value.scope == SL::ShaderNode::Uniform::SCOPE_INSTANCE) { continue; // Instances are indexed directly, don't need index uniforms. } @@ -590,8 +590,8 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge Vector<StringName> uniform_names; - for (Map<StringName, SL::ShaderNode::Uniform>::Element *E = pnode->uniforms.front(); E; E = E->next()) { - uniform_names.push_back(E->key()); + for (const KeyValue<StringName, SL::ShaderNode::Uniform> &E : pnode->uniforms) { + uniform_names.push_back(E.key); } uniform_names.sort_custom<StringName::AlphCompare>(); //ensure order is deterministic so the same shader is always produced @@ -724,8 +724,8 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge Vector<StringName> varying_names; - for (Map<StringName, SL::ShaderNode::Varying>::Element *E = pnode->varyings.front(); E; E = E->next()) { - varying_names.push_back(E->key()); + for (const KeyValue<StringName, SL::ShaderNode::Varying> &E : pnode->varyings) { + varying_names.push_back(E.key); } varying_names.sort_custom<StringName::AlphCompare>(); //ensure order is deterministic so the same shader is always produced diff --git a/servers/rendering/renderer_rd/shader_rd.cpp b/servers/rendering/renderer_rd/shader_rd.cpp index ffaf65ec35..b9a8947fa2 100644 --- a/servers/rendering/renderer_rd/shader_rd.cpp +++ b/servers/rendering/renderer_rd/shader_rd.cpp @@ -174,8 +174,8 @@ void ShaderRD::_build_variant_code(StringBuilder &builder, uint32_t p_variant, c if (p_version->uniforms.size()) { builder.append("#define MATERIAL_UNIFORMS_USED\n"); } - for (Map<StringName, CharString>::Element *E = p_version->code_sections.front(); E; E = E->next()) { - builder.append(String("#define ") + String(E->key()) + "_CODE_USED\n"); + for (const KeyValue<StringName, CharString> &E : p_version->code_sections) { + builder.append(String("#define ") + String(E.key) + "_CODE_USED\n"); } } break; case StageTemplate::Chunk::TYPE_MATERIAL_UNIFORMS: { @@ -355,8 +355,8 @@ String ShaderRD::_version_get_sha1(Version *p_version) const { hash_build.append(p_version->compute_globals.get_data()); Vector<StringName> code_sections; - for (Map<StringName, CharString>::Element *E = p_version->code_sections.front(); E; E = E->next()) { - code_sections.push_back(E->key()); + for (const KeyValue<StringName, CharString> &E : p_version->code_sections) { + code_sections.push_back(E.key); } code_sections.sort_custom<StringName::AlphCompare>(); @@ -530,8 +530,8 @@ void ShaderRD::version_set_code(RID p_version, const Map<String, String> &p_code version->fragment_globals = p_fragment_globals.utf8(); version->uniforms = p_uniforms.utf8(); version->code_sections.clear(); - for (Map<String, String>::Element *E = p_code.front(); E; E = E->next()) { - version->code_sections[StringName(E->key().to_upper())] = E->get().utf8(); + for (const KeyValue<String, String> &E : p_code) { + version->code_sections[StringName(E.key.to_upper())] = E.value.utf8(); } version->custom_defines.clear(); @@ -556,8 +556,8 @@ void ShaderRD::version_set_compute_code(RID p_version, const Map<String, String> version->uniforms = p_uniforms.utf8(); version->code_sections.clear(); - for (Map<String, String>::Element *E = p_code.front(); E; E = E->next()) { - version->code_sections[StringName(E->key().to_upper())] = E->get().utf8(); + for (const KeyValue<String, String> &E : p_code) { + version->code_sections[StringName(E.key.to_upper())] = E.value.utf8(); } version->custom_defines.clear(); diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp index 705e72c13d..558516ac7c 100644 --- a/servers/rendering/renderer_scene_cull.cpp +++ b/servers/rendering/renderer_scene_cull.cpp @@ -1403,8 +1403,8 @@ void RendererSceneCull::instance_geometry_get_shader_parameter_list(RID p_instan const_cast<RendererSceneCull *>(this)->update_dirty_instances(); Vector<StringName> names; - for (Map<StringName, Instance::InstanceShaderParameter>::Element *E = instance->instance_shader_parameters.front(); E; E = E->next()) { - names.push_back(E->key()); + for (const KeyValue<StringName, Instance::InstanceShaderParameter> &E : instance->instance_shader_parameters) { + names.push_back(E.key); } names.sort_custom<StringName::AlphCompare>(); for (int i = 0; i < names.size(); i++) { @@ -3688,9 +3688,9 @@ void RendererSceneCull::_update_dirty_instance(Instance *p_instance) { p_instance->instance_allocated_shader_parameters_offset = RSG::storage->global_variables_instance_allocate(p_instance->self); scene_render->geometry_instance_set_instance_shader_parameters_offset(geom->geometry_instance, p_instance->instance_allocated_shader_parameters_offset); - for (Map<StringName, Instance::InstanceShaderParameter>::Element *E = p_instance->instance_shader_parameters.front(); E; E = E->next()) { - if (E->get().value.get_type() != Variant::NIL) { - RSG::storage->global_variables_instance_update(p_instance->self, E->get().index, E->get().value); + for (const KeyValue<StringName, Instance::InstanceShaderParameter> &E : p_instance->instance_shader_parameters) { + if (E.value.value.get_type() != Variant::NIL) { + RSG::storage->global_variables_instance_update(p_instance->self, E.value.index, E.value.value); } } } else { diff --git a/servers/rendering/renderer_storage.cpp b/servers/rendering/renderer_storage.cpp index a402ecc668..aa005fac0a 100644 --- a/servers/rendering/renderer_storage.cpp +++ b/servers/rendering/renderer_storage.cpp @@ -33,21 +33,21 @@ RendererStorage *RendererStorage::base_singleton = nullptr; void RendererStorage::Dependency::changed_notify(DependencyChangedNotification p_notification) { - for (Map<DependencyTracker *, uint32_t>::Element *E = instances.front(); E; E = E->next()) { - if (E->key()->changed_callback) { - E->key()->changed_callback(p_notification, E->key()); + for (const KeyValue<DependencyTracker *, uint32_t> &E : instances) { + if (E.key->changed_callback) { + E.key->changed_callback(p_notification, E.key); } } } void RendererStorage::Dependency::deleted_notify(const RID &p_rid) { - for (Map<DependencyTracker *, uint32_t>::Element *E = instances.front(); E; E = E->next()) { - if (E->key()->deleted_callback) { - E->key()->deleted_callback(p_rid, E->key()); + for (const KeyValue<DependencyTracker *, uint32_t> &E : instances) { + if (E.key->deleted_callback) { + E.key->deleted_callback(p_rid, E.key); } } - for (Map<DependencyTracker *, uint32_t>::Element *E = instances.front(); E; E = E->next()) { - E->key()->dependencies.erase(this); + for (const KeyValue<DependencyTracker *, uint32_t> &E : instances) { + E.key->dependencies.erase(this); } instances.clear(); } @@ -56,8 +56,8 @@ RendererStorage::Dependency::~Dependency() { #ifdef DEBUG_ENABLED if (instances.size()) { WARN_PRINT("Leaked instance dependency: Bug - did not call instance_notify_deleted when freeing."); - for (Map<DependencyTracker *, uint32_t>::Element *E = instances.front(); E; E = E->next()) { - E->key()->dependencies.erase(this); + for (const KeyValue<DependencyTracker *, uint32_t> &E : instances) { + E.key->dependencies.erase(this); } } #endif diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index 2c07929357..74f18b1da5 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -210,9 +210,9 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { RendererCanvasRender::LightOccluderInstance *occluders = nullptr; //make list of occluders - for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) { - RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E->get().canvas); - Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E->get(), clip_rect.size); + for (KeyValue<RID, Viewport::CanvasData> &E : p_viewport->canvas_map) { + 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()) { if (!F->get()->enabled) { @@ -242,10 +242,10 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { int directional_light_count = 0; RENDER_TIMESTAMP("Cull Canvas Lights"); - for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) { - RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E->get().canvas); + for (KeyValue<RID, Viewport::CanvasData> &E : p_viewport->canvas_map) { + RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E.value.canvas); - Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E->get(), clip_rect.size); + Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E.value, clip_rect.size); //find lights in canvas @@ -307,7 +307,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { } } - canvas_map[Viewport::CanvasKey(E->key(), E->get().layer, E->get().sublayer)] = &E->get(); + canvas_map[Viewport::CanvasKey(E.key, E.value.layer, E.value.sublayer)] = &E.value; } if (lights_with_shadow) { @@ -319,9 +319,9 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { RENDER_TIMESTAMP("Cull Occluders"); //make list of occluders - for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) { - RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E->get().canvas); - Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E->get(), clip_rect.size); + for (KeyValue<RID, Viewport::CanvasData> &E : p_viewport->canvas_map) { + 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()) { if (!F->get()->enabled) { @@ -400,9 +400,9 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { //make list of occluders int occ_cullded = 0; - for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) { - RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E->get().canvas); - Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E->get(), clip_rect.size); + for (KeyValue<RID, Viewport::CanvasData> &E : p_viewport->canvas_map) { + 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()) { if (!F->get()->enabled) { @@ -439,17 +439,17 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { scenario_draw_canvas_bg = false; } - for (Map<Viewport::CanvasKey, Viewport::CanvasData *>::Element *E = canvas_map.front(); E; E = E->next()) { - RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E->get()->canvas); + for (const KeyValue<Viewport::CanvasKey, Viewport::CanvasData *> &E : canvas_map) { + RendererCanvasCull::Canvas *canvas = static_cast<RendererCanvasCull::Canvas *>(E.value->canvas); - Transform2D xform = _canvas_get_transform(p_viewport, canvas, E->get(), clip_rect.size); + Transform2D xform = _canvas_get_transform(p_viewport, canvas, E.value, clip_rect.size); RendererCanvasRender::Light *canvas_lights = nullptr; RendererCanvasRender::Light *canvas_directional_lights = nullptr; RendererCanvasRender::Light *ptr = lights; while (ptr) { - if (E->get()->layer >= ptr->layer_min && E->get()->layer <= ptr->layer_max) { + if (E.value->layer >= ptr->layer_min && E.value->layer <= ptr->layer_max) { ptr->next_ptr = canvas_lights; canvas_lights = ptr; } @@ -458,7 +458,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { ptr = directional_lights; while (ptr) { - if (E->get()->layer >= ptr->layer_min && E->get()->layer <= ptr->layer_max) { + if (E.value->layer >= ptr->layer_min && E.value->layer <= ptr->layer_max) { ptr->next_ptr = canvas_directional_lights; canvas_directional_lights = ptr; } @@ -471,7 +471,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { } i++; - if (scenario_draw_canvas_bg && E->key().get_layer() >= scenario_canvas_max_layer) { + if (scenario_draw_canvas_bg && E.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 { @@ -660,8 +660,8 @@ void RendererViewport::draw_viewports() { //this needs to be called to make screen swapping more efficient RSG::rasterizer->prepare_for_blitting_render_targets(); - for (Map<int, Vector<BlitToScreen>>::Element *E = blit_to_screen_list.front(); E; E = E->next()) { - RSG::rasterizer->blit_render_targets_to_screen(E->key(), E->get().ptr(), E->get().size()); + for (const KeyValue<int, Vector<BlitToScreen>> &E : blit_to_screen_list) { + RSG::rasterizer->blit_render_targets_to_screen(E.key, E.value.ptr(), E.value.size()); } } diff --git a/servers/rendering/rendering_device_binds.cpp b/servers/rendering/rendering_device_binds.cpp index fa3f2f3895..a21f28989b 100644 --- a/servers/rendering/rendering_device_binds.cpp +++ b/servers/rendering/rendering_device_binds.cpp @@ -171,7 +171,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String /* STEP 2, Compile the versions, add to shader file */ - for (Map<StringName, String>::Element *E = version_texts.front(); E; E = E->next()) { + for (const KeyValue<StringName, String> &E : version_texts) { Ref<RDShaderSPIRV> bytecode; bytecode.instantiate(); @@ -180,7 +180,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String if (code == String()) { continue; } - code = code.replace("VERSION_DEFINES", E->get()); + code = code.replace("VERSION_DEFINES", E.value); String error; Vector<uint8_t> spirv = RenderingDevice::get_singleton()->shader_compile_spirv_from_source(RD::ShaderStage(i), code, RD::SHADER_LANGUAGE_GLSL, &error, false); bytecode->set_stage_bytecode(RD::ShaderStage(i), spirv); @@ -195,7 +195,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String bytecode->set_stage_compile_error(RD::ShaderStage(i), error); } - set_bytecode(bytecode, E->key()); + set_bytecode(bytecode, E.key); } return errors_found ? ERR_PARSE_ERROR : OK; diff --git a/servers/rendering/rendering_device_binds.h b/servers/rendering/rendering_device_binds.h index ccc3e2fb39..da614877c4 100644 --- a/servers/rendering/rendering_device_binds.h +++ b/servers/rendering/rendering_device_binds.h @@ -351,8 +351,8 @@ public: Vector<StringName> get_version_list() const { Vector<StringName> vnames; - for (Map<StringName, Ref<RDShaderSPIRV>>::Element *E = versions.front(); E; E = E->next()) { - vnames.push_back(E->key()); + for (const KeyValue<StringName, Ref<RDShaderSPIRV>> &E : versions) { + vnames.push_back(E.key); } vnames.sort_custom<StringName::AlphCompare>(); return vnames; @@ -371,9 +371,9 @@ public: if (base_error != "") { ERR_PRINT("Error parsing shader '" + p_file + "':\n\n" + base_error); } else { - for (Map<StringName, Ref<RDShaderSPIRV>>::Element *E = versions.front(); E; E = E->next()) { + for (KeyValue<StringName, Ref<RDShaderSPIRV>> &E : versions) { for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) { - String error = E->get()->get_stage_compile_error(RD::ShaderStage(i)); + String error = E.value->get_stage_compile_error(RD::ShaderStage(i)); if (error != String()) { static const char *stage_str[RD::SHADER_STAGE_MAX] = { "vertex", @@ -383,7 +383,7 @@ public: "compute" }; - ERR_PRINT("Error parsing shader '" + p_file + "', version '" + String(E->key()) + "', stage '" + stage_str[i] + "':\n\n" + error); + ERR_PRINT("Error parsing shader '" + p_file + "', version '" + String(E.key) + "', stage '" + stage_str[i] + "':\n\n" + error); } } } diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index d6f8fe85c9..f960d4af5f 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -3546,9 +3546,9 @@ 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 (Map<StringName, Set<int>>::Element *E = arg->tex_argument_connect.front(); E; E = E->next()) { - for (Set<int>::Element *F = E->get().front(); F; F = F->next()) { - if (!_propagate_function_call_sampler_uniform_settings(E->key(), F->get(), p_filter, p_repeat)) { + for (KeyValue<StringName, Set<int>> &E : arg->tex_argument_connect) { + for (Set<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; } } @@ -3580,9 +3580,9 @@ bool ShaderLanguage::_propagate_function_call_sampler_builtin_reference(StringNa arg->tex_builtin_check = true; arg->tex_builtin = p_builtin; - for (Map<StringName, Set<int>>::Element *E = arg->tex_argument_connect.front(); E; E = E->next()) { - for (Set<int>::Element *F = E->get().front(); F; F = F->next()) { - if (!_propagate_function_call_sampler_builtin_reference(E->key(), F->get(), p_builtin)) { + for (KeyValue<StringName, Set<int>> &E : arg->tex_argument_connect) { + for (Set<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; } } @@ -7712,8 +7712,8 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct } if (p_functions.has("global")) { // Adds global variables: 'TIME' - for (Map<StringName, BuiltInInfo>::Element *E = p_functions["global"].built_ins.front(); E; E = E->next()) { - builtins.built_ins.insert(E->key(), E->value()); + for (const KeyValue<StringName, BuiltInInfo> &E : p_functions["global"].built_ins) { + builtins.built_ins.insert(E.key, E.value); } } @@ -7985,8 +7985,8 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct } bool ShaderLanguage::has_builtin(const Map<StringName, ShaderLanguage::FunctionInfo> &p_functions, const StringName &p_name) { - for (Map<StringName, ShaderLanguage::FunctionInfo>::Element *E = p_functions.front(); E; E = E->next()) { - if (E->get().built_ins.has(p_name)) { + for (const KeyValue<StringName, ShaderLanguage::FunctionInfo> &E : p_functions) { + if (E.value.built_ins.has(p_name)) { return true; } } @@ -8126,19 +8126,19 @@ String ShaderLanguage::get_shader_type(const String &p_code) { #ifdef DEBUG_ENABLED void ShaderLanguage::_check_warning_accums() { - for (Map<ShaderWarning::Code, Map<StringName, Map<StringName, Usage>> *>::Element *E = warnings_check_map2.front(); E; E = E->next()) { - for (Map<StringName, Map<StringName, Usage>>::Element *T = (*E->get()).front(); T; T = T->next()) { - for (const Map<StringName, Usage>::Element *U = T->get().front(); U; U = U->next()) { - if (!U->get().used) { - _add_warning(E->key(), U->get().decl_line, U->key()); + 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()) { + if (!U.value.used) { + _add_warning(E.key, U.value.decl_line, U.key); } } } } - for (Map<ShaderWarning::Code, Map<StringName, Usage> *>::Element *E = warnings_check_map.front(); E; E = E->next()) { - for (const Map<StringName, Usage>::Element *U = (*E->get()).front(); U; U = U->next()) { + 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()); + _add_warning(E.key, U->get().decl_line, U->key()); } } } @@ -8221,8 +8221,8 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct return OK; } break; case COMPLETION_MAIN_FUNCTION: { - for (const Map<StringName, FunctionInfo>::Element *E = p_functions.front(); E; E = E->next()) { - ScriptCodeCompletionOption option(E->key(), ScriptCodeCompletionOption::KIND_FUNCTION); + for (const KeyValue<StringName, FunctionInfo> &E : p_functions) { + ScriptCodeCompletionOption option(E.key, ScriptCodeCompletionOption::KIND_FUNCTION); r_options->push_back(option); } @@ -8238,9 +8238,9 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct if (completion_class == TAG_GLOBAL) { while (block) { if (comp_ident) { - for (const Map<StringName, BlockNode::Variable>::Element *E = block->variables.front(); E; E = E->next()) { - if (E->get().line < completion_line) { - matches.insert(E->key(), ScriptCodeCompletionOption::KIND_VARIABLE); + for (const KeyValue<StringName, BlockNode::Variable> &E : block->variables) { + if (E.value.line < completion_line) { + matches.insert(E.key, ScriptCodeCompletionOption::KIND_VARIABLE); } } } @@ -8258,30 +8258,30 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct if (comp_ident) { if (p_functions.has("global")) { - for (Map<StringName, BuiltInInfo>::Element *E = p_functions["global"].built_ins.front(); E; E = E->next()) { + for (const KeyValue<StringName, BuiltInInfo> &E : p_functions["global"].built_ins) { ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_MEMBER; - if (E->get().constant) { + if (E.value.constant) { kind = ScriptCodeCompletionOption::KIND_CONSTANT; } - matches.insert(E->key(), kind); + matches.insert(E.key, kind); } } if (skip_function != StringName() && p_functions.has(skip_function)) { - for (Map<StringName, BuiltInInfo>::Element *E = p_functions[skip_function].built_ins.front(); E; E = E->next()) { + for (const KeyValue<StringName, BuiltInInfo> &E : p_functions[skip_function].built_ins) { ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_MEMBER; - if (E->get().constant) { + if (E.value.constant) { kind = ScriptCodeCompletionOption::KIND_CONSTANT; } - matches.insert(E->key(), kind); + matches.insert(E.key, kind); } } - for (const Map<StringName, ShaderNode::Varying>::Element *E = shader->varyings.front(); E; E = E->next()) { - matches.insert(E->key(), ScriptCodeCompletionOption::KIND_VARIABLE); + for (const KeyValue<StringName, ShaderNode::Varying> &E : shader->varyings) { + matches.insert(E.key, ScriptCodeCompletionOption::KIND_VARIABLE); } - for (const Map<StringName, ShaderNode::Uniform>::Element *E = shader->uniforms.front(); E; E = E->next()) { - matches.insert(E->key(), ScriptCodeCompletionOption::KIND_MEMBER); + for (const KeyValue<StringName, ShaderNode::Uniform> &E : shader->uniforms) { + matches.insert(E.key, ScriptCodeCompletionOption::KIND_MEMBER); } } @@ -8296,8 +8296,8 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct bool low_end = RenderingServer::get_singleton()->is_low_end(); if (stages && stages->has(skip_function)) { - for (const Map<StringName, StageFunctionInfo>::Element *E = (*stages)[skip_function].stage_functions.front(); E; E = E->next()) { - matches.insert(String(E->key()), ScriptCodeCompletionOption::KIND_FUNCTION); + for (const KeyValue<StringName, StageFunctionInfo> &E : (*stages)[skip_function].stage_functions) { + matches.insert(String(E.key), ScriptCodeCompletionOption::KIND_FUNCTION); } } @@ -8326,9 +8326,9 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct } } - for (Map<String, ScriptCodeCompletionOption::Kind>::Element *E = matches.front(); E; E = E->next()) { - ScriptCodeCompletionOption option(E->key(), E->value()); - if (E->value() == ScriptCodeCompletionOption::KIND_FUNCTION) { + for (const KeyValue<String, ScriptCodeCompletionOption::Kind> &E : matches) { + ScriptCodeCompletionOption option(E.key, E.value); + if (E.value == ScriptCodeCompletionOption::KIND_FUNCTION) { option.insert_text += "("; } r_options->push_back(option); @@ -8420,14 +8420,14 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct bool low_end = RenderingServer::get_singleton()->is_low_end(); if (stages && stages->has(block_function)) { - for (const Map<StringName, StageFunctionInfo>::Element *E = (*stages)[block_function].stage_functions.front(); E; E = E->next()) { - if (completion_function == E->key()) { - calltip += get_datatype_name(E->get().return_type); + for (const KeyValue<StringName, StageFunctionInfo> &E : (*stages)[block_function].stage_functions) { + if (completion_function == E.key) { + calltip += get_datatype_name(E.value.return_type); calltip += " "; - calltip += E->key(); + calltip += E.key; calltip += "("; - for (int i = 0; i < E->get().arguments.size(); i++) { + for (int i = 0; i < E.value.arguments.size(); i++) { if (i > 0) { calltip += ", "; } else { @@ -8438,16 +8438,16 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct calltip += char32_t(0xFFFF); } - calltip += get_datatype_name(E->get().arguments[i].type); + calltip += get_datatype_name(E.value.arguments[i].type); calltip += " "; - calltip += E->get().arguments[i].name; + calltip += E.value.arguments[i].name; if (i == completion_argument) { calltip += char32_t(0xFFFF); } } - if (E->get().arguments.size()) { + if (E.value.arguments.size()) { calltip += " "; } calltip += ")"; diff --git a/servers/rendering/shader_warnings.cpp b/servers/rendering/shader_warnings.cpp index 0c1d6408c9..0b8476478c 100644 --- a/servers/rendering/shader_warnings.cpp +++ b/servers/rendering/shader_warnings.cpp @@ -119,10 +119,10 @@ ShaderWarning::CodeFlags ShaderWarning::get_flags_from_codemap(const Map<Code, b init_code_to_flags_map(); } - for (Map<Code, bool>::Element *E = p_map.front(); E; E = E->next()) { - if (E->get()) { - ERR_FAIL_COND_V(!code_to_flags_map->has((int)E->key()), ShaderWarning::NONE_FLAG); - result |= (*code_to_flags_map)[(int)E->key()]; + for (const KeyValue<Code, bool> &E : p_map) { + if (E.value) { + ERR_FAIL_COND_V(!code_to_flags_map->has((int)E.key), ShaderWarning::NONE_FLAG); + result |= (*code_to_flags_map)[(int)E.key]; } } return (CodeFlags)result; |