Loading...
Searching...
No Matches
TexturePort.hpp
1#pragma once
2#include <Process/Dataflow/Port.hpp>
3
4#include <Dataflow/PortItem.hpp>
5#include <Gfx/CommandFactory.hpp>
6#include <Gfx/ShaderSamplerSource.hpp>
7
8#include <score/command/PropertyCommand.hpp>
9
10#include <ossia/dataflow/texture_port.hpp>
11#include <ossia/gfx/port_index.hpp>
12
13#include <score_plugin_gfx_export.h>
14
15namespace Gfx
16{
17class TextureInlet;
18class TextureOutlet;
19}
20UUID_METADATA(, Process::Port, Gfx::TextureInlet, "5ac86198-2d03-4830-9e41-a6d529922d29")
21UUID_METADATA(
22 , Process::Port, Gfx::TextureOutlet, "f1c71046-b754-49a5-8e66-d01374773dfc")
23namespace Gfx
24{
25
26class SCORE_PLUGIN_GFX_EXPORT TextureInlet : public Process::Inlet
27{
28 W_OBJECT(TextureInlet)
29
30 SCORE_SERIALIZE_FRIENDS
31public:
32 MODEL_METADATA_IMPL_HPP(TextureInlet)
33 TextureInlet() = delete;
34 ~TextureInlet() override;
35 TextureInlet(const TextureInlet&) = delete;
36 TextureInlet(const QString& name, Id<Process::Port> c, QObject* parent);
37
38 TextureInlet(DataStream::Deserializer& vis, QObject* parent);
39 TextureInlet(JSONObject::Deserializer& vis, QObject* parent);
40 TextureInlet(DataStream::Deserializer&& vis, QObject* parent);
41 TextureInlet(JSONObject::Deserializer&& vis, QObject* parent);
42
43 VIRTUAL_CONSTEXPR Process::PortType type() const noexcept override
44 {
45 return Process::PortType::Texture;
46 }
47
48 std::optional<QSize> renderSize() const noexcept;
49 void renderSizeChanged(std::optional<QSize> sz) W_SIGNAL(renderSizeChanged, sz);
50 void setRenderSize(std::optional<QSize> sz);
51 void unsetRenderSize();
52
53 PROPERTY(
54 std::optional<QSize>,
55 renderSize W_READ renderSize W_WRITE setRenderSize W_NOTIFY renderSizeChanged)
56
57 INLINE_PROPERTY_VALUE(
58 std::optional<ossia::texture_format>, textureFormat, = std::nullopt,
59 textureFormat, setTextureFormat, textureFormatChanged)
60 // The sampler fields the user set on this inlet. One left unset is the
61 // shader's when its JSON declares a sampler (WRAP, FILTER, MIPMAP_MODE),
62 // otherwise linear, clamped to the edge, without mipmaps (shader board
63 // U34).
64 INLINE_PROPERTY_VALUE(
65 std::optional<ossia::texture_filter>, textureFilter, = std::nullopt,
66 textureFilter, setTextureFilter, textureFilterChanged)
67 INLINE_PROPERTY_VALUE(
68 std::optional<ossia::texture_address_mode>, textureAddressMode, = std::nullopt,
69 textureAddressMode, setTextureAddressMode, textureAddressModeChanged)
70 INLINE_PROPERTY_VALUE(
71 std::optional<ossia::texture_filter>, textureMipmapMode, = std::nullopt,
72 textureMipmapMode, setTextureMipmapMode, textureMipmapModeChanged)
73
77 const isf::sampler_config* shaderSampler() const noexcept;
78
79 void setupExecution(ossia::inlet&, QObject* exec_context) const noexcept override;
80
81private:
82 std::optional<QSize> m_renderSize;
83};
84
85
86class SCORE_PLUGIN_GFX_EXPORT TextureOutlet : public Process::Outlet
87{
88 W_OBJECT(TextureOutlet)
89
90 SCORE_SERIALIZE_FRIENDS
91public:
92 MODEL_METADATA_IMPL_HPP(TextureOutlet)
93 TextureOutlet() = delete;
94 ~TextureOutlet() override;
95 TextureOutlet(const TextureOutlet&) = delete;
96 TextureOutlet(const QString& name, Id<Process::Port> c, QObject* parent);
97
98 TextureOutlet(DataStream::Deserializer& vis, QObject* parent);
99 TextureOutlet(JSONObject::Deserializer& vis, QObject* parent);
100 TextureOutlet(DataStream::Deserializer&& vis, QObject* parent);
101 TextureOutlet(JSONObject::Deserializer&& vis, QObject* parent);
102
103 VIRTUAL_CONSTEXPR Process::PortType type() const noexcept override
104 {
105 return Process::PortType::Texture;
106 }
107
108 int nodeId{-1};
109 // Model outlet order includes value ports; unregistered outlets return {-1, -1}.
110 ossia::gfx::port_index graphicsPort() const noexcept;
111};
112
113struct SCORE_PLUGIN_GFX_TEST_EXPORT TextureInletFactory final
114 : public Dataflow::AutomatablePortFactory
115{
116 using Model_T = TextureInlet;
117 UuidKey<Process::Port> concreteKey() const noexcept override
118 {
120 }
121
122 Model_T* load(const VisitorVariant& vis, QObject* parent) override
123 {
124 return score::deserialize_dyn(vis, [&](auto&& deserializer) {
125 return new Model_T{deserializer, parent};
126 });
127 }
128
129 void setupInletInspector(
130 const Process::Inlet& port, const score::DocumentContext& ctx, QWidget* parent,
131 Inspector::Layout& lay, QObject* context) override;
132};
133
134struct TextureOutletFactory final : public Dataflow::AutomatablePortFactory
135{
136 using Model_T = TextureOutlet;
137 UuidKey<Process::Port> concreteKey() const noexcept override
138 {
140 }
141
142 Model_T* load(const VisitorVariant& vis, QObject* parent) override
143 {
144 return score::deserialize_dyn(vis, [&](auto&& deserializer) {
145 return new Model_T{deserializer, parent};
146 });
147 }
148
149 void setupOutletInspector(
150 const Process::Outlet& port, const score::DocumentContext& ctx, QWidget* parent,
151 Inspector::Layout& lay, QObject* context) override;
152};
153}
154
155namespace Gfx
156{
157class GeometryInlet;
158class GeometryOutlet;
159}
160UUID_METADATA(
161 , Process::Port, Gfx::GeometryInlet, "f2ab26ea-415d-45a2-bfbc-2968c7c92a33")
162UUID_METADATA(
163 , Process::Port, Gfx::GeometryOutlet, "848061c5-e8a0-4a13-9985-e8df30ce6d4f")
164namespace Gfx
165{
166
167class SCORE_PLUGIN_GFX_EXPORT GeometryInlet : public Process::Inlet
168{
169 W_OBJECT(GeometryInlet)
170
171 SCORE_SERIALIZE_FRIENDS
172public:
173 MODEL_METADATA_IMPL_HPP(GeometryInlet)
174 GeometryInlet() = delete;
175 ~GeometryInlet() override;
176 GeometryInlet(const GeometryInlet&) = delete;
177 GeometryInlet(const QString& name, Id<Process::Port> c, QObject* parent);
178
179 GeometryInlet(DataStream::Deserializer& vis, QObject* parent);
180 GeometryInlet(JSONObject::Deserializer& vis, QObject* parent);
181 GeometryInlet(DataStream::Deserializer&& vis, QObject* parent);
182 GeometryInlet(JSONObject::Deserializer&& vis, QObject* parent);
183
184 VIRTUAL_CONSTEXPR Process::PortType type() const noexcept override
185 {
186 return Process::PortType::Geometry;
187 }
188};
189
190class SCORE_PLUGIN_GFX_EXPORT GeometryOutlet : public Process::Outlet
191{
192 W_OBJECT(GeometryOutlet)
193
194 SCORE_SERIALIZE_FRIENDS
195public:
196 MODEL_METADATA_IMPL_HPP(GeometryOutlet)
197 GeometryOutlet() = delete;
198 ~GeometryOutlet() override;
199 GeometryOutlet(const GeometryOutlet&) = delete;
200 GeometryOutlet(const QString& name, Id<Process::Port> c, QObject* parent);
201
202 GeometryOutlet(DataStream::Deserializer& vis, QObject* parent);
203 GeometryOutlet(JSONObject::Deserializer& vis, QObject* parent);
204 GeometryOutlet(DataStream::Deserializer&& vis, QObject* parent);
205 GeometryOutlet(JSONObject::Deserializer&& vis, QObject* parent);
206
207 VIRTUAL_CONSTEXPR Process::PortType type() const noexcept override
208 {
209 return Process::PortType::Geometry;
210 }
211};
212
214{
215 using Model_T = GeometryInlet;
216 UuidKey<Process::Port> concreteKey() const noexcept override
217 {
219 }
220
221 void setupInletInspector(
222 const Process::Inlet& port, const score::DocumentContext& ctx, QWidget* parent,
223 Inspector::Layout& lay, QObject* context) override;
224
225 Model_T* load(const VisitorVariant& vis, QObject* parent) override
226 {
227 return score::deserialize_dyn(vis, [&](auto&& deserializer) {
228 return new Model_T{deserializer, parent};
229 });
230 }
231};
232
234{
235 using Model_T = GeometryOutlet;
236 UuidKey<Process::Port> concreteKey() const noexcept override
237 {
239 }
240
241 void setupOutletInspector(
242 const Process::Outlet& port, const score::DocumentContext& ctx, QWidget* parent,
243 Inspector::Layout& lay, QObject* context) override;
244
245 Model_T* load(const VisitorVariant& vis, QObject* parent) override
246 {
247 return score::deserialize_dyn(vis, [&](auto&& deserializer) {
248 return new Model_T{deserializer, parent};
249 });
250 }
251};
252}
253
254W_REGISTER_ARGTYPE(std::optional<QSize>);
255W_REGISTER_ARGTYPE(ossia::texture_format);
256W_REGISTER_ARGTYPE(std::optional<ossia::texture_format>);
257W_REGISTER_ARGTYPE(ossia::texture_filter);
258W_REGISTER_ARGTYPE(ossia::texture_address_mode);
259W_REGISTER_ARGTYPE(std::optional<ossia::texture_filter>);
260W_REGISTER_ARGTYPE(std::optional<ossia::texture_address_mode>);
261
262PROPERTY_COMMAND_T(
263 Gfx, ChangeTextureInletRenderSize, TextureInlet::p_renderSize,
264 "Change render target size")
265SCORE_COMMAND_DECL_T(Gfx::ChangeTextureInletRenderSize)
266
267PROPERTY_COMMAND_T(
268 Gfx, ChangeTextureInletFormat, TextureInlet::p_textureFormat,
269 "Change render target format")
270SCORE_COMMAND_DECL_T(Gfx::ChangeTextureInletFormat)
271
272PROPERTY_COMMAND_T(
273 Gfx, ChangeTextureInletFilter, TextureInlet::p_textureFilter,
274 "Change render target filter")
275SCORE_COMMAND_DECL_T(Gfx::ChangeTextureInletFilter)
276
277PROPERTY_COMMAND_T(
278 Gfx, ChangeTextureInletAddressMode, TextureInlet::p_textureAddressMode,
279 "Change render target address mode")
280SCORE_COMMAND_DECL_T(Gfx::ChangeTextureInletAddressMode)
281
282PROPERTY_COMMAND_T(
283 Gfx, ChangeTextureInletMipmapMode, TextureInlet::p_textureMipmapMode,
284 "Change render target mipmap mode")
285SCORE_COMMAND_DECL_T(Gfx::ChangeTextureInletMipmapMode)
Definition DataStreamVisitor.hpp:202
Definition score-plugin-dataflow/Dataflow/PortItem.hpp:37
Definition TexturePort.hpp:168
Definition TexturePort.hpp:191
Definition lib/score/widgets/Layout.hpp:53
Definition JSONVisitor.hpp:423
Definition Port.hpp:221
Definition Port.hpp:329
Definition Port.hpp:106
Definition UuidKey.hpp:345
The id_base_t class.
Definition Identifier.hpp:59
Binds the rendering pipeline to ossia processes.
Definition AssetTable.cpp:7
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1115
STL namespace.
Definition TexturePort.hpp:214
Definition TexturePort.hpp:234
Static metadata implementation.
Definition lib/score/tools/Metadata.hpp:36
The VisitorVariant struct.
Definition VisitorInterface.hpp:26
Definition DocumentContext.hpp:18