[D3D12] Don't crash if failed to compile a shader

This commit is contained in:
Triang3l 2018-08-01 14:02:32 +03:00
parent 235799eecd
commit 2b482352d0
2 changed files with 15 additions and 4 deletions

View File

@ -46,6 +46,7 @@ bool D3D12Shader::Prepare() {
break;
default:
assert_unhandled_case(shader_type_);
is_valid_ = false;
return false;
}
@ -61,19 +62,20 @@ bool D3D12Shader::Prepare() {
XELOGE("%s shader %.16llX compilation failed!", target, ucode_data_hash());
}
if (error_blob != nullptr) {
const char* error_log =
reinterpret_cast<const char*>(error_blob->GetBufferPointer());
host_error_log_ = error_log;
if (compiled) {
XELOGW("%s shader %.16llX compiled with warnings!", target,
ucode_data_hash());
XELOGW("%s",
reinterpret_cast<const char*>(error_blob->GetBufferPointer()));
XELOGW("%s", error_log);
XELOGW("HLSL source:");
// The buffer isn't terminated.
translated_binary_.push_back(0);
XELOGW("%s", reinterpret_cast<const char*>(translated_binary_.data()));
translated_binary_.pop_back();
} else {
XELOGE("%s",
reinterpret_cast<const char*>(error_blob->GetBufferPointer()));
XELOGE("%s", error_log);
XELOGE("HLSL source:");
translated_binary_.push_back(0);
XELOGE("%s", reinterpret_cast<const char*>(translated_binary_.data()));
@ -83,6 +85,7 @@ bool D3D12Shader::Prepare() {
}
if (!compiled) {
is_valid_ = false;
return false;
}

View File

@ -265,6 +265,14 @@ PipelineCache::UpdateStatus PipelineCache::UpdateShaderStages(
XELOGE("Failed to translate the pixel shader!");
return UpdateStatus::kError;
}
if (!vertex_shader->is_valid()) {
XELOGE("Failed to prepare the vertex shader!");
return UpdateStatus::kError;
}
if (pixel_shader != nullptr && !pixel_shader->is_valid()) {
XELOGE("Failed to prepare the pixel shader!");
return UpdateStatus::kError;
}
update_desc_.pRootSignature =
command_processor_->GetRootSignature(vertex_shader, pixel_shader);