Skip to content

Commit e814d2d

Browse files
start Boost.Wave (links) and "fix" the numeric_limits
1 parent fb816ba commit e814d2d

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

include/nbl/builtin/hlsl/limits.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ struct numeric_limits : impl::numeric_limits<T> {};
262262

263263

264264
template<class T>
265-
struct numeric_limits : std::numeric_limits<T>
265+
struct numeric_limits : std::conditional_t<std::is_same_v<T,float16_t>,IMATH_INTERNAL_NAMESPACE::limits<T>,std::numeric_limits<T>>
266266
{
267-
using base = std::numeric_limits<T>;
267+
using base = std::conditional_t<std::is_same_v<T,float16_t>,IMATH_INTERNAL_NAMESPACE::limits<T>,std::numeric_limits<T>>;
268268
using uint_type = std::remove_cvref_t<decltype(impl::num_traits<T>::infinity)>;
269269

270270
NBL_CONSTEXPR_STATIC_INLINE T min = base::min();

src/nbl/asset/utils/CHLSLCompiler.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
#include <iterator>
2222
#include <codecvt>
2323

24+
#include <boost/wave.hpp>
25+
#include <boost/wave/cpplexer/cpp_lex_token.hpp>
26+
#include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
27+
2428
#define TCPP_IMPLEMENTATION
2529
#include <tcpp/source/tcppLibrary.hpp>
2630
#undef TCPP_IMPLEMENTATION
@@ -225,6 +229,24 @@ DxcCompilationResult dxcCompile(const CHLSLCompiler* compiler, nbl::asset::hlsl:
225229

226230
std::string CHLSLCompiler::preprocessShader(std::string&& code, IShader::E_SHADER_STAGE& stage, const SPreprocessorOptions& preprocessOptions) const
227231
{
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+
228250
// Line 1 comes before all the extra defines in the main shader
229251
insertIntoStart(code, std::ostringstream(std::string(IShaderCompiler::PREPROC_DIRECTIVE_ENABLER) + "line 1\n"));
230252

@@ -309,7 +331,7 @@ std::string CHLSLCompiler::preprocessShader(std::string&& code, IShader::E_SHADE
309331
return std::string("");
310332
});
311333

312-
auto resolvedString = proc.Process();
334+
resolvedString = proc.Process();
313335
IShaderCompiler::reenableDirectives(resolvedString);
314336

315337
// for debugging cause MSVC doesn't like to show more than 21k LoC in TextVisualizer

0 commit comments

Comments
 (0)