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

The BrowserBridge implementation that actually calls the browser's GPU service. More...

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

Inheritance diagram for donner::gpu::browser::EmscriptenBrowserBridge:
[legend]

Public Member Functions

 EmscriptenBrowserBridge ()
 Constructs a bridge over the browser's GPU service. No browser call happens until beginDeviceRequest.
 ~EmscriptenBrowserBridge () override
 Destructor; releases this logical device's state on the browser side and leaves every other logical device's alone. The browser device, and the textures its shares still hold, go with the last logical device over it.
BridgeStatus beginDeviceRequest () override
 Asks for this logical device's browser GPU device. The first logical device in a worker to ask begins the browser's request, which settles asynchronously; every later one joins the device that request obtains.
BrowserDeviceRequestState deviceRequestState () const override
 How far the request begun by beginDeviceRequest has progressed.
RcString deviceRequestError () const override
 Why the request failed, when deviceRequestState reports a failure. Empty otherwise.
BridgeStatus deviceStatus () const override
 Checks current ownership and loss together. Returns Success for an owned, live device, NotOwner for a missing device or foreign context, or DeviceLost for an owned, lost device. Other statuses indicate a failed query. Implementations must not cache this state.
bool isDeviceLost () const override
 Whether the browser has reported the device lost. Once true it never becomes false again.
RcString deviceLostReason () const override
 What the browser said when it reported the device lost. Empty while the device is alive.
uint64_t completedSerial () const override
 Serial of this logical device's most recent submission the browser has reported finished (0 if none). Each logical device numbers its submissions on its own.
uint32_t maxTextureDimension2D () const override
 Largest width or height of a 2D texture the browser device supports, as its limits report it, or 0 when this logical device holds no device or the browser reports no such limit.
const void * sharedDeviceIdentity () const override
 Identity of the browser device this logical device runs on: the same for every bridge over that device and different for every other, including a device obtained after this one was released.
BridgeStatus shareTexture (BrowserObjectId textureId, std::shared_ptr< const BrowserSharedTexture > &shared) override
 Holds the texture textureId for the other logical devices over the same browser device.
BridgeStatus registerSharedTexture (BrowserObjectId id, const BrowserSharedTexture &shared) override
 Registers the texture shared names under id, as a read-only alias in this logical device.
BridgeStatus createBuffer (BrowserObjectId id, uint64_t byteSize, uint32_t usageBits) override
 Creates a buffer.
BridgeStatus createTexture (BrowserObjectId id, uint32_t width, uint32_t height, uint32_t formatCode, uint32_t usageBits) override
 Creates a texture.
BridgeStatus createTextureView (BrowserObjectId id, BrowserObjectId textureId) override
 Creates a view covering the whole texture.
BridgeStatus createSampler (BrowserObjectId id, uint32_t magFilterCode, uint32_t minFilterCode, uint32_t addressUCode, uint32_t addressVCode) override
 Creates a sampler.
BridgeStatus createBindGroupLayout (BrowserObjectId id, std::span< const BrowserBindGroupLayoutEntry > entries) override
 Creates a bind group layout.
BridgeStatus createBindGroup (BrowserObjectId id, BrowserObjectId layoutId, std::span< const BrowserBindGroupEntry > entries) override
 Creates a bind group.
BridgeStatus createPipelineLayout (BrowserObjectId id, std::span< const BrowserObjectId > groupLayoutIds) override
 Creates a pipeline layout.
BridgeStatus createShaderModule (BrowserObjectId id, std::string_view wgsl) override
 Creates a shader module from trusted build output.
BridgeStatus createRenderPipeline (BrowserObjectId id, const BrowserRenderPipelineRequest &request) override
 Creates a render pipeline.
BridgeStatus createComputePipeline (BrowserObjectId id, const BrowserComputePipelineRequest &request) override
 Creates a compute pipeline.
