Donner SVG 0.8.0
0.8.0 ยท ebf353960.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::geode::GeodeWgpuAdapterDevice Class Referencefinal

Implements donner::gpu::Device over one selected wgpu device, so the resvg comparison drives the production Geode contexts and renderer through an independent WebGPU implementation. More...

#include "donner/svg/renderer/geode/GeodeWgpuAdapterDevice.h"

Inheritance diagram for donner::geode::GeodeWgpuAdapterDevice:
[legend]

Public Member Functions

 GeodeWgpuAdapterDevice (std::shared_ptr< const WgpuReferenceRoot > root)
 Constructs a runtime device over root.
const WgpuReferenceRoot & root () const
 The wgpu objects this device renders through. Borrowed; the device retains them.
 ~GeodeWgpuAdapterDevice () override
 Destructor; waits for in-flight submissions (so deferred destructions drain), then releases every wgpu object the adapter still owns.
uint64_t completedSerial () const override
 Serial of the most recent submission whose queue work-done callback has fired (0 if none). wgpu delivers callbacks during gpu::Device::poll or a bounded serial wait (and opportunistically on submit).
void holdSubmittedWorkForTesting (uint64_t completedSerialCeiling)
 Makes this device behave like one that accepted work and stopped retiring it.
Public Member Functions inherited from donner::gpu::Device
virtual ~Device ()
 Destructor; expires the device-alive token (so handles that outlive the device release nothing) and frees all remaining resources. Backends that submit asynchronously must wait for in-flight submissions in their own destructor before backend state is torn down.
 Device (const Device &)=delete
Device & operator= (const Device &)=delete
 Device (Device &&)=delete
Device & operator= (Device &&)=delete
uint64_t deviceId () const
 Process-unique identity of this device (starts at 1, never reused). Baked into every handle for cross-device validation.
bool isLost () const
 True once the backend root this device drives has been declared lost, either by the backend's device-lost callback or by a bounded wait giving up on it.
DeviceLossSnapshot deviceLossSnapshot () const
 First-winner loss attribution, once its diagnostic fields have settled.
virtual RcString deviceLostReason () const
 Backend-provided loss reason, when the backend retains one. Empty otherwise.
void markLostAfterWaitTimeout (DeviceLostWaitSite site, std::chrono::milliseconds elapsed, const char *reason) const
 Declares this device's backend root lost because a bounded wait gave up, recording which wait it was and how long it actually ran.
virtual ShaderSourceKind shaderSourceKind () const
 Shader representation accepted by this device. Recording and WebGPU devices use WGSL; native backends override this so callers select the matching build-time artifact.
virtual bool supportsFullIndexRange (IndexFormat format) const
 Whether indexed draws through this device honor every value of format. Metal and WebGPU always do; a Vulkan device without fullDrawIndexUint32 caps 32-bit indices below the full range, and RenderPassEncoder::setIndexBuffer refuses that format on it rather than let a driver truncate index values.
Result< Buffer > createBuffer (const BufferDescriptor &descriptor)
 Creates a buffer.
Result< Texture > createTexture (const TextureDescriptor &descriptor)
 Creates a 2D texture.
Result< TextureDescriptor > textureDescriptor (const Texture &texture) const
 Returns the descriptor texture was created with, by value.
Result< TextureView > createTextureView (const Texture &texture, const TextureViewDescriptor &descriptor)
 Creates a view of texture covering the whole texture.
Result< Sampler > createSampler (const SamplerDescriptor &descriptor)
 Creates a sampler.
Result< BindGroupLayout > createBindGroupLayout (const BindGroupLayoutDescriptor &descriptor)
 Creates a bind group layout.
Result< BindGroup > createBindGroup (const BindGroupDescriptor &descriptor)
 Creates a bind group.
Result< PipelineLayout > createPipelineLayout (const PipelineLayoutDescriptor &descriptor)
 Creates a pipeline layout.
Result< ShaderModule > createShaderModule (const ShaderModuleDescriptor &descriptor)
 Creates a shader module from trusted generated source.
Result< RenderPipeline > createRenderPipeline (const RenderPipelineDescriptor &descriptor)
 Creates a render pipeline.
Result< ComputePipeline > createComputePipeline (const ComputePipelineDescriptor &descriptor)
 Creates a compute pipeline.
Status destroyBuffer (Buffer &&buffer)
 Destroys a buffer (see the destroy contract above).
