VideoCommon: Add support for Abstract Framebuffers

This commit is contained in:
Stenzek
2018-01-21 20:22:45 +10:00
parent 2a6d9e4713
commit 4c24a69710
31 changed files with 792 additions and 9 deletions

View File

@ -39,6 +39,14 @@ SWRenderer::CreateStagingTexture(StagingTextureType type, const TextureConfig& c
return std::make_unique<SW::SWStagingTexture>(type, config);
}
std::unique_ptr<AbstractFramebuffer>
SWRenderer::CreateFramebuffer(const AbstractTexture* color_attachment,
const AbstractTexture* depth_attachment)
{
return SW::SWFramebuffer::Create(static_cast<const SW::SWTexture*>(color_attachment),
static_cast<const SW::SWTexture*>(depth_attachment));
}
void SWRenderer::RenderText(const std::string& pstr, int left, int top, u32 color)
{
SWOGLWindow::s_instance->PrintText(pstr, left, top, color);

View File

@ -16,6 +16,9 @@ public:
std::unique_ptr<AbstractTexture> CreateTexture(const TextureConfig& config) override;
std::unique_ptr<AbstractStagingTexture>
CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override;
std::unique_ptr<AbstractFramebuffer>
CreateFramebuffer(const AbstractTexture* color_attachment,
const AbstractTexture* depth_attachment) override;
std::unique_ptr<AbstractShader> CreateShaderFromSource(ShaderStage stage, const char* source,
size_t length) override;

View File

@ -152,4 +152,31 @@ void SWStagingTexture::Flush()
{
m_needs_flush = false;
}
SWFramebuffer::SWFramebuffer(AbstractTextureFormat color_format, AbstractTextureFormat depth_format,
u32 width, u32 height, u32 layers, u32 samples)
: AbstractFramebuffer(color_format, depth_format, width, height, layers, samples)
{
}
std::unique_ptr<SWFramebuffer> SWFramebuffer::Create(const SWTexture* color_attachment,
const SWTexture* depth_attachment)
{
if (!ValidateConfig(color_attachment, depth_attachment))
return nullptr;
const AbstractTextureFormat color_format =
color_attachment ? color_attachment->GetFormat() : AbstractTextureFormat::Undefined;
const AbstractTextureFormat depth_format =
depth_attachment ? depth_attachment->GetFormat() : AbstractTextureFormat::Undefined;
const SWTexture* either_attachment = color_attachment ? color_attachment : depth_attachment;
const u32 width = either_attachment->GetWidth();
const u32 height = either_attachment->GetHeight();
const u32 layers = either_attachment->GetLayers();
const u32 samples = either_attachment->GetSamples();
return std::make_unique<SWFramebuffer>(color_format, depth_format, width, height, layers,
samples);
}
} // namespace SW

View File

@ -4,10 +4,12 @@
#pragma once
#include <memory>
#include <vector>
#include "Common/CommonTypes.h"
#include "VideoCommon/AbstractFramebuffer.h"
#include "VideoCommon/AbstractStagingTexture.h"
#include "VideoCommon/AbstractTexture.h"
@ -59,4 +61,15 @@ private:
std::vector<u8> m_data;
};
class SWFramebuffer final : public AbstractFramebuffer
{
public:
explicit SWFramebuffer(AbstractTextureFormat color_format, AbstractTextureFormat depth_format,
u32 width, u32 height, u32 layers, u32 samples);
~SWFramebuffer() override = default;
static std::unique_ptr<SWFramebuffer> Create(const SWTexture* color_attachment,
const SWTexture* depth_attachment);
};
} // namespace SW