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"
|
|
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.
|
|
| | 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 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 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.
|
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.
◆ donner::gpu::browser::BrowserDeferredCalls::Call
| struct donner::gpu::browser::BrowserDeferredCalls::Call |
◆ donner::gpu::browser::BrowserDeferredCalls::Report
| struct donner::gpu::browser::BrowserDeferredCalls::Report |
What one round trip's held calls reported.
◆ BrowserDeferredCalls()
| donner::gpu::browser::BrowserDeferredCalls::BrowserDeferredCalls |
( |
BrowserOwnerChannel & | channel | ) |
|
|
inlineexplicit |
Builds a queue that reaches the owner through channel.
- Parameters
-
◆ defer() [1/2]
Defers a call that owns everything it reads, or runs it now; see the other overload.
- Parameters
-
| origin | Device making the call. |
| operation | Its kind. |
| objectId | Its object. |
| call | The call. |
| payloadBytes | Bytes it holds a copy of. |
- Returns
- Success once held, or the call's own status when it ran now.
◆ defer() [2/2]
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
-
| origin | Device making the call. |
| operation | Its kind. |
| objectId | Its object. |
| now | The call over borrowed inputs, for when it runs at once. |
| makeHeld | Builds the held call over owned copies; called only when the call is held. |
| payloadBytes | Bytes 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
-
| data | Bytes to write. |
| write | Writes 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
-
| operation | The round trip's own call. |
| kind | Its diagnostic category. |
| carrying | Device 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: