mirror of
https://github.com/godotengine/godot.git
synced 2024-11-26 22:23:04 +00:00
Merge pull request #63338 from Chaosus/fix_shader_preprocessor_errors
Fix some errors after shader preprocessor PR
This commit is contained in:
commit
7c225f5bfe
@ -381,7 +381,7 @@ void ShaderTextEditor::_validate_script() {
|
||||
//preprocessor error
|
||||
ERR_FAIL_COND(err_positions.size() == 0);
|
||||
|
||||
String error_text;
|
||||
String error_text = error_pp;
|
||||
int error_line = err_positions.front()->get().line;
|
||||
if (err_positions.size() == 1) {
|
||||
// Error in main file
|
||||
@ -1198,12 +1198,12 @@ void ShaderEditorPlugin::edit(Object *p_object) {
|
||||
Ref<VisualShader> vs = es.shader;
|
||||
if (vs.is_valid()) {
|
||||
es.visual_shader_editor = memnew(VisualShaderEditor);
|
||||
es.visual_shader_editor->edit(vs.ptr());
|
||||
shader_tabs->add_child(es.visual_shader_editor);
|
||||
es.visual_shader_editor->edit(vs.ptr());
|
||||
} else {
|
||||
es.shader_editor = memnew(ShaderEditor);
|
||||
es.shader_editor->edit(s);
|
||||
shader_tabs->add_child(es.shader_editor);
|
||||
es.shader_editor->edit(s);
|
||||
es.shader_editor->connect("validation_changed", callable_mp(this, &ShaderEditorPlugin::_update_shader_list_status));
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user