| 1 | // Copyright 2017 Dolphin Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include "VideoCommon/TextureConfig.h" |
| 5 | |
| 6 | #include <tuple> |
| 7 | |
| 8 | #include "VideoCommon/AbstractTexture.h" |
| 9 | |
| 10 | bool TextureConfig::operator==(const TextureConfig& o) const |
| 11 | { |
| 12 | return std::tie(width, height, levels, layers, samples, format, flags, type) == |
| 13 | std::tie(o.width, o.height, o.levels, o.layers, o.samples, o.format, o.flags, o.type); |
| 14 | } |
| 15 | |
| 16 | MathUtil::Rectangle<int> TextureConfig::GetRect() const |
| 17 | { |
| 18 | return {0, 0, static_cast<int>(width), static_cast<int>(height)}; |
| 19 | } |
| 20 | |
| 21 | MathUtil::Rectangle<int> TextureConfig::GetMipRect(u32 level) const |
| 22 | { |
| 23 | return {0, 0, static_cast<int>(std::max(width >> level, 1u)), |
| 24 | static_cast<int>(std::max(height >> level, 1u))}; |
| 25 | } |
| 26 | |
| 27 | size_t TextureConfig::GetStride() const |
| 28 | { |
| 29 | return AbstractTexture::CalculateStrideForFormat(format, width); |
| 30 | } |
| 31 | |
| 32 | size_t TextureConfig::GetMipStride(u32 level) const |
| 33 | { |
| 34 | return AbstractTexture::CalculateStrideForFormat(format, std::max(width >> level, 1u)); |
| 35 | } |