LCOV - code coverage report
Current view: top level - source/renderer/backend - IFramebuffer.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 1 1 100.0 %
Date: 2026-11-27 01:44:37 Functions: 0 0 -

          Line data    Source code
       1             : /* Copyright (C) 2022 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_IFRAMEBUFFER
      19             : #define INCLUDED_RENDERER_BACKEND_IFRAMEBUFFER
      20             : 
      21             : #include "graphics/Color.h"
      22             : #include "renderer/backend/IDeviceObject.h"
      23             : 
      24             : #include <cstdint>
      25             : 
      26             : namespace Renderer
      27             : {
      28             : 
      29             : namespace Backend
      30             : {
      31             : 
      32             : class ITexture;
      33             : 
      34             : /**
      35             :  * Load operation is set for each attachment, what should be done with its
      36             :  * content on BeginFramebufferPass.
      37             :  */
      38             : enum class AttachmentLoadOp
      39             : {
      40             :     // Loads the attachment content.
      41             :     LOAD,
      42             :     // Clears the attachment content without loading. Prefer to use that
      43             :     // operation over manual ClearFramebuffer.
      44             :     CLEAR,
      45             :     // After BeginFramebufferPass the attachment content is undefined.
      46             :     DONT_CARE
      47             : };
      48             : 
      49             : /**
      50             :  * Store operation is set for each attachment, what should be done with its
      51             :  * content on EndFramebufferPass.
      52             :  */
      53             : enum class AttachmentStoreOp
      54             : {
      55             :     // Stores the attachment content.
      56             :     STORE,
      57             :     // After EndFramebufferPass the attachment content is undefined.
      58             :     DONT_CARE
      59             : };
      60             : 
      61             : struct SColorAttachment
      62             : {
      63             :     ITexture* texture = nullptr;
      64             :     AttachmentLoadOp loadOp = AttachmentLoadOp::DONT_CARE;
      65             :     AttachmentStoreOp storeOp = AttachmentStoreOp::DONT_CARE;
      66             :     CColor clearColor;
      67             : };
      68             : 
      69             : struct SDepthStencilAttachment
      70             : {
      71             :     ITexture* texture = nullptr;
      72             :     AttachmentLoadOp loadOp = AttachmentLoadOp::DONT_CARE;
      73             :     AttachmentStoreOp storeOp = AttachmentStoreOp::DONT_CARE;
      74             : };
      75             : 
      76             : /**
      77             :  * IFramebuffer stores attachments which should be used by backend as rendering
      78             :  * destinations. That combining allows to set these destinations at once.
      79             :  * IFramebuffer doesn't own its attachments so clients must keep them alive.
      80             :  * The number of framebuffers ever created for a device during its lifetime
      81             :  * should be as small as possible.
      82             :  *
      83             :  * Framebuffer is a term from OpenGL/Vulkan worlds (D3D synonym is a render
      84             :  * target).
      85             :  */
      86          20 : class IFramebuffer : public IDeviceObject<IFramebuffer>
      87             : {
      88             : public:
      89             :     /**
      90             :      * Returns a clear color for all color attachments of the framebuffer.
      91             :      * @see IDevice::CreateFramebuffer()
      92             :      */
      93             :     virtual const CColor& GetClearColor() const = 0;
      94             : 
      95             :     virtual uint32_t GetWidth() const = 0;
      96             :     virtual uint32_t GetHeight() const = 0;
      97             : };
      98             : 
      99             : } // namespace Backend
     100             : 
     101             : } // namespace Renderer
     102             : 
     103             : #endif // INCLUDED_RENDERER_BACKEND_IFRAMEBUFFER

Generated by: LCOV version 1.16