acdemiralp / fg Goto Github PK
View Code? Open in Web Editor NEWRendering abstraction which describes a frame as a directed acyclic graph of render tasks and resources.
License: MIT License
Rendering abstraction which describes a frame as a directed acyclic graph of render tasks and resources.
License: MIT License
Hi, I'm not sure how to use correctly the frame graph. I've got a simple resource which is a string and I want to create this resource in a first pass, then "transfer" the output of the first pass to 4 other passes. But these 4 passes get culled and I don't know why. For my liking, it should work.
namespace gl
{
using texture_2d = std::string;
}
namespace glr
{
struct texture_description
{
std::string name;
};
using texture_2d_resource = fg::resource<texture_description, gl::texture_2d>;
}
namespace fg
{
template<>
std::unique_ptr<gl::texture_2d> realize(const glr::texture_description& description)
{
return std::make_unique<gl::texture_2d>(description.name);
}
}
int main()
{
fg::framegraph framegraph;
struct render_task_0_data
{
glr::texture_2d_resource* output;
};
auto render_task_0 = framegraph.add_render_task<render_task_0_data>(
"Render Task 0",
[&](render_task_0_data& data, fg::render_task_builder& builder)
{
data.output = builder.write(builder.read(builder.create<glr::texture_2d_resource>("Resource 0", glr::texture_description("0"))));
},
[=](const render_task_0_data& data)
{
auto actual1 = data.output->actual();
//do something with the actual1
std::cout << *actual1 << "\n";
});
auto& data_0 = render_task_0->data();
struct render_task_data
{
glr::texture_2d_resource* input;
glr::texture_2d_resource* output;
};
for (int i = 1; i <= 4; ++i) {
auto render_task = framegraph.add_render_task<render_task_data>(
"Render Task " + std::to_string(i),
[&](render_task_data& data, fg::render_task_builder& builder)
{
data.input = builder.read(data_0.output);
data.output = builder.write<glr::texture_2d_resource>(builder.create<glr::texture_2d_resource>("Resource " + std::to_string(i), glr::texture_description(std::to_string(i))));
},
[=](const render_task_data& data)
{
auto actual1 = data.input->actual();
auto actual2 = data.output->actual();
//do something with the actual1 and actual2
std::cout << *actual2 << "\n";
});
}
framegraph.compile();
framegraph.execute();
framegraph.export_graphviz("framegraph.gv");
framegraph.clear();
return 0;
}
the first pass is executed correctly, but the next 4 passes are culled.
the generated graph looks ok, except that the resources have a ref of 0.
how to fix it?
The framegraph currently performs each unculled render task sequentially. It is possible to have multiple framegraphs executing render tasks in parallel (e.g. an OpenGL framegraph and a Cuda framegraph or two Vulkan framegraphs submitting to two distinct queues), but this only applies when communication and resource sharing between the tasks is not necessary.
The framegraph should ideally provide functionality for asynchronous launch of multiple render tasks. This requires:
Since the resource usage of each render task is specified during the setup phase, it is possible to identify parallel executable render tasks automatically during the compilation phase. This however may have an adverse effect on memory usage since a large amount of resources may be realized in parallel. Hence the framegraph should provide options to both automatically and manually (per render task) specify async execution.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.