Skip to content

Commit 86f8403

Browse files
committed
Fix issues with tcpp being weird
1 parent e2a5451 commit 86f8403

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/nbl/asset/utils/CHLSLCompiler.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,6 @@ std::string CHLSLCompiler::preprocessShader(std::string&& code, IShader::E_SHADE
184184
}
185185
);
186186

187-
proc.AddCustomDirectiveHandler(std::string("line"), [&](tcpp::Preprocessor& preprocessor, tcpp::Lexer& lexer, const std::string& text) {
188-
while (lexer.HasNextToken() && lexer.GetNextToken().mType != tcpp::E_TOKEN_TYPE::NEWLINE) {}
189-
return std::string("");
190-
});
191187
proc.AddCustomDirectiveHandler(std::string("pragma shader_stage"), [&](tcpp::Preprocessor& preprocessor, tcpp::Lexer& lexer, const std::string& text) {
192188
if (!lexer.HasNextToken()) return std::string("#error Malformed shader_stage pragma");
193189
auto token = lexer.GetNextToken();
@@ -229,7 +225,6 @@ std::string CHLSLCompiler::preprocessShader(std::string&& code, IShader::E_SHADE
229225

230226
auto resolvedString = proc.Process();
231227
IShaderCompiler::reenableDirectives(resolvedString);
232-
233228
return resolvedString;
234229
}
235230

src/nbl/asset/utils/IShaderCompiler.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ std::string IShaderCompiler::encloseWithinExtraInclGuards(std::string&& _code, u
6060
return undefs;
6161
};
6262

63+
// HACK: tcpp is having issues parsing the string, so this is a hack/mitigation that could be removed once tcpp is fixed
6364
std::string identifier = _identifier;
6465
std::replace(identifier.begin(), identifier.end(), '\\', '/');
6566

@@ -68,7 +69,8 @@ std::string IShaderCompiler::encloseWithinExtraInclGuards(std::string&& _code, u
6869
"\n"
6970
"#ifndef " + defBase_ + std::to_string(_maxInclusions) +
7071
"\n" +
71-
"#line 1 \"" + identifier.c_str() + "\"\n" +
72+
// This will get turned back into #line after the directives get re-enabled
73+
PREPROC_DIRECTIVE_DISABLER + "line 1 \"" + identifier.c_str() + "\"\n" +
7274
_code +
7375
"\n"
7476
"#endif"

0 commit comments

Comments
 (0)