Status destroyTexture (Texture &&texture)
 Destroys a texture (see the destroy contract above).
Status destroyTextureView (TextureView &&textureView)
 Destroys a texture view (see the destroy contract above).
Status destroySampler (Sampler &&sampler)
 Destroys a sampler (see the destroy contract above).
Status destroyBindGroupLayout (BindGroupLayout &&bindGroupLayout)
 Destroys a bind group layout (see the destroy contract above).
Status destroyBindGroup (BindGroup &&bindGroup)
 Destroys a bind group (see the destroy contract above).
Status destroyPipelineLayout (PipelineLayout &&pipelineLayout)
 Destroys a pipeline layout (see the destroy contract above).
Status destroyShaderModule (ShaderModule &&shaderModule)
 Destroys a shader module (see the destroy contract above).
Status destroyRenderPipeline (RenderPipeline &&renderPipeline)
 Destroys a render pipeline (see the destroy contract above).
Status destroyComputePipeline (ComputePipeline &&computePipeline)
 Destroys a compute pipeline (see the destroy contract above).
Status destroyBufferBacking (Buffer &&buffer)
 Destroys buffer and releases its backend allocation at once, rather than leaving the allocation to the backend's own collector.
Status destroyTextureBacking (Texture &&texture)
 Destroys texture and releases its backend allocation at once, the texture counterpart of destroyBufferBacking; a succession of resized render targets is where the deferred release shows up as retained memory.
bool ownsTextureBacking (const Texture &texture) const
 Whether texture names backing this device allocated, rather than memory some other owner holds and this device only named.
Result< TextureExport > exportTexture (const Texture &texture)
 Exports texture so another runtime device over the same backend device can register it.
Result< Texture > registerTexture (const TextureExport &source)
 Registers a texture another runtime device exported, as a read-only texture of this one.
bool waitForTextureSource (const Texture &registration, double timeoutSeconds)
 Waits until work naming registration may be submitted, the budget runs out, or either device is lost, and reports whether it may.
SerialWaitResult waitForTextureSourceUnlessStalled (const Texture &registration, std::chrono::milliseconds stallBound)
 waitForTextureSource for a caller whose bound exists to detect a hung producer: the wait gives up only once the producer has made no progress for stallBound, measured from that progress, rather than giving the producer's whole backlog a fixed budget.
uint64_t sharedTextureTailBytes () const
 Bytes of this device's exported textures that are still held by an export token or a registration after this device released its own handle.
Result< std::unique_ptr< CommandEncoder > > createCommandEncoder ()
 Creates a command encoder recording against this device. The encoder must not outlive the device.
Result< Surface > createSurface (const SurfaceDescriptor &descriptor)
 Creates a surface presenting to a platform object.
Result< SurfaceCapabilities > surfaceCapabilities (const Surface &surface) const
 What surface supports, for choosing a configuration.
Status configureSurface (const Surface &surface, const SurfaceConfiguration &configuration)
 Configures how surface presents, replacing any previous configuration.
Result< SurfaceTexture > acquireCurrentTexture (const Surface &surface)
 Acquires the texture for the next frame of surface.
Result< SurfaceStatus > presentSurface (const Surface &surface)
 Presents the texture acquired from surface and invalidates it.
Status abandonCurrentTexture (const Surface &surface)
 Releases the acquired texture of surface without presenting it, for a frame the caller decided not to show.
Status destroySurface (Surface &&surface)
 Destroys a surface (see the destroy contract above).
Result< BufferMapping > mapBufferAsync (const Buffer &buffer, MapMode mode, uint64_t offsetBytes, uint64_t byteCount)
 Begins mapping a range of buffer for host access, and returns the handle that names the mapping.
Result< MapSliceReport > pollMapping (const BufferMapping &mapping)
 Polls a mapping once without blocking or yielding; ready mappings become readable.
Result< MapWaitReport > waitForMapping (const BufferMapping &mapping, const MapWaitParams &params, const std::function< bool()> &shouldCancel, const MapWaitTestHooks &testHooks={})
 Waits for a pending mapping in slices, until it completes, the caller stops it, the budget runs out, or the device is lost.
Result< std::span< const uint8_t > > mappedBytes (const BufferMapping &mapping) const
 Returns the mapped bytes of a completed mapping.
Status unmapBuffer (BufferMapping &&mapping)
 Releases a mapping, invalidating the handle and every copy of it.