BridgeStatus destroyObject (BrowserObjectKind kind, BrowserObjectId id) override
 Releases a browser object and unregisters its identifier, which is never reissued. A texture a share still holds is not destroyed until the share is released.
BridgeStatus writeBuffer (BrowserObjectId bufferId, uint64_t offsetBytes, std::span< const uint8_t > data) override
 Writes bytes into a buffer.
BridgeStatus writeTexture (BrowserObjectId textureId, std::span< const uint8_t > data, const BrowserTexelLayout &layout, const BrowserCopyRegion &region) override
 Writes texel rows into a texture.
BridgeStatus beginCommandBuffer (uint64_t submissionSerial, uint32_t commandBufferIndex) override
 Opens recording for the command buffer at commandBufferIndex of the submission with submissionSerial. Index zero starts the submission and discards whatever an earlier attempt finished without submitting, so a refused command can never end up submitted as part of a later frame; a later index must find exactly that many finished buffers under the same serial, which is how the two halves agree on what is being recorded.
BridgeStatus beginRenderPass (std::span< const BrowserColorAttachment > colorAttachments) override
 Begins a render pass.
BridgeStatus endRenderPass () override
 Ends the open render pass.
BridgeStatus beginComputePass () override
 Begins a compute pass.
BridgeStatus endComputePass () override
 Ends the open compute pass.
BridgeStatus setRenderPipeline (BrowserObjectId pipelineId) override
 Sets the render pipeline of the open render pass.
BridgeStatus setComputePipeline (BrowserObjectId pipelineId) override
 Sets the compute pipeline of the open compute pass.
BridgeStatus setBindGroup (uint32_t index, BrowserObjectId bindGroupId) override
 Binds a group in the open pass.
BridgeStatus setVertexBuffer (uint32_t slot, BrowserObjectId bufferId, uint64_t offsetBytes) override
 Binds a vertex buffer.
BridgeStatus setIndexBuffer (BrowserObjectId bufferId, uint32_t indexFormatCode, uint64_t offsetBytes) override
 Binds an index buffer.
BridgeStatus setScissorRect (uint32_t x, uint32_t y, uint32_t width, uint32_t height) override
 Sets the scissor rectangle.
BridgeStatus setViewport (float x, float y, float width, float height, float minDepth, float maxDepth) override
 Sets the viewport.
BridgeStatus draw (uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) override
 Draws non-indexed geometry.
BridgeStatus drawIndexed (uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance) override
 Draws indexed geometry.
BridgeStatus dispatchWorkgroups (uint32_t countX, uint32_t countY, uint32_t countZ) override
 Dispatches compute workgroups.
BridgeStatus copyTextureToBuffer (BrowserObjectId textureId, BrowserObjectId bufferId, const BrowserTexelLayout &layout, const BrowserCopyRegion &region) override
 Copies texels into a buffer.
BridgeStatus copyTextureToTexture (BrowserObjectId sourceTextureId, BrowserObjectId destinationTextureId, const BrowserCopyRegion &region) override
 Copies texels between textures.
BridgeStatus endCommandBuffer (uint64_t submissionSerial) override
 Finishes the open command buffer and holds it for the submission, without reaching the queue: a submission of several buffers reaches the queue once, in submitCommandBuffers.
BridgeStatus submitCommandBuffers (uint64_t submissionSerial) override
 Submits every command buffer finished under submissionSerial as one queue submission, in the order they were recorded, and arranges for the reported completed serial to reach submissionSerial once that submission finishes.
BridgeStatus mapBufferAsync (BrowserObjectId mappingId, BrowserObjectId bufferId, uint64_t offsetBytes, uint64_t byteCount) override
 Begins mapping a buffer range for host reads.
MapSliceState mappingState (BrowserObjectId mappingId) const override
 State of a mapping the browser has been asked for.
BridgeStatus requestMappingProgress (BrowserObjectId mappingId) override
 Submits an empty command list while this mapping remains pending, without submitting recorded commands or changing logical submission serials.
