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

View File

@ -265,6 +265,14 @@ PipelineCache::UpdateStatus PipelineCache::UpdateShaderStages(
XELOGE("Failed to translate the pixel shader!"); XELOGE("Failed to translate the pixel shader!");
return UpdateStatus::kError; 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 = update_desc_.pRootSignature =
command_processor_->GetRootSignature(vertex_shader, pixel_shader); command_processor_->GetRootSignature(vertex_shader, pixel_shader);