3#if defined(PULP_GPU_RUNTIME)
7#include <gpu_runtime/gpu_surface.hpp>
10using gpu_runtime::GpuSurface;
11using gpu_runtime::SwapchainResizeState;
32 requested_width_ =
width;
33 requested_height_ =
height;
38 configured_width_ = requested_width_;
39 configured_height_ = requested_height_;
52 return requested_width_ != 0 && requested_height_ != 0;
57 return presentable() && (!configured_ || requested_width_ != configured_width_ ||
58 requested_height_ != configured_height_);
83 return requested_width_;
86 return requested_height_;
90 uint32_t requested_width_ = 0;
91 uint32_t requested_height_ = 0;
92 uint32_t configured_width_ = 0;
93 uint32_t configured_height_ = 0;
94 bool configured_ =
false;
95 uint32_t stable_frames_ = 0;
147 std::string
name =
"Mock Dawn Adapter";
Abstract GPU surface — a presentable rendering target backed by a native window/view.
Definition gpu_surface.hpp:112
virtual bool initialize(const Config &config)=0
virtual void * dawn_queue_handle() const =0
virtual void end_frame()=0
Present to native surface (or just process events if offscreen).
virtual void * current_texture_handle() const =0
The current presentable texture, valid only between begin_frame/end_frame.
virtual bool is_initialized() const =0
virtual ~GpuSurface()=default
virtual void * dawn_device_handle() const =0
Opaque accessors for the Dawn device/queue/texture.
virtual SwapchainStats swapchain_stats() const
Kept at the vtable tail for the same reason as startup_timings().
Definition gpu_surface.hpp:270
virtual AdapterInfo adapter_info() const =0
Snapshot describing the current adapter/device state for higher-level bridges.
static std::unique_ptr< GpuSurface > create_dawn()
virtual uint32_t height() const =0
virtual void * dawn_instance_handle() const =0
virtual uint32_t width() const =0
virtual bool has_surface() const =0
virtual StartupTimings startup_timings() const
Stage timings recorded by the most recent initialize() call.
Definition gpu_surface.hpp:256
virtual bool begin_frame()=0
Acquire the current presentable texture, first configuring the swapchain if the size changed since th...
virtual void resize(uint32_t width, uint32_t height)=0
Record a new size.
AdapterType
Native adapter type reported by Dawn/WebGPU.
Definition gpu_surface.hpp:117
@ integrated_gpu
Definition gpu_surface.hpp:119
@ discrete_gpu
Definition gpu_surface.hpp:120
@ unknown
Definition gpu_surface.hpp:118
@ cpu
Definition gpu_surface.hpp:121
AdapterBackendPreference
Definition gpu_surface.hpp:124
@ d3d12
Use the D3D12 backend without Dawn's fallback-adapter hint.
Definition gpu_surface.hpp:133
@ null_backend
Definition gpu_surface.hpp:126
@ vulkan
Use the Vulkan backend without Dawn's fallback-adapter hint.
Definition gpu_surface.hpp:130
@ default_backend
Definition gpu_surface.hpp:125
Decides when a presentable swapchain has to be (re)configured.
Definition gpu_surface.hpp:28
void note_frame(bool configured)
Record a presented frame.
Definition gpu_surface.hpp:63
static constexpr uint32_t kSettleFrames
Definition gpu_surface.hpp:79
bool settled() const
Settled: the last kSettleFrames frames presented without configuring, and no resize is pending,...
Definition gpu_surface.hpp:75
uint32_t height() const
Definition gpu_surface.hpp:85
uint32_t width() const
The requested size, which is what GpuSurface::width()/height() report.
Definition gpu_surface.hpp:82
void invalidate()
Make the next frame configure even at an unchanged size, for a swapchain the surface reported as subo...
Definition gpu_surface.hpp:45
bool needs_configure() const
True when the next frame must configure before it acquires a texture.
Definition gpu_surface.hpp:56
bool presentable() const
A zero dimension (a minimised or collapsed window) has nothing to present, and a swapchain cannot be ...
Definition gpu_surface.hpp:51
void mark_configured()
The swapchain now matches the requested size.
Definition gpu_surface.hpp:37
void request(uint32_t width, uint32_t height)
Record the size the host wants. Configures nothing.
Definition gpu_surface.hpp:31
Definition gpu_fwd.hpp:31
Definition gpu_surface.hpp:136
std::string name
Definition gpu_surface.hpp:147
AdapterType adapter_type
Definition gpu_surface.hpp:139
bool available
Definition gpu_surface.hpp:137
std::string backend
Definition gpu_surface.hpp:145
std::string backend_type
Definition gpu_surface.hpp:146
std::string description
Definition gpu_surface.hpp:150
std::string architecture
Definition gpu_surface.hpp:149
std::string vendor
Definition gpu_surface.hpp:148
std::string preferred_canvas_format
Definition gpu_surface.hpp:151
bool null_backend
Authoritative backend classification reported by Dawn/WebGPU.
Definition gpu_surface.hpp:144
bool native_bridge
Definition gpu_surface.hpp:138
Definition gpu_surface.hpp:154
bool force_fallback_adapter
Definition gpu_surface.hpp:175
AdapterBackendPreference backend_preference
Definition gpu_surface.hpp:176
uint32_t width
Definition gpu_surface.hpp:155
bool enable_gpu_timing
Request Dawn's timestamp-query feature for GPU render timing.
Definition gpu_surface.hpp:173
uint32_t height
Definition gpu_surface.hpp:156
bool vsync
Definition gpu_surface.hpp:157
void * native_surface_handle
Opaque platform-specific handle for on-screen rendering.
Definition gpu_surface.hpp:187
Wall-clock milliseconds spent in each stage of initialize(), measured with a monotonic clock.
Definition gpu_surface.hpp:243
double surface_ms
Native surface creation plus the first swapchain configure.
Definition gpu_surface.hpp:250
double instance_ms
Definition gpu_surface.hpp:244
double device_ms
Device request, including feature and toggle negotiation.
Definition gpu_surface.hpp:248
double adapter_ms
Adapter request (RequestAdapter / EnumerateAdapters).
Definition gpu_surface.hpp:246
Swapchain configurations issued since initialize(), the first one included, their total wall-clock mi...
Definition gpu_surface.hpp:262
bool settled
SwapchainResizeState::settled(): the size has held for two frames.
Definition gpu_surface.hpp:266
double configure_ms
Definition gpu_surface.hpp:264
uint64_t configure_count
Definition gpu_surface.hpp:263
Typed X11 surface handle.
Definition gpu_surface.hpp:196
unsigned long window
Definition gpu_surface.hpp:198
void * display
Definition gpu_surface.hpp:197