void yieldToBrowser (double seconds) override
 Gives the browser up to seconds of this thread to make progress.
BridgeStatus mappedBytes (BrowserObjectId mappingId, std::span< const uint8_t > &bytes) const override
 Bytes of a completed mapping, valid until the mapping is released. Returns an empty span with a non-success status when the mapping is not readable.
BridgeStatus unmapBuffer (BrowserObjectId mappingId) override
 Releases a mapping and unregisters its identifier.
BridgeStatus createSurface (BrowserObjectId id, std::string_view canvasSelector) override
 Creates a surface over the canvas named by canvasSelector.
BridgeStatus surfaceCapabilities (BrowserObjectId surfaceId, BrowserSurfaceCapabilities &capabilities) const override
 Reports what a surface supports.
BridgeStatus configureSurface (BrowserObjectId surfaceId, uint32_t formatCode, uint32_t usageBits, uint32_t width, uint32_t height, uint32_t alphaModeCode) override
 Configures how a surface presents.
BridgeStatus acquireCurrentTexture (BrowserObjectId surfaceId, BrowserObjectId textureId, SurfaceStatus &status) override
 Takes the surface's texture for this frame and registers it under textureId.
BridgeStatus presentSurface (BrowserObjectId surfaceId, SurfaceStatus &status) override
 Finishes the acquired canvas frame for implicit browser presentation.
BridgeStatus abandonCurrentTexture (BrowserObjectId surfaceId) override
 Gives back the acquired texture without showing it.
Public Member Functions inherited from donner::gpu::browser::BrowserBridge
virtual ~BrowserBridge ()
 Destructor; releases this logical device's state on the browser side. The browser device itself goes once no logical device over it is left.
 BrowserBridge (const BrowserBridge &)=delete
BrowserBridge & operator= (const BrowserBridge &)=delete
 BrowserBridge (BrowserBridge &&)=delete
BrowserBridge & operator= (BrowserBridge &&)=delete

Additional Inherited Members

Protected Member Functions inherited from donner::gpu::browser::BrowserBridge
 BrowserBridge ()
 Constructor for implementations.

Detailed Description

The BrowserBridge implementation that actually calls the browser's GPU service.

Every method forwards to one entry point of library_donner_gpu.js, which owns the browser objects and performs the identifier, kind and ownership checks on its side. This class holds no browser state of its own beyond the mapped bytes it copies out of the browser's heap, so what exists is recorded in one place rather than in two that could disagree.

Each bridge is one logical device and names itself to the library by a handle it is given at construction, which every entry point takes first. Handles come from one counter shared by every worker in the process and are never reused, so a handle names one logical device anywhere, and a stale one names nothing. The library keys each logical device's identifiers, mappings, recording and completed serial by that handle. The editor registers its application thread as GPU owner; all logical devices dispatch raw browser primitives to that thread and share its device/queue. Standalone modules without a registered owner execute on the caller. C++ handle tables and mapped byte storage stay on the creating caller; GPU objects never cross worker boundaries.

beginDeviceRequest compares ProtocolCodeTable against the table the library holds before asking for a device, so the two halves agree on what their numbers mean before anything is built on them. See BrowserWireCodes.h for what that check covers and what it does not.

Sizes and offsets cross as doubles rather than 64-bit integers. Every value that crosses is bounded far below the 2^53 a double represents exactly - the runtime caps buffers at 1 GiB and textures at 16384 texels a side - and a double is the one numeric type both sides agree on without a 64-bit calling-convention dependency.

WebAssembly only: it exists to call a browser.

Member Function Documentation

◆ abandonCurrentTexture()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::abandonCurrentTexture ( BrowserObjectId surfaceId)
overridevirtual

Gives back the acquired texture without showing it.

Parameters
surfaceIdSurface holding it.

Implements donner::gpu::browser::BrowserBridge.

