diff options
| author | Stenzek <stenzek@gmail.com> | 2018-01-21 20:22:45 +1000 |
|---|---|---|
| committer | Stenzek <stenzek@gmail.com> | 2018-03-02 20:20:48 +1000 |
| commit | 4c24a697106471b33973da619a43167c947276aa (patch) | |
| tree | a3c94597cfbffccc30d56ef58fcfefd2183b0126 /Source/Core/VideoCommon/AbstractFramebuffer.cpp | |
| parent | 2a6d9e4713a9a540684795cb10ee6e6462178ba1 (diff) | |
VideoCommon: Add support for Abstract Framebuffers
Diffstat (limited to 'Source/Core/VideoCommon/AbstractFramebuffer.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/AbstractFramebuffer.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/AbstractFramebuffer.cpp b/Source/Core/VideoCommon/AbstractFramebuffer.cpp new file mode 100644 index 0000000000..8a1adb7018 --- /dev/null +++ b/Source/Core/VideoCommon/AbstractFramebuffer.cpp @@ -0,0 +1,55 @@ +// Copyright 2018 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "VideoCommon/AbstractFramebuffer.h" +#include "VideoCommon/AbstractTexture.h" + +AbstractFramebuffer::AbstractFramebuffer(AbstractTextureFormat color_format, + AbstractTextureFormat depth_format, u32 width, u32 height, + u32 layers, u32 samples) + : m_color_format(color_format), m_depth_format(depth_format), m_width(width), m_height(height), + m_layers(layers), m_samples(samples) +{ +} + +AbstractFramebuffer::~AbstractFramebuffer() = default; + +bool AbstractFramebuffer::ValidateConfig(const AbstractTexture* color_attachment, + const AbstractTexture* depth_attachment) +{ + // Must have at least a color or depth attachment. + if (!color_attachment && !depth_attachment) + return false; + + // Currently we only expose a single mip level for render target textures. + // MSAA textures are not supported with mip levels on most backends, and it simplifies our + // handling of framebuffers. + auto CheckAttachment = [](const AbstractTexture* tex) { + return tex->GetConfig().rendertarget && tex->GetConfig().levels == 1; + }; + if ((color_attachment && !CheckAttachment(color_attachment)) || + depth_attachment && !CheckAttachment(depth_attachment)) + { + return false; + } + + // If both color and depth are present, their attributes must match. + if (color_attachment && depth_attachment) + { + if (color_attachment->GetConfig().width != depth_attachment->GetConfig().width || + color_attachment->GetConfig().height != depth_attachment->GetConfig().height || + color_attachment->GetConfig().layers != depth_attachment->GetConfig().layers || + color_attachment->GetConfig().samples != depth_attachment->GetConfig().samples) + { + return false; + } + } + + return true; +} + +MathUtil::Rectangle<int> AbstractFramebuffer::GetRect() const +{ + return MathUtil::Rectangle<int>(0, 0, static_cast<int>(m_width), static_cast<int>(m_height)); +} |
