Donner SVG Editor & Engine
SVG-native editor and embeddable SVG2 + CSS3 engine in C++20, with GPU (WebGPU) and compact CPU renderers, built for correctness, security, and performance.
Loading...
Searching...
No Matches
GeodeWgpuUtil.h File Reference

Small utility shims on top of the wgpu:: C++ wrapper (from eliemichel/WebGPU-distribution's webgpu.hpp) used throughout the Geode renderer. More...

#include <atomic>
#include <cstdio>
#include <cstdlib>
#include <string_view>
#include <utility>
#include <vector>
#include <webgpu/webgpu.hpp>
Include dependency graph for GeodeWgpuUtil.h:
This graph shows which files directly or indirectly include this file:

Classes

class  donner::geode::ScopedWgpuHandle< Handle >
 Move-only RAII owner for a single WebGPU handle. More...
class  donner::geode::ScopedWgpuResourceArena
 Scoped owner for short-lived WebGPU resources used while recording a command encoder. More...

Namespaces

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

Functions

wgpu::StringView donner::geode::wgpuLabel (const char *text) noexcept
 Wrap a NUL-terminated C string literal in a wgpu::StringView suitable for direct assignment to a descriptor's label field. std::string_view{} handles the strlen() at compile time when the argument is a literal.
wgpu::StringView donner::geode::wgpuLabel (std::string_view text) noexcept
 Wrap an arbitrary std::string_view as a wgpu::StringView. Kept separate from wgpuLabel(const char*) so the common label-literal call path stays trivially copyable without pulling string_view into callers that don't already need it.
bool donner::geode::wgpuForceFallbackAdapterRequested () noexcept
 Whether headless WebGPU creation should request a software fallback adapter. Tests exercise the platform-default hardware adapter unless the environment variable is set explicitly, for example while regenerating deterministic software-rendered goldens.
template<typename Handle>
void donner::geode::ReleaseWgpuHandle (Handle &handle)
 Release a raw WebGPU handle and reset the wrapper to null.

Detailed Description

Small utility shims on top of the wgpu:: C++ wrapper (from eliemichel/WebGPU-distribution's webgpu.hpp) used throughout the Geode renderer.

The vendored webgpu.hpp wraps wgpu-native's C API directly - its wgpu::StringView only has a std::string_view constructor, which makes the otherwise-common descriptor.label = "..." assignment verbose. The helpers in this header exist so the rest of the Geode code can stay readable:

desc.label = wgpuLabel("GeodePipeline");

rather than spelling out the std::string_view wrap at every site. This file also provides a small RAII owner for WebGPU handles returned from create / acquire calls. The vendored webgpu.hpp objects are typed raw handles, not owning smart handles.

Function Documentation

◆ ReleaseWgpuHandle()

template<typename Handle>
void donner::geode::ReleaseWgpuHandle ( Handle & handle)

Release a raw WebGPU handle and reset the wrapper to null.

Template Parameters
HandleA wgpu:: handle type with operator bool() and release().
Parameters
handleOwned raw handle to release.