mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Merge pull request #11859 from iwubcode/backend-multi-output
VideoBackends: add support to allow rendering to multiple output targets
This commit is contained in:
@ -6,10 +6,12 @@
|
||||
|
||||
AbstractFramebuffer::AbstractFramebuffer(AbstractTexture* color_attachment,
|
||||
AbstractTexture* depth_attachment,
|
||||
std::vector<AbstractTexture*> additional_color_attachments,
|
||||
AbstractTextureFormat color_format,
|
||||
AbstractTextureFormat depth_format, u32 width, u32 height,
|
||||
u32 layers, u32 samples)
|
||||
: m_color_attachment(color_attachment), m_depth_attachment(depth_attachment),
|
||||
m_additional_color_attachments(std::move(additional_color_attachments)),
|
||||
m_color_format(color_format), m_depth_format(depth_format), m_width(width), m_height(height),
|
||||
m_layers(layers), m_samples(samples)
|
||||
{
|
||||
@ -17,13 +19,18 @@ AbstractFramebuffer::AbstractFramebuffer(AbstractTexture* color_attachment,
|
||||
|
||||
AbstractFramebuffer::~AbstractFramebuffer() = default;
|
||||
|
||||
bool AbstractFramebuffer::ValidateConfig(const AbstractTexture* color_attachment,
|
||||
const AbstractTexture* depth_attachment)
|
||||
bool AbstractFramebuffer::ValidateConfig(
|
||||
const AbstractTexture* color_attachment, const AbstractTexture* depth_attachment,
|
||||
const std::vector<AbstractTexture*>& additional_color_attachments)
|
||||
{
|
||||
// Must have at least a color or depth attachment.
|
||||
if (!color_attachment && !depth_attachment)
|
||||
return false;
|
||||
|
||||
// Must have a color attachment if additional color attachments are defined
|
||||
if (!color_attachment && !additional_color_attachments.empty())
|
||||
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.
|
||||
@ -36,6 +43,14 @@ bool AbstractFramebuffer::ValidateConfig(const AbstractTexture* color_attachment
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto* attachment : additional_color_attachments)
|
||||
{
|
||||
if (!CheckAttachment(attachment))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// If both color and depth are present, their attributes must match.
|
||||
if (color_attachment && depth_attachment)
|
||||
{
|
||||
@ -48,6 +63,16 @@ bool AbstractFramebuffer::ValidateConfig(const AbstractTexture* color_attachment
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* attachment : additional_color_attachments)
|
||||
{
|
||||
if (color_attachment->GetConfig().width != attachment->GetConfig().width ||
|
||||
color_attachment->GetConfig().height != attachment->GetConfig().height ||
|
||||
color_attachment->GetConfig().samples != attachment->GetConfig().samples)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/MathUtil.h"
|
||||
#include "VideoCommon/TextureConfig.h"
|
||||
@ -18,12 +20,14 @@ class AbstractFramebuffer
|
||||
{
|
||||
public:
|
||||
AbstractFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment,
|
||||
std::vector<AbstractTexture*> additional_color_attachments,
|
||||
AbstractTextureFormat color_format, AbstractTextureFormat depth_format,
|
||||
u32 width, u32 height, u32 layers, u32 samples);
|
||||
virtual ~AbstractFramebuffer();
|
||||
|
||||
static bool ValidateConfig(const AbstractTexture* color_attachment,
|
||||
const AbstractTexture* depth_attachment);
|
||||
const AbstractTexture* depth_attachment,
|
||||
const std::vector<AbstractTexture*>& additional_color_attachments);
|
||||
|
||||
AbstractTexture* GetColorAttachment() const { return m_color_attachment; }
|
||||
AbstractTexture* GetDepthAttachment() const { return m_depth_attachment; }
|
||||
@ -42,6 +46,7 @@ protected:
|
||||
AbstractTexture* m_depth_attachment;
|
||||
AbstractTextureFormat m_color_format;
|
||||
AbstractTextureFormat m_depth_format;
|
||||
std::vector<AbstractTexture*> m_additional_color_attachments;
|
||||
u32 m_width;
|
||||
u32 m_height;
|
||||
u32 m_layers;
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class AbstractFramebuffer;
|
||||
class AbstractPipeline;
|
||||
@ -75,7 +76,8 @@ public:
|
||||
virtual std::unique_ptr<AbstractStagingTexture>
|
||||
CreateStagingTexture(StagingTextureType type, const TextureConfig& config) = 0;
|
||||
virtual std::unique_ptr<AbstractFramebuffer>
|
||||
CreateFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment) = 0;
|
||||
CreateFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment,
|
||||
std::vector<AbstractTexture*> additional_color_attachments = {}) = 0;
|
||||
|
||||
// Framebuffer operations.
|
||||
virtual void SetFramebuffer(AbstractFramebuffer* framebuffer);
|
||||
|
@ -19,7 +19,7 @@ namespace VideoCommon
|
||||
// As pipelines encompass both shader UIDs and render states, changes to either of these should
|
||||
// also increment the pipeline UID version. Incrementing the UID version will cause all UID
|
||||
// caches to be invalidated.
|
||||
constexpr u32 GX_PIPELINE_UID_VERSION = 6; // Last changed in PR 10890
|
||||
constexpr u32 GX_PIPELINE_UID_VERSION = 7; // Last changed in PR 11859
|
||||
|
||||
struct GXPipelineUid
|
||||
{
|
||||
|
@ -453,6 +453,7 @@ FramebufferState GetColorFramebufferState(AbstractTextureFormat format)
|
||||
state.depth_texture_format = AbstractTextureFormat::Undefined;
|
||||
state.per_sample_shading = false;
|
||||
state.samples = 1;
|
||||
state.additional_color_attachment_count = 0;
|
||||
return state;
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,12 @@ union FramebufferState
|
||||
BitField<16, 8, u32> samples;
|
||||
BitField<24, 1, u32> per_sample_shading;
|
||||
|
||||
// Note: all additional color attachments
|
||||
// have the same format as `color_texture_format`
|
||||
// TODO: in the future improve this so every attachment
|
||||
// can specify its own format
|
||||
BitField<25, 3, u32> additional_color_attachment_count;
|
||||
|
||||
u32 hex = 0;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user