43 const char* ExtraDefinitions =
nullptr);
47 template <
typename BlobType>
49 BlobType* pCompilerMsgBlob,
50 const std::string& ShaderSource,
51 const char* ShaderName,
54 const char* CompilerMsg = pCompilerMsgBlob ?
static_cast<const char*
>(pCompilerMsgBlob->GetBufferPointer()) :
nullptr;
55 const size_t CompilerMsgLen = CompilerMsg ? pCompilerMsgBlob->GetBufferSize() : 0;
57 if (ppOutputLog !=
nullptr)
59 const auto ShaderSourceLen = ShaderSource.length();
62 auto* log =
static_cast<char*
>(pOutputLogBlob->GetDataPtr());
64 if (CompilerMsg !=
nullptr)
65 memcpy(log, CompilerMsg, CompilerMsgLen);
66 log[CompilerMsgLen] = 0;
67 log += CompilerMsgLen + 1;
69 memcpy(log, ShaderSource.data(), ShaderSourceLen);
70 log[ShaderSourceLen] = 0;
72 pOutputLogBlob->QueryInterface(IID_DataBlob,
reinterpret_cast<IObject**
>(ppOutputLog));
75 if (!CompilationSucceeded || CompilerMsgLen != 0)
78 ss << (CompilationSucceeded ?
"Compiler output for shader '" :
"Failed to compile shader '")
79 << (ShaderName !=
nullptr ? ShaderName :
"<unknown>")
81 if (CompilerMsg !=
nullptr && CompilerMsgLen != 0)
83 ss <<
":" << std::endl
84 << std::string{CompilerMsg, CompilerMsgLen};
86 else if (!CompilationSucceeded)
88 ss <<
" (no shader log available).";
91 if (CompilationSucceeded)