Skip to content

Commit d76bb95

Browse files
committed
Add printing of warnings to HLSL Compiler
1 parent 8c61959 commit d76bb95

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/nbl/asset/utils/CHLSLCompiler.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ class DxcCompilationResult
122122
ComPtr<IDxcBlob> objectBlob;
123123
ComPtr<IDxcResult> compileResult;
124124

125-
char* GetErrorMessagesString()
125+
std::string GetErrorMessagesString()
126126
{
127-
return reinterpret_cast<char*>(errorMessages->GetBufferPointer());
127+
return std::string(reinterpret_cast<char*>(errorMessages->GetBufferPointer()), errorMessages->GetBufferSize());
128128
}
129129
};
130130

@@ -173,9 +173,17 @@ DxcCompilationResult dxcCompile(const CHLSLCompiler* compiler, nbl::asset::hlsl:
173173
result.compileResult = compileResult;
174174
result.objectBlob = nullptr;
175175

176-
if (!SUCCEEDED(compilationStatus))
176+
auto errorMessagesString = result.GetErrorMessagesString();
177+
if (SUCCEEDED(compilationStatus))
177178
{
178-
options.preprocessorOptions.logger.log(result.GetErrorMessagesString(), system::ILogger::ELL_ERROR);
179+
if (errorMessagesString.length() > 0)
180+
{
181+
options.preprocessorOptions.logger.log("DXC Compilation Warnings:\n%s", system::ILogger::ELL_WARNING, errorMessagesString.c_str());
182+
}
183+
}
184+
else
185+
{
186+
options.preprocessorOptions.logger.log("DXC Compilation Failed:\n%s", system::ILogger::ELL_ERROR, errorMessagesString.c_str());
179187
return result;
180188
}
181189

0 commit comments

Comments
 (0)