Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Framegraph

Rewlion edited this page May 15, 2024 · 1 revision

Framegraph api is used to decouple monolith rendering code into a bunch of micro rendering nodes.
It doesn't have a smart resource scheduling.

API is quite similar to the others implementations.
Resource Types:

  • GPU (buffer, texture, sampler)
  • CPU (binary data)

Resource Operations:

  • read
  • modify
  • rename

Node Operations:

  • order before, after

C++ API

fg::register_node("node_name", FG_FILE_DECL, [](fg::Registry& reg) {
  fg::TextureRequest someTexWeRead = reg.readTexture("some_tex", gapi::TextureState::ShaderRead);
  fg::TextureRequest someTexWeModify = reg.modifyTexture("some_tex2", gapi::TextureState::ShaderReadWrite);
  fg::BlobReadWriteRequest<SomeStruct> someBlob = reg.createBlob<SomeStruct>("cpuData");
  reg.orderMeAfter("some_node");

  return [someTexWeRead, someTexWeModify, someBlob](gapi::CmdEncoder& encoder)
  {
    tfx::set_extern("srvTex", someTexWeRead.get());
    tfx::set_extern("uavTex", someTexWeModify.get());
    cpuRes->value = float2(1.0, 2.0);
    ...
  };
});

DSL API

Same result can be achieved via DSL on macros. These DSL operations declares a structure that will be parsed by codegen tool via libClang to generate all boilerplate code with registration

NODE_BEGIN(node_name)
  ORDER_ME_AFTER(some_node)
  BIND_TEX_SRV_AS(some_tex, srvTex)
  BIND_TEX_UAV_AS(some_tex2, uavTex)
  CREATE_BLOB(cpuData, SomeStruct)

  EXEC(node_name_exec)
NODE_END()

NODE_EXEC()
void node_name_exec(gapi::CmdEncoder& encoder, SomeStruct& cpuData)
{
  cpuData.value = float2(1.0, 2.0);
}
Clone this wiki locally