Return error instead of crash if compile shader failed on D3D12

Bug: dawn:347
Change-Id: Id5cc8c9c7c3acf5daa6f17fd3235b584dd52d522
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/18720
Commit-Queue: Hao Li <hao.x.li@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Li, Hao 2020-04-03 08:34:38 +00:00 committed by Commit Bot service account
parent 2b24fab368
commit c00163ba09

View File

@ -15,6 +15,7 @@
#include "dawn_native/d3d12/RenderPipelineD3D12.h"
#include "common/Assert.h"
#include "common/Log.h"
#include "dawn_native/d3d12/D3D12Error.h"
#include "dawn_native/d3d12/DeviceD3D12.h"
#include "dawn_native/d3d12/PipelineLayoutD3D12.h"
@ -341,11 +342,14 @@ namespace dawn_native { namespace d3d12 {
DAWN_TRY_ASSIGN(hlslSource, module->GetHLSLSource(ToBackend(GetLayout())));
const PlatformFunctions* functions = device->GetFunctions();
if (FAILED(functions->d3dCompile(hlslSource.c_str(), hlslSource.length(), nullptr,
nullptr, nullptr, entryPoint, compileTarget,
compileFlags, 0, &compiledShader[stage], &errors))) {
printf("%s\n", reinterpret_cast<char*>(errors->GetBufferPointer()));
ASSERT(false);
MaybeError error = CheckHRESULT(
functions->d3dCompile(hlslSource.c_str(), hlslSource.length(), nullptr, nullptr,
nullptr, entryPoint, compileTarget, compileFlags, 0,
&compiledShader[stage], &errors),
"D3DCompile");
if (error.IsError()) {
dawn::WarningLog() << reinterpret_cast<char*>(errors->GetBufferPointer());
DAWN_TRY(std::move(error));
}
if (shader != nullptr) {