2 #include <Process/ProcessFlags.hpp>
4 #include <ossia/dataflow/geometry_port.hpp>
5 #include <ossia/detail/small_vector.hpp>
6 #include <ossia/detail/span.hpp>
8 #include <private/qrhi_p.h>
10 #include <score_plugin_gfx_export.h>
22 struct SCORE_PLUGIN_GFX_EXPORT
Mesh
30 HasPosition = SCORE_FLAG(1),
31 HasTexCoord = SCORE_FLAG(2),
32 HasColor = SCORE_FLAG(3),
33 HasNormals = SCORE_FLAG(4),
34 HasTangents = SCORE_FLAG(5),
36 using Flags = QFlags<Flag>;
38 [[nodiscard]]
virtual Flags flags()
const noexcept = 0;
40 [[nodiscard]]
virtual MeshBuffers init(QRhi& rhi)
const noexcept = 0;
42 virtual void update(
MeshBuffers& bufs, QRhiResourceUpdateBatch& cb)
const noexcept = 0;
43 virtual void preparePipeline(QRhiGraphicsPipeline& pip)
const noexcept = 0;
44 virtual void draw(
const MeshBuffers& bufs, QRhiCommandBuffer& cb)
const noexcept = 0;
49 ossia::geometry_filter_list_ptr filters;
51 std::atomic_int64_t dirtyGeometryIndex{-1};
53 bool hasGeometryChanged(int64_t& renderer)
const noexcept
55 int64_t res = dirtyGeometryIndex.load(std::memory_order_acquire);
68 Mesh(
const Mesh&) =
delete;
69 Mesh(Mesh&&) =
delete;
70 Mesh& operator=(
const Mesh&) =
delete;
71 Mesh& operator=(Mesh&&) =
delete;
74 Q_DECLARE_OPERATORS_FOR_FLAGS(Mesh::Flags);
79 [[nodiscard]]
virtual MeshBuffers init(QRhi& rhi)
const noexcept
override;
80 void update(
MeshBuffers& bufs, QRhiResourceUpdateBatch& cb)
const noexcept
override;
81 void preparePipeline(QRhiGraphicsPipeline& pip)
const noexcept
override;
82 void draw(
const MeshBuffers& bufs, QRhiCommandBuffer& cb)
const noexcept
override;
84 setupBindings(
const MeshBuffers& bufs, QRhiCommandBuffer& cb)
const noexcept = 0;
86 using pip = QRhiGraphicsPipeline;
87 pip::Topology topology = pip::Topology::TriangleStrip;
88 pip::CullMode cullMode = pip::CullMode::None;
89 pip::FrontFace frontFace = pip::FrontFace::CW;
91 ossia::small_vector<QRhiVertexInputBinding, 2> vertexBindings;
92 ossia::small_vector<QRhiVertexInputAttribute, 2> vertexAttributes;
94 tcb::span<const float> vertexArray;
103 explicit PlainMesh(tcb::span<const float> vtx,
int count);
104 [[nodiscard]] Flags flags()
const noexcept
override {
return HasPosition; }
105 const char* defaultVertexShader()
const noexcept
override;
107 setupBindings(
const MeshBuffers& bufs, QRhiCommandBuffer& cb)
const noexcept
override;
115 explicit TexturedMesh(tcb::span<const float> vtx,
int count);
116 [[nodiscard]] Flags flags()
const noexcept
override
118 return HasPosition | HasTexCoord;
121 const char* defaultVertexShader()
const noexcept
override;
129 static const constexpr
float data[] = {-1, -1, 3, -1, -1, 3};
142 static const constexpr
float data[] = {
143 -1, -1, 3, -1, -1, 3,
146 static const constexpr
float flipped_y_data[] = {
147 -1, -1, 3, -1, -1, 3,
154 setupBindings(
const MeshBuffers& bufs, QRhiCommandBuffer& cb)
const noexcept
override;
163 static const constexpr
float data[] = {
164 -1, -1, +1, -1, -1, +1, +1, +1,
166 0, 0, 1, 0, 0, 1, 1, 1};
168 static const constexpr
float flipped_y_data[] = {
169 -1, -1, +1, -1, -1, +1, +1, +1,
171 0, 1, 1, 1, 0, 0, 1, 0};
176 setupBindings(
const MeshBuffers& bufs, QRhiCommandBuffer& cb)
const noexcept
override;
Graphics rendering pipeline for ossia score.
Definition: Filter/PreviewWidget.hpp:12
Data model for meshes.
Definition: Mesh.hpp:23
virtual const char * defaultVertexShader() const noexcept=0
A basic vertex shader that is going to work with this mesh.
A mesh with only position attributes.
Definition: Mesh.hpp:102
A triangle mesh with only positions.
Definition: Mesh.hpp:128
A mesh with positions and texture coordinates.
Definition: Mesh.hpp:114
A quad mesh with positions and texture coordinates.
Definition: Mesh.hpp:162
A triangle mesh with positions and texture coordinates.
Definition: Mesh.hpp:141