Skip to content

Commit fecf44f

Browse files
committed
Apply pre-processor logging
1 parent b75b9f7 commit fecf44f

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

include/nbl/asset/utils/CHLSLCompiler.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ class NBL_API2 CHLSLCompiler final : public IShaderCompiler
7373
{
7474
return reinterpret_cast<char*>(errorMessages->GetBufferPointer());
7575
}
76+
77+
// TODO figure out why this is crashing when done as part of the destructor
78+
void release()
79+
{
80+
errorMessages->Release();
81+
objectBlob->Release();
82+
compileResult->Release();
83+
}
7684
};
7785

7886
CHLSLCompiler::DxcCompilationResult dxcCompile(std::string& source, LPCWSTR* args, uint32_t argCount, const SOptions& options) const;

src/nbl/asset/utils/CHLSLCompiler.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@ std::string CHLSLCompiler::preprocessShader(std::string&& code, IShader::E_SHADE
155155
tcpp::Lexer lexer(codeIs);
156156
tcpp::Preprocessor proc(
157157
lexer,
158-
[](auto errorInfo) {
159-
158+
[&](auto errorInfo) {
159+
preprocessOptions.logger.log("Pre-processor error at line %i:\n%s", nbl::system::ILogger::ELL_ERROR, errorInfo.mLine, tcpp::ErrorTypeToString(errorInfo.mType).c_str());
160160
},
161161
[&](auto path, auto isSystemPath) {
162162
return getInputStreamInclude(
163-
preprocessOptions.includeFinder, m_system.get(), preprocessOptions.maxSelfInclusionCount,
163+
preprocessOptions.includeFinder, m_system.get(), preprocessOptions.maxSelfInclusionCount + 1u,
164164
path.c_str(), !isSystemPath
165165
);
166166
}
@@ -244,6 +244,8 @@ core::smart_refctd_ptr<ICPUShader> CHLSLCompiler::compileToSPIRV(const char* cod
244244
auto outSpirv = core::make_smart_refctd_ptr<ICPUBuffer>(compileResult.objectBlob->GetBufferSize());
245245
memcpy(outSpirv->getPointer(), compileResult.objectBlob->GetBufferPointer(), compileResult.objectBlob->GetBufferSize());
246246

247+
compileResult.release();
248+
247249
return core::make_smart_refctd_ptr<asset::ICPUShader>(std::move(outSpirv), hlslOptions.stage, IShader::E_CONTENT_TYPE::ECT_SPIRV, hlslOptions.preprocessorOptions.sourceIdentifier.data());
248250
}
249251

0 commit comments

Comments
 (0)