Status writeBuffer (const Buffer &buffer, uint64_t offsetBytes, std::span< const uint8_t > data)
 Writes data into buffer at offsetBytes.
Status writeTexture (const Texture &texture, std::span< const uint8_t > data, const TexelCopyBufferLayout &dataLayout, const Extent2d &writeSize, const Origin2d &destinationOrigin={})
 Writes texel rows from data into the writeSize rectangle of texture whose top-left texel is destinationOrigin, leaving every texel outside that rectangle unchanged.
Result< uint64_t > submit (CommandBuffer commandBuffer)
 Submits a finished command buffer, consuming it, and returns the assigned submission serial.
Result< uint64_t > submit (std::span< CommandBuffer > commandBuffers)
 Submits finished command buffers as one submission, consuming them, and returns the single assigned submission serial.
void poll ()
 Processes deferred destructions: releases the backend object of every destroyed resource whose last referencing submission has completed (completedSerial), and recycles its slot.
void pollCompletionOnce ()
 Drive one nonblocking backend completion iteration even when no resource destroy is pending.
bool hasPendingDestroys () const
 Whether a completed submission can still release a backend object. Owner-thread only.
uint64_t lastSubmittedSerial () const
 Serial assigned to the most recent submission (0 if none yet).
bool waitForSerial (uint64_t serial, double timeoutSeconds)
 Blocks until completedSerial reaches serial, timeoutSeconds elapses, or the backend gives up on the work, and reports whether the submission completed.
SerialWaitResult waitForSerialUnlessStalled (uint64_t serial, std::chrono::milliseconds stallBound)
 Blocks until completedSerial reaches serial, giving up only when the work the serial waits behind stops making progress.
std::optional< std::chrono::steady_clock::time_point > lastProgress ()
 When the work this device's submissions wait behind last made progress, or nothing when the backend has no notion of progress.
Status installObserver (DeviceObserver &observer)
 Installs observer to be notified of the work this device accepts (see DeviceObserver).
void removeObserver (const DeviceObserver &observer)
 Removes observer when it is the installed one and otherwise changes nothing, so an owner can only ever remove its own.
const DeviceObserver * observer () const
 The installed observer, or null when there is none.

Static Public Attributes

static constexpr uint64_t kNoCompletedSerialCeiling = std::numeric_limits<uint64_t>::max()
 Ceiling value that leaves completedSerial reporting what the backend reports.
Static Public Attributes inherited from donner::gpu::Device
static constexpr size_t kMaxCommandBuffersPerSubmission = 256
 Most command buffers one submission may carry.
static constexpr double kMaxWaitSeconds = 1.0e6
 Longest a single waitForSerial may block, in seconds. A budget above this is clamped to it; the value is far past any deadline a caller has, and keeps the conversion to the clock's own duration from overflowing on a caller that means "wait indefinitely" and says so with a very large number.

Protected Member Functions

void onPollBackend () override
 One nonblocking backend event iteration before a pending-destroy scan. Native devices report completion directly; callback-driven adapters override this hook.
gpu::Status onMapBufferAsync (uint32_t mappingSlotIndex, uint32_t bufferSlotIndex, gpu::MapMode mode, uint64_t offsetBytes, uint64_t byteCount) override
 Backend hook: begin mapping a buffer range.
gpu::MapSliceReport onWaitMappingSlice (uint32_t mappingSlotIndex, double sliceSeconds) override
 Backend hook: wait up to sliceSeconds for a pending mapping, and report what it found and how it spent the slice.
bool onWaitForSerial (uint64_t serial, double timeoutSeconds) override
 Polls the backend without blocking until completedSerial reaches serial, the device is lost, or the budget elapses (see waitForSerialBounded).
void onDestroyBufferBacking (uint32_t slotIndex) override
 Destroys the wgpu buffer in slotIndex, so the allocation goes back now rather than when the host runtime next collects.
void onDestroyTextureBacking (uint32_t slotIndex) override
 Destroys the wgpu texture in slotIndex if this adapter allocated it; a registration of a sibling adapter's export belongs to that sibling and is left alone.
bool onOwnsTextureBacking (uint32_t slotIndex) const override
 Whether slotIndex holds a texture this adapter allocated, rather than a sibling's export named through onRegisterTexture.
gpu::BackendDeviceIdentity backendDeviceIdentity () const override
 Identifies the wgpu device this adapter records against.
