Add a new HashSet template

* Intended to replace RBSet in most cases.
* Optimized for iteration speed
This commit is contained in:
reduz 2022-05-19 17:00:06 +02:00
parent 410893ad0f
commit 45af29da80
243 changed files with 1400 additions and 662 deletions

View file

@ -34,7 +34,7 @@
#ifdef GLES3_ENABLED
#include "core/string/ustring.h"
#include "core/templates/rb_set.h"
#include "core/templates/hash_set.h"
// This must come first to avoid windows.h mess
#include "platform_config.h"
@ -65,7 +65,7 @@ public:
// TODO implement wireframe in OpenGL
// bool generate_wireframes;
RBSet<String> extensions;
HashSet<String> extensions;
bool float_texture_supported = false;
bool s3tc_supported = false;

View file

@ -2381,7 +2381,7 @@ void MaterialStorage::shader_free(RID p_rid) {
//make material unreference this
while (shader->owners.size()) {
material_set_shader(shader->owners.front()->get()->self, RID());
material_set_shader((*shader->owners.begin())->self, RID());
}
//clear data if exists

View file

@ -89,7 +89,7 @@ struct Shader {
String code;
RS::ShaderMode mode;
HashMap<StringName, HashMap<int, RID>> default_texture_parameter;
RBSet<Material *> owners;
HashSet<Material *> owners;
};
/* Material structs */
@ -384,7 +384,7 @@ struct GlobalVariables {
BUFFER_DIRTY_REGION_SIZE = 1024
};
struct Variable {
RBSet<RID> texture_materials; // materials using this
HashSet<RID> texture_materials; // materials using this
RS::GlobalVariableType type;
Variant value;

View file

@ -123,7 +123,7 @@ struct Mesh {
List<MeshInstance *> instances;
RID shadow_mesh;
RBSet<Mesh *> shadow_owners;
HashSet<Mesh *> shadow_owners;
RendererStorage::Dependency dependency;
};

View file

@ -132,13 +132,13 @@ static void update_external_dependency_for_store(VkSubpassDependency &dependency
void RenderingDeviceVulkan::_add_dependency(RID p_id, RID p_depends_on) {
if (!dependency_map.has(p_depends_on)) {
dependency_map[p_depends_on] = RBSet<RID>();
dependency_map[p_depends_on] = HashSet<RID>();
}
dependency_map[p_depends_on].insert(p_id);
if (!reverse_dependency_map.has(p_id)) {
reverse_dependency_map[p_id] = RBSet<RID>();
reverse_dependency_map[p_id] = HashSet<RID>();
}
reverse_dependency_map[p_id].insert(p_depends_on);
@ -147,10 +147,10 @@ void RenderingDeviceVulkan::_add_dependency(RID p_id, RID p_depends_on) {
void RenderingDeviceVulkan::_free_dependencies(RID p_id) {
//direct dependencies must be freed
HashMap<RID, RBSet<RID>>::Iterator E = dependency_map.find(p_id);
HashMap<RID, HashSet<RID>>::Iterator E = dependency_map.find(p_id);
if (E) {
while (E->value.size()) {
free(E->value.front()->get());
free(*E->value.begin());
}
dependency_map.remove(E);
}
@ -160,7 +160,7 @@ void RenderingDeviceVulkan::_free_dependencies(RID p_id) {
if (E) {
for (const RID &F : E->value) {
HashMap<RID, RBSet<RID>>::Iterator G = dependency_map.find(F);
HashMap<RID, HashSet<RID>>::Iterator G = dependency_map.find(F);
ERR_CONTINUE(!G);
ERR_CONTINUE(!G->value.has(p_id));
G->value.erase(p_id);
@ -4138,7 +4138,7 @@ RenderingDevice::VertexFormatID RenderingDeviceVulkan::vertex_format_create(cons
vdcache.bindings = memnew_arr(VkVertexInputBindingDescription, p_vertex_formats.size());
vdcache.attributes = memnew_arr(VkVertexInputAttributeDescription, p_vertex_formats.size());
RBSet<int> used_locations;
HashSet<int> used_locations;
for (int i = 0; i < p_vertex_formats.size(); i++) {
ERR_CONTINUE(p_vertex_formats[i].format >= DATA_FORMAT_MAX);
ERR_FAIL_COND_V(used_locations.has(p_vertex_formats[i].location), INVALID_ID);
@ -5468,7 +5468,7 @@ RID RenderingDeviceVulkan::texture_buffer_create(uint32_t p_size_elements, DataF
RenderingDeviceVulkan::DescriptorPool *RenderingDeviceVulkan::_descriptor_pool_allocate(const DescriptorPoolKey &p_key) {
if (!descriptor_pools.has(p_key)) {
descriptor_pools[p_key] = RBSet<DescriptorPool *>();
descriptor_pools[p_key] = HashSet<DescriptorPool *>();
}
DescriptorPool *pool = nullptr;

View file

@ -101,8 +101,8 @@ class RenderingDeviceVulkan : public RenderingDevice {
VkDevice device = VK_NULL_HANDLE;
HashMap<RID, RBSet<RID>> dependency_map; //IDs to IDs that depend on it
HashMap<RID, RBSet<RID>> reverse_dependency_map; //same as above, but in reverse
HashMap<RID, HashSet<RID>> dependency_map; //IDs to IDs that depend on it
HashMap<RID, HashSet<RID>> reverse_dependency_map; //same as above, but in reverse
void _add_dependency(RID p_id, RID p_depends_on);
void _free_dependencies(RID p_id);
@ -702,7 +702,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
uint32_t usage;
};
RBMap<DescriptorPoolKey, RBSet<DescriptorPool *>> descriptor_pools;
RBMap<DescriptorPoolKey, HashSet<DescriptorPool *>> descriptor_pools;
uint32_t max_descriptors_per_pool = 0;
DescriptorPool *_descriptor_pool_allocate(const DescriptorPoolKey &p_key);
@ -923,7 +923,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
};
struct State {
RBSet<Texture *> textures_to_sampled_layout;
HashSet<Texture *> textures_to_sampled_layout;
SetState sets[MAX_UNIFORM_SETS];
uint32_t set_count = 0;
RID pipeline;