2018-01-21 10:22:45 +00:00
|
|
|
// Copyright 2018 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-01-21 10:22:45 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-05-29 01:59:02 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2018-01-21 10:22:45 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
#include "Common/MathUtil.h"
|
|
|
|
#include "VideoCommon/TextureConfig.h"
|
|
|
|
|
|
|
|
class AbstractTexture;
|
|
|
|
|
|
|
|
// An abstract framebuffer wraps a backend framebuffer/view object, which can be used to
|
|
|
|
// draw onto a texture. Currently, only single-level textures are supported. Multi-layer
|
|
|
|
// textures will render by default only to the first layer, however, multiple layers
|
|
|
|
// be rendered in parallel using geometry shaders and layer variable.
|
|
|
|
|
|
|
|
class AbstractFramebuffer
|
|
|
|
{
|
|
|
|
public:
|
2019-02-15 01:59:50 +00:00
|
|
|
AbstractFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment,
|
2023-05-29 01:59:02 +00:00
|
|
|
std::vector<AbstractTexture*> additional_color_attachments,
|
2019-02-15 01:59:50 +00:00
|
|
|
AbstractTextureFormat color_format, AbstractTextureFormat depth_format,
|
2018-01-21 10:22:45 +00:00
|
|
|
u32 width, u32 height, u32 layers, u32 samples);
|
|
|
|
virtual ~AbstractFramebuffer();
|
|
|
|
|
|
|
|
static bool ValidateConfig(const AbstractTexture* color_attachment,
|
2023-05-29 01:59:02 +00:00
|
|
|
const AbstractTexture* depth_attachment,
|
|
|
|
const std::vector<AbstractTexture*>& additional_color_attachments);
|
2018-01-21 10:22:45 +00:00
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
AbstractTexture* GetColorAttachment() const { return m_color_attachment; }
|
|
|
|
AbstractTexture* GetDepthAttachment() const { return m_depth_attachment; }
|
2018-01-21 10:22:45 +00:00
|
|
|
AbstractTextureFormat GetColorFormat() const { return m_color_format; }
|
|
|
|
AbstractTextureFormat GetDepthFormat() const { return m_depth_format; }
|
|
|
|
bool HasColorBuffer() const { return m_color_format != AbstractTextureFormat::Undefined; }
|
|
|
|
bool HasDepthBuffer() const { return m_depth_format != AbstractTextureFormat::Undefined; }
|
|
|
|
u32 GetWidth() const { return m_width; }
|
|
|
|
u32 GetHeight() const { return m_height; }
|
|
|
|
u32 GetLayers() const { return m_layers; }
|
|
|
|
u32 GetSamples() const { return m_samples; }
|
|
|
|
MathUtil::Rectangle<int> GetRect() const;
|
|
|
|
|
|
|
|
protected:
|
2019-02-15 01:59:50 +00:00
|
|
|
AbstractTexture* m_color_attachment;
|
|
|
|
AbstractTexture* m_depth_attachment;
|
2023-08-13 03:37:01 +00:00
|
|
|
std::vector<AbstractTexture*> m_additional_color_attachments;
|
2018-01-21 10:22:45 +00:00
|
|
|
AbstractTextureFormat m_color_format;
|
|
|
|
AbstractTextureFormat m_depth_format;
|
|
|
|
u32 m_width;
|
|
|
|
u32 m_height;
|
|
|
|
u32 m_layers;
|
|
|
|
u32 m_samples;
|
|
|
|
};
|