D3D12: Include serializer error messages in pipeline layout creation
Currently, Dawn ignores the output of D3D12SerializeRootSignature. This
change adds these error messages to the the CheckHRESULT context.
Change-Id: Ieeb63d7b5408ca1bc9e4ab97d777f764cdf06664
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/62163
Commit-Queue: Michael Tang <tangm@microsoft.com>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/dawn_native/d3d12/PipelineLayoutD3D12.cpp b/src/dawn_native/d3d12/PipelineLayoutD3D12.cpp
index 8565eb0..f239fe5 100644
--- a/src/dawn_native/d3d12/PipelineLayoutD3D12.cpp
+++ b/src/dawn_native/d3d12/PipelineLayoutD3D12.cpp
@@ -13,6 +13,7 @@
// limitations under the License.
#include "dawn_native/d3d12/PipelineLayoutD3D12.h"
+#include <sstream>
#include "common/Assert.h"
#include "common/BitSetIterator.h"
@@ -195,10 +196,20 @@
ComPtr<ID3DBlob> signature;
ComPtr<ID3DBlob> error;
- DAWN_TRY(CheckHRESULT(
- device->GetFunctions()->d3d12SerializeRootSignature(
- &rootSignatureDescriptor, D3D_ROOT_SIGNATURE_VERSION_1, &signature, &error),
- "D3D12 serialize root signature"));
+ HRESULT hr = device->GetFunctions()->d3d12SerializeRootSignature(
+ &rootSignatureDescriptor, D3D_ROOT_SIGNATURE_VERSION_1, &signature, &error);
+ if (DAWN_UNLIKELY(FAILED(hr))) {
+ std::ostringstream messageStream;
+ if (error) {
+ messageStream << static_cast<const char*>(error->GetBufferPointer());
+
+ // |error| is observed to always end with a \n, but is not
+ // specified to do so, so we add an extra newline just in case.
+ messageStream << std::endl;
+ }
+ messageStream << "D3D12 serialize root signature";
+ DAWN_TRY(CheckHRESULT(hr, messageStream.str().c_str()));
+ }
DAWN_TRY(CheckHRESULT(device->GetD3D12Device()->CreateRootSignature(
0, signature->GetBufferPointer(), signature->GetBufferSize(),
IID_PPV_ARGS(&mRootSignature)),