gpu::Result< gpu::BackendTextureExport > onExportTexture (uint32_t slotIndex) override
 Exports the texture in slotIndex, taking a reference on the wgpu texture and on the root so the texture outlives this adapter if a registration does.
gpu::Status onRegisterTexture (uint32_t slotIndex, const gpu::ExportedTextureBacking &backing) override
 Names a sibling adapter's exported texture in slotIndex, refusing one whose adapter submits to a different queue.
gpu::Result< std::span< const uint8_t > > onMappedBytes (uint32_t mappingSlotIndex) const override
 Backend hook: bytes of a completed mapping.
void onUnmapBuffer (uint32_t mappingSlotIndex) override
 Backend hook: release a mapping.
gpu::Status onCreateBuffer (uint32_t slotIndex, const gpu::BufferDescriptor &descriptor) override
 Backend hook: a buffer passed validation and occupies slotIndex.
gpu::Status onCreateTexture (uint32_t slotIndex, const gpu::TextureDescriptor &descriptor) override
 Backend hook: a texture passed validation and occupies slotIndex.
gpu::Status onCreateTextureView (uint32_t slotIndex, uint32_t textureSlotIndex, const gpu::TextureViewDescriptor &descriptor) override
 Backend hook: a texture view passed validation and occupies slotIndex.
gpu::Status onCreateSampler (uint32_t slotIndex, const gpu::SamplerDescriptor &descriptor) override
 Backend hook: a sampler passed validation and occupies slotIndex.
gpu::Status onCreateBindGroupLayout (uint32_t slotIndex, const gpu::BindGroupLayoutDescriptor &descriptor) override
 Backend hook: a bind group layout passed validation and occupies slotIndex.
gpu::Status onCreateBindGroup (uint32_t slotIndex, const gpu::BindGroupDescriptor &descriptor) override
 Backend hook: a bind group passed validation and occupies slotIndex.
gpu::Status onCreatePipelineLayout (uint32_t slotIndex, const gpu::PipelineLayoutDescriptor &descriptor) override
 Backend hook: a pipeline layout passed validation and occupies slotIndex.
gpu::Status onCreateShaderModule (uint32_t slotIndex, const gpu::ShaderModuleDescriptor &descriptor) override
 Backend hook: a shader module passed validation and occupies slotIndex.
gpu::Status onCreateRenderPipeline (uint32_t slotIndex, const gpu::RenderPipelineDescriptor &descriptor) override
 Backend hook: a render pipeline passed validation and occupies slotIndex.
gpu::Status onCreateComputePipeline (uint32_t slotIndex, const gpu::ComputePipelineDescriptor &descriptor) override
 Backend hook: a compute pipeline passed validation and occupies slotIndex.
void onDestroyResource (std::string_view resourceName, uint32_t slotIndex) override
 Backend hook: a retired resource is no longer used by submitted work and can be released.
gpu::Status onWriteBuffer (uint32_t slotIndex, uint64_t offsetBytes, std::span< const uint8_t > data) override
 Backend hook: a validated buffer write.
gpu::Status onWriteTexture (uint32_t slotIndex, std::span< const uint8_t > data, const gpu::TexelCopyBufferLayout &dataLayout, const gpu::Extent2d &writeSize, const gpu::Origin2d &destinationOrigin) override
 Backend hook: a validated texture write. The written rectangle is writeSize texels wide and tall with its top-left texel at destinationOrigin; texels outside it keep their contents.
uint64_t onTextureWriteByteCount (std::span< const uint8_t > data) const override
 The bytes onWriteTexture handed the queue for the write it just accepted: the caller's span, or the repacked rows when the span ends at a minimal final row.
gpu::Status onSubmit (uint64_t submissionSerial, std::span< const gpu::SubmittedCommandBuffer > commandBuffers) override
 Backend hook: validated command buffers were submitted as one submission.
Protected Member Functions inherited from donner::gpu::Device
 Device ()
 Constructor for backends; assigns the process-unique device identity.
void adoptLostState (std::shared_ptr< DeviceLostState > state)
 Adopts the sticky loss condition of a backend root this device shares with another device.
uint64_t bufferLastUseSerial (uint32_t slotIndex) const
 Last accepted submission referencing a buffer slot already validated by the caller.
uint64_t textureLastUseSerial (uint32_t slotIndex) const
 Last accepted submission referencing a texture slot already validated by the caller.
