Implement async shader compilation plus caching for GL ES 3

Async. compilation via ubershader is currently available in the scene and particles shaders only.

Bonus:
- Use `#if defined()` syntax for not true conditionals, so they don't unnecessarily take a bit in the version flagset.
- Remove unused `ENABLE_CLIP_ALPHA` from scene shader.
- Remove unused `PARTICLES_COPY` from the particles shader.
- Remove unused uniform related code.
- Shader language/compiler: use ordered hash maps for deterministic code generation (needed for caching).
This commit is contained in:
Pedro J. Estébanez
2021-09-26 21:31:17 +02:00
parent b6f04dfd21
commit 4c710780d4
43 changed files with 2169 additions and 669 deletions

View File

@ -120,14 +120,14 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
case SL::Node::TYPE_SHADER: {
SL::ShaderNode *pnode = (SL::ShaderNode *)p_node;
for (Map<StringName, SL::ShaderNode::Uniform>::Element *E = pnode->uniforms.front(); E; E = E->next()) {
for (OrderedHashMap<StringName, SL::ShaderNode::Uniform>::Element E = pnode->uniforms.front(); E; E = E.next()) {
String ucode = "uniform ";
ucode += _prestr(E->get().precision);
ucode += _typestr(E->get().type);
ucode += " " + String(E->key());
ucode += _prestr(E.get().precision);
ucode += _typestr(E.get().type);
ucode += " " + String(E.key());
if (E->get().default_value.size()) {
ucode += " = " + get_constant_text(E->get().type, E->get().default_value);
if (E.get().default_value.size()) {
ucode += " = " + get_constant_text(E.get().type, E.get().default_value);
}
static const char *hint_name[SL::ShaderNode::Uniform::HINT_MAX] = {
@ -140,18 +140,18 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
"white"
};
if (E->get().hint) {
ucode += " : " + String(hint_name[E->get().hint]);
if (E.get().hint) {
ucode += " : " + String(hint_name[E.get().hint]);
}
code += ucode + "\n";
}
for (Map<StringName, SL::ShaderNode::Varying>::Element *E = pnode->varyings.front(); E; E = E->next()) {
for (OrderedHashMap<StringName, SL::ShaderNode::Varying>::Element E = pnode->varyings.front(); E; E = E.next()) {
String vcode = "varying ";
vcode += _prestr(E->get().precision);
vcode += _typestr(E->get().type);
vcode += " " + String(E->key());
vcode += _prestr(E.get().precision);
vcode += _typestr(E.get().type);
vcode += " " + String(E.key());
code += vcode + "\n";
}