Donner SVG 0.8.0
0.8.0 ยท ebf353960.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
BrowserWireCodes.h File Reference

Stable numeric codes the runtime and the browser side use to name enumerated descriptor values. More...

#include <cstdint>
#include <optional>
#include <span>
#include "donner/gpu/Descriptors.h"
#include "donner/gpu/browser/BrowserBridge.h"
Include dependency graph for BrowserWireCodes.h:

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Functions

std::optional< uint32_t > donner::gpu::browser::WireTextureFormat (TextureFormat value)
 Code for value, or nullopt if it is not a known enumerator.
std::optional< uint32_t > donner::gpu::browser::WireTextureUsage (TextureUsage value)
 Codes for the flags in value, or nullopt if it carries an unrecognized bit. An empty mask encodes as zero.
std::optional< uint32_t > donner::gpu::browser::WireBufferUsage (BufferUsage value)
 Codes for the flags in value, or nullopt if it carries an unrecognized bit. An empty mask encodes as zero.
std::optional< uint32_t > donner::gpu::browser::WireShaderStage (ShaderStage value)
 Codes for the flags in value, or nullopt if it carries an unrecognized bit. An empty mask encodes as zero.
std::optional< uint32_t > donner::gpu::browser::WireColorWriteMask (ColorWriteMask value)
 Codes for the flags in value, or nullopt if it carries an unrecognized bit. An empty mask encodes as zero.
std::optional< uint32_t > donner::gpu::browser::WireFilterMode (FilterMode value)
 Code for value, or nullopt if it is not a known enumerator.
std::optional< uint32_t > donner::gpu::browser::WireAddressMode (AddressMode value)
 Code for value, or nullopt if it is not a known enumerator.
std::optional< uint32_t > donner::gpu::browser::WireVertexFormat (VertexFormat value)
 Code for value, or nullopt if it is not a known enumerator.
std::optional< uint32_t > donner::gpu::browser::WireVertexStepMode (VertexStepMode value)
 Code for value, or nullopt if it is not a known enumerator.
std::optional< uint32_t > donner::gpu::browser::WireIndexFormat (IndexFormat value)
 Code for value, or nullopt if it is not a known enumerator.
std::optional< uint32_t > donner::gpu::browser::WirePrimitiveTopology (PrimitiveTopology value)
 Code for value, or nullopt if it is not a known enumerator.
std::optional< uint32_t > donner::gpu::browser::WireCullMode (CullMode value)
 Code for value, or nullopt if it is not a known enumerator.
std::optional< uint32_t > donner::gpu::browser::WireBlendFactor (BlendFactor value)
 Code for value, or nullopt if it is not a known enumerator.
std::optional< uint32_t > donner::gpu::browser::WireBlendOperation (BlendOperation value)
 Code for value, or nullopt if it is not a known enumerator.
std::optional< uint32_t > donner::gpu::browser::WireBindingType (BindingType value)
 Code for value, or nullopt if it is not a known enumerator.
std::optional< uint32_t > donner::gpu::browser::WireLoadOp (LoadOp value)
 Code for value, or nullopt if it is not a known enumerator.
std::optional< uint32_t > donner::gpu::browser::WireStoreOp (StoreOp value)
 Code for value, or nullopt if it is not a known enumerator.
std::optional< uint32_t > donner::gpu::browser::WirePresentMode (PresentMode value)
 Code for value, or nullopt if it is not a known enumerator.
std::optional< uint32_t > donner::gpu::browser::WireSurfaceAlphaMode (SurfaceAlphaMode value)
 Code for value, or nullopt if it is not a known enumerator.
std::optional< uint32_t > donner::gpu::browser::WireBrowserObjectKind (BrowserObjectKind value)
 Code for value, or nullopt if it is not a known kind.
std::optional< BridgeStatus > donner::gpu::browser::BridgeStatusFromWire (uint32_t code)
 The status code stands for, or nullopt if this protocol assigns it none.
std::optional< BrowserDeviceRequestState > donner::gpu::browser::RequestStateFromWire (uint32_t code)
 The request state code stands for, or nullopt if this protocol assigns it none.
