Skip to content

Commit

Permalink
render extract from composite better
Browse files Browse the repository at this point in the history
  • Loading branch information
martty committed Dec 30, 2024
1 parent bfdd8e2 commit 7ef702d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
1 change: 1 addition & 0 deletions include/vuk/IR.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace vuk {
std::vector<std::shared_ptr<Type>> child_types;
std::vector<size_t> offsets; // for now only useful for composites
std::unique_ptr<UserCallbackType> callback; // only useful for user CBs
std::vector<const char*> member_names;

union {
struct {
Expand Down
1 change: 1 addition & 0 deletions include/vuk/RenderGraph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ private:
.debug_info = current_module->types.allocate_type_debug_info(erased_tuple_adaptor<T>::name),
.child_types = child_types,
.offsets = offsets,
.member_names = { erased_tuple_adaptor<T>::member_names.begin(), erased_tuple_adaptor<T>::member_names.end() },
.composite = { .types = child_types,
.tag = std::hash<const char*>{}(erased_tuple_adaptor<T>::name),
.construct = &erased_tuple_adaptor<T>::construct,
Expand Down
13 changes: 8 additions & 5 deletions src/runtime/vk/Backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1760,17 +1760,20 @@ namespace vuk {
case Node::EXTRACT: {
if (sched.process(item)) {
// no sync - currently no extract composite needs sync
/* recorder.add_sync(sched.base_type(node->extract.composite),
sched.get_dependency_info(node->extract.composite, node->extract.composite.type(), RW::eWrite, nullptr),
sched.get_value(node->extract.composite));*/
#ifdef VUK_DUMP_EXEC
print_results(node);
fmt::print(" = ");
print_args(std::span{ &node->extract.composite, 1 });
fmt::print("[{}]", constant<uint64_t>(node->extract.index));
auto sty = Type::stripped(node->extract.composite.type());
if (sty->kind == Type::ARRAY_TY) {
fmt::print("[{}]", constant<uint64_t>(node->extract.index));
} else {
assert(sty->kind == Type::COMPOSITE_TY);
fmt::print(".{}", sty->member_names[constant<uint64_t>(node->extract.index)]);
}
fmt::print("\n");
#endif
sched.done(node, item.scheduled_stream, sched.get_value(first(node))); // extract doesn't execute
sched.done(node, item.scheduled_stream, sched.get_value(first(node)));
} else {
sched.schedule_new(node->extract.composite.node);
sched.schedule_dependency(node->extract.index, RW::eRead);
Expand Down
15 changes: 2 additions & 13 deletions tests/frame_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,19 +324,6 @@ TEST_CASE("adapt type to IR") {
auto vty = to_IR_type<view<BufferLike<float[]>>>();
}

template<class W, class T, class U>
void set(Value<W>& t, U T::*ptr, U arg)
requires std::is_base_of_v<ptr_base, W>
{
auto index = index_of<decltype(ptr)>(erased_tuple_adaptor<BufferCreateInfo>::members);
auto def_or_v = get_def(t.get_head());
if (!def_or_v || !def_or_v->is_ref) {
return;
}
auto def = def_or_v->ref;
def.node->construct.args[index] = current_module->make_constant(arg);
}

template<class T>
inline val_view<BufferLike<T>> clear(val_view<BufferLike<T>> in, T clear_value, VUK_CALLSTACK) {
auto clear = make_pass(
Expand Down Expand Up @@ -381,6 +368,8 @@ void main() {
auto test = { 1.f, 2.f, 3.f, 4.f };
auto schpen = std::span(&res[0], 4);
CHECK(schpen == std::span(test));

alloc.deallocate({ (ptr_base*) & res, 1 });
}

/*
Expand Down

0 comments on commit 7ef702d

Please sign in to comment.