upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src
diff options
context:
space:
mode:
authorTyrannys <80750971+Tyrannys@users.noreply.github.com>2026-11-27 05:46:06 -0600
committerTyrannys <80750971+Tyrannys@users.noreply.github.com>2026-11-27 05:46:06 -0600
commit8f59df0fb0ea33447dd8d4b2fd67de0798b0fbfc (patch)
tree1d60e03331da2f94e18f811d8df29ea85f2d03b7 /runtime/src
parent03ec559ac1a829f9ff2c7f6c425e05b65f30df64 (diff)
parent63185f4a35961916afbdc24b2ae989cbe88892be (diff)
Merge remote-tracking branch 'upstream/main' into claude/rt-async-compile-pool
# Conflicts: # docs/d3d12_vulkan.md
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/async_pipeline_size.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/runtime/src/async_pipeline_size.h b/runtime/src/async_pipeline_size.h
new file mode 100644
index 000000000..3146224c1
--- /dev/null
+++ b/runtime/src/async_pipeline_size.h
@@ -0,0 +1,40 @@
1// Which pipelines LEONIDA_ASYNC_PIPELINES=1 builds asynchronously, by size (LEONIDA_ASYNC_MIN_BYTES). Pure stdlib, so
2// async_pipeline_size_test checks it without a device; shims/d3d12_pipeline_compile.h reads the variables.
3//
4// An asynchronous pipeline that is not built yet has its draws and dispatches skipped until the compile worker has
5// it (queue_build in shims/d3d12_vulkan_device.cpp). With every pipeline asynchronous the small lighting and post
6// programs are skipped with the large ones, and the screen can stay black for as long as anything is compiling; with
7// none, a submission waits minutes for each large ray-tracing program. LEONIDA_ASYNC_MIN_BYTES=<n> splits the two: a
8// pipeline with less than n bytes of SPIR-V (compute: its module; graphics: all its stages) is built where it is
9// needed, as without LEONIDA_ASYNC_PIPELINES, and only one of n bytes or more is asynchronous.
10#pragma once
11
12#include <cstdint>
13
14namespace leonida::async_pipelines {
15
16// LEONIDA_ASYNC_MIN_BYTES as text: decimal bytes. 0 (every pipeline asynchronous, as without the variable) for null,
17// empty, "0" or text that is not a whole decimal number; `valid` (when given) says whether the text was usable, so the
18// caller can say that it ignored it.
19inline std::uint64_t parse_min_bytes(const char* text, bool* valid = nullptr) {
20 if (valid) *valid = true;
21 if (!text || !*text) return 0;
22 std::uint64_t value = 0;
23 for (const char* c = text; *c; ++c) {
24 const std::uint64_t digit = std::uint64_t(*c - '0');
25 if (*c < '0' || *c > '9' || value > (UINT64_MAX - digit) / 10) { // not a digit, or over 2^64 - 1
26 if (valid) *valid = false;
27 return 0;
28 }
29 value = value * 10 + digit;
30 }
31 return value;
32}
33
34// Whether a pipeline of `spirv_bytes` is built asynchronously: only with asynchronous builds on, and then when no
35// threshold is set (0) or the pipeline is at least that large.
36inline bool asynchronous(bool async_on, std::uint64_t min_bytes, std::uint64_t spirv_bytes) {
37 return async_on && (min_bytes == 0 || spirv_bytes >= min_bytes);
38}
39
40} // namespace leonida::async_pipelines