diff options
Diffstat (limited to 'source')
| -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); } |
