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(manual_url, "https://ossia.io/score-docs/processes/buffer-info.html")
27 halp_meta(uuid, "f1a3d6c8-2b4e-4c5d-8a9f-1e2d3c4b5a60")
28
29 struct
30 {
31 halp::gpu_buffer_input<"Buffer"> buffer;
32 } inputs;
33
34 struct
35 {
36 // Numeric metadata, exposed individually so it can be patched into
37 // other ports (size-driven UBO updates etc.).
38 halp::val_port<"Byte size", int64_t> byte_size;
39 halp::val_port<"Byte offset", int64_t> byte_offset;
40 // Raw native handle as an opaque integer. Useful only for visual
41 // identity ("did the upstream rebuild this buffer?"); the value is
42 // a QRhiBuffer* on every backend score supports today.
43 halp::val_port<"Handle", int64_t> handle;
44 halp::val_port<"Changed", bool> changed;
45 // One-line, copy-pasteable summary for tooltips / log scraping.
46 halp::val_port<"Readable", std::string> readable;
47 } outputs;
48
49 void operator()()
50 {
51 const auto& b = inputs.buffer.buffer;
52 outputs.byte_size.value = b.byte_size;
53 outputs.byte_offset.value = b.byte_offset;
54 outputs.handle.value = reinterpret_cast<std::int64_t>(b.handle);
55 outputs.changed.value = b.changed;
56
57 auto& ret = outputs.readable.value;
58 ret.clear();
59 fmt::format_to(
60 std::back_inserter(ret),
61 "handle=0x{:x}, byte_size={}, byte_offset={}, changed={}",
62 reinterpret_cast<std::uintptr_t>(b.handle), b.byte_size, b.byte_offset,
63 b.changed ? "yes" : "no");
64 }
65};
66}
Definition BufferInfo.hpp:21