From 2b482352d02bc5c575026d2050d6eb22a3c0f655 Mon Sep 17 00:00:00 2001 From: Triang3l Date: Wed, 1 Aug 2018 14:02:32 +0300 Subject: [PATCH] [D3D12] Don't crash if failed to compile a shader --- src/xenia/gpu/d3d12/d3d12_shader.cc | 11 +++++++---- src/xenia/gpu/d3d12/pipeline_cache.cc | 8 ++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/xenia/gpu/d3d12/d3d12_shader.cc b/src/xenia/gpu/d3d12/d3d12_shader.cc index 34238dc3a..5573392d5 100644 --- a/src/xenia/gpu/d3d12/d3d12_shader.cc +++ b/src/xenia/gpu/d3d12/d3d12_shader.cc @@ -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(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(error_blob->GetBufferPointer())); + XELOGW("%s", error_log); XELOGW("HLSL source:"); // The buffer isn't terminated. translated_binary_.push_back(0); XELOGW("%s", reinterpret_cast(translated_binary_.data())); translated_binary_.pop_back(); } else { - XELOGE("%s", - reinterpret_cast(error_blob->GetBufferPointer())); + XELOGE("%s", error_log); XELOGE("HLSL source:"); translated_binary_.push_back(0); XELOGE("%s", reinterpret_cast(translated_binary_.data())); @@ -83,6 +85,7 @@ bool D3D12Shader::Prepare() { } if (!compiled) { + is_valid_ = false; return false; } diff --git a/src/xenia/gpu/d3d12/pipeline_cache.cc b/src/xenia/gpu/d3d12/pipeline_cache.cc index 386e33a32..08a0dcaa7 100644 --- a/src/xenia/gpu/d3d12/pipeline_cache.cc +++ b/src/xenia/gpu/d3d12/pipeline_cache.cc @@ -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);