Donner SVG 0.8.0
0.8.0 ยท ebf353960.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
GeodeDevice.h File Reference

Logical rendering context over a selected GPU runtime device. More...

#include <algorithm>
#include <atomic>
#include <chrono>
#include <cstddef>
#include <deque>
#include <functional>
#include <map>
#include <memory>
#include <mutex>
#include <optional>
#include <tuple>
#include <vector>
#include "donner/base/Utils.h"
#include "donner/gpu/Device.h"
#include "donner/svg/renderer/geode/GeodeCounters.h"
#include "donner/svg/renderer/geode/GeodeGpuContext.h"
#include "donner/svg/renderer/geode/GeodeGpuWait.h"
#include "donner/svg/renderer/geode/GeodeHandleRetirement.h"
Include dependency graph for GeodeDevice.h:
This graph shows which files directly or indirectly include this file:

Classes

class  donner::geode::GeodePhysicalDeviceOwner
 Shared lifetime owner for one selected GPU runtime device and the backend root it drives. More...
struct  donner::geode::SnapshotReadbackResources
 Move-only resource set for one GPU snapshot unpremultiply readback: a straight-alpha staging texture, its view, and a map-readable readback buffer. More...
class  donner::geode::GeodeDevice
 Owns a logical Geode context over a selected GPU runtime device. More...
struct  donner::geode::GeodeDevice::ReadbackStats
 Readback timing, completion, loss, cancellation, and resource counters. More...
struct  donner::geode::GeodeDevice::SceneBatchBindGroupKey
 Key identifying a scene-batch bind group by its exact buffer bindings: the shared batch uniform allocation, the geometry slab chunk, and the record span. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.
namespace  donner::svg
 Donner SVG library, which can load, manipulate and render SVG files.

Functions

constexpr uint32_t donner::geode::AlignReadbackBytesPerRow (uint32_t rowBytes)
 256-align a tightly packed row-byte count per the GPU runtime's texture-to-buffer copy rules. Shared by the device's readback-buffer sizing and the renderer's map-range math; the two MUST agree, because a map request larger than the buffer fails with GpuErrorType::OutOfBounds and the readback with it.
gpu::Result< gpu::Texture > donner::geode::RegisterOrderedTexture (gpu::Device &consumer, const gpu::TextureExport &source, std::chrono::milliseconds bound=kDefaultGpuWaitTimeout)
 Registers a texture another context exported as a texture of consumer, and waits until what consumer records against it next may be submitted.

Detailed Description

Logical rendering context over a selected GPU runtime device.


Class Documentation

◆ donner::geode::GeodeDevice::ReadbackStats

struct donner::geode::GeodeDevice::ReadbackStats

Readback timing, completion, loss, cancellation, and resource counters.

Class Members
uint64_t bindgroupCreates = 0
uint64_t bufferCreates = 0 GPU allocation and submission work performed by isolated captures.
uint64_t captureCancellations = 0 Captures cancelled while acquiring the context, mapping, or copying pixels.
uint64_t captureTimeouts = 0 Captures whose total deadline expired.
uint64_t contextCreates = 0 Lazily created readback-only contexts; independent of rendering pipelines.
int count = 0 Readback buffer-map waits run since the last consume, including waits that were cancelled or timed out.
bool deviceLost = false True once this device has been declared lost. Sticky, so every later consume keeps reporting it: a frame that never rendered has no other evidence to carry.
int pollIterations = 0 Bounded wait iterations those readbacks ran.
uint64_t poolBytes = 0
uint64_t poolEntries = 0 Idle pooled resource sets and their logical backing bytes after the latest capture.
uint64_t sharedTextureTailBytes = 0 Bytes of this context's textures still resident because another context registered them or an export of them is alive, after this context released its own handle. No context counts that memory as its allocation, so a working set has to add it.
uint64_t submits = 0
uint64_t textureCreates = 0
int timedOutWaitMs = 0 Wall time that wait spent before giving up, in milliseconds.
GpuWaitSite timedOutWaitSite = GpuWaitSite::None Bounded wait that declared that loss, or None.
bool usedTimedWaitAny = false True when any of those waits blocked on the map's completion event rather than only polling for it (gpu::MapWaitKind::CompletionEvent).

Function Documentation

◆ RegisterOrderedTexture()

gpu::Result< gpu::Texture > donner::geode::RegisterOrderedTexture ( gpu::Device & consumer,
const gpu::TextureExport & source,
std::chrono::milliseconds bound = kDefaultGpuWaitTimeout )

Registers a texture another context exported as a texture of consumer, and waits until what consumer records against it next may be submitted.

For a context that draws the registration in a frame rather than capturing it. It returns at once on a backend whose contexts share one queue, and between contexts over one root on a backend that orders the consumer's work after the producer's on the device (Metal), where it waits only for the producer to have handed that work to its queue, which it has by the time it exports. Otherwise it blocks this thread for the producer's frame.

Loss policy. The runtime's source wait declares nothing when it gives up; this helper is the consumer's own bounded wait and applies the policy of every other bounded wait over a Geode root. A producer that made no progress for all of bound has stopped answering: the consumer's condition is declared lost with the queue-idle wait site and the measured wait, so later frames fail at once instead of stalling again. A producer still finishing work is waited out however long its backlog. A wait that failed did so because a device is lost or the producer failed, which is not this consumer's to report: the helper fails with DeviceLost and declares nothing. A producer already lost is refused at registration the same way.

Parameters
consumerRuntime device of the context that will name the texture.
sourceExport of the producer's texture.
boundLongest the producer's work may go without progress; must be positive.
Returns
The registration, or why it was refused or could not be ordered.