LCOV - code coverage report
Current view: top level - xenolith/backend/vk - XLVkLoop.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) 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_XLVKLOOP_H_
      25             : #define XENOLITH_BACKEND_VK_XLVKLOOP_H_
      26             : 
      27             : #include "XLVk.h"
      28             : #include "XLVkInstance.h"
      29             : #include "XLVkSync.h"
      30             : #include "XLCoreLoop.h"
      31             : 
      32             : namespace STAPPLER_VERSIONIZED stappler::xenolith::vk {
      33             : 
      34             : class Device;
      35             : class View;
      36             : 
      37             : class Loop : public core::Loop {
      38             : public:
      39             :         struct Timer;
      40             :         struct Internal;
      41             : 
      42             :         virtual ~Loop();
      43             : 
      44             :         Loop();
      45             : 
      46             :         bool init(Rc<Instance> &&, LoopInfo &&);
      47             : 
      48             :         virtual void waitRinning() override;
      49             : 
      50             :         virtual void threadInit() override;
      51             :         virtual void threadDispose() override;
      52             :         virtual bool worker() override;
      53             : 
      54             :         virtual void cancel() override;
      55             : 
      56       17551 :         virtual bool isRunning() const override { return _running.load(); }
      57             : 
      58             :         virtual void compileResource(Rc<core::Resource> &&req, Function<void(bool)> && = nullptr, bool preload = false) const override;
      59             :         virtual void compileQueue(const Rc<Queue> &req, Function<void(bool)> && = nullptr) const override;
      60             : 
      61             :         virtual void compileMaterials(Rc<core::MaterialInputData> &&req, const Vector<Rc<DependencyEvent>> & = Vector<Rc<DependencyEvent>>()) const override;
      62             :         virtual void compileImage(const Rc<core::DynamicImage> &, Function<void(bool)> && = nullptr) const override;
      63             : 
      64             :         // run frame with RenderQueue
      65             :         virtual void runRenderQueue(Rc<FrameRequest> &&req, uint64_t gen = 0, Function<void(bool)> && = nullptr) override;
      66             : 
      67             :         // callback should return true to end spinning
      68             :         virtual void schedule(Function<bool(core::Loop &)> &&, StringView) override;
      69             :         virtual void schedule(Function<bool(core::Loop &)> &&, uint64_t, StringView) override;
      70             : 
      71             :         virtual void performInQueue(Rc<thread::Task> &&) const override;
      72             :         virtual void performInQueue(Function<void()> &&func, Ref *target = nullptr) const override;
      73             : 
      74             :         virtual void performOnGlThread(Function<void()> &&func, Ref *target = nullptr, bool immediate = false) const override;
      75             : 
      76             :         virtual bool isOnGlThread() const override;
      77             : 
      78             :         virtual Rc<FrameHandle> makeFrame(Rc<FrameRequest> &&, uint64_t gen) override;
      79             : 
      80             :         virtual Rc<core::Framebuffer> acquireFramebuffer(const PassData *, SpanView<Rc<core::ImageView>>) override;
      81             :         virtual void releaseFramebuffer(Rc<core::Framebuffer> &&) override;
      82             : 
      83             :         virtual Rc<ImageStorage> acquireImage(const ImageAttachment *, const AttachmentHandle *, const core::ImageInfoData &) override;
      84             :         virtual void releaseImage(Rc<ImageStorage> &&) override;
      85             : 
      86             :         virtual Rc<core::Semaphore> makeSemaphore() override;
      87             : 
      88             :         virtual const Vector<core::ImageFormat> &getSupportedDepthStencilFormat() const override;
      89             : 
      90             :         Rc<Fence> acquireFence(uint32_t, bool init = true);
      91             : 
      92             :         virtual void signalDependencies(const Vector<Rc<DependencyEvent>> &, Queue *, bool success) override;
      93             :         virtual void waitForDependencies(const Vector<Rc<DependencyEvent>> &, Function<void(bool)> &&) override;
      94             : 
      95             :         virtual void wakeup() override;
      96             :         virtual void waitIdle() override;
      97             : 
      98             :         virtual void captureImage(Function<void(const ImageInfoData &info, BytesView view)> &&cb,
      99             :                         const Rc<core::ImageObject> &image, core::AttachmentLayout l) override;
     100             : 
     101             :         virtual void captureBuffer(Function<void(const BufferInfo &info, BytesView view)> &&cb, const Rc<core::BufferObject> &) override;
     102             : 
     103             : protected:
     104             :         using core::Loop::init;
     105             : 
     106             :         std::thread _thread;
     107             :         std::thread::id _threadId;
     108             : 
     109             :         std::mutex _mutex;
     110             :         std::condition_variable _cond;
     111             :         std::atomic<bool> _running = false;
     112             : 
     113             :         Internal *_internal = nullptr;
     114             : 
     115             :         Rc<Instance> _vkInstance;
     116             : 
     117             :         uint64_t _clock = 0;
     118             : };
     119             : 
     120             : }
     121             : 
     122             : #endif /* XENOLITH_BACKEND_VK_XLVKLOOP_H_ */

Generated by: LCOV version 1.14