summaryrefslogtreecommitdiff
path: root/servers/rendering/rendering_device_binds.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'servers/rendering/rendering_device_binds.cpp')
-rw-r--r--servers/rendering/rendering_device_binds.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/servers/rendering/rendering_device_binds.cpp b/servers/rendering/rendering_device_binds.cpp
index 43121e2cb5..91076a538e 100644
--- a/servers/rendering/rendering_device_binds.cpp
+++ b/servers/rendering/rendering_device_binds.cpp
@@ -30,7 +30,7 @@
#include "rendering_device_binds.h"
-Error RDShaderFile::parse_versions_from_text(const String &p_text, OpenIncludeFunction p_include_func, void *p_include_func_userdata) {
+Error RDShaderFile::parse_versions_from_text(const String &p_text, const String p_defines, OpenIncludeFunction p_include_func, void *p_include_func_userdata) {
Vector<String> lines = p_text.split("\n");
@@ -56,6 +56,9 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, OpenIncludeFu
{
String ls = line.strip_edges();
+ if (ls.begins_with("#[")) { //workaround for clang format
+ ls = ls.replace_first("#[", "[");
+ }
if (ls.begins_with("[") && ls.ends_with("]")) {
String section = ls.substr(1, ls.length() - 2).strip_edges();
if (section == "versions") {
@@ -90,9 +93,17 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, OpenIncludeFu
}
}
+ if (stage == RD::SHADER_STAGE_MAX && line.strip_edges() != "") {
+ line = line.strip_edges();
+ if (line.begins_with("//") || line.begins_with("/*")) {
+ continue; //assuming comment (single line)
+ }
+ }
+
if (reading_versions) {
String l = line.strip_edges();
if (l != "") {
+
int eqpos = l.find("=");
if (eqpos == -1) {
base_error = "Version syntax is version=\"<defines with C escaping>\".";
@@ -110,7 +121,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, OpenIncludeFu
}
define = "\n" + define.substr(1, define.length() - 2).c_unescape() + "\n"; //add newline before and after jsut in case
- version_texts[version] = define;
+ version_texts[version] = define + "\n" + p_defines;
}
} else {
if (stage == RD::SHADER_STAGE_MAX && line.strip_edges() != "") {