Skip to content

Commit 5095747

Browse files
committed
Fix issues with encloseWithinExtraInclGuards
1 parent 4ea00f5 commit 5095747

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

3rdparty/tcpp

src/nbl/asset/utils/CHLSLCompiler.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ static tcpp::IInputStream* getInputStreamInclude(
7373
}
7474

7575
IShaderCompiler::disableAllDirectivesExceptIncludes(res_str);
76-
// TODO support this
77-
//res_str = IShaderCompiler::encloseWithinExtraInclGuards(std::move(res_str), _maxInclCnt, name.string().c_str());
76+
res_str = IShaderCompiler::encloseWithinExtraInclGuards(std::move(res_str), _maxInclCnt, name.string().c_str());
7877

7978
return new tcpp::StringInputStream(std::move(res_str));
8079
}
@@ -185,6 +184,10 @@ std::string CHLSLCompiler::preprocessShader(std::string&& code, IShader::E_SHADE
185184
}
186185
);
187186

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+
});
188191
proc.AddCustomDirectiveHandler(std::string("pragma shader_stage"), [&](tcpp::Preprocessor& preprocessor, tcpp::Lexer& lexer, const std::string& text) {
189192
if (!lexer.HasNextToken()) return std::string("#error Malformed shader_stage pragma");
190193
auto token = lexer.GetNextToken();

src/nbl/asset/utils/IShaderCompiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ std::string IShaderCompiler::encloseWithinExtraInclGuards(std::string&& _code, u
6565
"\n"
6666
"#ifndef " + defBase_ + std::to_string(_maxInclusions) +
6767
"\n" +
68-
"#line 1 \"" + _identifier + "\"\n" +
68+
"#line 1 \"" + _identifier + "\"\n\n" +
6969
_code +
7070
"\n"
7171
"#endif"

0 commit comments

Comments
 (0)