32#include <unordered_set>
79 const std::vector<TextureHandle>*
inputs =
nullptr;
181 void begin(
const std::string& name);
189 void segment(
const std::string& name);
192 const std::vector<Entry>&
last()
const {
return last_; }
204 static constexpr u32 kFrames = 4;
206 const char* name =
nullptr;
212 std::vector<Slot> slots;
213 bool inflight =
false;
216 static constexpr u32 kMaxPasses = 512;
217 u32 framesRead_ = 0, framesDropped_ = 0, framesDisjoint_ = 0, framesSkipped_ = 0;
219 bool poll(Frame& frame);
223 bool arming_ =
false;
226 Frame frames_[kFrames];
227 std::vector<u32> queries_;
228 std::unordered_set<std::string> names_;
231 u32 frameNo_[kFrames] = {0, 0, 0, 0};
234 bool timing_ =
false;
235 static constexpr u32 kGiveUpFrames = 120;
236 std::vector<Entry> last_;
237 f32 lastTotal_ = -1.0f;
327 enum class Kind :
u8 { ImportedTexture, ImportedTarget,
Transient };
330 Kind kind = Kind::Transient;
342 void resolveSize(Resource& res)
const;
344 void release(Resource& res);
351 std::vector<Resource> resources_;
352 std::vector<PassDesc> passes_;
356 std::vector<TargetHandle> borrowed_;
357 std::vector<TextureHandle> inputScratch_;
358 std::vector<bool> live_;
359 std::vector<bool> wanted_;
360 std::vector<i32> last_writer_;
365 PassTimer* timer_ =
nullptr;
GPU framebuffer abstraction for render-to-texture.
Backend-agnostic graphics enumerations.
The render targets a frame borrows from, keyed by shape — owned by the frame, not by any one graph th...
Core type definitions and utilities for ESEngine.
Abstract graphics device interface.
A frame's full-screen passes, compiled and run.
void begin(const std::string &name)
u32 framesDisjoint() const
u32 framesDropped() const
const std::vector< Entry > & last() const
u32 framesSkipped() const
Frames not timed because every slot was still waiting on the device.
void segment(const std::string &name)
PassTimer(GfxDevice &device)
TextureHandle albedoTextureOf(ResourceId id) const
The third attachment of a gbuffer target: the surface's diffuse colour (alpha 1 where one was written...
ResourceId importTexture(TextureHandle texture, u32 width, u32 height)
ResourceId importTarget(FramebufferHandle target, u32 width, u32 height, bool output=true, TextureHandle readable=TextureHandle::Invalid)
The framebuffer the graph must end in (the screen, an editor FBO).
void addPass(PassDesc pass)
void begin(u32 refWidth, u32 refHeight)
RenderGraph & operator=(const RenderGraph &)=delete
u32 pooledTargetCount() const
RenderGraph(GfxDevice &device, TargetPool &pool)
FramebufferHandle framebufferOf(ResourceId id) const
TextureHandle textureOf(ResourceId id) const
ResourceId createTarget(const TargetDesc &desc)
TextureHandle gbufferTextureOf(ResourceId id) const
void setPassTimer(PassTimer *timer)
RenderGraph(const RenderGraph &)=delete
TextureHandle depthTextureOf(ResourceId id) const
u32 lastExecutedPassCount() const
ResourceId createExternalTarget(const TargetDesc &desc)
A pooled target filled by a producer OUTSIDE any pass callback.
u64 pooledTargetBytes() const
u32 TargetHandle
A borrowed target: a slot index, and the generation of what is in it.
constexpr ResourceId kNoResource
constexpr TargetHandle kNoTarget
FramebufferHandle
Handle 0 is the default framebuffer (backbuffer); it cannot be created or deleted.
std::int32_t i32
Signed 32-bit integer.
std::uint64_t u64
Unsigned 64-bit integer.
std::unique_ptr< T > Unique
Unique ownership smart pointer.
std::uint32_t u32
Unsigned 32-bit integer.
std::uint8_t u8
Unsigned 8-bit integer.
@ Transient
Rewritten before every use. Recovery recreates the storage zero-filled.
float f32
32-bit floating point
TextureHandle output
The texture this pass writes: the storage texture of a compute pass (a render pass draws into its fra...
const std::vector< TextureHandle > * inputs
The pass's declared reads, already bound to units 0..n-1, in order.
TextureHandle input(u32 i) const
std::function< void(const PassContext &)> execute
std::vector< ResourceId > reads
bool compute
A compute pass: no render pass is opened and no unit is bound — execute dispatches,...
AsyncComputePriority computePriority
std::vector< ResourceId > dependencies
Resources the pass uses but the graph must not bind.
bool keep
Wanted by a later frame rather than by this picture: not culled for nothing having read it yet.
u32 viewportX
The rect of its target this pass draws into. Zero width = all of it.
bool asyncCompute
The compute callback only accesses the graph resources it declares and private uniforms.
bool discardDepth
Its target's depth is only for testing while it draws, and nothing reads it afterwards (see RenderPas...
const char * name
Interned: valid as long as the timer.
Shape of a target the graph allocates.
bool gbuffer
A second colour attachment for the surface's material, drawn beside the first.
bool storage
Written by a compute shader (a pass with compute set), then sampled like any target.