virtual void onRetireBuffer (uint32_t slotIndex)
 Backend hook: a buffer handle was retired. Discard unsubmitted work, but keep native resources alive until onDestroyResource.
virtual void onRetireTexture (uint32_t slotIndex)
 Backend hook: a texture handle was retired. Discard unsubmitted work, but keep native resources alive until onDestroyResource.
virtual bool onTextureWritePending (uint32_t slotIndex) const
 Backend hook: whether the write writeTexture just accepted for slotIndex is waiting for this device's next submission, rather than complete or ordered on the queue already.
virtual SerialWaitResult onWaitForSerialUnlessStalled (uint64_t serial, std::chrono::milliseconds stallBound)
 Backend hook: waitForSerialUnlessStalled with a bound already clamped.
virtual std::optional< std::chrono::steady_clock::time_point > onLastProgress ()
 Backend hook: lastProgress. The default reports no notion of progress.
Status validateBufferHandleForBackend (const Buffer &buffer) const
 Validates a buffer handle for backend-provided auxiliary entry points (test readback helpers and similar), running the same null/device-identity/generation checks the template-method public API performs before its hooks.
Status validateTextureHandleForBackend (const Texture &texture) const
 Validates a texture handle for backend-provided auxiliary entry points, running the same null/device-identity/generation checks the template-method public API performs.
Status validateTextureViewHandleForBackend (const TextureView &textureView) const
 Validates a texture view handle for backend-provided auxiliary entry points: the view itself plus a re-resolution of its viewed texture, so a view of a destroyed (or slot-recycled) texture fails closed exactly like it does on the normal Device paths.
Status validateBufferMappingHandleForBackend (const BufferMapping &mapping) const
 Validates a buffer-mapping handle for backend-provided auxiliary entry points, running the same null/device-identity/generation checks the template-method public API performs, so a stale handle cannot read state belonging to the slot's new occupant.
virtual Status onCreateSurface (uint32_t slotIndex, const SurfaceDescriptor &descriptor)
 Backend hook: create a surface for a platform object.
virtual Result< SurfaceCapabilities > onSurfaceCapabilities (uint32_t slotIndex) const
 Backend hook: what a surface supports.
virtual Status onConfigureSurface (uint32_t slotIndex, const SurfaceConfiguration &configuration)
 Backend hook: apply a configuration.
virtual Result< SurfaceStatus > onAcquireCurrentTexture (uint32_t slotIndex, uint32_t textureSlotIndex)
 Backend hook: acquire the next frame's texture and report the surface's state.
virtual Result< SurfaceStatus > onPresentSurface (uint32_t slotIndex)
 Backend hook: present the acquired texture.
virtual void onAbandonCurrentTexture (uint32_t slotIndex)
 Backend hook: drop the acquired texture without presenting.
uint64_t lastTextureUseSerial (uint32_t textureSlotIndex) const
 Serial of the last submission that referenced the texture at textureSlotIndex, or 0 when nothing has submitted work naming it.
virtual void onDestroySurface (uint32_t slotIndex)
 Backend hook: release the platform state of a surface that is going away.
virtual Status onSubmitAfterSources (uint64_t submissionSerial, std::span< const SubmittedCommandBuffer > commandBuffers, std::span< const SourceWait > waits)
 Backend hook: onSubmit for a submission that must also wait on the device, before any of its work runs, for producer work it names through registrations ordered on the device (SourceOrdering::WaitOnDevice).
void notifyObserverOfBackendSubmission () const
 Reports a queue submission the backend made on its own, outside submit, to the installed observer as a submission of no command buffers and no draws.

Friends

struct GeodeWgpuAdapterDeviceTestAccess

Detailed Description

Implements donner::gpu::Device over one selected wgpu device, so the resvg comparison drives the production Geode contexts and renderer through an independent WebGPU implementation.

Every on* hook receives input the base class already validated fail-closed, and translates it to the corresponding webgpu.hpp call. wgpu objects are stored in per-kind slot vectors indexed by the base class's slot indices; bind groups capture their wgpu layout object at creation time (wgpu retains it internally), so encoding never resolves a layout by slot.

Retains its root, so the backend handles outlive it. It does NOT own the GeodeDevice that installs itself as the counter sink; that context must clear the sink or outlive the adapter, which it does by owning it.

Thread affinity matches donner::gpu::Device: single-threaded use. Completion callbacks touch only shared completion state, guarded independently of the adapter lifetime.

Constructor & Destructor Documentation

