aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/compatible_formats.h
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2020-06-30 15:36:13 -0400
committerGitHub <noreply@github.com>2020-06-30 15:36:13 -0400
commita4f48efea4f8a8f1fb8872f834ca18d44fc0ca50 (patch)
treed21d49387395ced53dcabc737921d54047718249 /src/video_core/compatible_formats.h
parent977a3ab3521d59c6a9642285d840ff3360887d13 (diff)
parentbb2cbdf7047ed765c236e2da0c04420082d7fd8f (diff)
Merge pull request #4176 from ReinUsesLisp/compatible-formats
texture_cache: Check format compatibility before copying
Diffstat (limited to 'src/video_core/compatible_formats.h')
-rw-r--r--src/video_core/compatible_formats.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/video_core/compatible_formats.h b/src/video_core/compatible_formats.h
new file mode 100644
index 000000000..d1082566d
--- /dev/null
+++ b/src/video_core/compatible_formats.h
@@ -0,0 +1,32 @@
+// Copyright 2020 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include <array>
+#include <bitset>
+#include <cstddef>
+
+#include "video_core/surface.h"
+
+namespace VideoCore::Surface {
+
+class FormatCompatibility {
+public:
+ using Table = std::array<std::bitset<MaxPixelFormat>, MaxPixelFormat>;
+
+ explicit FormatCompatibility();
+
+ bool TestView(PixelFormat format_a, PixelFormat format_b) const noexcept {
+ return view[static_cast<size_t>(format_a)][static_cast<size_t>(format_b)];
+ }
+
+ bool TestCopy(PixelFormat format_a, PixelFormat format_b) const noexcept {
+ return copy[static_cast<size_t>(format_a)][static_cast<size_t>(format_b)];
+ }
+
+private:
+ Table view;
+ Table copy;
+};
+
+} // namespace VideoCore::Surface