summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorbitsawer <sawerduster@gmail.com>2023-04-26 16:48:23 +0300
committerRĂ©mi Verschelde <rverschelde@gmail.com>2023-04-27 08:41:43 +0200
commita0a95c7bc72212df704c47602b03183b217b4bb2 (patch)
tree09b832b42bbd57463f0511b61215598366d0630f /servers
parentee9a268fd77844d1cf36cf74adb3c008f701b011 (diff)
Fix Shader Preprocessor line numbering when disabled
(cherry picked from commit 34896d8e89022935cde02b07f2b22e5a2dff5b4f)
Diffstat (limited to 'servers')
-rw-r--r--servers/rendering/shader_preprocessor.cpp16
-rw-r--r--servers/rendering/shader_preprocessor.h4
2 files changed, 8 insertions, 12 deletions
diff --git a/servers/rendering/shader_preprocessor.cpp b/servers/rendering/shader_preprocessor.cpp
index ff1d55f905..0644f5918c 100644
--- a/servers/rendering/shader_preprocessor.cpp
+++ b/servers/rendering/shader_preprocessor.cpp
@@ -54,9 +54,9 @@ int ShaderPreprocessor::Tokenizer::get_index() const {
return index;
}
-void ShaderPreprocessor::Tokenizer::get_and_clear_generated(Vector<ShaderPreprocessor::Token> *r_out) {
- for (int i = 0; i < generated.size(); i++) {
- r_out->push_back(generated[i]);
+void ShaderPreprocessor::Tokenizer::get_and_clear_generated(LocalVector<char32_t> *r_out) {
+ for (uint32_t i = 0; i < generated.size(); i++) {
+ r_out->push_back(generated[i].text);
}
generated.clear();
}
@@ -1206,18 +1206,14 @@ Error ShaderPreprocessor::preprocess(State *p_state, const String &p_code, Strin
break;
}
+ // Add autogenerated tokens if there are any.
+ p_tokenizer.get_and_clear_generated(&output);
+
if (state->disabled) {
// Preprocessor was disabled.
// Read the rest of the file into the output.
output.push_back(t.text);
continue;
- } else {
- // Add autogenerated tokens.
- Vector<Token> generated;
- p_tokenizer.get_and_clear_generated(&generated);
- for (int i = 0; i < generated.size(); i++) {
- output.push_back(generated[i].text);
- }
}
if (t.text == '#') {
diff --git a/servers/rendering/shader_preprocessor.h b/servers/rendering/shader_preprocessor.h
index f198af66f0..406b663228 100644
--- a/servers/rendering/shader_preprocessor.h
+++ b/servers/rendering/shader_preprocessor.h
@@ -83,7 +83,7 @@ private:
int line;
int index;
int size;
- Vector<Token> generated;
+ LocalVector<Token> generated;
private:
void add_generated(const Token &p_t);
@@ -95,7 +95,7 @@ private:
char32_t peek();
int consume_line_continuations(int p_offset);
- void get_and_clear_generated(Vector<Token> *r_out);
+ void get_and_clear_generated(LocalVector<char32_t> *r_out);
void backtrack(char32_t p_what);
LocalVector<Token> advance(char32_t p_what);
void skip_whitespace();