◆ GeodeWgpuAdapterDevice()

donner::geode::GeodeWgpuAdapterDevice::GeodeWgpuAdapterDevice ( std::shared_ptr< const WgpuReferenceRoot > root)
explicit

Constructs a runtime device over root.

Contexts receive them from the root SelectWgpuReference adopts.

Parameters
rootwgpu objects to render through; must not be null.

Member Function Documentation

◆ backendDeviceIdentity()

gpu::BackendDeviceIdentity donner::geode::GeodeWgpuAdapterDevice::backendDeviceIdentity ( ) const
overrideprotectedvirtual

Identifies the wgpu device this adapter records against.

Reimplemented from donner::gpu::Device.

◆ completedSerial()

uint64_t donner::geode::GeodeWgpuAdapterDevice::completedSerial ( ) const
overridevirtual

Serial of the most recent submission whose queue work-done callback has fired (0 if none). wgpu delivers callbacks during gpu::Device::poll or a bounded serial wait (and opportunistically on submit).

gpu::Device::poll drives one nonblocking wgpu poll when destruction is pending, then reclaims resources whose completion callback has arrived. An idle owner can call it without another submission or a serial wait. Capped by holdSubmittedWorkForTesting while a test holds submitted work incomplete.

Implements donner::gpu::Device.

◆ holdSubmittedWorkForTesting()

void donner::geode::GeodeWgpuAdapterDevice::holdSubmittedWorkForTesting ( uint64_t completedSerialCeiling)

Makes this device behave like one that accepted work and stopped retiring it.

Test seam: a healthy device completes everything in microseconds, so the bounded waits and their deadlines are otherwise unreachable. Lifting the ceiling, from any thread, delivers the held completions the way a callback does, waking a wait that is waiting for them.

Parameters
completedSerialCeilingHighest serial completedSerial may report; kNoCompletedSerialCeiling restores what the backend reports.

◆ onCreateBindGroup()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::onCreateBindGroup ( uint32_t slotIndex,
const gpu::BindGroupDescriptor & descriptor )
overrideprotectedvirtual

Backend hook: a bind group passed validation and occupies slotIndex.

Parameters
slotIndexSlot index of the new resource.
descriptorValidated descriptor.

Implements donner::gpu::Device.

◆ onCreateBindGroupLayout()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::onCreateBindGroupLayout ( uint32_t slotIndex,
const gpu::BindGroupLayoutDescriptor & descriptor )
overrideprotectedvirtual

Backend hook: a bind group layout passed validation and occupies slotIndex.

Parameters
slotIndexSlot index of the new resource.
descriptorValidated descriptor.

Implements donner::gpu::Device.

◆ onCreateBuffer()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::onCreateBuffer ( uint32_t slotIndex,
const gpu::BufferDescriptor & descriptor )
overrideprotectedvirtual

Backend hook: a buffer passed validation and occupies slotIndex.

Parameters
slotIndexSlot index of the new resource.
descriptorValidated descriptor.

Implements donner::gpu::Device.

◆ onCreateComputePipeline()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::onCreateComputePipeline ( uint32_t slotIndex,
const gpu::ComputePipelineDescriptor & descriptor )
overrideprotectedvirtual

Backend hook: a compute pipeline passed validation and occupies slotIndex.

Parameters
slotIndexSlot index of the new resource.
descriptorValidated descriptor.

Implements donner::gpu::Device.

◆ onCreatePipelineLayout()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::onCreatePipelineLayout ( uint32_t slotIndex,
const gpu::PipelineLayoutDescriptor & descriptor )
overrideprotectedvirtual

Backend hook: a pipeline layout passed validation and occupies slotIndex.

Parameters
slotIndexSlot index of the new resource.
descriptorValidated descriptor.

Implements donner::gpu::Device.

◆ onCreateRenderPipeline()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::onCreateRenderPipeline ( uint32_t slotIndex,
const gpu::RenderPipelineDescriptor & descriptor )
overrideprotectedvirtual

Backend hook: a render pipeline passed validation and occupies slotIndex.

Parameters
slotIndexSlot index of the new resource.
descriptorValidated descriptor.

Implements donner::gpu::Device.

◆ onCreateSampler()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::onCreateSampler ( uint32_t slotIndex,
const gpu::SamplerDescriptor & descriptor )
overrideprotectedvirtual

Backend hook: a sampler passed validation and occupies slotIndex.

