From eb030e7fc8056468068f10dc2c724be003711bdd Mon Sep 17 00:00:00 2001 From: Andre Weissflog Date: Tue, 13 Aug 2024 18:04:50 +0200 Subject: [PATCH] allow vertex attribute gaps, fixes regression #141 --- src/shdc/generators/yaml.cc | 10 ++++------ src/shdc/reflection.cc | 21 ++++++++++----------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/shdc/generators/yaml.cc b/src/shdc/generators/yaml.cc index 8e7615d5..ec7b60d5 100644 --- a/src/shdc/generators/yaml.cc +++ b/src/shdc/generators/yaml.cc @@ -44,18 +44,16 @@ ErrMsg YamlGenerator::generate(const GenInput& gen) { l("entry_point: {}\n", refl.entry_point_by_slang(slang)); l_open("inputs:\n"); for (const auto& input: src->stage_refl.inputs) { - if (input.slot == -1) { - break; + if (input.slot != -1) { + gen_attr(input); } - gen_attr(input); } l_close(); l_open("outputs:\n"); for (const auto& output: src->stage_refl.outputs) { - if (output.slot == -1) { - break; + if (output.slot != -1) { + gen_attr(output); } - gen_attr(output); } l_close(); if (refl.bindings.uniform_blocks.size() > 0) { diff --git a/src/shdc/reflection.cc b/src/shdc/reflection.cc index 8462c789..60c6c47c 100644 --- a/src/shdc/reflection.cc +++ b/src/shdc/reflection.cc @@ -289,18 +289,17 @@ std::vector Reflection::merge_vs_inputs(const std::vector{}; + if (attr.slot != -1) { + const StageAttr* other_attr = find_attr_by_name(out_attrs, attr.snippet_name, attr.name); + if (other_attr) { + // take snippet-name into account for equality check + if (!attr.equals(*other_attr, true)) { + out_error = ErrMsg::error(fmt::format("conflicting vertex shader attributes found for '{}/{}'", attr.snippet_name, attr.name)); + return std::vector{}; + } + } else { + out_attrs.push_back(attr); } - } else { - out_attrs.push_back(attr); } } }