summaryrefslogtreecommitdiff
path: root/servers/rendering
diff options
context:
space:
mode:
authorYuri Rubinsky <chaosus89@gmail.com>2022-07-23 09:38:59 +0300
committerYuri Rubinsky <chaosus89@gmail.com>2022-07-23 09:38:59 +0300
commit6d992abb541d4e772ef1fbc16d0b82ca3a6b343d (patch)
treec1b6dcbe8301cb5d1cc081ef6f5ef497bca6f774 /servers/rendering
parentfe929d4787b2b11390891fb03da1dda78b18eb65 (diff)
Fix some errors after shader preprocessor PR
Diffstat (limited to 'servers/rendering')
-rw-r--r--servers/rendering/shader_preprocessor.cpp44
-rw-r--r--servers/rendering/shader_preprocessor.h2
2 files changed, 9 insertions, 37 deletions
diff --git a/servers/rendering/shader_preprocessor.cpp b/servers/rendering/shader_preprocessor.cpp
index 9623d11010..a7b274b3e2 100644
--- a/servers/rendering/shader_preprocessor.cpp
+++ b/servers/rendering/shader_preprocessor.cpp
@@ -344,41 +344,23 @@ void ShaderPreprocessor::process_directive(Tokenizer *p_tokenizer) {
}
if (directive == "if") {
- if (check_directive_before_type(p_tokenizer, directive)) {
- process_if(p_tokenizer);
- }
+ process_if(p_tokenizer);
} else if (directive == "ifdef") {
- if (check_directive_before_type(p_tokenizer, directive)) {
- process_ifdef(p_tokenizer);
- }
+ process_ifdef(p_tokenizer);
} else if (directive == "ifndef") {
- if (check_directive_before_type(p_tokenizer, directive)) {
- process_ifndef(p_tokenizer);
- }
+ process_ifndef(p_tokenizer);
} else if (directive == "else") {
- if (check_directive_before_type(p_tokenizer, directive)) {
- process_else(p_tokenizer);
- }
+ process_else(p_tokenizer);
} else if (directive == "endif") {
- if (check_directive_before_type(p_tokenizer, directive)) {
- process_endif(p_tokenizer);
- }
+ process_endif(p_tokenizer);
} else if (directive == "define") {
- if (check_directive_before_type(p_tokenizer, directive)) {
- process_define(p_tokenizer);
- }
+ process_define(p_tokenizer);
} else if (directive == "undef") {
- if (check_directive_before_type(p_tokenizer, directive)) {
- process_undef(p_tokenizer);
- }
+ process_undef(p_tokenizer);
} else if (directive == "include") {
- if (check_directive_before_type(p_tokenizer, directive)) {
- process_include(p_tokenizer);
- }
+ process_include(p_tokenizer);
} else if (directive == "pragma") {
- if (check_directive_before_type(p_tokenizer, directive)) {
- process_pragma(p_tokenizer);
- }
+ process_pragma(p_tokenizer);
} else {
set_error(RTR("Unknown directive."), p_tokenizer->get_line());
}
@@ -880,14 +862,6 @@ void ShaderPreprocessor::set_error(const String &p_error, int p_line) {
}
}
-bool ShaderPreprocessor::check_directive_before_type(Tokenizer *p_tokenizer, const String &p_directive) {
- if (p_tokenizer->get_index() < state->shader_type_pos) {
- set_error(vformat(RTR("`#%s` may not be defined before `shader_type`."), p_directive), p_tokenizer->get_line());
- return false;
- }
- return true;
-}
-
ShaderPreprocessor::Define *ShaderPreprocessor::create_define(const String &p_body) {
ShaderPreprocessor::Define *define = memnew(Define);
define->body = p_body;
diff --git a/servers/rendering/shader_preprocessor.h b/servers/rendering/shader_preprocessor.h
index 9bac706049..a93fb680dd 100644
--- a/servers/rendering/shader_preprocessor.h
+++ b/servers/rendering/shader_preprocessor.h
@@ -136,7 +136,6 @@ private:
int include_depth = 0;
String current_include;
String current_shader_type;
- int shader_type_pos = -1;
String error;
List<FilePosition> include_positions;
RBMap<String, Vector<SkippedCondition *>> skipped_conditions;
@@ -179,7 +178,6 @@ private:
String next_directive(Tokenizer *p_tokenizer, const Vector<String> &p_directives);
void add_to_output(const String &p_str);
void set_error(const String &p_error, int p_line);
- bool check_directive_before_type(Tokenizer *p_tokenizer, const String &p_directive);
static Define *create_define(const String &p_body);