From 092834570c102f8a02ba2a9740559bf2eb97209c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=9A=D0=BE?= =?UTF-8?q?=D1=80=D0=BB=D0=BE=D0=B4=D0=BD=D1=8B=D0=B9?= Date: Mon, 30 Nov 2026 13:59:17 +0000 Subject: [PATCH 1/2] mem-probe: the breakdown line says how much of each part is in host memory (RT-MEM-PROBE-HOST-SHARE) The breakdown splits the runtime's allocations by consumer but not by where they landed; the memory types are only on the mem-probe t= line, summed over every consumer. A texture that did not fit in the card's memory, or the arena on a type without DEVICE_LOCAL, was not told apart from one in the card's memory. Each part now adds its share in memory types outside the device-local heaps ("sampled textures 2300 (412; 870 in host memory)"), and "in host memory" sums them after the parts. Imported memory stays apart, as before. Diagnostic only: nothing changes what is allocated or where. memory_breakdown_test: a new host_share case and the total in text(); it passes natively (g++) and as a clang-cl build under Wine, and fails with the host part no longer counted. mem_probe.h type-checks with clang-cl /Zs. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01JPqXc6svM4pbBagTsVEYA3 --- runtime/README.md | 2 +- runtime/src/mem_probe.h | 4 ++- runtime/src/memory_breakdown.h | 35 ++++++++++++++++++++++---- runtime/test/memory_breakdown_test.cpp | 35 ++++++++++++++++++++++++-- 4 files changed, 67 insertions(+), 9 deletions(-) diff --git a/runtime/README.md b/runtime/README.md index 62b7db7bcc..ff06fea2f3 100644 --- a/runtime/README.md +++ b/runtime/README.md @@ -409,7 +409,7 @@ ones marked *diagnostic* only add log lines or exist to compare a run with and w | `LEONIDA_INPUT_TRACE` | unset | `1` (diagnostic, the GameInput shim built without SDL3) logs the title's reading calls on the scripted pad: the first 128, then each one with a button down and every 1000th. Details in [docs/gameinput.md](../docs/gameinput.md#scripted-input-without-sdl3). | | `LEONIDA_LOG_ALLOCINFO` | unset | *Diagnostic.* `1` logs every device slot 25 call (`GetResourceAllocationInfo`) with its thread, description and sizes (`shims/d3d12_xs_device.cpp`). | | `LEONIDA_LOG_EXE_PIPELINES` | unset | *Diagnostic.* When set, one line per distinct graphics pipeline that uses a program translated from the executable's inline containers. | -| `LEONIDA_MEM_PROBE` | unset | *Diagnostic.* ``: every that many seconds the memory probe (`src/mem_probe.h`) logs `[rt] mem-probe t=` (live pipelines, shader modules and `VkDeviceMemory` per memory type), `[rt] mem-probe breakdown t=` (the same allocated bytes by consumer: the arena with its reserved, bound and in-use MiB, geometry copies, title windows and shadows, upload heaps, staging, texture blocks, sampled textures, render targets and depth, and `other`, which add up to the allocated total; `src/memory_breakdown.h`) and `[rt] mem-probe smaps` (the process's resident memory by kind). | +| `LEONIDA_MEM_PROBE` | unset | *Diagnostic.* ``: every that many seconds the memory probe (`src/mem_probe.h`) logs `[rt] mem-probe t=` (live pipelines, shader modules and `VkDeviceMemory` per memory type), `[rt] mem-probe breakdown t=` (the same allocated bytes by consumer: the arena with its reserved, bound and in-use MiB, geometry copies, title windows and shadows, upload heaps, staging, texture blocks, sampled textures, render targets and depth, and `other`, which add up to the allocated total, each with the part in host memory when it has one, e.g. `sampled textures 2300 (412; 870 in host memory)`, then `in host memory` for all of them: memory types outside the device-local heaps, which the GPU reads over the bus; `src/memory_breakdown.h`) and `[rt] mem-probe smaps` (the process's resident memory by kind). | | `LEONIDA_MEM_PROBE_CACHE` | unset | *Diagnostic.* `1` adds the pipeline cache's size to the memory probe's report; the driver serializes the whole cache to answer. | | `LEONIDA_TEXTURE_PROBE` | unset | *Diagnostic.* Logs a `[rt] texture-probe` line for every shader resource view of a texture in the title's memory. | | `LEONIDA_LOCAL_DIAGNOSTICS` | unset | *Diagnostic.* `1` turns on the boot diagnostics that write to stderr from the draw, clear, present and descriptor paths (the lines tagged `present-probe`, `fsdraw`, `heap-probe`, `desc-probe` and `PresentX diag`; `src/local_diagnostics.h`). They follow a frame of the title from its draws to the window and cost a lock and a line per draw, so they are off by default. The full-screen draw targets that `LEONIDA_CAPTURE_SOURCE` reads back are only collected with it. | diff --git a/runtime/src/mem_probe.h b/runtime/src/mem_probe.h index f8c573da49..e3f1b98015 100644 --- a/runtime/src/mem_probe.h +++ b/runtime/src/mem_probe.h @@ -547,7 +547,9 @@ inline void sample(const DeviceFacts& facts) { type_bytes[i] += a.bytes; } if (a.mapped && !a.imported) vk_mapped.push_back({a.mapped, a.mapped + a.mapped_bytes}); - tally.add(a.consumer, a.bytes, a.imported); + const bool host = i < facts.memory.memoryTypeCount && + !(facts.memory.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); + tally.add(a.consumer, a.bytes, a.imported, host); } modules = s.modules.size(); module_bytes = s.module_bytes; diff --git a/runtime/src/memory_breakdown.h b/runtime/src/memory_breakdown.h index f7963b1f58..d9e44e3e78 100644 --- a/runtime/src/memory_breakdown.h +++ b/runtime/src/memory_breakdown.h @@ -12,6 +12,9 @@ // buffer when the image is an attachment, else a sampled texture (image_consumer()). // Memory named neither way is "other", so the parts always sum to the total. // +// Each part also says how much of it is in host memory: a memory type outside the device-local heaps, which the GPU +// reads over the bus (a texture that did not fit in the card's memory, the arena on a type without DEVICE_LOCAL). +// // Pure standard library (the usage bits are passed in as plain integers), so the tally and the text are tested // without a GPU or Windows (memory_breakdown_test). @@ -83,12 +86,14 @@ class Owner { }; // Live allocations per consumer. Imported memory (host pointers, the title's own pages) is system memory the runtime -// did not allocate, so it is kept apart, as the probe's total keeps it apart. +// did not allocate, so it is kept apart, as the probe's total keeps it apart. `host`: the allocation's memory type is +// not DEVICE_LOCAL; host_bytes and host_count are the part of bytes and count in such types. struct Tally { std::array bytes{}, count{}; + std::array host_bytes{}, host_count{}; std::uint64_t imported_bytes = 0, imported_count = 0; - void add(Consumer consumer, std::uint64_t size, bool imported) { + void add(Consumer consumer, std::uint64_t size, bool imported, bool host = false) { if (imported) { imported_bytes += size; ++imported_count; @@ -97,12 +102,21 @@ struct Tally { const std::size_t i = std::size_t(consumer) < kConsumers ? std::size_t(consumer) : 0; bytes[i] += size; ++count[i]; + if (host) { + host_bytes[i] += size; + ++host_count[i]; + } } std::uint64_t total() const { std::uint64_t sum = 0; for (const std::uint64_t b : bytes) sum += b; return sum; } + std::uint64_t host_total() const { + std::uint64_t sum = 0; + for (const std::uint64_t b : host_bytes) sum += b; + return sum; + } }; // What the device knows about the arena and the tables outside the probe's wrapped allocations. @@ -123,7 +137,8 @@ struct DeviceShare { inline double mib(std::uint64_t bytes) { return double(bytes) / 1048576.0; } // The breakdown line's text after "[rt] mem-probe breakdown t=: ". Every consumer is printed, zero or not, so a -// reader can line up two ticks; the figures are whole MiB. +// reader can line up two ticks; the figures are whole MiB. A consumer with memory in host memory adds how much to its +// count ("sampled textures 2300 (412; 870 in host memory)"), and the total in host memory follows the parts. inline std::string format(const Tally& tally, const DeviceShare& device, std::uint64_t module_bytes) { std::string out; char item[256]; @@ -132,8 +147,13 @@ inline std::string format(const Tally& tally, const DeviceShare& device, std::ui bool first = true; for (std::size_t i = 1; i <= kConsumers; ++i) { const std::size_t c = i % kConsumers; // "other" last - std::snprintf(item, sizeof item, "%s %s %.0f (%llu)", first ? "" : " +", consumer_name(Consumer(c)), - mib(tally.bytes[c]), (unsigned long long)tally.count[c]); + if (tally.host_count[c]) + std::snprintf(item, sizeof item, "%s %s %.0f (%llu; %.0f in host memory)", first ? "" : " +", + consumer_name(Consumer(c)), mib(tally.bytes[c]), (unsigned long long)tally.count[c], + mib(tally.host_bytes[c])); + else + std::snprintf(item, sizeof item, "%s %s %.0f (%llu)", first ? "" : " +", consumer_name(Consumer(c)), + mib(tally.bytes[c]), (unsigned long long)tally.count[c]); out += item; first = false; if (Consumer(c) == Consumer::arena && device.arena) { @@ -168,6 +188,11 @@ inline std::string format(const Tally& tally, const DeviceShare& device, std::ui out += item; } } + std::uint64_t host_count = 0; + for (const std::uint64_t n : tally.host_count) host_count += n; + std::snprintf(item, sizeof item, "; in host memory %.0f MiB (%llu)", mib(tally.host_total()), + (unsigned long long)host_count); + out += item; std::snprintf(item, sizeof item, "; imported %.0f MiB (%llu); not in the total: bindless tables %.0f MiB (own function table), shader " "modules %.0f MiB SPIR-V, pipelines and swapchain images (the driver's)", diff --git a/runtime/test/memory_breakdown_test.cpp b/runtime/test/memory_breakdown_test.cpp index fd99fda42f..56abd2cd84 100644 --- a/runtime/test/memory_breakdown_test.cpp +++ b/runtime/test/memory_breakdown_test.cpp @@ -1,5 +1,5 @@ // leonida::memory_breakdown (src/memory_breakdown.h): the mem probe's breakdown line. The tally of synthetic -// allocations by consumer adds up to the allocated total, an Owner scope names the allocations made under it and +// allocations by consumer adds up to the allocated total with the part in host memory, an Owner scope names the allocations made under it and // nests, an image's usage picks its kind, and the text names every part. No GPU, no device. #include "../src/memory_breakdown.h" @@ -40,6 +40,36 @@ int tally() { std::uint64_t sum = 0; for (std::size_t i = 0; i < mb::kConsumers; ++i) sum += t.bytes[i]; EXPECT(sum == t.total()); + EXPECT(t.host_total() == 0); + return 0; +} + +// The part in host memory: counted in the consumer's bytes and count as well, never for imported memory, and an +// unknown consumer's goes to other. +int host_share() { + mb::Tally t; + t.add(mb::Consumer::sampled, 900 * kMiB, false, false); + t.add(mb::Consumer::sampled, 870 * kMiB, false, true); + t.add(mb::Consumer::sampled, 30 * kMiB, false, true); + t.add(mb::Consumer::arena, 4095 * kMiB, false, true); + t.add(mb::Consumer::render_target, 1180 * kMiB, false, false); + t.add(mb::Consumer::count, 2 * kMiB, false, true); // out of range: other + t.add(mb::Consumer::windows, 6 * kMiB, true, true); // imported: neither allocated nor in the host part + EXPECT(t.total() == (1800 + 4095 + 1180 + 2) * kMiB); + EXPECT(t.bytes[std::size_t(mb::Consumer::sampled)] == 1800 * kMiB); + EXPECT(t.count[std::size_t(mb::Consumer::sampled)] == 3); + EXPECT(t.host_bytes[std::size_t(mb::Consumer::sampled)] == 900 * kMiB); + EXPECT(t.host_count[std::size_t(mb::Consumer::sampled)] == 2); + EXPECT(t.host_bytes[std::size_t(mb::Consumer::render_target)] == 0); + EXPECT(t.host_bytes[std::size_t(mb::Consumer::other)] == 2 * kMiB); + EXPECT(t.host_bytes[std::size_t(mb::Consumer::windows)] == 0); + EXPECT(t.host_total() == (900 + 4095 + 2) * kMiB); + const std::string line = mb::format(t, mb::DeviceShare{}, 0); + std::fprintf(stderr, "%s\n", line.c_str()); + EXPECT(contains(line, " + sampled textures 1800 (3; 900 in host memory)")); + EXPECT(contains(line, "allocated 7077 MiB = arena 4095 (1; 4095 in host memory) + geometry copies 0 (0)")); + EXPECT(contains(line, " + render targets and depth 1180 (1) + ")); + EXPECT(contains(line, " + other 2 (1; 2 in host memory); in host memory 4997 MiB (4); imported 6 MiB (1)")); return 0; } @@ -100,7 +130,7 @@ int text() { EXPECT(contains(line, " + title windows and shadows 0 (0)")); EXPECT(contains(line, " + upload heaps 0 (0) + staging 0 (0) + texture blocks 0 (0) + sampled textures 0 (0)")); EXPECT(contains(line, " + render targets and depth 1180 (1) + page mirror 0 (0)")); - EXPECT(contains(line, " 0 host] + other 819 (1);")); + EXPECT(contains(line, " 0 host] + other 819 (1); in host memory 0 MiB (0); imported 206 MiB (1)")); EXPECT(contains(line, "page mirror 0 (0) [homes bound 2 MiB (32), pages mirrored 40, chunks 1, units 0 " "device-local 0 host]")); EXPECT(contains(line, "imported 206 MiB (1)")); @@ -117,6 +147,7 @@ int text() { int main() { if (int r = tally()) return r; + if (int r = host_share()) return r; if (int r = owner_scopes()) return r; if (int r = image_kinds()) return r; if (int r = text()) return r; From 5211e5c564d306dc0d2e69f8012f11dcf7e5a47d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=9A=D0=BE?= =?UTF-8?q?=D1=80=D0=BB=D0=BE=D0=B4=D0=BD=D1=8B=D0=B9?= Date: Tue, 1 Dec 2026 06:41:50 +0000 Subject: [PATCH 2/2] mem-probe: the host-memory rule is memory_breakdown::in_host_memory, tested; the line says what its counts are (RT-MEM-PROBE-HOST-SHARE) Review follow-up (KelboLive): - Which memory type counts as host memory was decided inline in mem_probe::sample and nothing tested it. It is now memory_breakdown::in_host_memory(type, type_count, flags): a reported type without DEVICE_LOCAL. sample() calls it. The new host_types case pins it for a discrete GPU (VRAM, system memory, the BAR window), an integrated one and a type index the device does not report; it fails with the type bound dropped. - The format comment and runtime/README.md say that a number in parentheses is an allocation count, that each MiB figure is rounded on its own, and how long the longest items get against the 256-character buffer. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01JPqXc6svM4pbBagTsVEYA3 --- runtime/README.md | 2 +- runtime/src/mem_probe.h | 4 ++-- runtime/src/memory_breakdown.h | 17 +++++++++++++++-- runtime/test/memory_breakdown_test.cpp | 19 +++++++++++++++++++ 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/runtime/README.md b/runtime/README.md index ff06fea2f3..f75bffb0e9 100644 --- a/runtime/README.md +++ b/runtime/README.md @@ -409,7 +409,7 @@ ones marked *diagnostic* only add log lines or exist to compare a run with and w | `LEONIDA_INPUT_TRACE` | unset | `1` (diagnostic, the GameInput shim built without SDL3) logs the title's reading calls on the scripted pad: the first 128, then each one with a button down and every 1000th. Details in [docs/gameinput.md](../docs/gameinput.md#scripted-input-without-sdl3). | | `LEONIDA_LOG_ALLOCINFO` | unset | *Diagnostic.* `1` logs every device slot 25 call (`GetResourceAllocationInfo`) with its thread, description and sizes (`shims/d3d12_xs_device.cpp`). | | `LEONIDA_LOG_EXE_PIPELINES` | unset | *Diagnostic.* When set, one line per distinct graphics pipeline that uses a program translated from the executable's inline containers. | -| `LEONIDA_MEM_PROBE` | unset | *Diagnostic.* ``: every that many seconds the memory probe (`src/mem_probe.h`) logs `[rt] mem-probe t=` (live pipelines, shader modules and `VkDeviceMemory` per memory type), `[rt] mem-probe breakdown t=` (the same allocated bytes by consumer: the arena with its reserved, bound and in-use MiB, geometry copies, title windows and shadows, upload heaps, staging, texture blocks, sampled textures, render targets and depth, and `other`, which add up to the allocated total, each with the part in host memory when it has one, e.g. `sampled textures 2300 (412; 870 in host memory)`, then `in host memory` for all of them: memory types outside the device-local heaps, which the GPU reads over the bus; `src/memory_breakdown.h`) and `[rt] mem-probe smaps` (the process's resident memory by kind). | +| `LEONIDA_MEM_PROBE` | unset | *Diagnostic.* ``: every that many seconds the memory probe (`src/mem_probe.h`) logs `[rt] mem-probe t=` (live pipelines, shader modules and `VkDeviceMemory` per memory type), `[rt] mem-probe breakdown t=` (the same allocated bytes by consumer: the arena with its reserved, bound and in-use MiB, geometry copies, title windows and shadows, upload heaps, staging, texture blocks, sampled textures, render targets and depth, and `other`, which add up to the allocated total, each with the part in host memory when it has one, e.g. `sampled textures 2300 (412; 870 in host memory)` (MiB, then the allocation count and the MiB of it in host memory), then `in host memory` for all of them with their allocation count: memory types without DEVICE_LOCAL, which the GPU reads over the bus, not the BAR window; each figure is rounded to a MiB on its own; `src/memory_breakdown.h`) and `[rt] mem-probe smaps` (the process's resident memory by kind). | | `LEONIDA_MEM_PROBE_CACHE` | unset | *Diagnostic.* `1` adds the pipeline cache's size to the memory probe's report; the driver serializes the whole cache to answer. | | `LEONIDA_TEXTURE_PROBE` | unset | *Diagnostic.* Logs a `[rt] texture-probe` line for every shader resource view of a texture in the title's memory. | | `LEONIDA_LOCAL_DIAGNOSTICS` | unset | *Diagnostic.* `1` turns on the boot diagnostics that write to stderr from the draw, clear, present and descriptor paths (the lines tagged `present-probe`, `fsdraw`, `heap-probe`, `desc-probe` and `PresentX diag`; `src/local_diagnostics.h`). They follow a frame of the title from its draws to the window and cost a lock and a line per draw, so they are off by default. The full-screen draw targets that `LEONIDA_CAPTURE_SOURCE` reads back are only collected with it. | diff --git a/runtime/src/mem_probe.h b/runtime/src/mem_probe.h index e3f1b98015..67cec31cd9 100644 --- a/runtime/src/mem_probe.h +++ b/runtime/src/mem_probe.h @@ -547,8 +547,8 @@ inline void sample(const DeviceFacts& facts) { type_bytes[i] += a.bytes; } if (a.mapped && !a.imported) vk_mapped.push_back({a.mapped, a.mapped + a.mapped_bytes}); - const bool host = i < facts.memory.memoryTypeCount && - !(facts.memory.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); + const bool host = memory_breakdown::in_host_memory( + i, facts.memory.memoryTypeCount, i < VK_MAX_MEMORY_TYPES ? facts.memory.memoryTypes[i].propertyFlags : 0); tally.add(a.consumer, a.bytes, a.imported, host); } modules = s.modules.size(); diff --git a/runtime/src/memory_breakdown.h b/runtime/src/memory_breakdown.h index d9e44e3e78..1e4a0cadcd 100644 --- a/runtime/src/memory_breakdown.h +++ b/runtime/src/memory_breakdown.h @@ -60,6 +60,15 @@ inline const char* consumer_name(Consumer c) { // VkImageUsageFlagBits values, as plain integers so this header needs no Vulkan headers. constexpr std::uint32_t kColorAttachment = 0x10; // VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT constexpr std::uint32_t kDepthStencilAttachment = 0x20; // VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT +// VkMemoryPropertyFlagBits value, likewise. +constexpr std::uint32_t kDeviceLocal = 0x1; // VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT + +// Whether an allocation of memory type `type` counts as in host memory: a type the device reports (type < type_count) +// whose flags lack DEVICE_LOCAL, so the GPU reads it over the bus. A device-local type that the CPU can also map (the +// BAR window, Resizable BAR) is the card's memory; a type index the device does not report is not counted as host. +inline bool in_host_memory(std::uint32_t type, std::uint32_t type_count, std::uint32_t property_flags) { + return type < type_count && !(property_flags & kDeviceLocal); +} // The consumer of memory an image of `usage` is bound to, when nobody named the memory. inline Consumer image_consumer(std::uint32_t usage) { @@ -137,8 +146,12 @@ struct DeviceShare { inline double mib(std::uint64_t bytes) { return double(bytes) / 1048576.0; } // The breakdown line's text after "[rt] mem-probe breakdown t=: ". Every consumer is printed, zero or not, so a -// reader can line up two ticks; the figures are whole MiB. A consumer with memory in host memory adds how much to its -// count ("sampled textures 2300 (412; 870 in host memory)"), and the total in host memory follows the parts. +// reader can line up two ticks. The figures are MiB, each rounded on its own, so the parts can differ from the total +// by a MiB or so; a number in parentheses is a count of allocations. A consumer with memory in host memory adds how +// much to its count ("sampled textures 2300 (412; 870 in host memory)": 412 allocations, 870 of the 2300 MiB in host +// memory), and the total in host memory follows the parts ("in host memory 4997 MiB (4)": 4 allocations). The longest +// items (the arena's bracket, the closing note) stay near 200 characters even with ten-digit figures, inside the 256 +// the formatting buffer holds. inline std::string format(const Tally& tally, const DeviceShare& device, std::uint64_t module_bytes) { std::string out; char item[256]; diff --git a/runtime/test/memory_breakdown_test.cpp b/runtime/test/memory_breakdown_test.cpp index 56abd2cd84..f2e04dd149 100644 --- a/runtime/test/memory_breakdown_test.cpp +++ b/runtime/test/memory_breakdown_test.cpp @@ -44,6 +44,24 @@ int tally() { return 0; } +// Which memory types count as host memory (the rule mem_probe::sample applies per allocation): a reported type without +// DEVICE_LOCAL. Flags as VkMemoryPropertyFlagBits: DEVICE_LOCAL 0x1, HOST_VISIBLE 0x2, HOST_COHERENT 0x4, +// HOST_CACHED 0x8. +int host_types() { + // A discrete GPU: VRAM, system memory, and the BAR window (DEVICE_LOCAL | HOST_VISIBLE | HOST_COHERENT). + EXPECT(!mb::in_host_memory(0, 3, 0x1)); + EXPECT(mb::in_host_memory(1, 3, 0x2 | 0x4)); + EXPECT(mb::in_host_memory(1, 3, 0x2 | 0x4 | 0x8)); + EXPECT(!mb::in_host_memory(2, 3, 0x1 | 0x2 | 0x4)); + EXPECT(mb::in_host_memory(1, 3, 0)); // a type with no flags at all is not the card's memory either + // An integrated GPU: every type device-local. + EXPECT(!mb::in_host_memory(0, 2, 0x1 | 0x2 | 0x4 | 0x8)); + // A type index the device does not report: not counted as host, whatever flags came with it. + EXPECT(!mb::in_host_memory(3, 3, 0x2)); + EXPECT(!mb::in_host_memory(32, 3, 0)); + return 0; +} + // The part in host memory: counted in the consumer's bytes and count as well, never for imported memory, and an // unknown consumer's goes to other. int host_share() { @@ -147,6 +165,7 @@ int text() { int main() { if (int r = tally()) return r; + if (int r = host_types()) return r; if (int r = host_share()) return r; if (int r = owner_scopes()) return r; if (int r = image_kinds()) return r;