mirror of
https://git.citron-emu.org/Citron/Citron.git
synced 2025-02-23 17:18:47 +01:00
texture_cache: Add equality operators for ImageInfo and ImageViewInfo
- Add operator== to ImageInfo and ImageViewInfo classes to enable direct equality comparisons. The implementations use std::tie to perform member-wise comparisons of all relevant fields in a safe and efficient manner. This allows for easier comparison of texture cache entries and view information, which can be useful for cache management and debugging.
This commit is contained in:
parent
7730d14b4a
commit
1c9e17496b
4 changed files with 26 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <fmt/ranges.h>
|
||||
|
@ -284,4 +285,15 @@ ImageInfo::ImageInfo(const Tegra::DMA::ImageOperand& config) noexcept {
|
|||
downscaleable = size.height > DownscaleHeightThreshold;
|
||||
}
|
||||
|
||||
bool ImageInfo::operator==(const ImageInfo& rhs) const noexcept {
|
||||
return std::tie(this->format, this->num_samples, this->resources, this->type,
|
||||
this->pitch, this->block, this->size, this->tile_width_spacing,
|
||||
this->is_sparse, this->rescaleable, this->downscaleable,
|
||||
this->forced_flushed, this->dma_downloaded) ==
|
||||
std::tie(rhs.format, rhs.num_samples, rhs.resources, rhs.type,
|
||||
rhs.pitch, rhs.block, rhs.size, rhs.tile_width_spacing,
|
||||
rhs.is_sparse, rhs.rescaleable, rhs.downscaleable,
|
||||
rhs.forced_flushed, rhs.dma_downloaded);
|
||||
}
|
||||
|
||||
} // namespace VideoCommon
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
@ -42,6 +43,8 @@ struct ImageInfo {
|
|||
bool forced_flushed = false;
|
||||
bool dma_downloaded = false;
|
||||
bool is_sparse = false;
|
||||
|
||||
bool operator==(const ImageInfo& rhs) const noexcept;
|
||||
};
|
||||
|
||||
} // namespace VideoCommon
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <limits>
|
||||
|
@ -87,4 +88,11 @@ bool ImageViewInfo::IsRenderTarget() const noexcept {
|
|||
z_source == RENDER_TARGET_SWIZZLE && w_source == RENDER_TARGET_SWIZZLE;
|
||||
}
|
||||
|
||||
bool ImageViewInfo::operator==(const ImageViewInfo& rhs) const noexcept {
|
||||
return std::tie(this->type, this->format, this->range,
|
||||
this->x_source, this->y_source, this->z_source, this->w_source) ==
|
||||
std::tie(rhs.type, rhs.format, rhs.range,
|
||||
rhs.x_source, rhs.y_source, rhs.z_source, rhs.w_source);
|
||||
}
|
||||
|
||||
} // namespace VideoCommon
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
@ -43,6 +44,8 @@ struct ImageViewInfo {
|
|||
u8 y_source = static_cast<u8>(SwizzleSource::G);
|
||||
u8 z_source = static_cast<u8>(SwizzleSource::B);
|
||||
u8 w_source = static_cast<u8>(SwizzleSource::A);
|
||||
|
||||
bool operator==(const ImageViewInfo& rhs) const noexcept;
|
||||
};
|
||||
static_assert(std::has_unique_object_representations_v<ImageViewInfo>);
|
||||
|
||||
|
|
Loading…
Reference in a new issue