◆ acquireCurrentTexture()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::acquireCurrentTexture ( BrowserObjectId surfaceId,
BrowserObjectId textureId,
SurfaceStatus & status )
overridevirtual

Takes the surface's texture for this frame and registers it under textureId.

Parameters
surfaceIdSurface to acquire from.
textureIdIdentifier for the frame texture.
statusReceives what the surface reported.

Implements donner::gpu::browser::BrowserBridge.

◆ beginCommandBuffer()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::beginCommandBuffer ( uint64_t submissionSerial,
uint32_t commandBufferIndex )
overridevirtual

Opens recording for the command buffer at commandBufferIndex of the submission with submissionSerial. Index zero starts the submission and discards whatever an earlier attempt finished without submitting, so a refused command can never end up submitted as part of a later frame; a later index must find exactly that many finished buffers under the same serial, which is how the two halves agree on what is being recorded.

Parameters
submissionSerialSerial the runtime assigned.
commandBufferIndexPosition of this buffer within the submission.

Implements donner::gpu::browser::BrowserBridge.

◆ beginComputePass()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::beginComputePass ( )
overridevirtual

Begins a compute pass.

Implements donner::gpu::browser::BrowserBridge.

◆ beginDeviceRequest()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::beginDeviceRequest ( )
overridevirtual

Asks for this logical device's browser GPU device. The first logical device in a worker to ask begins the browser's request, which settles asynchronously; every later one joins the device that request obtains.

Implements donner::gpu::browser::BrowserBridge.

◆ beginRenderPass()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::beginRenderPass ( std::span< const BrowserColorAttachment > colorAttachments)
overridevirtual

Begins a render pass.

Parameters
colorAttachmentsAttachments of the pass.

Implements donner::gpu::browser::BrowserBridge.

◆ completedSerial()

uint64_t donner::gpu::browser::EmscriptenBrowserBridge::completedSerial ( ) const
overridevirtual

Serial of this logical device's most recent submission the browser has reported finished (0 if none). Each logical device numbers its submissions on its own.

Implements donner::gpu::browser::BrowserBridge.

◆ configureSurface()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::configureSurface ( BrowserObjectId surfaceId,
uint32_t formatCode,
uint32_t usageBits,
uint32_t width,
uint32_t height,
uint32_t alphaModeCode )
overridevirtual

Configures how a surface presents.

Parameters
surfaceIdSurface to configure.
formatCodeEncoded TextureFormat.
usageBitsEncoded TextureUsage mask.
widthWidth in texels.
heightHeight in texels.
alphaModeCodeEncoded SurfaceAlphaMode.

Implements donner::gpu::browser::BrowserBridge.

◆ copyTextureToBuffer()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::copyTextureToBuffer ( BrowserObjectId textureId,
BrowserObjectId bufferId,
const BrowserTexelLayout & layout,
const BrowserCopyRegion & region )
overridevirtual

Copies texels into a buffer.

Parameters
textureIdSource texture.
bufferIdDestination buffer.
layoutDestination row layout.
regionCopied rectangle.

Implements donner::gpu::browser::BrowserBridge.

◆ copyTextureToTexture()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::copyTextureToTexture ( BrowserObjectId sourceTextureId,
BrowserObjectId destinationTextureId,
const BrowserCopyRegion & region )
overridevirtual

Copies texels between textures.

Parameters
sourceTextureIdSource.
destinationTextureIdDestination.
regionCopied rectangle with both origins.

Implements donner::gpu::browser::BrowserBridge.

◆ createBindGroup()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::createBindGroup ( BrowserObjectId id,
BrowserObjectId layoutId,
std::span< const BrowserBindGroupEntry > entries )
overridevirtual

Creates a bind group.

Parameters
idIdentifier to register it under.
layoutIdLayout the entries match.
entriesBound resources.

Implements donner::gpu::browser::BrowserBridge.

◆ createBindGroupLayout()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::createBindGroupLayout ( BrowserObjectId id,
std::span< const BrowserBindGroupLayoutEntry > entries )
overridevirtual

