summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZephyron <zephyron@citron-emu.orgq>2025-02-16 18:30:50 +1000
committerZephyron <zephyron@citron-emu.orgq>2025-02-16 18:30:50 +1000
commit1c9e17496b6f9f4b083c62aa25548617dd179a8b (patch)
tree50e17cc903d7c80021ca4489e08db4f3ed595cd7 /src
parent7730d14b4a267c9579636a18af73d4252385e15f (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/texture_cache/image_info.cpp12
-rw-r--r--src/video_core/texture_cache/image_info.h3
-rw-r--r--src/video_core/texture_cache/image_view_info.cpp8
-rw-r--r--src/video_core/texture_cache/image_view_info.h3
4 files changed, 26 insertions, 0 deletions
diff --git a/src/video_core/texture_cache/image_info.cpp b/src/video_core/texture_cache/image_info.cpp
index 135dd64de..08df876b1 100644
--- a/src/video_core/texture_cache/image_info.cpp
+++ b/src/video_core/texture_cache/image_info.cpp
@@ -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
diff --git a/src/video_core/texture_cache/image_info.h b/src/video_core/texture_cache/image_info.h
index eb490a642..63bc9bf78 100644
--- a/src/video_core/texture_cache/image_info.h
+++ b/src/video_core/texture_cache/image_info.h
@@ -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
diff --git a/src/video_core/texture_cache/image_view_info.cpp b/src/video_core/texture_cache/image_view_info.cpp
index f47885147..5930204db 100644
--- a/src/video_core/texture_cache/image_view_info.cpp
+++ b/src/video_core/texture_cache/image_view_info.cpp
@@ -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
diff --git a/src/video_core/texture_cache/image_view_info.h b/src/video_core/texture_cache/image_view_info.h
index 921f88988..a28248795 100644
--- a/src/video_core/texture_cache/image_view_info.h
+++ b/src/video_core/texture_cache/image_view_info.h
@@ -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>);