|
21 | 21 | #include <iterator>
|
22 | 22 | #include <codecvt>
|
23 | 23 |
|
| 24 | +#include <boost/wave.hpp> |
| 25 | +#include <boost/wave/cpplexer/cpp_lex_token.hpp> |
| 26 | +#include <boost/wave/cpplexer/cpp_lex_iterator.hpp> |
| 27 | + |
24 | 28 | #define TCPP_IMPLEMENTATION
|
25 | 29 | #include <tcpp/source/tcppLibrary.hpp>
|
26 | 30 | #undef TCPP_IMPLEMENTATION
|
@@ -225,6 +229,24 @@ DxcCompilationResult dxcCompile(const CHLSLCompiler* compiler, nbl::asset::hlsl:
|
225 | 229 |
|
226 | 230 | std::string CHLSLCompiler::preprocessShader(std::string&& code, IShader::E_SHADER_STAGE& stage, const SPreprocessorOptions& preprocessOptions) const
|
227 | 231 | {
|
| 232 | + using lex_token_t = boost::wave::cpplexer::lex_token<>; |
| 233 | + using lex_iterator_t = boost::wave::cpplexer::lex_iterator<lex_token_t>; |
| 234 | + using wave_context_t = boost::wave::context< |
| 235 | + core::string::iterator, |
| 236 | + lex_iterator_t, |
| 237 | + boost::wave::iteration_context_policies::load_file_to_string/*, |
| 238 | + TODO: OurCustomDirectiveHooks -> for pragmas and includes! |
| 239 | + */ |
| 240 | + >; |
| 241 | + |
| 242 | + // TODO: change `code` to `const core::string&` because its supposed to be immutable |
| 243 | + wave_context_t context(code.begin(),code.end(),preprocessOptions.sourceIdentifier.data()/*,TODO: instance of OurCustomDirectiveHooks*/); |
| 244 | +// context.add_include_path |
| 245 | +// context.add_sysinclude_path <- for dem builtins! / preprocessOptions.includeFinder? |
| 246 | +// context.add_macro_definition from preprocessOptions.extraDefines |
| 247 | + core::string resolvedString; |
| 248 | + // TODO: fill `resolvedString` with `[context.begin(),context.end()]` |
| 249 | + |
228 | 250 | // Line 1 comes before all the extra defines in the main shader
|
229 | 251 | insertIntoStart(code, std::ostringstream(std::string(IShaderCompiler::PREPROC_DIRECTIVE_ENABLER) + "line 1\n"));
|
230 | 252 |
|
@@ -309,7 +331,7 @@ std::string CHLSLCompiler::preprocessShader(std::string&& code, IShader::E_SHADE
|
309 | 331 | return std::string("");
|
310 | 332 | });
|
311 | 333 |
|
312 |
| - auto resolvedString = proc.Process(); |
| 334 | + resolvedString = proc.Process(); |
313 | 335 | IShaderCompiler::reenableDirectives(resolvedString);
|
314 | 336 |
|
315 | 337 | // for debugging cause MSVC doesn't like to show more than 21k LoC in TextVisualizer
|
|
0 commit comments