Creates a bind group layout.

Parameters
idIdentifier to register it under.
entriesLayout entries.

Implements donner::gpu::browser::BrowserBridge.

◆ createBuffer()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::createBuffer ( BrowserObjectId id,
uint64_t byteSize,
uint32_t usageBits )
overridevirtual

Creates a buffer.

Parameters
idIdentifier to register it under.
byteSizeSize in bytes.
usageBitsEncoded BufferUsage mask.

Implements donner::gpu::browser::BrowserBridge.

◆ createComputePipeline()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::createComputePipeline ( BrowserObjectId id,
const BrowserComputePipelineRequest & request )
overridevirtual

Creates a compute pipeline.

Parameters
idIdentifier to register it under.
requestPipeline description.

Implements donner::gpu::browser::BrowserBridge.

◆ createPipelineLayout()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::createPipelineLayout ( BrowserObjectId id,
std::span< const BrowserObjectId > groupLayoutIds )
overridevirtual

Creates a pipeline layout.

Parameters
idIdentifier to register it under.
groupLayoutIdsBind group layouts, by group index.

Implements donner::gpu::browser::BrowserBridge.

◆ createRenderPipeline()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::createRenderPipeline ( BrowserObjectId id,
const BrowserRenderPipelineRequest & request )
overridevirtual

Creates a render pipeline.

Parameters
idIdentifier to register it under.
requestPipeline description.

Implements donner::gpu::browser::BrowserBridge.

◆ createSampler()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::createSampler ( BrowserObjectId id,
uint32_t magFilterCode,
uint32_t minFilterCode,
uint32_t addressUCode,
uint32_t addressVCode )
overridevirtual

Creates a sampler.

Parameters
idIdentifier to register it under.
magFilterCodeEncoded magnification FilterMode.
minFilterCodeEncoded minification FilterMode.
addressUCodeEncoded U AddressMode.
addressVCodeEncoded V AddressMode.

Implements donner::gpu::browser::BrowserBridge.

◆ createShaderModule()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::createShaderModule ( BrowserObjectId id,
std::string_view wgsl )
overridevirtual

Creates a shader module from trusted build output.

Parameters
idIdentifier to register it under.
wgslShader source text.

Implements donner::gpu::browser::BrowserBridge.

◆ createSurface()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::createSurface ( BrowserObjectId id,
std::string_view canvasSelector )
overridevirtual

Creates a surface over the canvas named by canvasSelector.

Parameters
idIdentifier to register it under.
canvasSelectorCSS selector naming the canvas.

Implements donner::gpu::browser::BrowserBridge.

◆ createTexture()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::createTexture ( BrowserObjectId id,
uint32_t width,
uint32_t height,
uint32_t formatCode,
uint32_t usageBits )
overridevirtual

Creates a texture.

Parameters
idIdentifier to register it under.
widthWidth in texels.
heightHeight in texels.
formatCodeEncoded TextureFormat.
usageBitsEncoded TextureUsage mask.

Implements donner::gpu::browser::BrowserBridge.

◆ createTextureView()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::createTextureView ( BrowserObjectId id,
BrowserObjectId textureId )
overridevirtual

Creates a view covering the whole texture.

Parameters
idIdentifier to register it under.
textureIdTexture to view.

Implements donner::gpu::browser::BrowserBridge.

◆ destroyObject()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::destroyObject ( BrowserObjectKind kind,
BrowserObjectId id )
overridevirtual

Releases a browser object and unregisters its identifier, which is never reissued. A texture a share still holds is not destroyed until the share is released.

Parameters
kindKind the identifier must name.
idIdentifier to release.

Implements donner::gpu::browser::BrowserBridge.

◆ deviceLostReason()

RcString donner::gpu::browser::EmscriptenBrowserBridge::deviceLostReason ( ) const
overridevirtual

