96 ossia::small_vector<BufferView, 2> buffers;
103 QRhiBuffer* indirectDrawBuffer{};
104 bool useIndirectDraw{
false};
105 bool indirectDrawIndexed{
false};
106 bool gpuIndirectSupported{
false};
108 bool baseInstanceSupported{
true};
109 quint32 indirectDrawOffset{0};
110 quint32 indirectDrawCount{1};
111 quint32 indirectDrawStride{0};
117 static constexpr quint32 indirect_record_stride = 5 *
sizeof(uint32_t);
126 void enableIndirectDraw(
127 QRhiBuffer* buffer,
bool indexed, int64_t byte_size,
128 quint32 byte_offset = 0) noexcept
130 indirectDrawBuffer = buffer;
131 useIndirectDraw =
true;
132 indirectDrawIndexed = indexed;
133 indirectDrawOffset = byte_offset;
134 indirectDrawStride = indirect_record_stride;
135 indirectDrawCount = quint32(byte_size / indirect_record_stride);
136 if(indirectDrawCount == 0)
137 indirectDrawCount = 1;
152 QRhiBuffer* indirectCountBuffer{};
153 quint32 indirectCountOffset{0};
154 bool gpuIndirectCountSupported{
false};
156 bool gpuIndirectMultiSupported{
false};
163 ossia::small_vector<ossia::geometry::draw_command, 0> cpuDrawCommands;
168#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
169 QRhiReadbackResult readbackResult;
172 QRhiReadbackResult countReadbackResult;
174 QRhiBufferReadbackResult readbackResult;
175 QRhiBufferReadbackResult countReadbackResult;
181struct SCORE_PLUGIN_GFX_EXPORT
Mesh
189 HasPosition = SCORE_FLAG(1),
190 HasTexCoord = SCORE_FLAG(2),
191 HasColor = SCORE_FLAG(3),
192 HasNormals = SCORE_FLAG(4),
193 HasTangents = SCORE_FLAG(5),
195 using Flags = QFlags<Flag>;
197 [[nodiscard]]
virtual Flags flags()
const noexcept = 0;
199 [[nodiscard]]
virtual MeshBuffers init(QRhi& rhi)
const noexcept = 0;
202 update(QRhi& rhi,
MeshBuffers& bufs, QRhiResourceUpdateBatch& cb)
const noexcept
204 virtual void preparePipeline(QRhiGraphicsPipeline& pip)
const noexcept = 0;
208 [[nodiscard]]
virtual bool hasGeometry()
const noexcept {
return true; }
209 virtual void draw(
const MeshBuffers& bufs, QRhiCommandBuffer& cb)
const noexcept = 0;
220 virtual const ossia::
geometry* semanticGeometry() const noexcept {
return nullptr; }
222 ossia::geometry_filter_list_ptr filters;
224 std::atomic_int64_t dirtyGeometryIndex{-1};
226 bool hasGeometryChanged(int64_t& renderer)
const noexcept
228 int64_t res = dirtyGeometryIndex.load(std::memory_order_acquire);
241 Mesh(
const Mesh&) =
delete;
242 Mesh(Mesh&&) =
delete;
243 Mesh& operator=(
const Mesh&) =
delete;
244 Mesh& operator=(Mesh&&) =
delete;
252 [[nodiscard]]
virtual MeshBuffers init(QRhi& rhi)
const noexcept override;
254 QRhi& rhi,
MeshBuffers& bufs, QRhiResourceUpdateBatch& cb)
const noexcept override;
255 void preparePipeline(QRhiGraphicsPipeline& pip)
const noexcept override;
256 void draw(
const MeshBuffers& bufs, QRhiCommandBuffer& cb)
const noexcept override;
258 setupBindings(
const MeshBuffers& bufs, QRhiCommandBuffer& cb)
const noexcept = 0;
260 using pip = QRhiGraphicsPipeline;
261 pip::Topology topology = pip::Topology::TriangleStrip;
262 pip::CullMode cullMode = pip::CullMode::None;
263 pip::FrontFace frontFace = pip::FrontFace::CW;
265 ossia::small_vector<QRhiVertexInputBinding, 2> vertexBindings;
266 ossia::small_vector<QRhiVertexInputAttribute, 2> vertexAttributes;
268 std::span<const float> vertexArray;
349 static const constexpr float data[] = {
350 -1, -1, +1, -1, -1, +1, +1, +1,
352 0, 0, 1, 0, 0, 1, 1, 1};
354 static const constexpr float flipped_y_data[] = {
355 -1, -1, +1, -1, -1, +1, +1, +1,
357 0, 1, 1, 1, 0, 0, 1, 0};
362 setupBindings(
const MeshBuffers& bufs, QRhiCommandBuffer& cb)
const noexcept override;
void drawMeshWithOptionalIndirect(const Mesh &mesh, const MeshBuffers &bufs, QRhiCommandBuffer &cb) noexcept
Draw a mesh, using indirect multi-draw when available in MeshBuffers.
Definition Mesh.cpp:314
A mesh with positions and texture coordinates.
Definition Mesh.hpp:300
A quad mesh with positions and texture coordinates.
Definition Mesh.hpp:348
A triangle mesh with positions and texture coordinates.
Definition Mesh.hpp:327