Skip to content

Commit

Permalink
allow vertex attribute gaps, fixes regression #141
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Aug 13, 2024
1 parent 212b603 commit eb030e7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
10 changes: 4 additions & 6 deletions src/shdc/generators/yaml.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
21 changes: 10 additions & 11 deletions src/shdc/reflection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -289,18 +289,17 @@ std::vector<StageAttr> Reflection::merge_vs_inputs(const std::vector<ProgramRefl
out_error = ErrMsg();
for (const ProgramReflection& prog: progs) {
for (const StageAttr& attr: prog.vs().inputs) {
if (attr.slot == -1) {
break;
}
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<StageAttr>{};
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<StageAttr>{};
}
} else {
out_attrs.push_back(attr);
}
} else {
out_attrs.push_back(attr);
}
}
}
Expand Down

0 comments on commit eb030e7

Please sign in to comment.