std::optional< MapSliceState > donner::gpu::browser::MapSliceStateFromWire (uint32_t code)
 The mapping state code stands for, or nullopt if this protocol assigns it none.
std::optional< SurfaceStatus > donner::gpu::browser::SurfaceStatusFromWire (uint32_t code)
 The surface outcome code stands for, or nullopt if this protocol assigns it none.
std::span< const uint32_t > donner::gpu::browser::ProtocolCodeTable ()
 Every code this protocol assigns, in one fixed order.

Detailed Description

Stable numeric codes the runtime and the browser side use to name enumerated descriptor values.

The browser side is JavaScript, so it cannot share the runtime's C++ enumerators. Rather than let it read their underlying values - which would turn reordering an enumerator into a silent change of what a descriptor means - every enumerated value that crosses the boundary is translated here into a code that is fixed for the life of the protocol.

Three things keep the two halves in agreement, and it is worth being exact about which does what, because none of them covers the others:

  • The translations below are exhaustive switches, so adding an enumerator without giving it a code fails to compile and removing one stops compiling at its use.
  • The tests in this package pin every code, so changing a number on this side is a test failure. They cannot see the JavaScript side.
  • ProtocolCodeTable is compared against the table library_donner_gpu.js holds, element by element, before a device is requested. That is the check that covers the JavaScript side, and it is a runtime one: a disagreement fails the device request rather than the build.

Linking covers something narrower still: it proves the C++ half references no entry point the library leaves undefined. It does not check parameter lists, because a JavaScript function ignores extra arguments and reads missing ones as undefined.

Every translation is total over the enumerators it accepts and returns nullopt for anything else, so a value that reached here without passing the runtime's own enum validation stops at the boundary instead of being handed to the browser as a number it will interpret as something else.

Function Documentation

◆ BridgeStatusFromWire()

std::optional< BridgeStatus > donner::gpu::browser::BridgeStatusFromWire ( uint32_t code)

The status code stands for, or nullopt if this protocol assigns it none.

Parameters
codeCode the browser side returned.

◆ MapSliceStateFromWire()

std::optional< MapSliceState > donner::gpu::browser::MapSliceStateFromWire ( uint32_t code)

The mapping state code stands for, or nullopt if this protocol assigns it none.

Parameters
codeCode the browser side returned.

◆ ProtocolCodeTable()

std::span< const uint32_t > donner::gpu::browser::ProtocolCodeTable ( )

Every code this protocol assigns, in one fixed order.

This is the table the two halves of the bridge agree on. It is built from the translations above rather than written out a second time, so it cannot describe something other than what is actually sent, and library_donner_gpu.js holds the same sequence. The bridge compares the two before it asks for a device, so a code that means one thing here and another there stops the device request instead of reaching a browser call as a number that was read as something else.

Appending to this table is a protocol change: both sides change together or the comparison fails, which is the point.

◆ RequestStateFromWire()

std::optional< BrowserDeviceRequestState > donner::gpu::browser::RequestStateFromWire ( uint32_t code)

The request state code stands for, or nullopt if this protocol assigns it none.

Parameters
codeCode the browser side returned.

◆ SurfaceStatusFromWire()

std::optional< SurfaceStatus > donner::gpu::browser::SurfaceStatusFromWire ( uint32_t code)

The surface outcome code stands for, or nullopt if this protocol assigns it none.

Parameters
codeCode the browser side returned.

◆ WireAddressMode()

std::optional< uint32_t > donner::gpu::browser::WireAddressMode ( AddressMode value)

Code for value, or nullopt if it is not a known enumerator.

Parameters
valueValue to encode.

◆ WireBindingType()

std::optional< uint32_t > donner::gpu::browser::WireBindingType ( BindingType value)

Code for value, or nullopt if it is not a known enumerator.

Parameters
valueValue to encode.

◆ WireBlendFactor()

std::optional< uint32_t > donner::gpu::browser::WireBlendFactor ( BlendFactor value)

Code for value, or nullopt if it is not a known enumerator.

