Skip to content

Commit 1a03a7d

Browse files
committed
HLSL-Preprocessor: check if pre-processing failed
Signed-off-by: Ali Cheraghi <[email protected]>
1 parent 2dfc2e8 commit 1a03a7d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/nbl/asset/utils/CHLSLCompiler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ std::string CHLSLCompiler::preprocessShader(std::string&& code, IShader::E_SHADE
333333
for (auto i=context.begin(); i!=context.end(); i++) {
334334
auto value = i->get_value();
335335
stream << i->get_value();
336-
336+
337337
// TODO: replace this hack with `support_option_emit_contnewlines` flag when Boost::Wave respect it
338338
// See also https://github.com/Devsh-Graphics-Programming/Nabla/issues/746
339339
if (emit_nl_after != -1) {
@@ -397,6 +397,7 @@ core::smart_refctd_ptr<ICPUShader> CHLSLCompiler::compileToSPIRV_impl(const std:
397397
std::vector<std::string> dxc_compile_flags = {};
398398
IShader::E_SHADER_STAGE stage = options.stage;
399399
auto newCode = preprocessShader(std::string(code), stage, hlslOptions.preprocessorOptions, dxc_compile_flags, dependencies);
400+
if (newCode.empty()) return nullptr;
400401

401402
// Suffix is the shader model version
402403
std::wstring targetProfile(SHADER_MODEL_PROFILE);

0 commit comments

Comments
 (0)