mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
VideoBackends: Add AbstractStagingTexture class
Can be used for asynchronous readback or upload of textures.
This commit is contained in:
@ -25,4 +25,43 @@ void NullTexture::Load(u32 level, u32 width, u32 height, u32 row_length, const u
|
||||
{
|
||||
}
|
||||
|
||||
NullStagingTexture::NullStagingTexture(StagingTextureType type, const TextureConfig& config)
|
||||
: AbstractStagingTexture(type, config)
|
||||
{
|
||||
m_texture_buf.resize(m_texel_size * config.width * config.height);
|
||||
m_map_pointer = reinterpret_cast<char*>(m_texture_buf.data());
|
||||
m_map_stride = m_texel_size * config.width;
|
||||
}
|
||||
|
||||
NullStagingTexture::~NullStagingTexture() = default;
|
||||
|
||||
void NullStagingTexture::CopyFromTexture(const AbstractTexture* src,
|
||||
const MathUtil::Rectangle<int>& src_rect, u32 src_layer,
|
||||
u32 src_level, const MathUtil::Rectangle<int>& dst_rect)
|
||||
{
|
||||
m_needs_flush = true;
|
||||
}
|
||||
|
||||
void NullStagingTexture::CopyToTexture(const MathUtil::Rectangle<int>& src_rect,
|
||||
AbstractTexture* dst,
|
||||
const MathUtil::Rectangle<int>& dst_rect, u32 dst_layer,
|
||||
u32 dst_level)
|
||||
{
|
||||
m_needs_flush = true;
|
||||
}
|
||||
|
||||
bool NullStagingTexture::Map()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void NullStagingTexture::Unmap()
|
||||
{
|
||||
}
|
||||
|
||||
void NullStagingTexture::Flush()
|
||||
{
|
||||
m_needs_flush = false;
|
||||
}
|
||||
|
||||
} // namespace Null
|
||||
|
@ -4,8 +4,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
#include "VideoCommon/AbstractStagingTexture.h"
|
||||
#include "VideoCommon/AbstractTexture.h"
|
||||
|
||||
namespace Null
|
||||
@ -25,4 +28,25 @@ public:
|
||||
size_t buffer_size) override;
|
||||
};
|
||||
|
||||
class NullStagingTexture final : public AbstractStagingTexture
|
||||
{
|
||||
public:
|
||||
explicit NullStagingTexture(StagingTextureType type, const TextureConfig& config);
|
||||
~NullStagingTexture();
|
||||
|
||||
void CopyFromTexture(const AbstractTexture* src, const MathUtil::Rectangle<int>& src_rect,
|
||||
u32 src_layer, u32 src_level,
|
||||
const MathUtil::Rectangle<int>& dst_rect) override;
|
||||
void CopyToTexture(const MathUtil::Rectangle<int>& src_rect, AbstractTexture* dst,
|
||||
const MathUtil::Rectangle<int>& dst_rect, u32 dst_layer,
|
||||
u32 dst_level) override;
|
||||
|
||||
bool Map() override;
|
||||
void Unmap() override;
|
||||
void Flush() override;
|
||||
|
||||
private:
|
||||
std::vector<u8> m_texture_buf;
|
||||
};
|
||||
|
||||
} // namespace Null
|
||||
|
@ -27,6 +27,12 @@ std::unique_ptr<AbstractTexture> Renderer::CreateTexture(const TextureConfig& co
|
||||
return std::make_unique<NullTexture>(config);
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractStagingTexture> Renderer::CreateStagingTexture(StagingTextureType type,
|
||||
const TextureConfig& config)
|
||||
{
|
||||
return std::make_unique<NullStagingTexture>(type, config);
|
||||
}
|
||||
|
||||
void Renderer::RenderText(const std::string& text, int left, int top, u32 color)
|
||||
{
|
||||
NOTICE_LOG(VIDEO, "RenderText: %s", text.c_str());
|
||||
|
@ -15,6 +15,8 @@ public:
|
||||
~Renderer() override;
|
||||
|
||||
std::unique_ptr<AbstractTexture> CreateTexture(const TextureConfig& config) override;
|
||||
std::unique_ptr<AbstractStagingTexture>
|
||||
CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override;
|
||||
|
||||
void RenderText(const std::string& pstr, int left, int top, u32 color) override;
|
||||
u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) override { return 0; }
|
||||
|
Reference in New Issue
Block a user