Merge pull request #93866 from Chaosus/shader_fix_global_func_set
Improve code for setup of `global_func_set` in `ShaderLanguage`
This commit is contained in:
commit
40cb283dd7
2 changed files with 15 additions and 9 deletions
|
@ -39,6 +39,8 @@
|
||||||
|
|
||||||
#define HAS_WARNING(flag) (warning_flags & flag)
|
#define HAS_WARNING(flag) (warning_flags & flag)
|
||||||
|
|
||||||
|
int ShaderLanguage::instance_counter = 0;
|
||||||
|
|
||||||
String ShaderLanguage::get_operator_text(Operator p_op) {
|
String ShaderLanguage::get_operator_text(Operator p_op) {
|
||||||
static const char *op_names[OP_MAX] = { "==",
|
static const char *op_names[OP_MAX] = { "==",
|
||||||
"!=",
|
"!=",
|
||||||
|
@ -10812,17 +10814,16 @@ ShaderLanguage::ShaderLanguage() {
|
||||||
nodes = nullptr;
|
nodes = nullptr;
|
||||||
completion_class = TAG_GLOBAL;
|
completion_class = TAG_GLOBAL;
|
||||||
|
|
||||||
|
if (instance_counter == 0) {
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
while (builtin_func_defs[idx].name) {
|
while (builtin_func_defs[idx].name) {
|
||||||
if (builtin_func_defs[idx].tag == SubClassTag::TAG_GLOBAL) {
|
if (builtin_func_defs[idx].tag == SubClassTag::TAG_GLOBAL) {
|
||||||
const StringName &name = StringName(builtin_func_defs[idx].name);
|
global_func_set.insert(builtin_func_defs[idx].name);
|
||||||
|
|
||||||
if (!global_func_set.has(name)) {
|
|
||||||
global_func_set.insert(name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
instance_counter++;
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
warnings_check_map.insert(ShaderWarning::UNUSED_CONSTANT, &used_constants);
|
warnings_check_map.insert(ShaderWarning::UNUSED_CONSTANT, &used_constants);
|
||||||
|
@ -10837,5 +10838,8 @@ ShaderLanguage::ShaderLanguage() {
|
||||||
|
|
||||||
ShaderLanguage::~ShaderLanguage() {
|
ShaderLanguage::~ShaderLanguage() {
|
||||||
clear();
|
clear();
|
||||||
|
instance_counter--;
|
||||||
|
if (instance_counter == 0) {
|
||||||
global_func_set.clear();
|
global_func_set.clear();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -800,6 +800,8 @@ public:
|
||||||
static bool is_control_flow_keyword(String p_keyword);
|
static bool is_control_flow_keyword(String p_keyword);
|
||||||
static void get_builtin_funcs(List<String> *r_keywords);
|
static void get_builtin_funcs(List<String> *r_keywords);
|
||||||
|
|
||||||
|
static int instance_counter;
|
||||||
|
|
||||||
struct BuiltInInfo {
|
struct BuiltInInfo {
|
||||||
DataType type = TYPE_VOID;
|
DataType type = TYPE_VOID;
|
||||||
bool constant = false;
|
bool constant = false;
|
||||||
|
|
Loading…
Reference in a new issue