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

          Line data    Source code
       1             : /**
       2             :  Copyright (c) 2021 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_XLVKATTACHMENT_H_
      25             : #define XENOLITH_BACKEND_VK_XLVKATTACHMENT_H_
      26             : 
      27             : #include "XLVkSync.h"
      28             : #include "XLCoreAttachment.h"
      29             : #include "XLVkDeviceQueue.h"
      30             : 
      31             : namespace STAPPLER_VERSIONIZED stappler::xenolith::vk {
      32             : 
      33             : class BufferAttachment : public core::BufferAttachment {
      34             : public:
      35         840 :         virtual ~BufferAttachment() { }
      36             : 
      37             :         virtual Rc<AttachmentHandle> makeFrameHandle(const FrameQueue &) override;
      38             : };
      39             : 
      40             : class ImageAttachment : public core::ImageAttachment {
      41             : public:
      42         189 :         virtual ~ImageAttachment() { }
      43             : 
      44             :         virtual Rc<AttachmentHandle> makeFrameHandle(const FrameQueue &) override;
      45             : };
      46             : 
      47             : 
      48             : class BufferAttachmentHandle : public core::AttachmentHandle {
      49             : public:
      50             :         struct BufferView {
      51             :                 Rc<Buffer> buffer;
      52             :                 VkDeviceSize offset = 0;
      53             :                 VkDeviceSize size = VK_WHOLE_SIZE;
      54             :                 bool dirty = true;
      55             :         };
      56             : 
      57             :         virtual ~BufferAttachmentHandle();
      58             : 
      59             :         virtual bool writeDescriptor(const core::QueuePassHandle &, DescriptorBufferInfo &);
      60             :         virtual bool isDescriptorDirty(const PassHandle &, const PipelineDescriptor &, uint32_t, bool isExternal) const override;
      61             : 
      62             :         void clearBufferViews();
      63             :         void addBufferView(Buffer *buffer, VkDeviceSize offset = 0, VkDeviceSize size = VK_WHOLE_SIZE, bool dirty = true);
      64             :         void addBufferView(Rc<Buffer> &&buffer, VkDeviceSize offset = 0, VkDeviceSize size = VK_WHOLE_SIZE, bool dirty = true);
      65             : 
      66     2217377 :         SpanView<BufferView> getBuffers() const { return _buffers; }
      67             : 
      68             : protected:
      69             :         Vector<BufferView> _buffers; // assign this to use default binding
      70             : };
      71             : 
      72             : class ImageAttachmentHandle : public core::AttachmentHandle {
      73             : public:
      74       66808 :         virtual ~ImageAttachmentHandle() { }
      75             : 
      76             :         const Rc<core::ImageStorage> &getImage() const;
      77             : 
      78             :         virtual bool writeDescriptor(const core::QueuePassHandle &, DescriptorImageInfo &);
      79             :         virtual bool isDescriptorDirty(const PassHandle &, const PipelineDescriptor &, uint32_t, bool isExternal) const override;
      80             : };
      81             : 
      82             : class TexelAttachmentHandle : public core::AttachmentHandle {
      83             : public:
      84             :         virtual ~TexelAttachmentHandle();
      85             : 
      86             :         virtual bool writeDescriptor(const core::QueuePassHandle &, DescriptorBufferViewInfo &) { return false; }
      87             : };
      88             : 
      89             : }
      90             : 
      91             : #endif /* XENOLITH_BACKEND_VK_XLVKATTACHMENT_H_ */

Generated by: LCOV version 1.14