diff options
author | Yuri Roubinsky <chaosus89@gmail.com> | 2022-01-13 19:38:21 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-13 19:38:21 +0300 |
commit | 2b4290609ad6a87eb17aec0d75d8611f7d05eb25 (patch) | |
tree | 5dac18de78edc24a8c5da4a430942e7de6cbd0a7 | |
parent | 99b46a2615905fa4b6af0cb78da3c8b1950d8b90 (diff) | |
parent | c377891145b5a8576282f06707e3edb95ea8051e (diff) |
Merge pull request #56753 from Chaosus/shader_type
-rw-r--r-- | servers/rendering/shader_language.cpp | 25 | ||||
-rw-r--r-- | servers/rendering/shader_language.h | 1 |
2 files changed, 17 insertions, 9 deletions
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index c4d9ba4260..8a65faea61 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -7563,17 +7563,13 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct return ERR_PARSE_ERROR; } - tk = _get_token(); + StringName shader_type_identifier; + _get_completable_identifier(nullptr, COMPLETION_SHADER_TYPE, shader_type_identifier); - if (tk.type != TK_IDENTIFIER) { + if (shader_type_identifier == StringName()) { _set_error("Expected identifier after 'shader_type', indicating type of shader. Valid types are: " + _get_shader_type_list(p_shader_types)); return ERR_PARSE_ERROR; } - - String shader_type_identifier; - - shader_type_identifier = tk.text; - if (!p_shader_types.has(shader_type_identifier)) { _set_error("Invalid shader type. Valid types are: " + _get_shader_type_list(p_shader_types)); return ERR_PARSE_ERROR; @@ -8346,6 +8342,10 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct } } break; + case TK_SHADER_TYPE: { + _set_error("Shader type is already defined."); + return ERR_PARSE_ERROR; + } break; default: { //function or constant variable @@ -9267,6 +9267,13 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ //do nothing return OK; } break; + case COMPLETION_SHADER_TYPE: { + for (const String &shader_type : p_info.shader_types) { + ScriptCodeCompletionOption option(shader_type, ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + r_options->push_back(option); + } + return OK; + } break; case COMPLETION_RENDER_MODE: { for (int i = 0; i < p_info.render_modes.size(); i++) { const ModeInfo &info = p_info.render_modes[i]; @@ -9282,7 +9289,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ if (!found) { for (int j = 0; j < info.options.size(); j++) { - ScriptCodeCompletionOption option(String(info.name) + "_" + String(info.options[j]), ScriptCodeCompletionOption::KIND_ENUM); + ScriptCodeCompletionOption option(String(info.name) + "_" + String(info.options[j]), ScriptCodeCompletionOption::KIND_PLAIN_TEXT); r_options->push_back(option); } } @@ -9290,7 +9297,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ const String name = String(info.name); if (!shader->render_modes.has(name)) { - ScriptCodeCompletionOption option(name, ScriptCodeCompletionOption::KIND_ENUM); + ScriptCodeCompletionOption option(name, ScriptCodeCompletionOption::KIND_PLAIN_TEXT); r_options->push_back(option); } } diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index b9c2d4b33c..bc6dae7fa2 100644 --- a/servers/rendering/shader_language.h +++ b/servers/rendering/shader_language.h @@ -742,6 +742,7 @@ public: enum CompletionType { COMPLETION_NONE, + COMPLETION_SHADER_TYPE, COMPLETION_RENDER_MODE, COMPLETION_MAIN_FUNCTION, COMPLETION_IDENTIFIER, |