Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::geode::GeodeWgpuAdapterDevice Class Referencefinal

Implements donner::gpu::Device on top of the wgpu device a GeodeDevice already owns, so Geode subsystems can migrate onto the Donner GPU runtime one at a time while the process still renders through wgpu underneath. More...

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

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

Public Member Functions

 GeodeWgpuAdapterDevice (GeodeDevice &geodeDevice)
 Constructs the adapter over geodeDevice.
 ~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 the callbacks during waitForSerial's polling (and opportunistically on submit), so call waitForSerial to guarantee progress.
bool waitForSerial (uint64_t serial, double timeoutSeconds)
 Blocks until completedSerial reaches serial or timeoutSeconds elapses, driving wgpu::Device::poll so queued work-done callbacks are delivered (on Emscripten the poll shim yields through Asyncify, mirroring GeodeDevice's wait machinery).
gpu::Status destroyTextureBacking (gpu::Texture &&texture)
 TEMPORARY escape hatch (deleted with the readback and presentation migration): registers an externally owned wgpu texture - e.g.
gpu::Status destroyBufferBacking (gpu::Buffer &&buffer)
 Destroys the backend object behind buffer explicitly, then releases its slot.
bool mappingUsedTimedWaitAny (const gpu::BufferMapping &mapping) const
 Whether any wait slice of mapping waited on the map's completion event rather than polling for it.
void setSimulateEventWaitForTest (bool simulate)
 Test seam: makes a wait slice behave as the browser's timed wait does when it expires without the map completing - it reports that it handled the slice, having learned nothing.
gpu::Result< gpu::TextureimportExternalTexture (wgpu::Texture texture, const gpu::Extent2d &size, gpu::TextureFormat format, gpu::TextureUsage usage)
void setHostCommandEncoder (wgpu::CommandEncoder encoder)
 Installs encoder as the host command encoder: while one is installed, a submitted command stream is replayed into it instead of into an encoder this adapter owns, and this adapter performs no queue submit of its own.
void clearHostCommandEncoder ()
 Uninstalls the host command encoder, returning this adapter to owning and submitting the encoders it records into. Serials already replayed into a host encoder stay incomplete until notifyHostSubmitted reports their submit.
bool hasHostCommandEncoder () const
 True while a host command encoder is installed, i.e. while submissions are replayed into it instead of reaching the queue.
void notifyHostSubmitted ()
 Reports that the host submitted a command buffer carrying every stream replayed since the previous report, so their completion can now be observed.
gpu::Result< uint64_t > submitStandalone (gpu::CommandBuffer &&commands)
 Submits commands straight to the queue, even while a host command encoder is installed.
wgpu::Texture wgpuTextureOf (const gpu::Texture &texture) const
 TEMPORARY escape hatch (deleted with the readback and presentation migration): returns the wgpu texture behind texture, or a null handle if the handle does not name a live texture of this adapter.
wgpu::TextureView wgpuTextureViewOf (const gpu::TextureView &textureView) const
 TEMPORARY escape hatch (deleted with the readback and presentation migration): returns the wgpu texture view behind textureView, or a null handle if unknown.
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.
Result< BuffercreateBuffer (const BufferDescriptor &descriptor)
 Creates a buffer.
Result< TexturecreateTexture (const TextureDescriptor &descriptor)
 Creates a 2D texture.
Result< TextureViewcreateTextureView (const Texture &texture, const TextureViewDescriptor &descriptor)
 Creates a view of texture covering the whole texture.
Result< SamplercreateSampler (const SamplerDescriptor &descriptor)
 Creates a sampler.
Result< BindGroupLayoutcreateBindGroupLayout (const BindGroupLayoutDescriptor &descriptor)
 Creates a bind group layout.
Result< BindGroupcreateBindGroup (const BindGroupDescriptor &descriptor)
 Creates a bind group.
Result< PipelineLayoutcreatePipelineLayout (const PipelineLayoutDescriptor &descriptor)
 Creates a pipeline layout.
Result< ShaderModulecreateShaderModule (const ShaderModuleDescriptor &descriptor)
 Creates a shader module from trusted generated source.
Result< RenderPipelinecreateRenderPipeline (const RenderPipelineDescriptor &descriptor)
 Creates a render pipeline.
Result< ComputePipelinecreateComputePipeline (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).
Result< std::unique_ptr< CommandEncoder > > createCommandEncoder ()
 Creates a command encoder recording against this device. The encoder must not outlive the device.
Result< SurfacecreateSurface (const SurfaceDescriptor &descriptor)
 Creates a surface presenting to a platform object.
Result< SurfaceCapabilitiessurfaceCapabilities (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< SurfaceTextureacquireCurrentTexture (const Surface &surface)
 Acquires the texture for the next frame of surface.
Result< SurfaceStatuspresentSurface (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< BufferMappingmapBufferAsync (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< MapWaitOutcomewaitForMapping (const BufferMapping &mapping, const MapWaitParams &params, const std::function< bool()> &shouldCancel, const MapWaitTestHooks &testHooks={})
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)
 Writes texel rows from data into texture starting at texel (0, 0).
Result< uint64_t > submit (CommandBuffer commandBuffer)
 Submits a finished command buffer, consuming it, and returns the 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.
uint64_t lastSubmittedSerial () const
 Serial assigned to the most recent submission (0 if none yet).

Protected Member Functions

gpu::Status onCreateSurface (uint32_t slotIndex, const gpu::SurfaceDescriptor &descriptor) override
 Backend hook: create a surface for a platform object.
gpu::Result< gpu::SurfaceCapabilitiesonSurfaceCapabilities (uint32_t slotIndex) const override
 Backend hook: what a surface supports.
gpu::Status onConfigureSurface (uint32_t slotIndex, const gpu::SurfaceConfiguration &configuration) override
 Backend hook: apply a configuration.
gpu::Result< gpu::SurfaceStatusonAcquireCurrentTexture (uint32_t slotIndex, uint32_t textureSlotIndex) override
 Backend hook: acquire the next frame's texture and report the surface's state.
gpu::Result< gpu::SurfaceStatusonPresentSurface (uint32_t slotIndex) override
 Backend hook: present the acquired texture.
void onAbandonCurrentTexture (uint32_t slotIndex) override
 Backend hook: drop the acquired texture without presenting.
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::MapSliceState onWaitMappingSlice (uint32_t mappingSlotIndex, double sliceSeconds) override
 Backend hook: wait up to sliceSeconds for a pending mapping and report what it found.
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 validated resource was destroyed.
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) override
 Backend hook: a validated texture write.
gpu::Status onSubmit (uint64_t submissionSerial, uint32_t commandBufferSlotIndex, std::span< const gpu::Command > commands) override
 Backend hook: a validated command buffer was submitted.
Protected Member Functions inherited from donner::gpu::Device
 Device ()
 Constructor for backends; assigns the process-unique device identity.
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.

Detailed Description

Implements donner::gpu::Device on top of the wgpu device a GeodeDevice already owns, so Geode subsystems can migrate onto the Donner GPU runtime one at a time while the process still renders through wgpu underneath.

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.

Does NOT own the GeodeDevice: the constructing scope must keep it alive for the adapter's whole lifetime (in practice GeodeDevice owns the adapter alongside its shared pipelines).

Thread affinity matches donner::gpu::Device: single-threaded use. Completion callbacks touch only the atomic completed-serial counter.

Constructor & Destructor Documentation

◆ GeodeWgpuAdapterDevice()

donner::geode::GeodeWgpuAdapterDevice::GeodeWgpuAdapterDevice ( GeodeDevice & geodeDevice)
explicit

Constructs the adapter over geodeDevice.

Parameters
geodeDeviceDevice wrapper providing the wgpu device/queue; must outlive the adapter.

Member Function Documentation

◆ 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 the callbacks during waitForSerial's polling (and opportunistically on submit), so call waitForSerial to guarantee progress.

Warning
The base class's Device::poll() does NOT drive wgpu polling - it only processes deferred destructions against the serial this method reports. Per-frame destroy+poll churn therefore defers unboundedly until something waits: a frame loop must call waitForSerial on its frame cadence (or extend the adapter with a non-blocking wgpu poll) so completions are observed and deferred destroys drain.

Implements donner::gpu::Device.

◆ destroyBufferBacking()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::destroyBufferBacking ( gpu::Buffer && buffer)

Destroys the backend object behind buffer explicitly, then releases its slot.

The buffer counterpart of destroyTextureBacking, and needed for the same reason: releasing a buffer handle on its own only drops this adapter's reference, which leaves the backend object resident until the host runtime collects it. A readback buffer whose map was cancelled, and a pooled readback set evicted to keep the pool inside its ceiling, both have to release their memory at that moment rather than whenever a collector next runs.

Parameters
bufferLive buffer handle of this adapter; consumed either way.

◆ destroyTextureBacking()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::destroyTextureBacking ( gpu::Texture && texture)

TEMPORARY escape hatch (deleted with the readback and presentation migration): registers an externally owned wgpu texture - e.g.

a render target created by the host or an earlier non-migrated subsystem - as a donner::gpu::Texture of this adapter so migrated code can reference it in render passes and copies. The adapter does NOT take ownership; destroying the returned handle only forgets the registration.

Parameters
textureExternally owned wgpu texture; must remain valid while registered.
sizeTexture extent in texels.
formatTexel format matching the wgpu texture.
usageUsage flags matching the wgpu texture's capabilities. Destroys the backend object behind texture explicitly, then releases its slot.

Releasing a texture handle on its own only drops this adapter's reference, which leaves the backend object resident until the host runtime collects it; a succession of resized render targets is exactly where that shows up as retained memory. Externally imported textures are left alone: their owner is the embedder, not this adapter.

Parameters
textureLive texture handle of this adapter; consumed either way.

◆ hasHostCommandEncoder()

bool donner::geode::GeodeWgpuAdapterDevice::hasHostCommandEncoder ( ) const

True while a host command encoder is installed, i.e. while submissions are replayed into it instead of reaching the queue.

This device is shared by everything drawing through one GeodeDevice, but a host encoder belongs to the single caller that installed it. Anything else submitting during that window would be spliced into a command buffer it does not own, at a point in that buffer it cannot reason about, and its submit would report success for work that has not reached the queue. A caller whose submission must stand on its own checks this first and declines.

◆ mappingUsedTimedWaitAny()

bool donner::geode::GeodeWgpuAdapterDevice::mappingUsedTimedWaitAny ( const gpu::BufferMapping & mapping) const

Whether any wait slice of mapping waited on the map's completion event rather than polling for it.

The distinction is a property of how this adapter waited, so it is reported here rather than inferred by the caller; the readback statistics carry it because a browser frame that fell back to polling takes orders of magnitude longer to observe the same completion.

Parameters
mappingLive mapping handle of this adapter.
Returns
True if a completion-event wait was used; false for a polled wait, an unknown handle, or a mapping no slice ever waited on.

◆ notifyHostSubmitted()

void donner::geode::GeodeWgpuAdapterDevice::notifyHostSubmitted ( )

Reports that the host submitted a command buffer carrying every stream replayed since the previous report, so their completion can now be observed.

Advances completedSerial to the highest replayed serial once the queue drains, exactly as an adapter-owned submit does. A no-op when nothing has been replayed since the last report.

◆ onAbandonCurrentTexture()

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

Backend hook: drop the acquired texture without presenting.

Parameters
slotIndexSlot of the surface.

Reimplemented from donner::gpu::Device.

◆ onAcquireCurrentTexture()

gpu::Result< gpu::SurfaceStatus > donner::geode::GeodeWgpuAdapterDevice::onAcquireCurrentTexture ( uint32_t slotIndex,
uint32_t textureSlotIndex )
overrideprotectedvirtual

Backend hook: acquire the next frame's texture and report the surface's state.

Parameters
slotIndexSlot of the surface.
textureSlotIndexSlot the runtime allocated for the acquired texture.

Reimplemented from donner::gpu::Device.

◆ onConfigureSurface()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::onConfigureSurface ( uint32_t slotIndex,
const gpu::SurfaceConfiguration & configuration )
overrideprotectedvirtual

Backend hook: apply a configuration.

Parameters
slotIndexSlot of the surface.
configurationConfiguration to apply.

Reimplemented from donner::gpu::Device.

◆ 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.

◆ onCreateSurface()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::onCreateSurface ( uint32_t slotIndex,
const gpu::SurfaceDescriptor & descriptor )
overrideprotectedvirtual

Backend hook: create a surface for a platform object.

Defaults to reporting presentation as unsupported, so a backend that cannot present needs no implementation.

Parameters
slotIndexSlot the surface occupies.
descriptorLabel and platform object.

Reimplemented from 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.

◆ onDestroyResource()

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

Backend hook: a validated resource was destroyed.

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

Implements 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.

◆ onPresentSurface()

gpu::Result< gpu::SurfaceStatus > donner::geode::GeodeWgpuAdapterDevice::onPresentSurface ( uint32_t slotIndex)
overrideprotectedvirtual

Backend hook: present the acquired texture.

Parameters
slotIndexSlot of the surface.

Reimplemented from donner::gpu::Device.

◆ onSubmit()

gpu::Status donner::geode::GeodeWgpuAdapterDevice::onSubmit ( uint64_t submissionSerial,
uint32_t commandBufferSlotIndex,
std::span< const gpu::Command > commands )
overrideprotectedvirtual

Backend hook: a validated command buffer was submitted.

Parameters
submissionSerialSerial assigned to this submission.
commandBufferSlotIndexSlot the command buffer occupied before being consumed.
commandsValidated commands, in recording order.

Implements donner::gpu::Device.

◆ onSurfaceCapabilities()

gpu::Result< gpu::SurfaceCapabilities > donner::geode::GeodeWgpuAdapterDevice::onSurfaceCapabilities ( uint32_t slotIndex) const
overrideprotectedvirtual

Backend hook: what a surface supports.

Parameters
slotIndexSlot of the surface.

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.

◆ onWaitMappingSlice()

gpu::MapSliceState 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.

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 )
overrideprotectedvirtual

Backend hook: a validated texture write.

Parameters
slotIndexDestination texture slot.
dataPayload bytes.
dataLayoutRow layout of data.
writeSizeExtent written in texels.

Implements donner::gpu::Device.

◆ setHostCommandEncoder()

void donner::geode::GeodeWgpuAdapterDevice::setHostCommandEncoder ( wgpu::CommandEncoder encoder)

Installs encoder as the host command encoder: while one is installed, a submitted command stream is replayed into it instead of into an encoder this adapter owns, and this adapter performs no queue submit of its own.

One command buffer therefore still carries a whole frame in recording order, including the spans a caller records directly into the same encoder around the replayed ones.

Temporary bridge: it exists because a frame encoder is shared with subsystems that have not migrated onto the runtime yet, so their spans cannot be replayed through it. It is removed once every subsystem sharing the frame encoder records through the runtime.

The caller owns encoder, must keep it alive until it is replaced or cleared, and must call notifyHostSubmitted after each queue submit of a command buffer finished from it. Until then the serials replayed into it are deliberately not observable as complete.

Parameters
encoderHost-owned command encoder to replay into.

◆ setSimulateEventWaitForTest()

void donner::geode::GeodeWgpuAdapterDevice::setSimulateEventWaitForTest ( bool simulate)
inline

Test seam: makes a wait slice behave as the browser's timed wait does when it expires without the map completing - it reports that it handled the slice, having learned nothing.

That arm is compiled out on every platform the test suites run on, so its contract is otherwise checked only by the browser lane, which is exactly where it went unchecked.

Parameters
simulateWhether slices should take the simulated event-wait path.

◆ submitStandalone()

gpu::Result< uint64_t > donner::geode::GeodeWgpuAdapterDevice::submitStandalone ( gpu::CommandBuffer && commands)

Submits commands straight to the queue, even while a host command encoder is installed.

submit replays into that encoder so a frame stays one command buffer in recording order, and a caller whose work must stand on its own is otherwise told to decline. The snapshot readback cannot decline: it is asked for while another renderer's frame may be open, and it has its own completion to wait on. Splicing it into that frame's buffer would leave it unsubmitted until the frame ends, and the readback would wait out its whole deadline for a map of work that had not reached the queue.

Bypassing the frame is correct here by construction rather than by timing: the readback reads textures whose contents were submitted before it was asked for, and writes only its own staging texture and readback buffer, so it shares no resource with the spans the open frame is still recording. A caller that cannot say the same must use submit.

Bridge machinery, removed with the host-encoder bridge itself.

Parameters
commandsFinished command buffer; consumed.
Returns
Submission serial, or an error if encoding or submission failed.

◆ waitForSerial()

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

Blocks until completedSerial reaches serial or timeoutSeconds elapses, driving wgpu::Device::poll so queued work-done callbacks are delivered (on Emscripten the poll shim yields through Asyncify, mirroring GeodeDevice's wait machinery).

This is the only entry point that drives wgpu polling for this adapter - see the warning on completedSerial.

Parameters
serialSubmission serial to wait for.
timeoutSecondsMaximum time to wait, in seconds.
Returns
True once completedSerial reached serial; false if the timeout (or the bounded poll-iteration budget) elapsed first.

◆ wgpuTextureOf()

wgpu::Texture donner::geode::GeodeWgpuAdapterDevice::wgpuTextureOf ( const gpu::Texture & texture) const

TEMPORARY escape hatch (deleted with the readback and presentation migration): returns the wgpu texture behind texture, or a null handle if the handle does not name a live texture of this adapter.

Borrowed; the adapter (or the external owner) retains ownership.

Parameters
textureLive texture handle of this adapter.

◆ wgpuTextureViewOf()

wgpu::TextureView donner::geode::GeodeWgpuAdapterDevice::wgpuTextureViewOf ( const gpu::TextureView & textureView) const

TEMPORARY escape hatch (deleted with the readback and presentation migration): returns the wgpu texture view behind textureView, or a null handle if unknown.

Borrowed.

Parameters
textureViewLive texture view handle of this adapter.

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