Loading...
Searching...
No Matches
TextureView.hpp
1#pragma once
2#include <QGraphicsSceneHoverEvent>
3
4#include <Ui/Monitor/LayerHelpers.hpp>
5#include <Ui/Monitor/TextureLayers.hpp>
6#include <Gfx/Widgets/OutletPreviewLayer.hpp>
7#include <halp/controls.hpp>
8#include <halp/meta.hpp>
9#include <halp/texture.hpp>
10
11#include <array>
12#include <memory>
13#include <optional>
14
15class QRhi;
16class QRhiBuffer;
17class QRhiCommandBuffer;
18class QRhiComputePipeline;
19class QRhiResourceUpdateBatch;
20class QRhiSampler;
21class QRhiShaderResourceBindings;
22class QRhiTexture;
23namespace score::gfx
24{
25class RenderList;
26struct Edge;
27}
28
43namespace Ui::TextureView
44{
45enum class Mode
46{
47 View,
48 Red,
49 Green,
50 Blue,
51 Alpha,
52 Luma,
53 FalseColor,
54 Zebra,
55 Peaking,
56 Gamut,
57 Wipe,
58 Difference
59};
60inline constexpr std::string_view mode_names[]{
61 "View", "Red", "Green", "Blue", "Alpha", "Luma", "False colour", "Zebra",
62 "Focus peaking", "Out of gamut", "Wipe", "Difference"};
63
64enum class Background
65{
66 Checkerboard,
67 Black,
68 Grey,
69 White,
70 Magenta,
71 IgnoreAlpha
72};
73
74enum class LumaStandard
75{
76 Rec709,
77 Rec2020
78};
79
80struct Layer;
81
82struct Node
83{
84 halp_meta(name, "Texture view")
85 halp_meta(c_name, "TextureView")
86 halp_meta(category, "Monitoring/Visuals")
87 halp_meta(author, "ossia score")
88 halp_meta(manual_url, "")
89 halp_meta(
90 description,
91 "Show a texture: channels, luma, false colour, zebras, focus peaking, "
92 "out of gamut and NaN values, or a wipe or difference with a reference")
93 halp_meta(uuid, "ede620d7-9f3f-4a0a-a6f0-27297cfe7801")
94 halp_flag(fully_custom_item);
96
97 struct
98 {
99 halp::gpu_texture_input<"In"> image;
100 halp::gpu_texture_input<"Reference"> reference;
101 struct : halp::combobox_t<"Mode", Mode>
102 {
103 struct range
104 {
105 std::string_view values[12]{
106 mode_names[0], mode_names[1], mode_names[2], mode_names[3],
107 mode_names[4], mode_names[5], mode_names[6], mode_names[7],
108 mode_names[8], mode_names[9], mode_names[10], mode_names[11]};
109 Mode init{Mode::View};
110 };
111 } mode;
112 struct : halp::spinbox_f32<"Exposure", halp::range{-10., 10., 0.}>
113 {
114 halp_meta(description, "Stops of gain applied before display, to read floating point images")
115 } exposure;
116 struct : halp::toggle_t<bool, "NaN", halp::toggle_setup{.init = true}>
117 {
118 halp_meta(description, "Flash pixels that are NaN or infinite, in every mode")
119 } nan;
120 struct : halp::combobox_t<"Background", Background>
121 {
122 halp_meta(description, "What transparent pixels are shown over in View mode")
123 struct range
124 {
125 std::string_view values[6]{"Checkerboard", "Black", "Grey", "White", "Magenta", "Ignore alpha"};
126 Background init{Background::Checkerboard};
127 };
128 } background;
129 struct : halp::combobox_t<"Luma", LumaStandard>
130 {
131 struct range
132 {
133 std::string_view values[2]{"Rec. 709", "Rec. 2020"};
134 LumaStandard init{LumaStandard::Rec709};
135 };
136 } luma;
137 struct : halp::hslider_f32<"Zebra high", halp::range{0.5, 1.5, 0.95}>
138 {
139 } zebra_high;
140 struct : halp::hslider_f32<"Zebra low", halp::range{0., 0.1, 0.02}>
141 {
142 } zebra_low;
143 struct : halp::hslider_f32<"Peaking", halp::range{0.01, 1., 0.15}>
144 {
145 halp_meta(description, "Edge strength above which focus peaking marks a pixel")
146 } peaking;
147 struct : halp::hslider_f32<"Blend", halp::range{0., 1., 0.6}>
148 {
149 halp_meta(description, "How much the overlays cover the image")
150 } blend;
151 struct : halp::hslider_f32<"Wipe", halp::range{0., 1., 0.5}>
152 {
153 halp_meta(description, "Where the reference starts, from the left, in Wipe mode")
154 } wipe;
158 } inputs;
159
160 struct
161 {
162 halp::gpu_texture_output<"Out"> texture;
163 struct : halp::val_port<"Resolution", std::array<float, 2>>
164 {
165 halp_meta(description, "Width and height the input is rendered at, in pixels: the graph renders an input at the size its consumer shows it")
166 enum widget
167 {
168 control
169 };
170 } resolution;
171 } outputs;
172
173 std::shared_ptr<Ui::Monitor::TextureShapeMonitor> monitor
174 = std::make_shared<Ui::Monitor::TextureShapeMonitor>();
175
176 Node();
177 ~Node();
178
179 void init(score::gfx::RenderList& r, QRhiResourceUpdateBatch& res);
180 void runInitialPasses(
181 score::gfx::RenderList& r, QRhiCommandBuffer& cb, QRhiResourceUpdateBatch*& res,
183 void release(score::gfx::RenderList& r);
184 void operator()() { }
185
186private:
187 void setBindings(QRhiTexture* input, QRhiTexture* reference);
188 bool resizeOutput(QSize sz);
190 QRhiComputePipeline* pipeline(score::gfx::RenderList& r, score::gfx::TextureKind kind);
191
192 QRhi* m_rhi{};
193 QRhiBuffer* m_params{};
194 QRhiTexture* m_out{};
195 QRhiSampler* m_sampler{};
196 QRhiShaderResourceBindings* m_srb{};
197 std::array<QRhiComputePipeline*, score::gfx::texture_kind_count> m_pipelines{};
199 std::array<bool, score::gfx::texture_kind_count> m_failed{};
200 void* m_boundInput{};
201 void* m_boundReference{};
202 int m_frame{};
203};
204
206{
207 Layer(
208 const Process::ProcessModel& process, const Process::Context& doc,
209 QGraphicsItem* parent);
210
211protected:
212 void hoverMoveEvent(QGraphicsSceneHoverEvent* ev) override;
213 void hoverLeaveEvent(QGraphicsSceneHoverEvent* ev) override;
214 void paintOverlay(QPainter* p, const QRectF& image) const override;
215
216private:
217 std::array<float, 2> resolution() const;
218 score::gfx::TextureShape textureShape() const;
219 const Process::ProcessModel& m_process;
220 const Process::ControlOutlet* m_resolution{};
221 std::optional<QPointF> m_hover;
222};
223}
Definition OutletPreviewLayer.hpp:25
Definition Port.hpp:481
The Process class.
Definition score-lib-process/Process/Process.hpp:82
List of nodes to be rendered to an output.
Definition RenderList.hpp:36
Definition TextureView.cpp:14
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
TextureKind
Definition TextureKind.hpp:20
Definition ProcessContext.hpp:12
Definition TextureLayers.hpp:52
Definition TextureLayers.hpp:33
Definition TextureLayers.hpp:46
Definition TextureView.hpp:206
void paintOverlay(QPainter *p, const QRectF &image) const override
Drawn over the image.
Definition TextureView.cpp:407
Definition TextureView.hpp:83
Definition MIDISync.hpp:149
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:236
Definition TextureKind.hpp:31