From 3bd6376d2239762f7eab58914529b853ea875b89 Mon Sep 17 00:00:00 2001 From: Lucas Alber Date: Thu, 21 Nov 2024 13:33:09 +0100 Subject: [PATCH] merian/merian-nodes: Fix compilation_failed not handled correctly --- include/merian-nodes/graph/graph.hpp | 8 ++++---- src/merian/vk/shader/shader_compiler_shaderc.cpp | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/merian-nodes/graph/graph.hpp b/include/merian-nodes/graph/graph.hpp index eae11df4..c737ed01 100644 --- a/include/merian-nodes/graph/graph.hpp +++ b/include/merian-nodes/graph/graph.hpp @@ -1386,9 +1386,9 @@ class Graph : public std::enable_shared_from_this> { try { data.input_connectors = node->describe_inputs(); } catch (const graph_errors::node_error& e) { - data.errors.emplace_back(fmt::format("node error: ", e.what())); + data.errors.emplace_back(fmt::format("node error: {}", e.what())); } catch (const ShaderCompiler::compilation_failed& e) { - data.errors.emplace_back(fmt::format("compilation failed: ", e.what())); + data.errors.emplace_back(fmt::format("compilation failed: {}", e.what())); } for (const InputConnectorHandle& input : data.input_connectors) { if (data.input_connector_for_name.contains(input->name)) { @@ -1472,9 +1472,9 @@ class Graph : public std::enable_shared_from_this> { register_event_listener_for_connect(event_pattern, listener); })); } catch (const graph_errors::node_error& e) { - data.errors.emplace_back(fmt::format("node error: ", e.what())); + data.errors.emplace_back(fmt::format("node error: {}", e.what())); } catch (const ShaderCompiler::compilation_failed& e) { - data.errors.emplace_back(fmt::format("compilation failed: ", e.what())); + data.errors.emplace_back(fmt::format("compilation failed: {}", e.what())); } for (const auto& output : data.output_connectors) { diff --git a/src/merian/vk/shader/shader_compiler_shaderc.cpp b/src/merian/vk/shader/shader_compiler_shaderc.cpp index 8350bd32..c63f2910 100644 --- a/src/merian/vk/shader/shader_compiler_shaderc.cpp +++ b/src/merian/vk/shader/shader_compiler_shaderc.cpp @@ -158,6 +158,9 @@ std::vector ShadercCompiler::compile_glsl(const std::string& source, const auto binary_result = shader_compiler.CompileGlslToSpv( preprocess_result.begin(), preprocess_result.end() - preprocess_result.begin(), kind, source_name.data(), compile_options); + if (binary_result.GetCompilationStatus() != shaderc_compilation_status_success) { + throw ShaderCompiler::compilation_failed{binary_result.GetErrorMessage()}; + } return std::vector(binary_result.begin(), binary_result.end()); }