| // Generated by src/wasm/idl/generate.py from lane_layout.py. Do not edit. | |
| // | |
| // The numbers lanes and their hosts agree on, which librive and the | |
| // bake both read. | |
| #ifndef _RIVE_WASM_LANE_LAYOUT_GEN_HPP_ | |
| #define _RIVE_WASM_LANE_LAYOUT_GEN_HPP_ | |
| #include <algorithm> | |
| #include <cmath> | |
| #include <cstdint> | |
| #include <string> | |
| #include <string_view> | |
| // clang-format off | |
| namespace rive | |
| { | |
| /// The rive_lanes_v1 lane kinds. | |
| enum class LaneKind : uint32_t | |
| { | |
| job = 0, | |
| worker = 1, | |
| processor = 2, | |
| }; | |
| /// The rive_lanes_v1 states every lane moves through. | |
| enum class LaneState : uint32_t | |
| { | |
| starting = 0, | |
| running = 1, | |
| done = 2, | |
| failed = 3, | |
| stopped = 4, | |
| }; | |
| /// The main module section each kind's lane module rides in. | |
| constexpr const char* kLaneSections[] = { | |
| "rive.jobs", | |
| "rive.workers", | |
| "rive.audio", | |
| }; | |
| /// The main module section beside each kind's lane module that names | |
| /// its entries in order: a count, then each name after its length. | |
| constexpr const char* kLaneNameSections[] = { | |
| "rive.jobs.names", | |
| "rive.workers.names", | |
| "rive.audio.names", | |
| }; | |
| /// Each lane kind's name, by LaneKind. | |
| constexpr const char* kLaneKindNames[] = {"job", "worker", "processor"}; | |
| /// How messages name each kind's lane module, as the bake does. | |
| constexpr const char* kLaneModuleNames[] = { | |
| "jobs module", | |
| "workers module", | |
| "processors module", | |
| }; | |
| /// What each kind's lane fails with when it trapped without a message. | |
| constexpr const char* kLaneTrapTexts[] = { | |
| "job trapped", | |
| "worker trapped", | |
| "processor trapped", | |
| }; | |
| /// The prefix each kind's entries export under, before their number. | |
| constexpr const char* kLaneEntryPrefixes[] = { | |
| "__rive_job_", | |
| "__rive_worker_", | |
| "__rive_processor_", | |
| }; | |
| namespace lane_layout | |
| { | |
| // What join answers instead of a state when the joiner holds a shared region. | |
| constexpr uint32_t kJoinRefused = 5; | |
| // What start answers instead of a lane when the section is there but its module | |
| // failed to load; failed then answers the load error for it. | |
| constexpr uint32_t kStartFailed = 0xffffffff; | |
| // What join_any answers when the joiner holds a shared region. | |
| constexpr uint32_t kJoinAnyRefused = 0xffffffff; | |
| // What a processor event carries for a console line, in place of a state. | |
| constexpr uint32_t kProcessorEventLog = 0xffffffff; | |
| // The most 64 KiB pages a job instance's memory may have grown to for another | |
| // job to reuse it, as memory never shrinks. | |
| constexpr uint32_t kReuseMaxPages = 256; | |
| // How long a processor's init may run in milliseconds, natively per step and in | |
| // a worklet as a whole, far longer than a block as it may build tables. | |
| constexpr uint32_t kProcessorInitMs = 1000; | |
| // Where a parallel call's control block keeps each word, in bytes from its | |
| // start. The words its parts race on sit 128 bytes apart, each alone on a cache | |
| // line, Apple's included. The claim takes 8 bytes, so no grain can wrap it. | |
| constexpr uint32_t kParallelThunk = 0; | |
| constexpr uint32_t kParallelArgs = 4; | |
| constexpr uint32_t kParallelParts = 8; | |
| constexpr uint32_t kParallelCount = 12; | |
| constexpr uint32_t kParallelAtOnce = 16; | |
| constexpr uint32_t kParallelCallerParks = 20; | |
| constexpr uint32_t kParallelGeneration = 128; | |
| constexpr uint32_t kParallelArrived = 256; | |
| constexpr uint32_t kParallelSleepers = 384; | |
| constexpr uint32_t kParallelClaim = 512; | |
| constexpr uint32_t kParallelStop = 640; | |
| constexpr uint32_t kParallelBytes = 768; | |
| // The exports a lane module may carry besides its entries. | |
| constexpr const char* kLaneAllocExport = "__rive_lane_alloc"; | |
| constexpr const char* kLaneFreeExport = "__rive_lane_free"; | |
| constexpr const char* kHostBudgetExport = "__riveHostBudget"; | |
| constexpr const char* kFuelCheckExport = "__riveFuelCheck"; | |
| constexpr const char* kWorkerWakeExport = "__rive_worker_wake"; | |
| constexpr const char* kProcessorProcessExport = "__rive_processor_process"; | |
| constexpr const char* kFrameMinorExport = "__riveFrameMinor"; | |
| constexpr const char* kLiftedStartExport = "__riveLiftedStart"; | |
| constexpr const char* kLaneResetExport = "__riveLaneReset"; | |
| // What an awaited wait settles with when it timed out. | |
| constexpr double kWaitTimedOut = -1; | |
| // What an awaited wait settles with inside a worker being stopped. | |
| constexpr double kWaitStopping = -2; | |
| // What an awaited wait settles with when its signal is gone, as when the ring | |
| // or port it waits on was released. | |
| constexpr double kWaitGone = -3; | |
| // What wait_within answers when the waiter holds a shared region. | |
| constexpr double kWaitRefused = -4; | |
| // What lanes report the same way on every host. | |
| constexpr const char* kProcessorHolds = "a processor cannot pass shared objects through rings or snapshots, as the audio thread may not hold or give them back; pass them in Audio.start's argument"; | |
| constexpr const char* kProcessorOverran = "processor overran its block budget"; | |
| constexpr const char* kProcessorInitOverran = "processor init overran its budget"; | |
| constexpr const char* kProcessorNode = "rive-processors"; | |
| // A processor block's budget in milliseconds, first for its first block; 0 for none. | |
| inline uint32_t processorBlockBudgetMs(uint32_t hardBlocks, uint32_t frames, double sampleRate, bool first) | |
| { | |
| // A rate of 0 or a huge hard limit must not overflow the cast. | |
| return (uint32_t)std::min(4294967295.0, hardBlocks == 0 ? 0.0 : std::max(first ? 100.0 : 1.0, std::ceil(hardBlocks * 1000.0 * frames / sampleRate))); | |
| } | |
| // Why a lane module that imports module.name cannot load. | |
| inline std::string laneImportError(std::string_view module, | |
| std::string_view name) | |
| { | |
| return "lane module imports " + std::string(module) + "." + std::string(name) + ", which it cannot reach"; | |
| } | |
| } // namespace lane_layout | |
| } // namespace rive | |
| #endif |