Donner SVG main
0.8.0 ยท 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::gpu::DeviceObserver Class Referenceabstract

Receives one notification for each operation a Device accepted, one for each queue submission its backend made on its own, and one when the device's ownership of a texture allocation ends, which can happen inside Device::poll as well as inside a destroy. More...

#include "donner/gpu/DeviceObserver.h"

Inheritance diagram for donner::gpu::DeviceObserver:
[legend]

Public Member Functions

virtual ~DeviceObserver ()=default
 Destructor.
virtual void onBufferCreated ()=0
 A buffer allocation was created.
virtual void onTextureCreated ()=0
 A texture allocation the device owns was created. A registration of a texture the device does not own is not an allocation and is not reported.
virtual void onTextureReleased ()=0
 The device's ownership of a texture allocation it made ended: its backing was released through Device::destroyTextureBacking, or the texture was destroyed and the last submission using it completed and its slot was recycled.
virtual void onBindGroupCreated ()=0
 A bind group was created.
virtual void onBufferWritten (uint64_t byteCount)=0
 A queue write to a buffer was accepted.
virtual void onTextureWritten (uint64_t byteCount)=0
 A queue write to a texture was accepted.
virtual void onSubmitted (uint64_t commandBufferCount, uint64_t drawCount)=0
 Work reached the backend's queue as one submission.

Protected Member Functions

 DeviceObserver ()=default
 Constructible only as a base.
 DeviceObserver (const DeviceObserver &)=default
 Copyable only by a derived observer, so an observer is never sliced through its base.
DeviceObserver & operator= (const DeviceObserver &)=default
 Assignable only by a derived observer.

Detailed Description

Receives one notification for each operation a Device accepted, one for each queue submission its backend made on its own, and one when the device's ownership of a texture allocation ends, which can happen inside Device::poll as well as inside a destroy.

Installed per device with Device::installObserver. Notifications for the caller's operations come from the shared validation layer, after the backend accepted the operation, so a caller measuring its allocation, upload, and submission traffic counts it under the same rules whichever backend the device runs on. A refused operation, whether the validation layer or the backend refused it, notifies nothing.

Calls are synchronous, on the thread using the device. An observer must not call back into the device that notified it.

Member Function Documentation

◆ onBindGroupCreated()

virtual void donner::gpu::DeviceObserver::onBindGroupCreated ( )
pure virtual

A bind group was created.

Implemented in donner::geode::benchmarks::DrawCountObserver.

◆ onBufferCreated()

virtual void donner::gpu::DeviceObserver::onBufferCreated ( )
pure virtual

A buffer allocation was created.

Implemented in donner::geode::benchmarks::DrawCountObserver.

◆ onBufferWritten()

virtual void donner::gpu::DeviceObserver::onBufferWritten ( uint64_t byteCount)
pure virtual

A queue write to a buffer was accepted.

Parameters
byteCountBytes written.

Implemented in donner::geode::benchmarks::DrawCountObserver.

◆ onSubmitted()

virtual void donner::gpu::DeviceObserver::onSubmitted ( uint64_t commandBufferCount,
uint64_t drawCount )
pure virtual

Work reached the backend's queue as one submission.

Parameters
commandBufferCountCommand buffers the submission carried. Zero for a submission a backend made on its own, outside Device::submit, to make the queue progress.
drawCountDraws counted under one rule on every backend: each draw command, including one with no vertices or no instances, and each indexed draw command that is not empty (see IsEmptyIndexedDraw), whether or not the backend issues it natively.

Implemented in donner::geode::benchmarks::DrawCountObserver.

◆ onTextureCreated()

virtual void donner::gpu::DeviceObserver::onTextureCreated ( )
pure virtual

A texture allocation the device owns was created. A registration of a texture the device does not own is not an allocation and is not reported.

Implemented in donner::geode::benchmarks::DrawCountObserver.

◆ onTextureReleased()

virtual void donner::gpu::DeviceObserver::onTextureReleased ( )
pure virtual

The device's ownership of a texture allocation it made ended: its backing was released through Device::destroyTextureBacking, or the texture was destroyed and the last submission using it completed and its slot was recycled.

Reported at most once per owned allocation, on the thread using the device, to the observer installed at that moment. That includes an allocation made before this observer was installed, whose creation it never heard, so an observer installed late can count more releases than creations. An allocation still owned when the device is destroyed, and one whose retired slot is never recycled, are not reported. Releasing a registration of a texture the device does not own ends no ownership and is not reported.

The allocation itself may outlive the report: an export of the texture keeps it alive until its last holder lets go, and Device::sharedTextureTailBytes counts those bytes meanwhile. Nothing is reported when that holder finally releases it. A destroyed texture a holder still reads enters that gauge when it is retired but is reported here only when its slot is recycled, so while its last submission is in flight both count it.

Implemented in donner::geode::benchmarks::DrawCountObserver.

◆ onTextureWritten()

virtual void donner::gpu::DeviceObserver::onTextureWritten ( uint64_t byteCount)
pure virtual

A queue write to a texture was accepted.

Parameters
byteCountBytes the backend handed its queue for the write: the caller's span, or the repacked rows on a backend that repacks them first, so this can differ between backends.

Implemented in donner::geode::benchmarks::DrawCountObserver.

◆ operator=()

DeviceObserver & donner::gpu::DeviceObserver::operator= ( const DeviceObserver & )
protecteddefault

Assignable only by a derived observer.

Returns
This observer.

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