Donner SVG 0.8.0
0.8.0 ยท ebf353960.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::svg::components::FilterExecutionBudget Class Reference

Shared per-frame filter budget. More...

#include "donner/svg/components/filter/FilterGraph.h"

Classes

struct  Reservation
 Successful preflight reservation made before allocating a filter capture surface. More...

Public Types

enum class  RejectionReason : std::uint8_t {
  None ,
  InvalidGraph ,
  ExecutionLimit ,
  WorkLimit ,
  MemoryLimit ,
  External
}
 Reason the frame stopped admitting filter work. More...

Public Member Functions

void reset ()
 Reset all per-frame accounting.
bool beginChunkAfterSubmit ()
 Release GPU-retained accounting after submitting one ordered command-buffer chunk.
std::optional< Reservation > reserve (const FilterGraph &graph, std::uint64_t pixelCount, FilterMemoryModel memoryModel, std::uint64_t captureBytes, std::uint64_t retainedGpuBufferBytes=0, std::uint64_t memoryPixels=UINT64_MAX, std::uint64_t executions=1, std::size_t gpuSurfaces=0)
 Reserve graph execution and capture memory before allocating the capture surface.
void release (Reservation &reservation)
 Release a successful CPU capture reservation after its filter layer is popped.
bool consume (const FilterGraph &graph, std::uint64_t pixelCount, FilterMemoryModel memoryModel, std::uint64_t retainedGpuBufferBytes=0)
 Consume a graph at execution time for direct callers without a capture preflight.
void requireMemoryChunk ()
 Requests an ordered chunk when another shared GPU budget lacks forecast capacity.
std::size_t reservedGpuSurfaces () const
 Forecast surface count retained by GPU executions until the next submitted chunk.
void reject ()
 Latch the frame closed after an allocation or other external preflight failure.
std::uint64_t executions () const
 Filter graph executions admitted during the current frame.
std::uint64_t workUnits () const
 Estimated pixel-work units admitted during the current frame.
std::uint64_t retainedBytes () const
 Total intermediate, persistent GPU, and live CPU capture bytes accounted for this frame.
std::uint64_t captureBytesReserved () const
 Bytes reserved for capture surfaces before allocation.
std::uint64_t activeGpuReservations () const
 GPU capture reservations still active in the current frame.
std::uint64_t retainedGpuBytes () const
 Intermediate and persistent GPU bytes retained for filter execution.
std::uint64_t chunks () const
 Ordered GPU chunks submitted since this budget was constructed.
bool rejected () const
 Whether the frame has stopped admitting filter work.
RejectionReason rejectionReason () const
 Current recorded reason for rejecting filter work in this frame.

Static Public Attributes

static constexpr std::uint64_t kMaximumExecutions = 1024
 Maximum number of graph executions, including zero-area and otherwise inexpensive graphs.

Detailed Description

Shared per-frame filter budget.

A graph that is safe in isolation can still exhaust memory or CPU when an SVG repeats it across many elements or <use> instances. Renderers reset this object at beginFrame() and consume it before every graph execution.


Class Documentation

◆ donner::svg::components::FilterExecutionBudget::Reservation

struct donner::svg::components::FilterExecutionBudget::Reservation

Successful preflight reservation made before allocating a filter capture surface.

Class Members
bool active = false
uint64_t captureBytes = 0
FilterMemoryModel memoryModel = FilterMemoryModel::CpuFloatNamedResults

Member Enumeration Documentation

◆ RejectionReason

Reason the frame stopped admitting filter work.

Enumerator
None 

No rejection has occurred.

InvalidGraph 

A graph failed validation or cost estimation.

ExecutionLimit 

The frame exceeded its graph execution count.

WorkLimit 

The frame exceeded its estimated pixel-work limit.

MemoryLimit 

Intermediate or capture memory exceeded its limit.

External 

A renderer-owned allocation or preflight failed.

Member Function Documentation

◆ reserve()

std::optional< Reservation > donner::svg::components::FilterExecutionBudget::reserve ( const FilterGraph & graph,
std::uint64_t pixelCount,
FilterMemoryModel memoryModel,
std::uint64_t captureBytes,
std::uint64_t retainedGpuBufferBytes = 0,
std::uint64_t memoryPixels = UINT64_MAX,
std::uint64_t executions = 1,
std::size_t gpuSurfaces = 0 )
inline

Reserve graph execution and capture memory before allocating the capture surface.

Rejection latches the frame closed, preventing a document from repeatedly attempting large allocations that were never charged. CPU capture bytes are released at pop; GPU capture and intermediate textures remain charged until frame reset because command buffers retain them.


The documentation for this class was generated from the following file: