1 // Copyright 2018 Dolphin Emulator Project
2 // Licensed under GPLv2+
3 // Refer to the license.txt file included.
4 
5 #pragma once
6 
7 #include "Common/CommonTypes.h"
8 #include "Common/MathUtil.h"
9 #include "VideoCommon/TextureConfig.h"
10 
11 class AbstractTexture;
12 
13 // An abstract framebuffer wraps a backend framebuffer/view object, which can be used to
14 // draw onto a texture. Currently, only single-level textures are supported. Multi-layer
15 // textures will render by default only to the first layer, however, multiple layers
16 // be rendered in parallel using geometry shaders and layer variable.
17 
18 class AbstractFramebuffer
19 {
20 public:
21   AbstractFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment,
22                       AbstractTextureFormat color_format, AbstractTextureFormat depth_format,
23                       u32 width, u32 height, u32 layers, u32 samples);
24   virtual ~AbstractFramebuffer();
25 
26   static bool ValidateConfig(const AbstractTexture* color_attachment,
27                              const AbstractTexture* depth_attachment);
28 
GetColorAttachment()29   AbstractTexture* GetColorAttachment() const { return m_color_attachment; }
GetDepthAttachment()30   AbstractTexture* GetDepthAttachment() const { return m_depth_attachment; }
GetColorFormat()31   AbstractTextureFormat GetColorFormat() const { return m_color_format; }
GetDepthFormat()32   AbstractTextureFormat GetDepthFormat() const { return m_depth_format; }
HasColorBuffer()33   bool HasColorBuffer() const { return m_color_format != AbstractTextureFormat::Undefined; }
HasDepthBuffer()34   bool HasDepthBuffer() const { return m_depth_format != AbstractTextureFormat::Undefined; }
GetWidth()35   u32 GetWidth() const { return m_width; }
GetHeight()36   u32 GetHeight() const { return m_height; }
GetLayers()37   u32 GetLayers() const { return m_layers; }
GetSamples()38   u32 GetSamples() const { return m_samples; }
39   MathUtil::Rectangle<int> GetRect() const;
40 
41 protected:
42   AbstractTexture* m_color_attachment;
43   AbstractTexture* m_depth_attachment;
44   AbstractTextureFormat m_color_format;
45   AbstractTextureFormat m_depth_format;
46   u32 m_width;
47   u32 m_height;
48   u32 m_layers;
49   u32 m_samples;
50 };
51