Move most backend functionality to VideoCommon

This commit is contained in:
Stenzek
2019-02-15 11:59:50 +10:00
parent 933f3ba008
commit f039149198
182 changed files with 8334 additions and 15917 deletions

View File

@ -15,6 +15,10 @@ AbstractTexture::AbstractTexture(const TextureConfig& c) : m_config(c)
{
}
void AbstractTexture::FinishedRendering()
{
}
bool AbstractTexture::Save(const std::string& filename, unsigned int level)
{
// We can't dump compressed textures currently (it would mean drawing them to a RGBA8
@ -30,7 +34,7 @@ bool AbstractTexture::Save(const std::string& filename, unsigned int level)
// Use a temporary staging texture for the download. Certainly not optimal,
// but this is not a frequently-executed code path..
TextureConfig readback_texture_config(level_width, level_height, 1, 1, 1,
AbstractTextureFormat::RGBA8, false);
AbstractTextureFormat::RGBA8, 0);
auto readback_texture =
g_renderer->CreateStagingTexture(StagingTextureType::Readback, readback_texture_config);
if (!readback_texture)
@ -84,7 +88,24 @@ bool AbstractTexture::IsStencilFormat(AbstractTextureFormat format)
return format == AbstractTextureFormat::D24_S8 || format == AbstractTextureFormat::D32F_S8;
}
size_t AbstractTexture::CalculateStrideForFormat(AbstractTextureFormat format, u32 row_length)
AbstractTextureFormat AbstractTexture::GetColorFormatForDepthFormat(AbstractTextureFormat format)
{
switch (format)
{
case AbstractTextureFormat::D16:
return AbstractTextureFormat::R16;
case AbstractTextureFormat::D24_S8: // TODO: Incorrect
case AbstractTextureFormat::D32F:
case AbstractTextureFormat::D32F_S8:
return AbstractTextureFormat::R32F;
default:
return format;
}
}
u32 AbstractTexture::CalculateStrideForFormat(AbstractTextureFormat format, u32 row_length)
{
switch (format)
{
@ -111,7 +132,7 @@ size_t AbstractTexture::CalculateStrideForFormat(AbstractTextureFormat format, u
}
}
size_t AbstractTexture::GetTexelSizeForFormat(AbstractTextureFormat format)
u32 AbstractTexture::GetTexelSizeForFormat(AbstractTextureFormat format)
{
switch (format)
{
@ -138,6 +159,21 @@ size_t AbstractTexture::GetTexelSizeForFormat(AbstractTextureFormat format)
}
}
u32 AbstractTexture::GetBlockSizeForFormat(AbstractTextureFormat format)
{
switch (format)
{
case AbstractTextureFormat::DXT1:
case AbstractTextureFormat::DXT3:
case AbstractTextureFormat::DXT5:
case AbstractTextureFormat::BPTC:
return 4;
default:
return 1;
}
}
const TextureConfig& AbstractTexture::GetConfig() const
{
return m_config;