Loading...
Searching...
No Matches
BufferInfo.hpp
1#pragma once
2#include <fmt/format.h>
3#include <halp/buffer.hpp>
4#include <halp/controls.hpp>
5#include <halp/meta.hpp>
6
7#include <cstdint>
8#include <string>
9
10namespace Threedim
11{
12// Tiny inspector node: takes a halp::gpu_buffer_input and exposes its
13// metadata (handle, byte size, byte offset, dirty flag) on regular
14// value-output ports plus a single human-readable summary string --
15// a debug breakpoint in a GPU buffer pipeline.
16//
17// Mirrors the structure of GeometryInfo: pure CPU operator(), no GPU
18// init/update/runInitialPasses needed because the framework already
19// publishes the gpu_buffer's metadata into our input port each tick.
21{
22public:
23 halp_meta(name, "Buffer Info")
24 halp_meta(category, "Visuals/Utilities")
25 halp_meta(c_name, "buffer_info")
26 halp_meta(description, "Report a GPU buffer's handle, byte size, offset and change state as values and readable text.")
27 halp_meta(manual_url, "https://ossia.io/score-docs/processes/buffer-info.html")
28 halp_meta(uuid, "f1a3d6c8-2b4e-4c5d-8a9f-1e2d3c4b5a60")
29
30 struct
31 {
32 struct : halp::gpu_buffer_input<"Buffer">
33 {
34 halp_flag(single_cable);
35 } buffer;
36 } inputs;
37
38 struct
39 {
40 // Numeric metadata, exposed individually so it can be patched into
41 // other ports (size-driven UBO updates etc.).
42 halp::val_port<"Byte size", int64_t> byte_size;
43 halp::val_port<"Byte offset", int64_t> byte_offset;
44 // Raw native handle as an opaque integer. Useful only for visual
45 // identity ("did the upstream rebuild this buffer?"); the value is
46 // a QRhiBuffer* on every backend score supports today.
47 halp::val_port<"Handle", int64_t> handle;
48 halp::val_port<"Changed", bool> changed;
49 // One-line, copy-pasteable summary for tooltips / log scraping.
50 halp::val_port<"Readable", std::string> readable;
51 } outputs;
52
53 void operator()()
54 {
55 const auto& b = inputs.buffer.buffer;
56 outputs.byte_size.value = b.byte_size;
57 outputs.byte_offset.value = b.byte_offset;
58 outputs.handle.value = reinterpret_cast<std::int64_t>(b.handle);
59 outputs.changed.value = b.changed;
60
61 auto& ret = outputs.readable.value;
62 ret.clear();
63 fmt::format_to(
64 std::back_inserter(ret),
65 "handle=0x{:x}, byte_size={}, byte_offset={}, changed={}",
66 reinterpret_cast<std::uintptr_t>(b.handle), b.byte_size, b.byte_offset,
67 b.changed ? "yes" : "no");
68 }
69};
70}
Definition BufferInfo.hpp:21