39 QRhiCommandBuffer* m_currentCommands{};
40 std::shared_ptr<RenderState> m_state;
56 [[nodiscard]] QRhiResourceUpdateBatch* initialBatch()
const noexcept;
64 void setInitialBatch(QRhiResourceUpdateBatch* batch)
noexcept { m_initialBatch = batch; }
75 void flushInitialBatch();
83 MeshBuffers initMeshBuffer(
const Mesh& mesh, QRhiResourceUpdateBatch& res);
88 void update(QRhiResourceUpdateBatch& res);
98 void render(QRhiCommandBuffer& commands,
bool force =
false) noexcept;
103 QRhiCommandBuffer* currentCommandBuffer() const noexcept
105 return m_currentCommands;
127 void releaseBuffer(QRhiBuffer* buf);
142 static void adoptBuffer(QRhiBuffer* buf);
144 static void dropAdoptedBuffer(QRhi& rhi, QRhiBuffer* buf);
156 static void releaseResource(QRhi& rhi, QRhiResource* res);
158 static int adoptedBufferCount() noexcept;
179 static
bool isRetiredBuffer(const QRhiBuffer* buf) noexcept;
182 static
bool isRetiringBuffer(const QRhiBuffer* buf) noexcept;
185 static QByteArray retiredBufferName(const QRhiBuffer* buf);
186 static
int retiredBufferCount() noexcept;
191 static
void noteBufferLive(const QRhiBuffer* buf) noexcept;
193 static
void noteFrameCompleted() noexcept;
197 bool checkBindingsLive(
198 const QRhiShaderResourceBindings& srb, const
char* where) const noexcept;
202 static
bool hasRetiredBinding(const QRhiShaderResourceBindings& srb) noexcept;
206 static
bool strictBindingsEnabled() noexcept;
211 static
int staleBindingCount() noexcept;
212 static
void resetStaleBindingCount() noexcept;
217 bool maybeRebuild(
bool force = false);
242 bool resizeSwapchainSizedTargets(QSize newOutputSize, QSize newRenderSize);
258 QRhiTexture* previewSource(const
Node& node,
int port) const noexcept;
267 static const
RenderList* previewHost(const
Node& node,
int port) noexcept;
271 bool rendersLive() const noexcept;
289 QImage adaptImage(const QImage& in);
303 const ossia::geometry_spec&, QRhiResourceUpdateBatch& res, const
Mesh* current,
309 void sweepMeshCache() noexcept;
324 void clearRenderers();
329 QRhiTexture& emptyTexture() const noexcept {
return *m_emptyTexture; }
355 QRhiTexture& emptyTextureFor(
const Port& in)
const noexcept;
363 QRhiTexture* selfFeedbackGrab(
const Port& in)
const noexcept;
371 QRhiBuffer&
outputUBO() const noexcept {
return *m_outputUBO; }
383 QRhiBuffer& outputUBO(
int sampleCount)
const noexcept;
431 const GpuTimings& gpuTimings() const noexcept {
return m_gpuTimings; }
451 const
score::gfx::Mesh& defaultTriangle() const noexcept;
458 bool requiresDepth(const
score::gfx::Port& p) const noexcept;
459 bool anyNodeRequiresDepth() const noexcept {
return m_requiresDepth; }
461 int samples() const noexcept {
return m_samples; }
463 const Quirks& quirks() const noexcept {
return m_quirks; }
471 void isolateFollowingPasses() noexcept;
473 bool canRender() const noexcept {
return m_ready; }
475 QSize renderSize(
const Edge* e)
const noexcept;
479 float currentDate[4]{};
483 bool dateFromStepClock{
false};
485 void createAllInputRenderTargets();
494 void markBuilt() noexcept { m_built =
true; m_lastSize = state.renderSize; }
503 [[nodiscard]]
bool isBuilt() const noexcept {
return m_built; }
520 m_outputTargetsStale =
true;
530 if(value != m_requiresDepth && m_built)
531 m_outputTargetsStale =
true;
532 m_requiresDepth = value;
543 onEdgeRemoved(
Edge& edge,
const ossia::hash_set<const Port*>* preserveSinks =
nullptr);
546 void removeInputRenderTarget(
const Port* port);
550 void ensureSelfFeedbackTargets();
564 QSize resolveDownstreamSize(
566 const ossia::small_flat_map<const Port*, RenderTargetSpecs, 16>& resolvedSpecs)
582 const Node& node, int32_t port,
583 const ossia::small_flat_map<const Port*, RenderTargetSpecs, 16>& resolvedSpecs)
noexcept;
586 void resolveAllInletSpecs(
587 ossia::small_flat_map<const Port*, RenderTargetSpecs, 16>& resolvedSpecs)
noexcept;
588 QSize resolveInletSize(
590 const ossia::small_flat_map<const Port*, RenderTargetSpecs, 16>& resolvedSpecs,
591 ossia::flat_set<const Node*>& visiting)
const noexcept;
592 QSize resolveDownstreamSize(
594 const ossia::small_flat_map<const Port*, RenderTargetSpecs, 16>& resolvedSpecs,
595 ossia::flat_set<const Node*>& visiting)
const noexcept;
597 void renderImpl(QRhiCommandBuffer& commands,
bool force);
601 int m_renderFailures{};
602 int m_nestedRenders{};
605 OutputUBO m_outputUBOData;
608 QRhiResourceUpdateBatch* m_initialBatch{};
609 void retireResourcesReleasedOutsideFrame() noexcept;
621 GpuResourceRegistry* m_registry{};
626 std::unique_ptr<VertexFallbackPool> m_vertexFallbackPool;
630 GpuTimings m_gpuTimings;
637 QRhiBuffer* m_outputUBO{};
639 std::vector<std::pair<int, QRhiBuffer*>> m_outputUBOBySamples;
640 QRhiTexture* m_emptyTexture{};
641 QRhiTexture* m_emptyTexture3D{};
642 QRhiTexture* m_emptyTextureCube{};
643 QRhiTexture* m_emptyTextureArray{};
644 QRhiTexture* m_whiteTexture{};
649 ossia::flat_map<Mesh*, MeshBuffers> m_vertexBuffers;
651 ossia::flat_map<ossia::geometry_spec, Mesh*> m_customMeshCache;
659 ossia::small_flat_map<const Port*, TextureRenderTarget, 8> m_inputRenderTargets;
669 struct SelfFeedbackTarget
671 TextureRenderTarget back;
674 ossia::small_flat_map<const Port*, SelfFeedbackTarget, 2> m_selfFeedbackTargets;
681 ossia::small_flat_map<const Port*, QRhiTexture*, 2> m_selfFeedbackGrabs;
685 void renderPreviewTaps(QRhiCommandBuffer& commands, QRhiResourceUpdateBatch*& res);
686 void releasePreviewTaps();
688 struct PreviewTapTarget
690 std::weak_ptr<PreviewTap> tap;
691 TextureRenderTarget rt;
692 QRhiSampler* sampler{};
695 QRhiTexture* source{};
699 std::shared_ptr<QRhiReadbackResult> readback;
704 std::vector<PreviewTapTarget> m_previewTaps;
706 std::array<std::pair<QShader, QShader>, texture_kind_count> m_previewShaders;
709 struct RetiredPreviewReadback
711 std::shared_ptr<QRhiReadbackResult> readback;
714 std::vector<RetiredPreviewReadback> m_retiredPreviewReadbacks;
715 void retirePreviewTap(PreviewTapTarget& t);
716 std::chrono::steady_clock::time_point m_lastRender{std::chrono::steady_clock::now()};
717 ossia::small_flat_map<const Port*, QRhiTexture*, 2> m_selfFeedbackPlaceholders;
718 ossia::flat_set<const Port*> m_selfFeedbackWarned;
731 ossia::flat_set<const QRhiTexture*> m_targetsToClear;
732 void clearOnFirstUse(
const TextureRenderTarget& rt);
733 void clearNewTargets(QRhiCommandBuffer& commands, QRhiResourceUpdateBatch& res);
735 void updateSelfFeedbackTargets(QRhiResourceUpdateBatch& res);
736 void updateSelfFeedbackGrabs(QRhiResourceUpdateBatch& res);
737 void removeSelfFeedbackTarget(
const Port* port);
738 bool ensureSelfFeedbackTarget(
const Port& in);
740 void rebuildOutputTargets(QRhiResourceUpdateBatch& res);
752 bool m_warnedMixedDepthCompare =
false;
753 bool m_requiresDepth{};
756 bool m_outputTargetsStale{};
757 bool m_renderSizeChanged{};
Useful abstraction for storing all the data related to a render target.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:307