2017-04-23 06:44:34 +02:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
2021-07-05 03:22:19 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-04-23 06:44:34 +02:00
|
|
|
|
|
|
|
#include "VideoCommon/TextureConfig.h"
|
|
|
|
|
|
|
|
#include <tuple>
|
|
|
|
|
2021-12-10 03:22:16 +01:00
|
|
|
#include "VideoCommon/AbstractTexture.h"
|
|
|
|
|
2017-04-23 06:44:34 +02:00
|
|
|
bool TextureConfig::operator==(const TextureConfig& o) const
|
|
|
|
{
|
2019-02-15 02:59:50 +01:00
|
|
|
return std::tie(width, height, levels, layers, samples, format, flags) ==
|
|
|
|
std::tie(o.width, o.height, o.levels, o.layers, o.samples, o.format, o.flags);
|
2017-04-23 06:44:34 +02:00
|
|
|
}
|
|
|
|
|
2017-10-21 16:49:40 +02:00
|
|
|
bool TextureConfig::operator!=(const TextureConfig& o) const
|
|
|
|
{
|
|
|
|
return !operator==(o);
|
|
|
|
}
|
|
|
|
|
2017-04-23 06:44:34 +02:00
|
|
|
MathUtil::Rectangle<int> TextureConfig::GetRect() const
|
|
|
|
{
|
|
|
|
return {0, 0, static_cast<int>(width), static_cast<int>(height)};
|
|
|
|
}
|
2017-10-21 16:49:40 +02:00
|
|
|
|
|
|
|
MathUtil::Rectangle<int> TextureConfig::GetMipRect(u32 level) const
|
|
|
|
{
|
|
|
|
return {0, 0, static_cast<int>(std::max(width >> level, 1u)),
|
|
|
|
static_cast<int>(std::max(height >> level, 1u))};
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t TextureConfig::GetStride() const
|
|
|
|
{
|
|
|
|
return AbstractTexture::CalculateStrideForFormat(format, width);
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t TextureConfig::GetMipStride(u32 level) const
|
|
|
|
{
|
|
|
|
return AbstractTexture::CalculateStrideForFormat(format, std::max(width >> level, 1u));
|
|
|
|
}
|