mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-11-21 16:37:20 +01:00
Prevent shuffling custom shader functions (shader cache requires determinism)
This commit is contained in:
parent
b952bfcc36
commit
7101e4aed7
@ -230,17 +230,18 @@ void ShaderCompilerGLES2::_dump_function_deps(const SL::ShaderNode *p_node, cons
|
||||
|
||||
ERR_FAIL_COND(fidx == -1);
|
||||
|
||||
for (RBSet<StringName>::Element *E = p_node->functions[fidx].uses_function.front(); E; E = E->next()) {
|
||||
if (r_added.has(E->get())) {
|
||||
for (int ufidx = 0; ufidx < p_node->functions[fidx].uses_function.size(); ufidx++) {
|
||||
StringName function_name = p_node->functions[fidx].uses_function[ufidx];
|
||||
if (r_added.has(function_name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
_dump_function_deps(p_node, E->get(), p_func_code, r_to_add, r_added);
|
||||
_dump_function_deps(p_node, function_name, p_func_code, r_to_add, r_added);
|
||||
|
||||
SL::FunctionNode *fnode = nullptr;
|
||||
|
||||
for (int i = 0; i < p_node->functions.size(); i++) {
|
||||
if (p_node->functions[i].name == E->get()) {
|
||||
if (p_node->functions[i].name == function_name) {
|
||||
fnode = p_node->functions[i].function;
|
||||
break;
|
||||
}
|
||||
@ -273,9 +274,9 @@ void ShaderCompilerGLES2::_dump_function_deps(const SL::ShaderNode *p_node, cons
|
||||
|
||||
header += ")\n";
|
||||
r_to_add += header.as_string();
|
||||
r_to_add += p_func_code[E->get()];
|
||||
r_to_add += p_func_code[function_name];
|
||||
|
||||
r_added.insert(E->get());
|
||||
r_added.insert(function_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3404,7 +3404,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||
//add to current function as dependency
|
||||
for (int j = 0; j < shader->functions.size(); j++) {
|
||||
if (shader->functions[j].name == current_function) {
|
||||
shader->functions.write[j].uses_function.insert(name);
|
||||
shader->functions.write[j].uses_function.push_back(name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -603,7 +603,7 @@ public:
|
||||
struct Function {
|
||||
StringName name;
|
||||
FunctionNode *function;
|
||||
RBSet<StringName> uses_function;
|
||||
Vector<StringName> uses_function;
|
||||
bool callable;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user