From 0ae2e8b3b763ba7f8d13326bf00e5f29545a6bf3 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Fri, 22 Nov 2024 20:46:20 -0600 Subject: [PATCH] Vulkan: Re-add shaderc status strings to error messages --- pcsx2/GS/Renderers/Vulkan/VKShaderCache.cpp | 29 ++++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/pcsx2/GS/Renderers/Vulkan/VKShaderCache.cpp b/pcsx2/GS/Renderers/Vulkan/VKShaderCache.cpp index e001aef8bbd0e..48a6ab685b452 100644 --- a/pcsx2/GS/Renderers/Vulkan/VKShaderCache.cpp +++ b/pcsx2/GS/Renderers/Vulkan/VKShaderCache.cpp @@ -205,6 +205,25 @@ static void DumpBadShader(std::string_view code, std::string_view errors) } } +static const char* compilation_status_to_string(shaderc_compilation_status status) +{ + switch (status) + { +#define CASE(x) case shaderc_compilation_status_##x: return #x + CASE(success); + CASE(invalid_stage); + CASE(compilation_error); + CASE(internal_error); + CASE(null_result_object); + CASE(invalid_assembly); + CASE(validation_error); + CASE(transformation_error); + CASE(configuration_error); +#undef CASE + } + return "unknown_error"; +} + std::optional VKShaderCache::CompileShaderToSPV(u32 stage, std::string_view source, bool debug) { std::optional ret; @@ -230,11 +249,13 @@ std::optional VKShaderCache::CompileShaderToSPV( dyn_shaderc::s_compiler, source.data(), source.length(), static_cast(stage), "source", "main", options); - if (!result || dyn_shaderc::shaderc_result_get_compilation_status(result) != shaderc_compilation_status_success) + shaderc_compilation_status status = shaderc_compilation_status_internal_error; + if (!result || (status = dyn_shaderc::shaderc_result_get_compilation_status(result)) != shaderc_compilation_status_success) { - const std::string_view errors(result ? dyn_shaderc::shaderc_result_get_error_message(result) : - "null result object"); - ERROR_LOG("Failed to compile shader to SPIR-V: {}", errors); + const std::string_view errors(result ? dyn_shaderc::shaderc_result_get_error_message(result) + : "null result object"); + + ERROR_LOG("Failed to compile shader to SPIR-V: {}\n{}", compilation_status_to_string(status), errors); DumpBadShader(source, errors); } else