2#include <Process/Monitoring/Monitor.hpp>
3#include <Process/Monitoring/MonitorLink.hpp>
5#include <Effect/EffectLayer.hpp>
7#include <QGraphicsSceneHoverEvent>
11#include <Ui/Monitor/BufferDecode.hpp>
12#include <Ui/Monitor/BufferGather.hpp>
13#include <Ui/Monitor/LayerHelpers.hpp>
14#include <halp/buffer.hpp>
15#include <halp/controls.hpp>
16#include <halp/meta.hpp>
24class QRhiResourceUpdateBatch;
56inline constexpr std::string_view mode_names[]{
"Curves",
"Table",
"Image",
"Histogram"};
57inline constexpr std::string_view type_names[]{
58 "Float (32 bit)",
"Half (16 bit)",
"Int (32 bit)",
59 "UInt (32 bit)",
"UInt8 (normalised)",
"UInt8 (raw)"};
100 halp_meta(name,
"Buffer view")
101 halp_meta(c_name,
"BufferView")
102 halp_meta(category,
"Monitoring/Visuals")
103 halp_meta(author,
"ossia score")
104 halp_meta(manual_url,
"")
107 "Show the contents of a GPU buffer as curves, a table, an image or "
108 "histograms, read with the element type, components, stride and offset given")
109 halp_meta(uuid,
"4c1f7a2e-93b8-4d56-a0e1-6b2d8f3c9e14")
110 halp_flag(fully_custom_item);
115 struct : halp::gpu_buffer_input<
"Buffer">
117 halp_flag(single_cable);
119 struct : halp::combobox_t<
"Mode", Mode>
123 std::string_view values[4]{mode_names[0], mode_names[1], mode_names[2], mode_names[3]};
124 Mode init{Mode::Curves};
127 struct : halp::combobox_t<
"Type", ElementType>
129 halp_meta(description,
"What each component of an element is")
132 std::string_view values[6]{type_names[0], type_names[1], type_names[2],
133 type_names[3], type_names[4], type_names[5]};
134 ElementType init{ElementType::Float};
137 struct : halp::spinbox_i32<
"Components", halp::range{1, 4, 1}>
139 halp_meta(description,
"Components of an element: 4 for a vec4")
141 struct : halp::spinbox_i32<
"Stride", halp::range{0, 65536, 0}>
143 halp_meta(description,
"Bytes from one element to the next; 0 when they follow each other")
145 struct : halp::spinbox_i32<
"Offset", halp::range{0, 2147483647, 0}>
147 halp_meta(description,
"Bytes before element 0")
149 struct : halp::spinbox_i32<
"Width", halp::range{0, 16384, 0}>
151 halp_meta(description,
"Elements per row in Image mode; 0 makes the image square")
153 struct : halp::toggle_t<bool,
"Autoscale", halp::toggle_setup{.init =
true}>
155 halp_meta(description,
"Fit the scales to the values; off, values are shown from 0 to 1")
157 struct : halp::spinbox_i32<
"Max elements", halp::range{1, 1048576, 65536}>
161 "Elements read back at most, from the first shown; a readback holds 16 MiB at most")
164 struct : halp::spinbox_i32<
"First element", halp::range{0, 2147483647, 0}>
166 halp_meta(description,
"Index of the first element shown")
168 struct : halp::toggle_t<bool,
"Overview", halp::toggle_setup{.init =
false}>
172 "When more elements follow the first than Max elements, show elements spread "
173 "evenly over all of them, and the extent of every one")
181 std::shared_ptr<BufferMonitor> monitor = std::make_shared<BufferMonitor>();
186 void inputAboutToFinish(
189 void operator()() { }
196 void decodeReadback();
197 void publishEmpty(int64_t buffer_bytes, int64_t available, int64_t first,
const Layout& l);
199 std::shared_ptr<Readback> m_readback;
206 QGraphicsItem* parent);
208 void paint_impl(QPainter* p)
const override;
211 void hoverMoveEvent(QGraphicsSceneHoverEvent* ev)
override;
212 void hoverLeaveEvent(QGraphicsSceneHoverEvent* ev)
override;
216 bool autoscale()
const;
217 int components()
const noexcept;
218 std::pair<float, float> rangeOf(
int c)
const;
225 QRectF plotRect()
const;
226 void paintCurves(QPainter* p)
const;
227 void paintTable(QPainter* p)
const;
228 void paintImage(QPainter* p)
const;
229 void paintHistogram(QPainter* p)
const;
233 QPainter* p,
const QRectF& plot,
const QStringList& extra,
bool bottom =
false)
const;
235 QRectF imageRect(QSize& size)
const;
236 void buildImage()
const;
237 QString formatValue(
float v)
const;
239 int64_t indexOf(int64_t i)
const noexcept;
250 std::array<float, 4> m_lo{}, m_hi{};
252 std::array<float, 4> m_frameLo{}, m_frameHi{};
253 int64_t m_nonFinite{};
254 std::optional<QPointF> m_hover;
257 mutable QPolygonF m_polyline;
258 mutable QImage m_image;
259 mutable bool m_imageDirty{
true};
260 mutable std::array<std::array<int, 64>, 4> m_bins{};
Definition EffectLayer.hpp:17
Definition Monitor.hpp:59
Definition MonitorLink.hpp:31
The Process class.
Definition score-lib-process/Process/Process.hpp:82
Definition LayerHelpers.hpp:103
List of nodes to be rendered to an output.
Definition RenderList.hpp:36
Definition BufferView.cpp:21
Fallback
Why a buffer is read back as one range instead of through the gather pass.
Definition BufferGather.hpp:27
ElementType
Definition BufferDecode.hpp:18
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
Definition ProcessContext.hpp:12
Definition Monitor.hpp:27
Definition BufferView.hpp:90
std::atomic< int > interval
Milliseconds between two readbacks: the refresh interval of the views.
Definition BufferView.hpp:93
The elements of one readback, decoded.
Definition BufferView.hpp:63
int64_t count
Elements in values
Definition BufferView.hpp:67
int64_t read_bytes
Bytes the readback held.
Definition BufferView.hpp:77
int64_t available
Elements the buffer holds under the layout, read back or not.
Definition BufferView.hpp:69
int64_t step
Elements of the buffer from one in values to the next.
Definition BufferView.hpp:73
std::vector< float > values
The components of each element, one after the other.
Definition BufferView.hpp:65
int64_t first
Index of the element values starts with.
Definition BufferView.hpp:71
bool capped
Whether the 16 MiB a readback holds kept count below what was asked.
Definition BufferView.hpp:82
bool exact
Definition BufferView.hpp:85
Fallback fallback
Why the elements were read as one contiguous range.
Definition BufferView.hpp:80
int64_t buffer_bytes
Size of the buffer; 0 without one.
Definition BufferView.hpp:75
Definition BufferView.hpp:203
void mousePressEvent(QGraphicsSceneMouseEvent *ev) override
A double click fits the scales to the elements shown now.
Definition BufferView.cpp:469
Definition BufferView.cpp:76
Definition BufferView.hpp:99
Layout layout() const noexcept
The layout the controls describe.
Definition BufferView.cpp:115
What the header of a staging buffer says of the elements measured.
Definition BufferGather.hpp:210
Definition BufferDecode.hpp:29
Definition MIDISync.hpp:149
Port of a score::gfx::Node.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:215