Parameters
slotIndexSlot index of the new resource.
descriptorValidated descriptor.

Implements donner::gpu::Device.

◆ onCreateShaderModule()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::onCreateShaderModule ( uint32_t slotIndex,
const gpu::ShaderModuleDescriptor & descriptor )
overrideprotectedvirtual

Backend hook: a shader module passed validation and occupies slotIndex.

Parameters
slotIndexSlot index of the new resource.
descriptorValidated descriptor.

Implements donner::gpu::Device.

◆ onCreateTexture()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::onCreateTexture ( uint32_t slotIndex,
const gpu::TextureDescriptor & descriptor )
overrideprotectedvirtual

Backend hook: a texture passed validation and occupies slotIndex.

Parameters
slotIndexSlot index of the new resource.
descriptorValidated descriptor.

Implements donner::gpu::Device.

◆ onCreateTextureView()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::onCreateTextureView ( uint32_t slotIndex,
uint32_t textureSlotIndex,
const gpu::TextureViewDescriptor & descriptor )
overrideprotectedvirtual

Backend hook: a texture view passed validation and occupies slotIndex.

Parameters
slotIndexSlot index of the new resource.
textureSlotIndexSlot index of the viewed texture.
descriptorValidated descriptor.

Implements donner::gpu::Device.

◆ onDestroyBufferBacking()

void donner::geode::GeodeWgpuAdapterDevice::onDestroyBufferBacking ( uint32_t slotIndex)
overrideprotectedvirtual

Destroys the wgpu buffer in slotIndex, so the allocation goes back now rather than when the host runtime next collects.

Parameters
slotIndexValidated live buffer slot.

Reimplemented from donner::gpu::Device.

◆ onDestroyResource()

void donner::geode::GeodeWgpuAdapterDevice::onDestroyResource ( std::string_view resourceName,
uint32_t slotIndex )
overrideprotectedvirtual

Backend hook: a retired resource is no longer used by submitted work and can be released.

Parameters
resourceNameResource type name, e.g. "buffer".
slotIndexSlot index of the destroyed resource.

Implements donner::gpu::Device.

◆ onDestroyTextureBacking()

void donner::geode::GeodeWgpuAdapterDevice::onDestroyTextureBacking ( uint32_t slotIndex)
overrideprotectedvirtual

Destroys the wgpu texture in slotIndex if this adapter allocated it; a registration of a sibling adapter's export belongs to that sibling and is left alone.

Parameters
slotIndexValidated live texture slot.

Reimplemented from donner::gpu::Device.

◆ onExportTexture()

gpu::Result< gpu::BackendTextureExport > donner::geode::GeodeWgpuAdapterDevice::onExportTexture ( uint32_t slotIndex)
overrideprotectedvirtual

Exports the texture in slotIndex, taking a reference on the wgpu texture and on the root so the texture outlives this adapter if a registration does.

Every adapter over one root submits to the root's one queue, so registrations are ordered by submission order alone.

Parameters
slotIndexValidated live texture slot.

Reimplemented from donner::gpu::Device.

◆ onMapBufferAsync()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::onMapBufferAsync ( uint32_t mappingSlotIndex,
uint32_t bufferSlotIndex,
gpu::MapMode mode,
uint64_t offsetBytes,
uint64_t byteCount )
overrideprotectedvirtual

Backend hook: begin mapping a buffer range.

Defaults to reporting the capability as unsupported, so a backend without host mapping needs no implementation and callers get a clean unsupported result rather than a missing symbol.

Parameters
mappingSlotIndexSlot the mapping occupies.
bufferSlotIndexSlot of the buffer being mapped.
modeHow the host will access the range.
offsetBytesByte offset of the mapped range.
byteCountLength of the mapped range.

Reimplemented from donner::gpu::Device.

◆ onMappedBytes()

gpu::Result< std::span< const uint8_t > > donner::geode::GeodeWgpuAdapterDevice::onMappedBytes ( uint32_t mappingSlotIndex) const
overrideprotectedvirtual

Backend hook: bytes of a completed mapping.

Parameters
mappingSlotIndexSlot of the mapping.

Reimplemented from donner::gpu::Device.

◆ onOwnsTextureBacking()

bool donner::geode::GeodeWgpuAdapterDevice::onOwnsTextureBacking ( uint32_t slotIndex) const
nodiscardoverrideprotectedvirtual

Whether slotIndex holds a texture this adapter allocated, rather than a sibling's export named through onRegisterTexture.

