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

Browser GPU root selection. More...

#include <cstdint>
#include <memory>
#include <optional>
#include <ostream>
#include <string_view>
#include "donner/base/Utils.h"
#include "donner/gpu/Device.h"
Include dependency graph for GeodeBrowserRoot.h:

Classes

struct  donner::geode::GeodeGpuRootCapabilities
 Capabilities shared by runtime devices opened over one browser GPU device. More...
class  donner::geode::GeodeGpuRoot
 Owns the browser GPU device and loss condition shared by logical Geode contexts. More...
struct  donner::geode::GpuRootSelection
 Inputs to browser-root selection. A named unsupported backend is refused. More...
struct  donner::geode::GeodeRuntimeDevice
 One logical runtime device over the selected browser root. More...

Namespaces

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

Enumerations

enum class  donner::geode::GpuBackendKind : uint8_t {
  NativeMetal ,
  NativeVulkan ,
  Browser ,
  NativeMetal ,
  NativeVulkan ,
  Browser ,
  External
}
 The backend selected for a Geode runtime device. More...

Functions

std::string_view donner::geode::GpuBackendKindName (GpuBackendKind kind)
 Human-readable name of a selected backend.
std::ostream & donner::geode::operator<< (std::ostream &os, GpuBackendKind kind)
 Prints the kind's human-readable name.
gpu::Result< GpuBackendKind > donner::geode::ProcessDefaultGpuBackendKind ()
 In WebAssembly builds, the backend DONNER_GPU_BACKEND requests, or the browser backend when it is unset or empty.
std::optional< GpuBackendKind > donner::geode::BuildDefaultGpuBackendKind ()
 In WebAssembly builds, the browser backend, selected when nothing else names a backend.
gpu::Result< GpuBackendKind > donner::geode::ResolveGpuBackendKind (const GpuRootSelection &options, std::string_view request, std::optional< GpuBackendKind > buildDefault)
 In WebAssembly builds, resolves the caller's backend, then DONNER_GPU_BACKEND, then the build default, without opening a device.
std::shared_ptr< GeodeGpuRoot > donner::geode::SelectGpuRoot (const GpuRootSelection &options)
 In WebAssembly builds, opens the browser's GPU device as a root. When the caller names no backend, halts if DONNER_GPU_BACKEND is invalid or names a native backend. A caller-named native backend halts when DONNER_GPU_BACKEND is non-empty and returns null otherwise. Also returns null when the device request fails.
GeodeRuntimeDevice donner::geode::CreateGpuDeviceOver (std::shared_ptr< GeodeGpuRoot > root)
 In WebAssembly builds, opens one runtime device over the browser root, sharing its loss condition.

Detailed Description

Browser GPU root selection.

Enumeration Type Documentation

◆ GpuBackendKind

enum class donner::geode::GpuBackendKind : uint8_t
strong

The backend selected for a Geode runtime device.

Enumerator
External 

Runtime devices a GeodeRuntimeDeviceSource opens. Never selected: only adopting a source produces it.

Function Documentation

◆ CreateGpuDeviceOver()

GeodeRuntimeDevice donner::geode::CreateGpuDeviceOver ( std::shared_ptr< GeodeGpuRoot > root)

In WebAssembly builds, opens one runtime device over the browser root, sharing its loss condition.

Opens one runtime device over root.

Every logical rendering context gets its own, with its own handle tables and submission serials, while all of them share the root's loss condition.

Parameters
rootRoot to render through; must not be null.
Returns
The device, or an empty device when the backend could not open one.

◆ GpuBackendKindName()

std::string_view donner::geode::GpuBackendKindName ( GpuBackendKind kind)

Human-readable name of a selected backend.

Parameters
kindBackend kind to name.

◆ operator<<()

std::ostream & donner::geode::operator<< ( std::ostream & os,
GpuBackendKind kind )

Prints the kind's human-readable name.

Parameters
osOutput stream.
kindValue to output.

◆ ProcessDefaultGpuBackendKind()

gpu::Result< GpuBackendKind > donner::geode::ProcessDefaultGpuBackendKind ( )

In WebAssembly builds, the backend DONNER_GPU_BACKEND requests, or the browser backend when it is unset or empty.

The backend DONNER_GPU_BACKEND requests: metal or vulkan in any letter case, or the platform default (native Metal on Apple, native Vulkan on Linux) when the variable is unset or empty.

Returns
The kind, or an error when the variable names no backend or the platform has no native backend.

◆ ResolveGpuBackendKind()

gpu::Result< GpuBackendKind > donner::geode::ResolveGpuBackendKind ( const GpuRootSelection & options,
std::string_view request,
std::optional< GpuBackendKind > buildDefault )

In WebAssembly builds, resolves the caller's backend, then DONNER_GPU_BACKEND, then the build default, without opening a device.

Parameters
optionsCaller-supplied inputs.
requestValue of DONNER_GPU_BACKEND; empty when it is unset or empty.
buildDefaultBackend chosen when nothing names one; the browser backend when empty.
Returns
The kind, or an error when the caller names no backend and a non-empty request names none.

◆ SelectGpuRoot()

std::shared_ptr< GeodeGpuRoot > donner::geode::SelectGpuRoot ( const GpuRootSelection & options)

In WebAssembly builds, opens the browser's GPU device as a root. When the caller names no backend, halts if DONNER_GPU_BACKEND is invalid or names a native backend. A caller-named native backend halts when DONNER_GPU_BACKEND is non-empty and returns null otherwise. Also returns null when the device request fails.

Selects a native backend root for options and opens the system device behind it.

Halts the process when the Vulkan presentation options are inconsistent with each other or with the resolved backend. When the caller names no backend and DONNER_GPU_BACKEND controls selection, it also halts if the variable names no backend or one this process cannot open: an explicit process request is never silently replaced with another backend.

Parameters
optionsCaller-supplied inputs.
Returns
The root, or null when a caller-named or platform-default backend cannot be opened or this build cannot serve it.