LCOV - code coverage report
Current view: top level - source/renderer/backend/vulkan - RenderPassManager.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 0 1 0.0 %
Date: 2023-01-19 00:18:29 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /* Copyright (C) 2023 Wildfire Games.
       2             :  * This file is part of 0 A.D.
       3             :  *
       4             :  * 0 A.D. is free software: you can redistribute it and/or modify
       5             :  * it under the terms of the GNU General Public License as published by
       6             :  * the Free Software Foundation, either version 2 of the License, or
       7             :  * (at your option) any later version.
       8             :  *
       9             :  * 0 A.D. is distributed in the hope that it will be useful,
      10             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  * GNU General Public License for more details.
      13             :  *
      14             :  * You should have received a copy of the GNU General Public License
      15             :  * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
      16             :  */
      17             : 
      18             : #ifndef INCLUDED_RENDERER_BACKEND_VULKAN_RENDERPASSMANAGER
      19             : #define INCLUDED_RENDERER_BACKEND_VULKAN_RENDERPASSMANAGER
      20             : 
      21             : #include "renderer/backend/IFramebuffer.h"
      22             : 
      23             : #include <glad/vulkan.h>
      24             : #include <optional>
      25             : #include <unordered_map>
      26             : #include <vector>
      27             : 
      28             : namespace Renderer
      29             : {
      30             : 
      31             : namespace Backend
      32             : {
      33             : 
      34             : namespace Vulkan
      35             : {
      36             : 
      37             : class CDevice;
      38             : 
      39             : /**
      40             :  * A helper class to store unique render passes.
      41             :  */
      42             : class CRenderPassManager
      43             : {
      44             : public:
      45             :     CRenderPassManager(CDevice* device);
      46             :     ~CRenderPassManager();
      47             : 
      48             :     /**
      49             :      * @return a renderpass with required attachments. Currently we use only
      50             :      * single subpass renderpasses.
      51             :      * @note it should be called as rarely as possible.
      52             :      */
      53             :     VkRenderPass GetOrCreateRenderPass(
      54             :         SColorAttachment* colorAttachment,
      55             :         SDepthStencilAttachment* depthStencilAttachment);
      56             : 
      57             : private:
      58             :     CDevice* m_Device = nullptr;
      59             : 
      60             :     struct Attachment
      61             :     {
      62             :         VkFormat format;
      63             :         AttachmentLoadOp loadOp;
      64             :         AttachmentStoreOp storeOp;
      65             :     };
      66           0 :     struct Desc
      67             :     {
      68             :         uint8_t sampleCount;
      69             :         std::optional<Attachment> colorAttachment;
      70             :         std::optional<Attachment> depthStencilAttachment;
      71             :     };
      72             :     struct DescHash
      73             :     {
      74             :         size_t operator()(const Desc& desc) const;
      75             :     };
      76             :     struct DescEqual
      77             :     {
      78             :         bool operator()(const Desc& lhs, const Desc& rhs) const;
      79             :     };
      80             :     std::unordered_map<Desc, VkRenderPass, DescHash, DescEqual> m_RenderPassMap;
      81             : };
      82             : 
      83             : } // namespace Vulkan
      84             : 
      85             : } // namespace Backend
      86             : 
      87             : } // namespace Renderer
      88             : 
      89             : #endif // INCLUDED_RENDERER_BACKEND_VULKAN_RENDERPASSMANAGER

Generated by: LCOV version 1.13