Replace VMap with HashMap in VisualShader.
This commit is contained in:
@ -1516,16 +1516,9 @@ String VisualShader::generate_preview_shader(Type p_type, int p_node, int p_port
|
|||||||
global_code += global_expressions;
|
global_code += global_expressions;
|
||||||
|
|
||||||
//make it faster to go around through shader
|
//make it faster to go around through shader
|
||||||
VMap<ConnectionKey, const List<Connection>::Element *> input_connections;
|
HashMap<ConnectionKey, const List<Connection>::Element *> input_connections;
|
||||||
VMap<ConnectionKey, const List<Connection>::Element *> output_connections;
|
|
||||||
|
|
||||||
for (const List<Connection>::Element *E = graph[p_type].connections.front(); E; E = E->next()) {
|
for (const List<Connection>::Element *E = graph[p_type].connections.front(); E; E = E->next()) {
|
||||||
ConnectionKey from_key;
|
|
||||||
from_key.node = E->get().from_node;
|
|
||||||
from_key.port = E->get().from_port;
|
|
||||||
|
|
||||||
output_connections.insert(from_key, E);
|
|
||||||
|
|
||||||
ConnectionKey to_key;
|
ConnectionKey to_key;
|
||||||
to_key.node = E->get().to_node;
|
to_key.node = E->get().to_node;
|
||||||
to_key.port = E->get().to_port;
|
to_key.port = E->get().to_port;
|
||||||
@ -1536,7 +1529,7 @@ String VisualShader::generate_preview_shader(Type p_type, int p_node, int p_port
|
|||||||
shader_code += "\nvoid fragment() {\n";
|
shader_code += "\nvoid fragment() {\n";
|
||||||
|
|
||||||
HashSet<int> processed;
|
HashSet<int> processed;
|
||||||
Error err = _write_node(p_type, &global_code, &global_code_per_node, &global_code_per_func, shader_code, default_tex_params, input_connections, output_connections, p_node, processed, true, classes);
|
Error err = _write_node(p_type, &global_code, &global_code_per_node, &global_code_per_func, shader_code, default_tex_params, input_connections, p_node, processed, true, classes);
|
||||||
ERR_FAIL_COND_V(err != OK, String());
|
ERR_FAIL_COND_V(err != OK, String());
|
||||||
|
|
||||||
switch (node->get_output_port_type(p_port)) {
|
switch (node->get_output_port_type(p_port)) {
|
||||||
@ -1955,7 +1948,7 @@ void VisualShader::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Error VisualShader::_write_node(Type type, StringBuilder *p_global_code, StringBuilder *p_global_code_per_node, HashMap<Type, StringBuilder> *p_global_code_per_func, StringBuilder &r_code, Vector<VisualShader::DefaultTextureParam> &r_def_tex_params, const VMap<ConnectionKey, const List<Connection>::Element *> &p_input_connections, const VMap<ConnectionKey, const List<Connection>::Element *> &p_output_connections, int p_node, HashSet<int> &r_processed, bool p_for_preview, HashSet<StringName> &r_classes) const {
|
Error VisualShader::_write_node(Type type, StringBuilder *p_global_code, StringBuilder *p_global_code_per_node, HashMap<Type, StringBuilder> *p_global_code_per_func, StringBuilder &r_code, Vector<VisualShader::DefaultTextureParam> &r_def_tex_params, const HashMap<ConnectionKey, const List<Connection>::Element *> &p_input_connections, int p_node, HashSet<int> &r_processed, bool p_for_preview, HashSet<StringName> &r_classes) const {
|
||||||
const Ref<VisualShaderNode> vsnode = graph[type].nodes[p_node].node;
|
const Ref<VisualShaderNode> vsnode = graph[type].nodes[p_node].node;
|
||||||
|
|
||||||
if (vsnode->is_disabled()) {
|
if (vsnode->is_disabled()) {
|
||||||
@ -1977,7 +1970,7 @@ Error VisualShader::_write_node(Type type, StringBuilder *p_global_code, StringB
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Error err = _write_node(type, p_global_code, p_global_code_per_node, p_global_code_per_func, r_code, r_def_tex_params, p_input_connections, p_output_connections, from_node, r_processed, p_for_preview, r_classes);
|
Error err = _write_node(type, p_global_code, p_global_code_per_node, p_global_code_per_func, r_code, r_def_tex_params, p_input_connections, from_node, r_processed, p_for_preview, r_classes);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -2702,8 +2695,7 @@ void VisualShader::_update_shader() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//make it faster to go around through shader
|
//make it faster to go around through shader
|
||||||
VMap<ConnectionKey, const List<Connection>::Element *> input_connections;
|
HashMap<ConnectionKey, const List<Connection>::Element *> input_connections;
|
||||||
VMap<ConnectionKey, const List<Connection>::Element *> output_connections;
|
|
||||||
|
|
||||||
StringBuilder func_code;
|
StringBuilder func_code;
|
||||||
HashSet<int> processed;
|
HashSet<int> processed;
|
||||||
@ -2764,12 +2756,6 @@ void VisualShader::_update_shader() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const List<Connection>::Element *E = graph[i].connections.front(); E; E = E->next()) {
|
for (const List<Connection>::Element *E = graph[i].connections.front(); E; E = E->next()) {
|
||||||
ConnectionKey from_key;
|
|
||||||
from_key.node = E->get().from_node;
|
|
||||||
from_key.port = E->get().from_port;
|
|
||||||
|
|
||||||
output_connections.insert(from_key, E);
|
|
||||||
|
|
||||||
ConnectionKey to_key;
|
ConnectionKey to_key;
|
||||||
to_key.node = E->get().to_node;
|
to_key.node = E->get().to_node;
|
||||||
to_key.port = E->get().to_port;
|
to_key.port = E->get().to_port;
|
||||||
@ -2791,19 +2777,19 @@ void VisualShader::_update_shader() const {
|
|||||||
}
|
}
|
||||||
insertion_pos.insert(i, shader_code.get_string_length() + func_code.get_string_length());
|
insertion_pos.insert(i, shader_code.get_string_length() + func_code.get_string_length());
|
||||||
|
|
||||||
Error err = _write_node(Type(i), &global_code, &global_code_per_node, &global_code_per_func, func_code, default_tex_params, input_connections, output_connections, NODE_ID_OUTPUT, processed, false, classes);
|
Error err = _write_node(Type(i), &global_code, &global_code_per_node, &global_code_per_func, func_code, default_tex_params, input_connections, NODE_ID_OUTPUT, processed, false, classes);
|
||||||
ERR_FAIL_COND(err != OK);
|
ERR_FAIL_COND(err != OK);
|
||||||
|
|
||||||
if (varying_setters.has(i)) {
|
if (varying_setters.has(i)) {
|
||||||
for (int &E : varying_setters[i]) {
|
for (int &E : varying_setters[i]) {
|
||||||
err = _write_node(Type(i), &global_code, &global_code_per_node, nullptr, func_code, default_tex_params, input_connections, output_connections, E, processed, false, classes);
|
err = _write_node(Type(i), &global_code, &global_code_per_node, nullptr, func_code, default_tex_params, input_connections, E, processed, false, classes);
|
||||||
ERR_FAIL_COND(err != OK);
|
ERR_FAIL_COND(err != OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (emitters.has(i)) {
|
if (emitters.has(i)) {
|
||||||
for (int &E : emitters[i]) {
|
for (int &E : emitters[i]) {
|
||||||
err = _write_node(Type(i), &global_code, &global_code_per_node, &global_code_per_func, func_code, default_tex_params, input_connections, output_connections, E, processed, false, classes);
|
err = _write_node(Type(i), &global_code, &global_code_per_node, &global_code_per_func, func_code, default_tex_params, input_connections, E, processed, false, classes);
|
||||||
ERR_FAIL_COND(err != OK);
|
ERR_FAIL_COND(err != OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -156,12 +156,11 @@ private:
|
|||||||
uint64_t port : 32;
|
uint64_t port : 32;
|
||||||
};
|
};
|
||||||
uint64_t key = 0;
|
uint64_t key = 0;
|
||||||
bool operator<(const ConnectionKey &p_key) const {
|
// This is used to apply default equal and hash methods for uint64_t to ConnectionKey.
|
||||||
return key < p_key.key;
|
operator uint64_t() const { return key; }
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Error _write_node(Type p_type, StringBuilder *p_global_code, StringBuilder *p_global_code_per_node, HashMap<Type, StringBuilder> *p_global_code_per_func, StringBuilder &r_code, Vector<DefaultTextureParam> &r_def_tex_params, const VMap<ConnectionKey, const List<Connection>::Element *> &p_input_connections, const VMap<ConnectionKey, const List<Connection>::Element *> &p_output_connections, int p_node, HashSet<int> &r_processed, bool p_for_preview, HashSet<StringName> &r_classes) const;
|
Error _write_node(Type p_type, StringBuilder *p_global_code, StringBuilder *p_global_code_per_node, HashMap<Type, StringBuilder> *p_global_code_per_func, StringBuilder &r_code, Vector<DefaultTextureParam> &r_def_tex_params, const HashMap<ConnectionKey, const List<Connection>::Element *> &p_input_connections, int p_node, HashSet<int> &r_processed, bool p_for_preview, HashSet<StringName> &r_classes) const;
|
||||||
|
|
||||||
void _input_type_changed(Type p_type, int p_id);
|
void _input_type_changed(Type p_type, int p_id);
|
||||||
bool has_func_name(RenderingServer::ShaderMode p_mode, const String &p_func_name) const;
|
bool has_func_name(RenderingServer::ShaderMode p_mode, const String &p_func_name) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user