What the browser said when it reported the device lost. Empty while the device is alive.

Implements donner::gpu::browser::BrowserBridge.

◆ deviceRequestError()

RcString donner::gpu::browser::EmscriptenBrowserBridge::deviceRequestError ( ) const
overridevirtual

Why the request failed, when deviceRequestState reports a failure. Empty otherwise.

Implements donner::gpu::browser::BrowserBridge.

◆ deviceRequestState()

BrowserDeviceRequestState donner::gpu::browser::EmscriptenBrowserBridge::deviceRequestState ( ) const
overridevirtual

How far the request begun by beginDeviceRequest has progressed.

Implements donner::gpu::browser::BrowserBridge.

◆ deviceStatus()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::deviceStatus ( ) const
overridevirtual

Checks current ownership and loss together. Returns Success for an owned, live device, NotOwner for a missing device or foreign context, or DeviceLost for an owned, lost device. Other statuses indicate a failed query. Implementations must not cache this state.

Implements donner::gpu::browser::BrowserBridge.

◆ dispatchWorkgroups()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::dispatchWorkgroups ( uint32_t countX,
uint32_t countY,
uint32_t countZ )
overridevirtual

Dispatches compute workgroups.

Parameters
countXWorkgroups along X.
countYWorkgroups along Y.
countZWorkgroups along Z.

Implements donner::gpu::browser::BrowserBridge.

◆ draw()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::draw ( uint32_t vertexCount,
uint32_t instanceCount,
uint32_t firstVertex,
uint32_t firstInstance )
overridevirtual

Draws non-indexed geometry.

Parameters
vertexCountVertices.
instanceCountInstances.
firstVertexFirst vertex.
firstInstanceFirst instance.

Implements donner::gpu::browser::BrowserBridge.

◆ drawIndexed()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::drawIndexed ( uint32_t indexCount,
uint32_t instanceCount,
uint32_t firstIndex,
int32_t baseVertex,
uint32_t firstInstance )
overridevirtual

Draws indexed geometry.

Parameters
indexCountIndices.
instanceCountInstances.
firstIndexFirst index.
baseVertexValue added to every index.
firstInstanceFirst instance.

Implements donner::gpu::browser::BrowserBridge.

◆ endCommandBuffer()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::endCommandBuffer ( uint64_t submissionSerial)
overridevirtual

Finishes the open command buffer and holds it for the submission, without reaching the queue: a submission of several buffers reaches the queue once, in submitCommandBuffers.

Parameters
submissionSerialSerial the runtime assigned.

Implements donner::gpu::browser::BrowserBridge.

◆ endComputePass()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::endComputePass ( )
overridevirtual

Ends the open compute pass.

Implements donner::gpu::browser::BrowserBridge.

◆ endRenderPass()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::endRenderPass ( )
overridevirtual

Ends the open render pass.

Implements donner::gpu::browser::BrowserBridge.

◆ isDeviceLost()

bool donner::gpu::browser::EmscriptenBrowserBridge::isDeviceLost ( ) const
overridevirtual

Whether the browser has reported the device lost. Once true it never becomes false again.

Implements donner::gpu::browser::BrowserBridge.

◆ mapBufferAsync()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::mapBufferAsync ( BrowserObjectId mappingId,
BrowserObjectId bufferId,
uint64_t offsetBytes,
uint64_t byteCount )
overridevirtual

Begins mapping a buffer range for host reads.

Parameters
mappingIdIdentifier to register the mapping under.
bufferIdBuffer to map.
offsetBytesByte offset of the range.
byteCountLength of the range.

Implements donner::gpu::browser::BrowserBridge.

◆ mappedBytes()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::mappedBytes ( BrowserObjectId mappingId,
std::span< const uint8_t > & bytes ) const
overridevirtual

Bytes of a completed mapping, valid until the mapping is released. Returns an empty span with a non-success status when the mapping is not readable.

Parameters
mappingIdMapping to read.
bytesReceives the mapped bytes on success.

