LCOV - code coverage report
Current view: top level - xenolith/backend/vk - XLVkQueuePass.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1 100.0 %
Date: 2024-05-12 00:16:13 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /**
       2             :  Copyright (c) 2021-2022 Roman Katuntsev <sbkarr@stappler.org>
       3             :  Copyright (c) 2023 Stappler LLC <admin@stappler.dev>
       4             : 
       5             :  Permission is hereby granted, free of charge, to any person obtaining a copy
       6             :  of this software and associated documentation files (the "Software"), to deal
       7             :  in the Software without restriction, including without limitation the rights
       8             :  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
       9             :  copies of the Software, and to permit persons to whom the Software is
      10             :  furnished to do so, subject to the following conditions:
      11             : 
      12             :  The above copyright notice and this permission notice shall be included in
      13             :  all copies or substantial portions of the Software.
      14             : 
      15             :  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      16             :  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      17             :  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      18             :  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      19             :  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      20             :  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
      21             :  THE SOFTWARE.
      22             :  **/
      23             : 
      24             : #ifndef XENOLITH_BACKEND_VK_XLVKQUEUEPASS_H_
      25             : #define XENOLITH_BACKEND_VK_XLVKQUEUEPASS_H_
      26             : 
      27             : #include "XLVkSync.h"
      28             : #include "XLVkObject.h"
      29             : #include "XLCoreQueuePass.h"
      30             : 
      31             : namespace STAPPLER_VERSIONIZED stappler::xenolith::vk {
      32             : 
      33             : class CommandBuffer;
      34             : class Device;
      35             : class Loop;
      36             : class Fence;
      37             : class CommandPool;
      38             : class ImageAttachmentHandle;
      39             : class BufferAttachmentHandle;
      40             : 
      41             : struct MaterialBuffers {
      42             :         Rc<Buffer> stagingBuffer;
      43             :         Rc<Buffer> targetBuffer;
      44             :         HashMap<core::MaterialId, uint32_t> ordering;
      45             : };
      46             : 
      47             : class QueuePass : public core::QueuePass {
      48             : public:
      49             :         virtual ~QueuePass();
      50             : 
      51             :         virtual bool init(QueuePassBuilder &passBuilder) override;
      52             :         virtual void invalidate() override;
      53             : 
      54      345260 :         QueueOperations getQueueOps() const { return _queueOps; }
      55             : 
      56             : protected:
      57             :         QueueOperations _queueOps = QueueOperations::Graphics;
      58             : };
      59             : 
      60             : class QueuePassHandle : public core::QueuePassHandle {
      61             : public:
      62             :         static VkRect2D rotateScissor(const core::FrameContraints &constraints, const URect &scissor);
      63             : 
      64             :         struct ImageInputOutputBarrier {
      65             :                 vk::ImageMemoryBarrier input;
      66             :                 vk::ImageMemoryBarrier output;
      67             :                 core::PipelineStage inputFrom;
      68             :                 core::PipelineStage inputTo;
      69             :                 core::PipelineStage outputFrom;
      70             :                 core::PipelineStage outputTo;
      71             :         };
      72             : 
      73             :         struct BufferInputOutputBarrier {
      74             :                 vk::BufferMemoryBarrier input;
      75             :                 vk::BufferMemoryBarrier output;
      76             :                 core::PipelineStage inputFrom;
      77             :                 core::PipelineStage inputTo;
      78             :                 core::PipelineStage outputFrom;
      79             :                 core::PipelineStage outputTo;
      80             :         };
      81             : 
      82             :         virtual ~QueuePassHandle();
      83             :         void invalidate();
      84             : 
      85             :         virtual bool prepare(FrameQueue &, Function<void(bool)> &&) override;
      86             :         virtual void submit(FrameQueue &, Rc<FrameSync> &&, Function<void(bool)> &&onSubmited, Function<void(bool)> &&onComplete) override;
      87             :         virtual void finalize(FrameQueue &, bool) override;
      88             : 
      89             :         virtual QueueOperations getQueueOps() const;
      90             : 
      91             :         ImageInputOutputBarrier getImageInputOutputBarrier(Device *, Image *, ImageAttachmentHandle &) const;
      92             :         BufferInputOutputBarrier getBufferInputOutputBarrier(Device *, Buffer *, BufferAttachmentHandle &, VkDeviceSize offset, VkDeviceSize size) const;
      93             : 
      94             :         void setQueueIdleMode(DeviceQueue::IdleMode);
      95             : 
      96             : protected:
      97             :         virtual Vector<const CommandBuffer *> doPrepareCommands(FrameHandle &);
      98             :         virtual bool doSubmit(FrameHandle &frame, Function<void(bool)> &&onSubmited);
      99             : 
     100             :         virtual void doSubmitted(FrameHandle &, Function<void(bool)> &&, bool, Rc<Fence> &&);
     101             : 
     102             :         // called before OnComplete event sended to FrameHandle (so, before any finalization)
     103             :         virtual void doComplete(FrameQueue &, Function<void(bool)> &&, bool);
     104             : 
     105             :         virtual void doFinalizeTransfer(core::MaterialSet * materials,
     106             :                 Vector<ImageMemoryBarrier> &outputImageBarriers, Vector<BufferMemoryBarrier> &outputBufferBarriers);
     107             : 
     108             :         virtual MaterialBuffers updateMaterials(FrameHandle &iframe, const Rc<core::MaterialSet> &data,
     109             :                         const Vector<Rc<core::Material>> &materials, SpanView<core::MaterialId> dynamicMaterials, SpanView<core::MaterialId> materialsToRemove);
     110             : 
     111             :         vk::ComputePipeline *getComputePipelineByName(uint32_t subpass, StringView) const;
     112             :         vk::ComputePipeline *getComputePipelineBySubName(uint32_t subpass, StringView) const;
     113             : 
     114             :         vk::GraphicPipeline *getGraphicPipelineByName(uint32_t subpass, StringView) const;
     115             :         vk::GraphicPipeline *getGraphicPipelineBySubName(uint32_t subpass, StringView) const;
     116             : 
     117             :         DeviceQueue::IdleMode _queueIdleMode = DeviceQueue::IdleMode::None;
     118             :         Function<void(bool)> _onPrepared;
     119             :         bool _valid = true;
     120             :         bool _commandsReady = false;
     121             :         bool _descriptorsReady = false;
     122             : 
     123             :         Device *_device = nullptr;
     124             :         Loop *_loop = nullptr;
     125             :         Rc<Fence> _fence;
     126             :         Rc<CommandPool> _pool;
     127             :         Rc<DeviceQueue> _queue;
     128             :         Vector<const CommandBuffer *> _buffers;
     129             :         Rc<FrameSync> _sync;
     130             :         core::FrameContraints _constraints;
     131             : };
     132             : 
     133             : }
     134             : 
     135             : #endif /* XENOLITH_BACKEND_VK_XLVKQUEUEPASS_H_ */

Generated by: LCOV version 1.14