From 0c27aae7d3af2a5d5c60dae0f9dc70eb6ccfecbb Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 6 Mar 2016 18:31:46 +1000 Subject: [PATCH] D3D12: Improve output of shader compiler errors These were completely broken due to lack of c_str(). We also output warnings now as well (these can be useful). --- Source/Core/VideoBackends/D3D12/D3DShader.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/Core/VideoBackends/D3D12/D3DShader.cpp b/Source/Core/VideoBackends/D3D12/D3DShader.cpp index 1b0eae1681..d99a02c5ac 100644 --- a/Source/Core/VideoBackends/D3D12/D3DShader.cpp +++ b/Source/Core/VideoBackends/D3D12/D3DShader.cpp @@ -19,7 +19,7 @@ namespace DX12 namespace D3D { -bool CompileShader(const std::string& code, ID3DBlob** blob, const D3D_SHADER_MACRO* defines, std::string shader_version_string) +bool CompileShader(const std::string& code, ID3DBlob** blob, const D3D_SHADER_MACRO* defines, const std::string& shader_version_string) { ID3D10Blob* shader_buffer = nullptr; ID3D10Blob* error_buffer = nullptr; @@ -34,21 +34,26 @@ bool CompileShader(const std::string& code, ID3DBlob** blob, const D3D_SHADER_MA if (error_buffer) { - INFO_LOG(VIDEO, "Shader compiler messages:\n%s\n", + WARN_LOG(VIDEO, "Warning generated when compiling %s shader:\n%s\n", + shader_version_string.c_str(), static_cast(error_buffer->GetBufferPointer())); } if (FAILED(hr)) { static int num_failures = 0; - std::string filename = StringFromFormat("%sbad_%s_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), shader_version_string, num_failures++); + std::string filename = StringFromFormat("%sbad_%s_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), shader_version_string.c_str(), num_failures++); std::ofstream file; OpenFStream(file, filename, std::ios_base::out); file << code; + file << std::endl << "Errors:" << std::endl; + file << static_cast(error_buffer->GetBufferPointer()); file.close(); PanicAlert("Failed to compile shader: %s\nDebug info (%s):\n%s", - filename.c_str(), shader_version_string, static_cast(error_buffer->GetBufferPointer())); + filename.c_str(), + shader_version_string.c_str(), + static_cast(error_buffer->GetBufferPointer())); *blob = nullptr; error_buffer->Release();