2017-04-23 04:44:34 +00:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include "VideoCommon/AbstractTexture.h"
|
|
|
|
|
|
|
|
AbstractTexture::AbstractTexture(const TextureConfig& c) : m_config(c)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
AbstractTexture::~AbstractTexture() = default;
|
|
|
|
|
|
|
|
bool AbstractTexture::Save(const std::string& filename, unsigned int level)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-06-12 17:37:28 +00:00
|
|
|
bool AbstractTexture::IsCompressedHostTextureFormat(AbstractTextureFormat format)
|
2017-04-23 04:44:34 +00:00
|
|
|
{
|
|
|
|
// This will need to be changed if we add any other uncompressed formats.
|
2017-06-12 17:37:28 +00:00
|
|
|
return format != AbstractTextureFormat::RGBA8;
|
2017-04-23 04:44:34 +00:00
|
|
|
}
|
|
|
|
|
2017-06-12 17:37:28 +00:00
|
|
|
size_t AbstractTexture::CalculateHostTextureLevelPitch(AbstractTextureFormat format, u32 row_length)
|
2017-04-23 04:44:34 +00:00
|
|
|
{
|
|
|
|
switch (format)
|
|
|
|
{
|
2017-06-12 17:37:28 +00:00
|
|
|
case AbstractTextureFormat::DXT1:
|
2017-04-23 04:44:34 +00:00
|
|
|
return static_cast<size_t>(std::max(1u, row_length / 4)) * 8;
|
2017-06-12 17:37:28 +00:00
|
|
|
case AbstractTextureFormat::DXT3:
|
|
|
|
case AbstractTextureFormat::DXT5:
|
2017-04-23 04:44:34 +00:00
|
|
|
return static_cast<size_t>(std::max(1u, row_length / 4)) * 16;
|
2017-06-12 17:37:28 +00:00
|
|
|
case AbstractTextureFormat::RGBA8:
|
2017-04-23 04:44:34 +00:00
|
|
|
default:
|
|
|
|
return static_cast<size_t>(row_length) * 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-19 03:33:15 +00:00
|
|
|
const TextureConfig& AbstractTexture::GetConfig() const
|
2017-04-23 04:44:34 +00:00
|
|
|
{
|
|
|
|
return m_config;
|
|
|
|
}
|