Donner SVG main
0.8.0 ยท 766e862a0.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::gpu::browser::BrowserDeferredCalls Class Reference

Browser calls whose answer the calling thread does not wait for, held until its next round trip to the GPU owner carries them, in call order, ahead of that round trip's own call. More...

#include "donner/gpu/browser/BrowserDeferredCalls.h"

Classes

struct  Call
 One held call. More...
struct  Report
 What one round trip's held calls reported. More...

Public Types

using HeldCall = std::function<BridgeStatus()>
 A call ready to run on the owner.
using HeldCallFactory = std::function<HeldCall()>
 Builds the held form of a call, owning copies of what it reads.

Public Member Functions

 BrowserDeferredCalls (BrowserOwnerChannel &channel)
 Builds a queue that reaches the owner through channel.
 ~BrowserDeferredCalls ()
 Drops what is still held, without a round trip; see the class documentation. A thread's queue is destroyed at thread exit, after the thread's last flush.
 BrowserDeferredCalls (const BrowserDeferredCalls &)=delete
BrowserDeferredCalls & operator= (const BrowserDeferredCalls &)=delete
BridgeStatus defer (const std::shared_ptr< BrowserDeferredOrigin > &origin, BrowserDeferredOperation operation, uint64_t objectId, const HeldCall &now, const HeldCallFactory &makeHeld, std::size_t payloadBytes=0)
 Defers a call, or runs it now: where calls do not cross threads, and for a payload too large to hold, which runs at once after the calls held before it.
BridgeStatus defer (const std::shared_ptr< BrowserDeferredOrigin > &origin, BrowserDeferredOperation operation, uint64_t objectId, const HeldCall &call, std::size_t payloadBytes=0)
 Defers a call that owns everything it reads, or runs it now; see the other overload.
template<typename Operation>
Report run (Operation &&operation, uint32_t kind, const BrowserDeferredOrigin *carrying=nullptr)
 Runs operation in one owner round trip after every held call, which run first, in call order.
Report flush ()
 Sends the held calls now, with no call of its own; makes no round trip when nothing is held.
void dropReleased ()
 Drops held calls whose device has begun releasing.
bool empty () const
 Whether no call is held.
std::size_t size () const
 Calls held now.
std::size_t bytes () const
 Payload bytes held now.
std::size_t capacity () const
 Capacity the queue keeps for held calls across round trips.

Static Public Member Functions

static std::function< BridgeStatus()> OwningWrite (std::span< const uint8_t > data, std::function< BridgeStatus(std::span< const uint8_t >)> write)
 Builds the execution of a buffer write that owns a copy of data, so the caller's bytes can change or go away as soon as this returns.

Static Public Attributes

static constexpr std::size_t kMaxCalls = 256
 Calls held before they must be sent on their own, bounding the owner callback that runs them.
static constexpr std::size_t kMaxBytes = 256 * 1024
 Payload bytes held before the calls must be sent on their own, bounding their copies.
static constexpr uint32_t kCommandBatchKind = 9
 Diagnostic category of a round trip that sends held calls on their own; the owner's BrowserGpuOperationKind::CommandBatch.

Detailed Description

Browser calls whose answer the calling thread does not wait for, held until its next round trip to the GPU owner carries them, in call order, ahead of that round trip's own call.

Only the operations in BrowserDeferredOperation are held. The runtime validates each before it reaches the bridge, so only the browser side's own refusals are deferred: a lost or foreign device, an identifier it does not hold, or a browser call that throws.

  • Ordering: run runs every held call, in call order, before the round trip's own call, inside the same owner callback. Every later call from the thread goes through it.
  • Bounds: at most kMaxCalls calls and kMaxBytes payload bytes are held; reaching either sends them on their own. A single write of kMaxBytes or more is not held or copied: it runs at once, after the calls held before it.
  • Payload: a held write owns a copy of its bytes until the round trip that runs it returns. The copy is made only when the call is held, never for a call that runs at once.
  • Liveness: a held call whose device has begun releasing does not run; its copies are freed with the queue.
  • Refusals: a refused write or bind group construction is stored into its own device's origin, which that device reads as a loss. A refused destruction is counted there for diagnostics only. A round trip whose own call belongs to a device with a call refused in the same trip does not run that call, so a submission cannot go ahead over a write that failed.
  • Thread exit: a thread flushes before it exits. Calls still held when its queue is destroyed are dropped, never sent: a thread-exit round trip could wait on an owner that is itself waiting for this thread to be joined. The drop is printed. A dropped write or bind group construction of a live device stores a refusal in its origin, so that device fails closed if it is used again; a dropped destruction only waits for its device's release, which frees all of its objects.

