Loading...
Searching...
No Matches
VertexFallbackPlan.hpp
1#pragma once
2
3#include <vector>
4
5class QRhiBuffer;
6
7namespace score::gfx
8{
9
10// Draw-time bindings the renderer must merge into its vertex-input
11// array to satisfy "REQUIRED: false" VERTEX_INPUTS whose upstream
12// geometry did not provide a matching attribute.
13//
14// Emitted by the fallback-aware remapPipelineVertexInputs overload and
15// consumed by RenderedRawRasterPipelineNode at draw time. Each Slot has
16// a `binding_index` — the slot in the pipeline's vertex-input binding
17// array that was appended during pipeline build — and a QRhiBuffer* the
18// runtime binds at that index when issuing the draw.
19//
20// The plan is safe to hold across frames: the buffer handles come from
21// the VertexFallbackPool which lives alongside the RenderList.
22//
23// This struct lives in its own header so consumers (CustomMesh, the
24// renderer) can depend on it without pulling the full Utils.hpp /
25// VertexFallbackPool.hpp graph in via Mesh.hpp.
27{
28 struct Slot
29 {
30 int binding_index{};
31 QRhiBuffer* buffer{};
32 };
33 std::vector<Slot> slots;
34
35 // Which of the upstream geometry's vertex bindings the pipeline
36 // actually consumes, in pipeline binding order: `mesh_bindings[k]` is
37 // the index into `geometry.bindings` / `geometry.input` that pipeline
38 // binding k was built from.
39 //
40 // A geometry publishes every stream it has; a shader reads the handful
41 // it declares. Without this the draw binds all of them, and the count
42 // is what the backend sees: Qt's D3D11 command buffer carries at most
43 // MAX_VERTEX_BUFFER_BINDING_COUNT == 8 (qrhid3d11_p.h) and silently
44 // drops the rest. Compacting to the consumed set keeps the draw within
45 // reach of the narrowest backend and skips buffer binds nothing reads.
46 //
47 // Only meaningful when `compacted` is true; the pipeline builders that
48 // do not compute a plan leave it false, and the draw path then binds
49 // the geometry's inputs one-to-one.
50 std::vector<int> mesh_bindings;
51 bool compacted{false};
52
53 bool empty() const noexcept { return slots.empty() && !compacted; }
54 void clear() noexcept
55 {
56 slots.clear();
57 mesh_bindings.clear();
58 compacted = false;
59 }
60};
61
62} // namespace score::gfx
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
Definition VertexFallbackPlan.hpp:29
Definition VertexFallbackPlan.hpp:27