Parameters
slotIndexValidated live texture slot.

Reimplemented from donner::gpu::Device.

◆ onPollBackend()

void donner::geode::GeodeWgpuAdapterDevice::onPollBackend ( )
overrideprotectedvirtual

One nonblocking backend event iteration before a pending-destroy scan. Native devices report completion directly; callback-driven adapters override this hook.

Reimplemented from donner::gpu::Device.

◆ onRegisterTexture()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::onRegisterTexture ( uint32_t slotIndex,
const gpu::ExportedTextureBacking & backing )
overrideprotectedvirtual

Names a sibling adapter's exported texture in slotIndex, refusing one whose adapter submits to a different queue.

Nothing is allocated or counted.

Parameters
slotIndexSlot the registration occupies.
backingThe producer's export.

Reimplemented from donner::gpu::Device.

◆ onSubmit()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::onSubmit ( uint64_t submissionSerial,
std::span< const gpu::SubmittedCommandBuffer > commandBuffers )
overrideprotectedvirtual

Backend hook: validated command buffers were submitted as one submission.

The span holds at least one buffer and they execute in the order given. The backend owes the caller one completion for the whole span: whatever native objects it splits the work across, completedSerial reaches submissionSerial only once all of them have finished, and a backend that reports the submission accepted has accepted all of it.

Parameters
submissionSerialSerial assigned to this submission.
commandBuffersCommand buffers of this submission, in execution order.

Implements donner::gpu::Device.

◆ onTextureWriteByteCount()

uint64_t donner::geode::GeodeWgpuAdapterDevice::onTextureWriteByteCount ( std::span< const uint8_t > data) const
overrideprotectedvirtual

The bytes onWriteTexture handed the queue for the write it just accepted: the caller's span, or the repacked rows when the span ends at a minimal final row.

Reimplemented from donner::gpu::Device.

◆ onUnmapBuffer()

void donner::geode::GeodeWgpuAdapterDevice::onUnmapBuffer ( uint32_t mappingSlotIndex)
overrideprotectedvirtual

Backend hook: release a mapping.

Parameters
mappingSlotIndexSlot of the mapping.

Reimplemented from donner::gpu::Device.

◆ onWaitForSerial()

bool donner::geode::GeodeWgpuAdapterDevice::onWaitForSerial ( uint64_t serial,
double timeoutSeconds )
overrideprotectedvirtual

Polls the backend without blocking until completedSerial reaches serial, the device is lost, or the budget elapses (see waitForSerialBounded).

Idle retirement instead uses a single nonblocking gpu::Device::poll iteration.

Parameters
serialSubmission serial to wait for.
timeoutSecondsLongest to wait, in seconds.

Reimplemented from donner::gpu::Device.

◆ onWaitMappingSlice()

gpu::MapSliceReport donner::geode::GeodeWgpuAdapterDevice::onWaitMappingSlice ( uint32_t mappingSlotIndex,
double sliceSeconds )
overrideprotectedvirtual

Backend hook: wait up to sliceSeconds for a pending mapping, and report what it found and how it spent the slice.

The runtime owns the deadline and the caller's cancellation; this reports only the mapping.

Parameters
mappingSlotIndexSlot of the pending mapping.
sliceSecondsLongest this call may block.

Reimplemented from donner::gpu::Device.

◆ onWriteBuffer()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::onWriteBuffer ( uint32_t slotIndex,
uint64_t offsetBytes,
std::span< const uint8_t > data )
overrideprotectedvirtual

Backend hook: a validated buffer write.

Parameters
slotIndexDestination buffer slot.
offsetBytesDestination byte offset.
dataPayload bytes.

Implements donner::gpu::Device.

◆ onWriteTexture()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::onWriteTexture ( uint32_t slotIndex,
std::span< const uint8_t > data,
const gpu::TexelCopyBufferLayout & dataLayout,
const gpu::Extent2d & writeSize,
const gpu::Origin2d & destinationOrigin )
overrideprotectedvirtual

Backend hook: a validated texture write. The written rectangle is writeSize texels wide and tall with its top-left texel at destinationOrigin; texels outside it keep their contents.

Parameters
slotIndexDestination texture slot.
dataPayload bytes.
dataLayoutRow layout of data.
writeSizeExtent written in texels.
destinationOriginTop-left texel of the written rectangle.

Implements donner::gpu::Device.


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