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