diff options
author | Yuri Rubinsky <chaosus89@gmail.com> | 2022-08-19 07:01:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-19 07:01:22 +0300 |
commit | 35cfaafda8073f700c9d2fe42a43d3d81eaaea67 (patch) | |
tree | 83901508aba081fd1bea195c70f3b7d0e15a4120 /servers/rendering/shader_preprocessor.h | |
parent | 0ba1046355b689d33eeed13a2633b174d62ccff8 (diff) | |
parent | 13ab70ed2afdd5cb11a08c41948b94c57f494360 (diff) |
Merge pull request #64459 from Chaosus/shader_elif
Diffstat (limited to 'servers/rendering/shader_preprocessor.h')
-rw-r--r-- | servers/rendering/shader_preprocessor.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/servers/rendering/shader_preprocessor.h b/servers/rendering/shader_preprocessor.h index 41b574298d..71dd9a6ca8 100644 --- a/servers/rendering/shader_preprocessor.h +++ b/servers/rendering/shader_preprocessor.h @@ -130,14 +130,23 @@ private: String body; }; - struct SkippedCondition { - int start_line = -1; - int end_line = -1; + struct Branch { + Vector<bool> conditions; + Branch *parent = nullptr; + bool else_defined = false; + + Branch() {} + + Branch(bool p_condition, Branch *p_parent) : + parent(p_parent) { + conditions.push_back(p_condition); + } }; struct State { RBMap<String, Define *> defines; - Vector<bool> skip_stack_else; + List<Branch> branches; + Branch *current_branch = nullptr; int condition_depth = 0; RBSet<String> includes; List<uint64_t> cyclic_include_hashes; // Holds code hash of includes. @@ -149,7 +158,6 @@ private: bool save_regions = false; RBMap<String, List<Region>> regions; Region *previous_region = nullptr; - RBMap<String, Vector<SkippedCondition *>> skipped_conditions; bool disabled = false; CompletionType completion_type = COMPLETION_TYPE_NONE; HashSet<Ref<ShaderInclude>> shader_includes; @@ -169,6 +177,7 @@ private: void process_directive(Tokenizer *p_tokenizer); void process_define(Tokenizer *p_tokenizer); + void process_elif(Tokenizer *p_tokenizer); void process_else(Tokenizer *p_tokenizer); void process_endif(Tokenizer *p_tokenizer); void process_if(Tokenizer *p_tokenizer); @@ -179,7 +188,7 @@ private: void process_undef(Tokenizer *p_tokenizer); void add_region(int p_line, bool p_enabled, Region *p_parent_region); - void start_branch_condition(Tokenizer *p_tokenizer, bool p_success); + void start_branch_condition(Tokenizer *p_tokenizer, bool p_success, bool p_continue = false); void expand_output_macros(int p_start, int p_line); Error expand_macros(const String &p_string, int p_line, String &r_result); |