Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
gpu_proc_installer.hpp
Go to the documentation of this file.
1// gpu_proc_installer.hpp — who installs Dawn's process-global proc table.
2//
3// Dawn's C++ wrappers dispatch every call through one process-wide table of
4// function pointers that must be installed before the first Dawn object is
5// created. GpuSurface and GpuCompute never install it themselves: each calls
6// ensure_dawn_procs() first, and that resolves the process's installer exactly
7// once.
8//
9// By default the installer is Pulp's own: it installs Dawn's native procs once
10// per process. A build configured with PULP_DAWN_PROCS_HOST_OWNED has no
11// default: ensure_dawn_procs() fails until a host registers an installer. An embedding host that owns the table instead (because it
12// authenticates the Dawn build, shares the table with other code, or installs
13// it itself) registers its installer with set_dawn_proc_installer() before any
14// GpuSurface or GpuCompute is created. An installer may install the table, or
15// only verify that the host already did and report failure otherwise; Pulp
16// treats both the same way and creates no Dawn object until one returns true.
17//
18// The header names no Dawn type, so it stays usable from code that links the
19// GPU device API alone.
20#pragma once
21
22#if defined(PULP_GPU_RUNTIME)
23// This build's device layer is gpu-runtime's (tools/cmake/PulpGpuRuntime.cmake):
24// these are its types and functions under their Pulp names, so a Pulp object
25// and a gpu-runtime object are one and the same.
26#include <gpu_runtime/gpu_proc_installer.hpp>
27
28namespace pulp::render {
29using gpu_runtime::DawnProcInstaller;
30using gpu_runtime::ensure_dawn_procs;
31using gpu_runtime::set_dawn_proc_installer;
32} // namespace pulp::render
33#else // !PULP_GPU_RUNTIME
34
35#include <string>
36
37namespace pulp::render {
38
47 bool (*install)(void* context, std::string* error) = nullptr;
48 void* context = nullptr;
49};
50
60[[nodiscard]] bool set_dawn_proc_installer(const DawnProcInstaller& installer,
61 std::string* error = nullptr);
62
70[[nodiscard]] bool ensure_dawn_procs(std::string* error = nullptr);
71
72} // namespace pulp::render
73
74#endif // PULP_GPU_RUNTIME
Definition gpu_fwd.hpp:31
@ error
Definition gpu_diagnostics.hpp:58
bool set_dawn_proc_installer(const DawnProcInstaller &installer, std::string *error=nullptr)
Register the process's Dawn proc-table installer in place of Pulp's native default.
bool ensure_dawn_procs(std::string *error=nullptr)
Make Dawn's proc table usable before creating a Dawn object.
A host-supplied installer for Dawn's process-global proc table.
Definition gpu_proc_installer.hpp:46
bool(* install)(void *context, std::string *error)
Definition gpu_proc_installer.hpp:47
void * context
Definition gpu_proc_installer.hpp:48