From a71ea9917a132c84c98a3e1f72cf50636627275a 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 | 28 ++++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/pcsx2/GS/Renderers/Vulkan/VKShaderCache.cpp b/pcsx2/GS/Renderers/Vulkan/VKShaderCache.cpp index e001aef8bb..6128a8177b 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,12 @@ 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_null_result_object; + 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