|
25 | 25 | #include <boost/wave/cpplexer/cpp_lex_token.hpp>
|
26 | 26 | #include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
|
27 | 27 |
|
28 |
| -//#define TCPP_IMPLEMENTATION |
29 |
| -//#include <tcpp/source/tcppLibrary.hpp> |
30 |
| -//#undef TCPP_IMPLEMENTATION |
31 |
| - |
32 | 28 | using namespace nbl;
|
33 | 29 | using namespace nbl::asset;
|
34 | 30 | using Microsoft::WRL::ComPtr;
|
@@ -332,14 +328,23 @@ std::string CHLSLCompiler::preprocessShader(std::string&& code, IShader::E_SHADE
|
332 | 328 | hlsl::impl::custom_preprocessing_hooks hooks(preprocessOptions, stage);
|
333 | 329 | std::string startingFileIdentifier = std::string("../") + preprocessOptions.sourceIdentifier.data();
|
334 | 330 | wave_context_t context(code.begin(), code.end(), startingFileIdentifier.data(), hooks);
|
335 |
| - |
| 331 | + context.set_language(boost::wave::support_cpp20); |
| 332 | + context.add_macro_definition("__HLSL_VERSION"); |
336 | 333 | //TODO fix bad syntax and uncomment
|
337 | 334 | // instead of defining extraDefines as "NBL_GLSL_LIMIT_MAX_IMAGE_DIMENSION_1D 32768",
|
338 | 335 | // now define them as "NBL_GLSL_LIMIT_MAX_IMAGE_DIMENSION_1D=32768"
|
339 | 336 | // to match boost wave syntax
|
340 | 337 | // https://www.boost.org/doc/libs/1_82_0/libs/wave/doc/class_reference_context.html#:~:text=Maintain%20defined%20macros-,add_macro_definition,-bool%20add_macro_definition
|
341 |
| - /* for (auto iter = preprocessOptions.extraDefines.begin(); iter != preprocessOptions.extraDefines.end(); iter++) |
342 |
| - context.add_macro_definition(*iter); */ |
| 338 | + for (auto iter = preprocessOptions.extraDefines.begin(); iter != preprocessOptions.extraDefines.end(); iter++) |
| 339 | + { |
| 340 | + std::string s = *iter; |
| 341 | + size_t firstParenthesis = s.find(')'); |
| 342 | + if (firstParenthesis == -1) firstParenthesis = 0; |
| 343 | + size_t firstWhitespace = s.find(' ', firstParenthesis); |
| 344 | + if (firstWhitespace != -1) |
| 345 | + s[firstWhitespace] = '='; |
| 346 | + context.add_macro_definition(s); |
| 347 | + } |
343 | 348 |
|
344 | 349 | // preprocess
|
345 | 350 | std::stringstream stream = std::stringstream();
|
|
0 commit comments