Implements donner::gpu::browser::BrowserBridge.

◆ mappingState()

MapSliceState donner::gpu::browser::EmscriptenBrowserBridge::mappingState ( BrowserObjectId mappingId) const
overridevirtual

State of a mapping the browser has been asked for.

Parameters
mappingIdMapping to query.

Implements donner::gpu::browser::BrowserBridge.

◆ maxTextureDimension2D()

uint32_t donner::gpu::browser::EmscriptenBrowserBridge::maxTextureDimension2D ( ) const
overridevirtual

Largest width or height of a 2D texture the browser device supports, as its limits report it, or 0 when this logical device holds no device or the browser reports no such limit.

Implements donner::gpu::browser::BrowserBridge.

◆ presentSurface()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::presentSurface ( BrowserObjectId surfaceId,
SurfaceStatus & status )
overridevirtual

Finishes the acquired canvas frame for implicit browser presentation.

Parameters
surfaceIdSurface holding the frame.
statusReceives the presentation outcome.

Implements donner::gpu::browser::BrowserBridge.

◆ registerSharedTexture()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::registerSharedTexture ( BrowserObjectId id,
const BrowserSharedTexture & shared )
overridevirtual

Registers the texture shared names under id, as a read-only alias in this logical device.

Destroying the alias releases nothing but the identifier.

Parameters
idIdentifier to register the alias under.
sharedShare another logical device over the same browser device made.

Implements donner::gpu::browser::BrowserBridge.

◆ requestMappingProgress()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::requestMappingProgress ( BrowserObjectId mappingId)
overridevirtual

Submits an empty command list while this mapping remains pending, without submitting recorded commands or changing logical submission serials.

Parameters
mappingIdMapping to advance.
Returns
Success only when a queue submission was made.

Implements donner::gpu::browser::BrowserBridge.

◆ setBindGroup()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::setBindGroup ( uint32_t index,
BrowserObjectId bindGroupId )
overridevirtual

Binds a group in the open pass.

Parameters
indexGroup index.
bindGroupIdBind group.

Implements donner::gpu::browser::BrowserBridge.

◆ setComputePipeline()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::setComputePipeline ( BrowserObjectId pipelineId)
overridevirtual

Sets the compute pipeline of the open compute pass.

Parameters
pipelineIdCompute pipeline.

Implements donner::gpu::browser::BrowserBridge.

◆ setIndexBuffer()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::setIndexBuffer ( BrowserObjectId bufferId,
uint32_t indexFormatCode,
uint64_t offsetBytes )
overridevirtual

Binds an index buffer.

Parameters
bufferIdBuffer.
indexFormatCodeEncoded IndexFormat.
offsetBytesByte offset of the first index.

Implements donner::gpu::browser::BrowserBridge.

◆ setRenderPipeline()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::setRenderPipeline ( BrowserObjectId pipelineId)
overridevirtual

Sets the render pipeline of the open render pass.

Parameters
pipelineIdRender pipeline.

Implements donner::gpu::browser::BrowserBridge.

◆ setScissorRect()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::setScissorRect ( uint32_t x,
uint32_t y,
uint32_t width,
uint32_t height )
overridevirtual

Sets the scissor rectangle.

Parameters
xLeft edge.
yTop edge.
widthWidth.
heightHeight.

Implements donner::gpu::browser::BrowserBridge.

◆ setVertexBuffer()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::setVertexBuffer ( uint32_t slot,
BrowserObjectId bufferId,
uint64_t offsetBytes )
overridevirtual

Binds a vertex buffer.

Parameters
slotVertex buffer slot.
bufferIdBuffer.
offsetBytesByte offset of the first element.

Implements donner::gpu::browser::BrowserBridge.

◆ setViewport()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::setViewport ( float x,
float y,
float width,
float height,
float minDepth,
float maxDepth )
overridevirtual

Sets the viewport.