Class Documentation

◆ donner::gpu::browser::BrowserDeferredCalls::Call

struct donner::gpu::browser::BrowserDeferredCalls::Call

One held call.

Class Members
function< BridgeStatus()> execute
uint64_t objectId = 0 Identifier of the object it writes, builds or destroys. Runs it on the owner; owns copies of everything it reads.
BrowserDeferredOperation operation = BrowserDeferredOperation::WriteBuffer Its kind.
shared_ptr< BrowserDeferredOrigin > origin The device that made it; kept alive by the call.

◆ donner::gpu::browser::BrowserDeferredCalls::Report

struct donner::gpu::browser::BrowserDeferredCalls::Report

What one round trip's held calls reported.

Class Members
bool carriedCallSkipped = false
uint64_t objectId = 0 Its object identifier.
BrowserDeferredOperation operation = BrowserDeferredOperation::WriteBuffer First refused call. Meaningful when refused is nonzero.
size_t refused = 0 Refused calls.
size_t skipped = 0 Calls not run because their device was released. Whether the round trip's own call was not run, because its device had a call refused in the same trip.
BridgeStatus status = BridgeStatus::Success Its status.

Constructor & Destructor Documentation

◆ BrowserDeferredCalls()

donner::gpu::browser::BrowserDeferredCalls::BrowserDeferredCalls ( BrowserOwnerChannel & channel)
inlineexplicit

Builds a queue that reaches the owner through channel.

Parameters
channelMust outlive it.

Member Function Documentation

◆ defer() [1/2]

BridgeStatus donner::gpu::browser::BrowserDeferredCalls::defer ( const std::shared_ptr< BrowserDeferredOrigin > & origin,
BrowserDeferredOperation operation,
uint64_t objectId,
const HeldCall & call,
std::size_t payloadBytes = 0 )
inline

Defers a call that owns everything it reads, or runs it now; see the other overload.

Parameters
originDevice making the call.
operationIts kind.
objectIdIts object.
callThe call.
payloadBytesBytes it holds a copy of.
Returns
Success once held, or the call's own status when it ran now.

◆ defer() [2/2]

BridgeStatus donner::gpu::browser::BrowserDeferredCalls::defer ( const std::shared_ptr< BrowserDeferredOrigin > & origin,
BrowserDeferredOperation operation,
uint64_t objectId,
const HeldCall & now,
const HeldCallFactory & makeHeld,
std::size_t payloadBytes = 0 )
inline

Defers a call, or runs it now: where calls do not cross threads, and for a payload too large to hold, which runs at once after the calls held before it.

Parameters
originDevice making the call.
operationIts kind.
objectIdIts object.
nowThe call over borrowed inputs, for when it runs at once.
makeHeldBuilds the held call over owned copies; called only when the call is held.
payloadBytesBytes the held call would copy.
Returns
Success once held, or the call's own status when it ran now.

◆ OwningWrite()

std::function< BridgeStatus()> donner::gpu::browser::BrowserDeferredCalls::OwningWrite ( std::span< const uint8_t > data,
std::function< BridgeStatus(std::span< const uint8_t >)> write )
inlinestatic

Builds the execution of a buffer write that owns a copy of data, so the caller's bytes can change or go away as soon as this returns.

Parameters
dataBytes to write.
writeWrites the bytes it is handed.

◆ run()

template<typename Operation>
Report donner::gpu::browser::BrowserDeferredCalls::run ( Operation && operation,
uint32_t kind,
const BrowserDeferredOrigin * carrying = nullptr )
inline

Runs operation in one owner round trip after every held call, which run first, in call order.

Where calls do not cross threads, runs it at once.

Parameters
operationThe round trip's own call.
kindIts diagnostic category.
carryingDevice operation belongs to, or null. If one of its held calls is refused in this trip, operation is not run.
Returns
What the held calls reported.

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