30 void updateInputTexture(
const Port& input, QRhiTexture* tex, QRhiTexture* depthTex =
nullptr)
override;
32 QRhiTexture* textureForOutput(
const Port& output)
override;
34 void init(
RenderList& renderer, QRhiResourceUpdateBatch& res)
override;
35 void update(
RenderList& renderer, QRhiResourceUpdateBatch& res,
Edge* edge)
override;
36 bool updateMaterials(
RenderList& renderer, QRhiResourceUpdateBatch& res,
Edge* edge);
39 void initState(
RenderList& renderer, QRhiResourceUpdateBatch& res)
override;
40 void releaseState(
RenderList& renderer)
override;
41 void addOutputPass(
RenderList& renderer,
Edge& edge, QRhiResourceUpdateBatch& res)
override;
43 bool hasOutputPassForEdge(
Edge& edge)
const override;
44 void addInputEdge(
RenderList& renderer,
Edge& edge, QRhiResourceUpdateBatch& res)
override;
47 void runInitialPasses(
48 RenderList&, QRhiCommandBuffer& commands, QRhiResourceUpdateBatch*& res,
51 void runRenderPass(
RenderList&, QRhiCommandBuffer& commands,
Edge& edge)
override;
53 QRhiGraphicsPipeline::CompareOp depthCompare()
const noexcept override;
54 bool followsRenderSize()
const noexcept override;
56 void process(int32_t port,
const ossia::transform3d& v)
override;
64 void bindAuxTexturesInit(
RenderList& renderer);
75 QRhiTexture* portTexture(
RenderList& renderer,
int sampler_idx)
const;
79 QRhiResourceUpdateBatch& res,
Edge& edge);
80 void initMRTPass(
RenderList& renderer, QRhiResourceUpdateBatch& res);
81 void initMRTBlitPasses(
RenderList& renderer, QRhiResourceUpdateBatch& res);
82 void initMRTBlitPass(
RenderList& renderer, QRhiResourceUpdateBatch& res,
Edge& edge);
90 int resolveManualInvocationCount()
const;
91 bool outputSizeReadsBufferSizes()
const noexcept;
93 QSize declaredOutputSize()
const;
95 QSize m_declaredOutputSize;
101 bool isProceduralDraw()
const noexcept;
105 std::optional<uint32_t> declaredVertexCount()
const;
106 std::optional<uint32_t> declaredInstanceCount()
const;
112 int resolveIntExpression(
const std::string& expr,
int fallback)
const;
114 template <
typename F>
115 void refreshStorageBuffers(F&& refresh);
116 void bindGeometryBuffersToAllSrbs(
117 RenderList& renderer, QRhiResourceUpdateBatch& res);
129 void drawWithPerMeshAuxRebind(
130 QRhiGraphicsPipeline& pipeline,
const QRhiViewport& viewport,
131 QRhiShaderResourceBindings& srb, QRhiCommandBuffer& cb,
136 QRhiGraphicsPipeline* blendPassPipeline(QRhiGraphicsPipeline& pipeline);
137 void releaseBlendPassPipeline(QRhiGraphicsPipeline* pipeline);
138 ossia::small_flat_map<QRhiGraphicsPipeline*, QRhiGraphicsPipeline*, 2>
139 m_blendPassPipelines;
141 QRhi* m_blendPassRhi{};
143 std::vector<Sampler> allSamplers()
const noexcept;
145 ossia::small_vector<std::pair<Edge*, Pass>, 2> m_passes;
149 std::vector<Sampler> m_inputSamplers;
150 std::vector<int> m_storageImageSamplers;
151 std::vector<Sampler> m_audioSamplers;
152 ossia::small_flat_map<Edge*, QRhiSampler*, 4> m_blitSamplersByEdge;
154 int64_t meshChangedIndex{-1};
155 const Mesh* m_mesh{};
156 const Mesh* currentMesh()
const noexcept override {
return m_mesh; }
160 const Mesh* m_blitMesh{};
163 QRhiBuffer* m_materialUBO{};
164 int m_materialSize{};
166 QRhiBuffer* m_modelUBO{};
170 QRhiBuffer* buffer{};
171 QRhiBuffer* prev_buffer{};
179 bool is_uniform{
false};
180 bool persistent{
false};
190 int prev_binding{-1};
195 int64_t declared_size{};
200 std::vector<AuxiliarySSBO> m_auxiliarySSBOs;
201 static void createAuxPlaceholder(
202 QRhi& rhi, QRhiResourceUpdateBatch& res, AuxiliarySSBO& aux, QSize renderSize);
207 QRhiBuffer* m_cameraInletBuffer{};
208 int64_t m_cameraInletFrame{-1};
209 bool m_cameraInletActive{
false};
210 void updateCameraInlet(
RenderList& renderer, QRhiResourceUpdateBatch& res, QSize renderSize);
211 void dropCameraInletGeometry();
220 int m_firstStorageBinding{-1};
221 int m_firstSamplerBinding{3};
222 int m_firstAuxImageBinding{3};
230 struct AuxTextureBinding
236 QRhiTexture* applied{};
241 std::vector<AuxTextureBinding> m_auxTextureBindings;
247 std::vector<QRhiSampler*> m_inputSamplerOverrides;
253 struct AuxTextureAuxSampler
255 QRhiSampler* sampler{};
256 QRhiTexture* texture{};
264 QRhiTexture* placeholder{};
265 bool owns_placeholder{
false};
271 bool is_storage{
false};
278 int ladder_index{-1};
280 bool in_ladder()
const noexcept {
return ladder_size > 0; }
281 bool owns_ladder()
const noexcept {
return ladder_index == 0 && ladder_size > 0; }
286 QRhiSampler* sampler_override{};
287 bool declares_compare{
false};
290 bool mips_follow_texture{
false};
291 QRhiSampler* boundSampler()
const noexcept
293 return sampler_override ? sampler_override : sampler;
296 std::vector<AuxTextureAuxSampler> m_auxTextureSamplers;
300 bool m_auxSamplerChanged{
false};
304 const ossia::geometry_spec& drawGeometry();
305 ossia::geometry_spec m_primitiveGeometry;
306 ossia::geometry_spec m_primitiveSource;
307 int64_t m_primitiveSourceIndex{};
308 uint64_t m_primitiveSourceHash{};
309 std::vector<std::pair<const void*, int64_t>> m_primitiveSourceBuffers;
310 bool m_warnedPrimitiveData{
false};
312 void applyModeTopology(
313 QRhiGraphicsPipeline& ps,
int mode,
314 std::optional<QRhiGraphicsPipeline::Topology>
geometry);
315 void warnModeOverridesGeometry(
316 std::optional<QRhiGraphicsPipeline::Topology>
geometry,
317 QRhiGraphicsPipeline::Topology drawn);
318 int m_warnedModeTopology{-1};
323 void applyPointQuads(
325 bool m_warnedPointQuads{
false};
332 bool refusesBackend(
const RenderList& renderer);
333 bool m_backendRefusalLogged{
false};
335 void requestIndirectCommandBuffers(
336 QRhiGraphicsPipeline& ps,
const QRhi& rhi,
const QShader& vs,
339 void appendAuxTextureBindings(
340 ossia::small_vector<QRhiShaderResourceBinding, 4>& out,
int& binding,
343 std::optional<AudioTextureUpload> m_audioTex;
347 bool m_hasMRT{
false};
348 bool m_mrtRenderedThisFrame{
false};
353 bool m_countClampedThisFrame{
false};
357 bool m_drawBindsTextures{
true};
358 int m_countPathLogged{0};
359 const char* m_countClampLastRefusal{};
360 int64_t m_frameIndexFrame{-1};
376 enum class ExecutionMode : std::uint8_t
384 ExecutionMode m_executionMode{ExecutionMode::Single};
393 int m_perCubeFaceOutputIndex{-1};
400 int m_perMipOutputIndex{-1};
406 int m_perMipViews{1};
409 int m_perLayerViews{0};
412 QRhiTextureRenderTarget* renderTarget{};
413 QRhiRenderPassDescriptor* renderPass{};
414 QRhiTexture* depth{};
418 std::vector<QRhiTexture*> scratch;
421 std::vector<QRhiRenderBuffer*> msaa;
424 std::vector<MipRT> m_mipRTs;
441 int m_perLayerOutputIndex{-1};
442 bool m_perLayerIsDepth{
false};
443 QRhiTexture* m_perLayerDummyColor{
nullptr};
446 int m_manualCount{1};
459 std::vector<QRhiBuffer*> m_perInvocationUBOs;
460 std::vector<QRhiShaderResourceBindings*> m_perInvocationSRBs;
474 QRhiTexture* m_cubeCopyShadowArray{};
475 QRhiTexture* m_cubeCopyCube{};
476 int m_cubeCopyOutputIdx{-1};
480 static constexpr int size_of_pipeline_material = 32;
481 alignas(4)
char m_prevPipelineChangingMaterial[size_of_pipeline_material]{0};
482 struct PipelineChangingMaterial
485 int32_t enable_blend;
486 QRhiGraphicsPipeline::BlendFactor src_color;
487 QRhiGraphicsPipeline::BlendFactor dst_color;
488 QRhiGraphicsPipeline::BlendOp op_color;
489 QRhiGraphicsPipeline::BlendFactor src_alpha;
490 QRhiGraphicsPipeline::BlendFactor dst_alpha;
491 QRhiGraphicsPipeline::BlendOp op_alpha;
493 static_assert(
sizeof(PipelineChangingMaterial) == size_of_pipeline_material);
495 ossia::transform3d m_modelTransform;
503 std::vector<QRhiTexture*> targets;
504 QRhiTextureRenderTarget* renderTarget{};
505 QRhiRenderPassDescriptor* renderPass{};
506 QRhiTextureRenderTarget* resumeTarget{};
507 QRhiRenderPassDescriptor* resumePass{};
508 QRhiTextureRenderTarget* readDepthTarget{};
509 QRhiRenderPassDescriptor* readDepthPass{};
510 QRhiTexture* depthInput{};
511 QRhiTexture* depthPlaceholder{};
512 QRhiSampler* sampler{};
519 ossia::small_flat_map<Edge*, LayerTargets, 2> m_layers;
520 bool m_warnedLayerFallback{
false};
524 QRhiResourceUpdateBatch& res);
525 void initLayerResolve(
RenderList& renderer, LayerTargets& t, QRhiBuffer* processUBO);
526 void releaseLayerTargets(
Edge* edge);
527 void releaseLayerTargets();
528 void applyLayerState(QRhiGraphicsPipeline& ps,
bool depthAvailable,
bool internal)
const;