Parameters
xLeft edge.
yTop edge.
widthWidth.
heightHeight.
minDepthMinimum depth.
maxDepthMaximum depth.

Implements donner::gpu::browser::BrowserBridge.

◆ sharedDeviceIdentity()

const void * donner::gpu::browser::EmscriptenBrowserBridge::sharedDeviceIdentity ( ) const
overridevirtual

Identity of the browser device this logical device runs on: the same for every bridge over that device and different for every other, including a device obtained after this one was released.

Null until the request is Ready.

Implements donner::gpu::browser::BrowserBridge.

◆ shareTexture()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::shareTexture ( BrowserObjectId textureId,
std::shared_ptr< const BrowserSharedTexture > & shared )
overridevirtual

Holds the texture textureId for the other logical devices over the same browser device.

Parameters
textureIdTexture of this logical device; refused if it is a registration or is already shared.
sharedReceives the share on success.

Implements donner::gpu::browser::BrowserBridge.

◆ submitCommandBuffers()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::submitCommandBuffers ( uint64_t submissionSerial)
overridevirtual

Submits every command buffer finished under submissionSerial as one queue submission, in the order they were recorded, and arranges for the reported completed serial to reach submissionSerial once that submission finishes.

Parameters
submissionSerialSerial the runtime assigned.

Implements donner::gpu::browser::BrowserBridge.

◆ surfaceCapabilities()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::surfaceCapabilities ( BrowserObjectId surfaceId,
BrowserSurfaceCapabilities & capabilities ) const
overridevirtual

Reports what a surface supports.

Parameters
surfaceIdSurface to query.
capabilitiesReceives the capabilities on success.

Implements donner::gpu::browser::BrowserBridge.

◆ unmapBuffer()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::unmapBuffer ( BrowserObjectId mappingId)
overridevirtual

Releases a mapping and unregisters its identifier.

Parameters
mappingIdMapping to release.

Implements donner::gpu::browser::BrowserBridge.

◆ writeBuffer()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::writeBuffer ( BrowserObjectId bufferId,
uint64_t offsetBytes,
std::span< const uint8_t > data )
overridevirtual

Writes bytes into a buffer.

Parameters
bufferIdDestination buffer.
offsetBytesDestination byte offset.
dataPayload.

Implements donner::gpu::browser::BrowserBridge.

◆ writeTexture()

BridgeStatus donner::gpu::browser::EmscriptenBrowserBridge::writeTexture ( BrowserObjectId textureId,
std::span< const uint8_t > data,
const BrowserTexelLayout & layout,
const BrowserCopyRegion & region )
overridevirtual

Writes texel rows into a texture.

Parameters
textureIdDestination texture.
dataPayload.
layoutRow layout of data.
regionDestination rectangle; its source coordinates are unused.

Implements donner::gpu::browser::BrowserBridge.

◆ yieldToBrowser()

void donner::gpu::browser::EmscriptenBrowserBridge::yieldToBrowser ( double seconds)
overridevirtual

Gives the browser up to seconds of this thread to make progress.

A browser settles a mapping on its own event loop, so a caller that waits by blocking prevents the very progress it is waiting for: the promise that would mark the mapping ready cannot run until this thread yields. Resting between slices is not enough, because resting is still not yielding. This is the call that hands the loop back.

How a shipped build yields is not settled. The implementation unwinds the stack, which needs that support enabled at link time and costs module size and speed; the WebAssembly binaries enable it today, but they do so for the transitional WebGPU path this bridge is meant to replace, so its presence is not something this bridge can assume it keeps. The alternatives are stack switching, which is not available on every browser in the support matrix, and making readback asynchronous up the calling stack so nothing ever waits here. That choice belongs to the production cutover and touches renderer code outside this package; until it is made, treat a blocking wait through this call as workable rather than as the shipped design.

Parameters
secondsLongest this call may yield for.

Implements donner::gpu::browser::BrowserBridge.


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