Skip to content

Commit

Permalink
submit waits together
Browse files Browse the repository at this point in the history
  • Loading branch information
martty committed Dec 2, 2024
1 parent 932fcd4 commit 763436e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
9 changes: 4 additions & 5 deletions include/vuk/Value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,13 @@ namespace vuk {
return std::move(a).transmute<uint64_t>(ref);
}

inline Result<void> wait_for_values_explicit(Allocator& alloc, Compiler& compiler, std::span<UntypedValue> values) {
Result<void> submit(Allocator& allocator, Compiler& compiler, std::span<UntypedValue> values, RenderGraphCompileOptions options);

inline Result<void> wait_for_values_explicit(Allocator& alloc, Compiler& compiler, std::span<UntypedValue> values, RenderGraphCompileOptions options = {}) {
std::vector<SyncPoint> waits;
VUK_DO_OR_RETURN(submit(alloc, compiler, values, options));
for (uint64_t i = 0; i < values.size(); i++) {
auto& value = values[i];
auto res = value.submit(alloc, compiler, {});
if (!res) {
return res;
}
if (value.node->acqrel->status != Signal::Status::eSynchronizable) {
continue;
}
Expand Down
28 changes: 28 additions & 0 deletions src/runtime/vk/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,34 @@ namespace vuk {
return { expected_value };
}

Result<void> submit(Allocator& allocator, Compiler& compiler, std::span<UntypedValue> values, RenderGraphCompileOptions options) {
std::vector<std::shared_ptr<ExtNode>> extnodes;
for (auto& value : values) {
auto& node = value.node;
if (node->acqrel->status == Signal::Status::eHostAvailable || node->acqrel->status == Signal::Status::eSynchronizable) {
// nothing to do
} else {
if (node->get_node()->splice.dst_access == Access::eNone && node->get_node()->splice.dst_domain == DomainFlagBits::eAny) {
value.release();
}
extnodes.push_back(node);
}
}
if (extnodes.size() == 0) {
compiler.reset();
return { expected_value }; // nothing to do
}
auto erg = compiler.link(extnodes, options);
if (!erg) {
return erg;
}

std::pair v = { &allocator, &*erg };
VUK_DO_OR_RETURN(execute_submit(allocator, std::span{ &v, 1 }));
compiler.reset();
return { expected_value };
}

Result<void> UntypedValue::wait(Allocator& allocator, Compiler& compiler, RenderGraphCompileOptions options) {
auto res = submit(allocator, compiler, options);
if (!res) {
Expand Down

0 comments on commit 763436e

Please sign in to comment.