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

Test-only wgpu-native implementation of donner::gpu::Device, the reference the Linux resvg comparison renders the production Geode contexts through. More...

#include <atomic>
#include <chrono>
#include <condition_variable>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <memory>
#include <mutex>
#include <span>
#include <string_view>
#include <vector>
#include <webgpu/webgpu.hpp>
#include "donner/base/SmallVector.h"
#include "donner/gpu/Device.h"
#include "donner/svg/renderer/geode/GeodeWgpuUtil.h"
Include dependency graph for GeodeWgpuAdapterDevice.h:

Classes

struct  donner::geode::GeodeWgpuRoots
 The wgpu objects one reference device is reached through, released together. More...
class  donner::geode::WgpuReferenceRoot
 The wgpu objects every reference runtime device records against, and the sticky loss condition they share. More...
struct  donner::geode::WgpuReferenceSelection
 A selected wgpu reference: the Geode root production contexts are created over, and the wgpu objects behind it. More...
class  donner::geode::GeodeWgpuAdapterDevice
 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...
struct  donner::geode::GeodeWgpuAdapterDevice::CompletionState::Pending
 One queued submission, named by the ticket its completion callback retains. More...
struct  donner::geode::GeodeWgpuAdapterDevice::MappingSlot::Completion
 Shared completion state for an asynchronous buffer mapping. More...

Namespaces

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

Functions

WgpuReferenceSelection donner::geode::SelectWgpuReference (std::string_view label)
 Selects the wgpu-native reference: creates an instance, requests an adapter and a device, and takes the default queue, then adopts them as a Geode root whose runtime devices are GeodeWgpuAdapterDevice instances.
std::unique_ptr< GeodeDevice > donner::geode::CreateWgpuReferenceContext (gpu::TextureFormat textureFormat=gpu::TextureFormat::RGBA8Unorm)
 Creates a headless Geode context over a newly selected wgpu reference.
gpu::TextureFormat donner::geode::GpuTextureFormatFromWgpu (wgpu::TextureFormat format)
 Maps a wgpu render-target format onto the donner::gpu format enum.
wgpu::TextureFormat donner::geode::WgpuTextureFormatFrom (gpu::TextureFormat format)
 Maps a donner::gpu render-target format onto the wgpu format enum, for the call sites that still describe a backend texture.

Detailed Description

Test-only wgpu-native implementation of donner::gpu::Device, the reference the Linux resvg comparison renders the production Geode contexts through.

Function Documentation

◆ CreateWgpuReferenceContext()

std::unique_ptr< GeodeDevice > donner::geode::CreateWgpuReferenceContext ( gpu::TextureFormat textureFormat = gpu::TextureFormat::RGBA8Unorm)

Creates a headless Geode context over a newly selected wgpu reference.

Parameters
textureFormatFormat the context's render targets and pipelines are built for.
Returns
The context, or null when SelectWgpuReference found no adapter or device.

◆ GpuTextureFormatFromWgpu()

gpu::TextureFormat donner::geode::GpuTextureFormatFromWgpu ( wgpu::TextureFormat format)

Maps a wgpu render-target format onto the donner::gpu format enum.

Halts (release assert) on formats outside the runtime's supported set - RGBA8Unorm, BGRA8Unorm, R8Unorm - which are the only formats Geode's shaders and render targets are built for.

Parameters
formatwgpu texture format to map.

◆ SelectWgpuReference()

WgpuReferenceSelection donner::geode::SelectWgpuReference ( std::string_view label)

Selects the wgpu-native reference: creates an instance, requests an adapter and a device, and takes the default queue, then adopts them as a Geode root whose runtime devices are GeodeWgpuAdapterDevice instances.

WGPU_BACKEND names the wgpu backend (vulkan, metal, opengl or opengles; Vulkan when unset on Linux), and DONNER_GEODE_FORCE_FALLBACK_ADAPTER=1 requests wgpu's fallback adapter. Adapter and device requests that fail under parallel load are retried on a short logged schedule.

The production contexts, renderer and caches drive the reference only through the runtime contract, so a comparison against it exercises the same Geode code as a native backend.

Parameters
labelLabel the selected device carries in driver diagnostics.
Returns
The selection, with both members null when no adapter or device could be obtained.

◆ WgpuTextureFormatFrom()

wgpu::TextureFormat donner::geode::WgpuTextureFormatFrom ( gpu::TextureFormat format)

Maps a donner::gpu render-target format onto the wgpu format enum, for the call sites that still describe a backend texture.

Halts (release assert) on a format the backend cannot name.

Parameters
formatRuntime texture format to map.