Parameters
valueValue to encode.

◆ WireBlendOperation()

std::optional< uint32_t > donner::gpu::browser::WireBlendOperation ( BlendOperation value)

Code for value, or nullopt if it is not a known enumerator.

Parameters
valueValue to encode.

◆ WireBrowserObjectKind()

std::optional< uint32_t > donner::gpu::browser::WireBrowserObjectKind ( BrowserObjectKind value)

Code for value, or nullopt if it is not a known kind.

Parameters
valueKind to encode.

◆ WireBufferUsage()

std::optional< uint32_t > donner::gpu::browser::WireBufferUsage ( BufferUsage value)

Codes for the flags in value, or nullopt if it carries an unrecognized bit. An empty mask encodes as zero.

Parameters
valueMask to encode.

◆ WireColorWriteMask()

std::optional< uint32_t > donner::gpu::browser::WireColorWriteMask ( ColorWriteMask value)

Codes for the flags in value, or nullopt if it carries an unrecognized bit. An empty mask encodes as zero.

Parameters
valueMask to encode.

◆ WireCullMode()

std::optional< uint32_t > donner::gpu::browser::WireCullMode ( CullMode value)

Code for value, or nullopt if it is not a known enumerator.

Parameters
valueValue to encode.

◆ WireFilterMode()

std::optional< uint32_t > donner::gpu::browser::WireFilterMode ( FilterMode value)

Code for value, or nullopt if it is not a known enumerator.

Parameters
valueValue to encode.

◆ WireIndexFormat()

std::optional< uint32_t > donner::gpu::browser::WireIndexFormat ( IndexFormat value)

Code for value, or nullopt if it is not a known enumerator.

Parameters
valueValue to encode.

◆ WireLoadOp()

std::optional< uint32_t > donner::gpu::browser::WireLoadOp ( LoadOp value)

Code for value, or nullopt if it is not a known enumerator.

Parameters
valueValue to encode.

◆ WirePresentMode()

std::optional< uint32_t > donner::gpu::browser::WirePresentMode ( PresentMode value)

Code for value, or nullopt if it is not a known enumerator.

Parameters
valueValue to encode.

◆ WirePrimitiveTopology()

std::optional< uint32_t > donner::gpu::browser::WirePrimitiveTopology ( PrimitiveTopology value)

Code for value, or nullopt if it is not a known enumerator.

Parameters
valueValue to encode.

◆ WireShaderStage()

std::optional< uint32_t > donner::gpu::browser::WireShaderStage ( ShaderStage value)

Codes for the flags in value, or nullopt if it carries an unrecognized bit. An empty mask encodes as zero.

Parameters
valueMask to encode.

◆ WireStoreOp()

std::optional< uint32_t > donner::gpu::browser::WireStoreOp ( StoreOp value)

Code for value, or nullopt if it is not a known enumerator.

Parameters
valueValue to encode.

◆ WireSurfaceAlphaMode()

std::optional< uint32_t > donner::gpu::browser::WireSurfaceAlphaMode ( SurfaceAlphaMode value)

Code for value, or nullopt if it is not a known enumerator.

Parameters
valueValue to encode.

◆ WireTextureFormat()

std::optional< uint32_t > donner::gpu::browser::WireTextureFormat ( TextureFormat value)

Code for value, or nullopt if it is not a known enumerator.

Parameters
valueValue to encode.

◆ WireTextureUsage()

std::optional< uint32_t > donner::gpu::browser::WireTextureUsage ( TextureUsage value)

Codes for the flags in value, or nullopt if it carries an unrecognized bit. An empty mask encodes as zero.

Parameters
valueMask to encode.

◆ WireVertexFormat()

std::optional< uint32_t > donner::gpu::browser::WireVertexFormat ( VertexFormat value)

Code for value, or nullopt if it is not a known enumerator.

Parameters
valueValue to encode.

◆ WireVertexStepMode()

std::optional< uint32_t > donner::gpu::browser::WireVertexStepMode ( VertexStepMode value)

Code for value, or nullopt if it is not a known enumerator.

Parameters
valueValue to encode.