Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
device_capability.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <compare>
4#include <cstddef>
5#include <cstdint>
6
24namespace pulp::platform {
25
26// ── Capability tier ────────────────────────────────────────────────────────
27
43enum class DeviceCapabilityTier : std::uint8_t {
46 Full = 2,
47};
48
49inline constexpr std::size_t kDeviceCapabilityTierCount = 3;
50
51// ── Thermal ladder ─────────────────────────────────────────────────────────
52
64enum class ThermalState : std::uint8_t {
66 Fair = 1,
69};
70
71inline constexpr std::size_t kThermalStateCount = 4;
72
73// ── Observable inputs ──────────────────────────────────────────────────────
74
76enum class PointerPrecision : std::uint8_t {
78 Coarse = 0,
80 Fine = 1,
81};
82
120
121// ── Tier projection ────────────────────────────────────────────────────────
122
124inline constexpr std::uint64_t kStandardTierMemoryBytes = 3ull * 1024 * 1024 * 1024;
126inline constexpr std::uint64_t kFullTierMemoryBytes = 8ull * 1024 * 1024 * 1024;
128inline constexpr std::uint32_t kStandardTierCoreCount = 4;
130inline constexpr std::uint32_t kFullTierCoreCount = 8;
131
132namespace detail {
133
135[[nodiscard]] constexpr DeviceCapabilityTier
137 return left < right ? left : right;
138}
139
140} // namespace detail
141
149[[nodiscard]] constexpr DeviceCapabilityTier
151 const DeviceCapabilityTier by_memory =
152 inputs.usable_memory_bytes >= kFullTierMemoryBytes ? DeviceCapabilityTier::Full
153 : inputs.usable_memory_bytes >= kStandardTierMemoryBytes ? DeviceCapabilityTier::Standard
155
156 const DeviceCapabilityTier by_cores =
157 inputs.usable_core_count >= kFullTierCoreCount ? DeviceCapabilityTier::Full
158 : inputs.usable_core_count >= kStandardTierCoreCount ? DeviceCapabilityTier::Standard
160
161 // No realtime render path caps the device at the review-and-perform rung,
162 // whatever its memory and cores: the rungs above it are defined by being
163 // able to render locally.
164 const DeviceCapabilityTier by_realtime = inputs.realtime_render_available
167
168 // Full-tier quotas assume the system will report heat so the consumer can
169 // step down. Without that signal the top rung is not grantable.
170 const DeviceCapabilityTier by_thermal_reporting = inputs.thermal_reporting_available
173
174 // The top rung is precision authoring, which presumes a precise pointer
175 // and modifier keys. Neither bars authoring outright, so each caps at
176 // Standard rather than Constrained.
177 const DeviceCapabilityTier by_pointer = inputs.pointer_precision == PointerPrecision::Fine
180 const DeviceCapabilityTier by_keyboard = inputs.precision_keyboard_available
183
184 DeviceCapabilityTier tier = by_memory;
185 tier = detail::min_tier(tier, by_cores);
186 tier = detail::min_tier(tier, by_realtime);
187 tier = detail::min_tier(tier, by_thermal_reporting);
188 tier = detail::min_tier(tier, by_pointer);
189 tier = detail::min_tier(tier, by_keyboard);
190 return tier;
191}
192
193} // namespace pulp::platform
Definition device_capability.hpp:132
constexpr DeviceCapabilityTier min_tier(DeviceCapabilityTier left, DeviceCapabilityTier right)
Returns the lower of two tiers.
Definition device_capability.hpp:136
Device capability vocabulary: one tier ladder, one thermal ladder, and the projection from observed i...
Definition child_process.hpp:15
constexpr std::uint32_t kStandardTierCoreCount
Core-count floor for DeviceCapabilityTier::Standard.
Definition device_capability.hpp:128
PointerPrecision
Precision of the device's primary pointing device.
Definition device_capability.hpp:76
@ Coarse
Touch or another pointer whose contact area exceeds a small target.
Definition device_capability.hpp:78
@ Fine
Mouse, trackpad, or stylus with sub-target precision.
Definition device_capability.hpp:80
constexpr std::uint64_t kFullTierMemoryBytes
Memory floor for DeviceCapabilityTier::Full.
Definition device_capability.hpp:126
constexpr std::size_t kDeviceCapabilityTierCount
Definition device_capability.hpp:49
constexpr std::uint32_t kFullTierCoreCount
Core-count floor for DeviceCapabilityTier::Full.
Definition device_capability.hpp:130
constexpr std::uint64_t kStandardTierMemoryBytes
Memory floor for DeviceCapabilityTier::Standard.
Definition device_capability.hpp:124
DeviceCapabilityTier
How much of the product a device can carry, on one ascending ladder.
Definition device_capability.hpp:43
@ Full
Definition device_capability.hpp:46
@ Constrained
Definition device_capability.hpp:44
@ Standard
Definition device_capability.hpp:45
constexpr DeviceCapabilityTier project_device_capability_tier(DeviceCapabilityInputs inputs)
Projects observed capabilities onto the tier ladder.
Definition device_capability.hpp:150
ThermalState
Live thermal pressure, ascending in heat.
Definition device_capability.hpp:64
@ Critical
Definition device_capability.hpp:68
@ Serious
Definition device_capability.hpp:67
@ Nominal
Definition device_capability.hpp:65
@ Fair
Definition device_capability.hpp:66
constexpr std::size_t kThermalStateCount
Definition device_capability.hpp:71
What a shell observed about the device it is running on.
Definition device_capability.hpp:88
constexpr auto operator<=>(const DeviceCapabilityInputs &) const =default
PointerPrecision pointer_precision
Precision of the primary pointer.
Definition device_capability.hpp:113
bool realtime_render_available
Whether a realtime render path — a dedicated audio callback fed across a shared memory region — can b...
Definition device_capability.hpp:110
std::uint64_t usable_memory_bytes
Memory the process may actually use, not the memory the device has installed.
Definition device_capability.hpp:92
std::uint32_t usable_core_count
Cores available to this process for sustained work.
Definition device_capability.hpp:95
bool precision_keyboard_available
Whether a physical keyboard with modifier keys is attached.
Definition device_capability.hpp:116
bool thermal_reporting_available
Whether the platform will report thermal pressure at all.
Definition device_capability.hpp:100