diff options
| author | Jay Kwak <82421531+jkwak-work@users.noreply.github.com> | 2024-07-23 12:30:12 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-23 12:30:12 -0700 |
| commit | 6216177eb4e57f9574aa840da5d87748a0133fdf (patch) | |
| tree | b3511c92f4e8f43e9edf2c988e46de65b62baa47 | |
| parent | 1670d7ee3ed29a03f50ba9deb4e8af47d31eab64 (diff) | |
Print SPIRV validation error message (#4697)
Closes #4692
This is a quick fix for the issue that SPIR-V validation error message
is not printed. A more proper way is to return the error messages to the
application and let the application handle it.
| -rw-r--r-- | source/slang-glslang/slang-glslang.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/source/slang-glslang/slang-glslang.cpp b/source/slang-glslang/slang-glslang.cpp index 8ae85b631..d29d22e89 100644 --- a/source/slang-glslang/slang-glslang.cpp +++ b/source/slang-glslang/slang-glslang.cpp @@ -145,6 +145,28 @@ struct SPIRVOptimizationDiagnostic std::string message; }; +// TODO: the actual printing should happen on the application side. +static void validationMessageConsumer(spv_message_level_t level, const char*, + const spv_position_t& position, const char* message) +{ + switch (level) + { + case SPV_MSG_FATAL: + case SPV_MSG_INTERNAL_ERROR: + case SPV_MSG_ERROR: + std::cerr << "error: line " << position.index << ": " << message << std::endl; + break; + case SPV_MSG_WARNING: + std::cout << "warning: line " << position.index << ": " << message << std::endl; + break; + case SPV_MSG_INFO: + std::cout << "info: line " << position.index << ": " << message << std::endl; + break; + default: + break; + } +} + // Validate the given SPIRV-ASM instructions. extern "C" #ifdef _MSC_VER @@ -160,7 +182,7 @@ bool glslang_validateSPIRV(const uint32_t* contents, int contentsSize) options.SetScalarBlockLayout(true); spvtools::SpirvTools tools(target_env); - //tools.SetMessageConsumer(spvtools::utils::CLIMessageConsumer); + tools.SetMessageConsumer(validationMessageConsumer); return tools.Validate(contents, contentsSize, options); } |
