summaryrefslogtreecommitdiffstats
path: root/src/video_core/texture_cache/format_lookup_table.h
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-11-09 07:26:30 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-11-15 00:57:10 +0100
commit80eacdf89b55528a66b2e94391e640e641e8cb57 (patch)
tree38f52e7744ba4db1aba6252837459b1ca72fa465 /src/video_core/texture_cache/format_lookup_table.h
parenttexture_cache: Drop abstracted ComponentType (diff)
downloadyuzu-80eacdf89b55528a66b2e94391e640e641e8cb57.tar
yuzu-80eacdf89b55528a66b2e94391e640e641e8cb57.tar.gz
yuzu-80eacdf89b55528a66b2e94391e640e641e8cb57.tar.bz2
yuzu-80eacdf89b55528a66b2e94391e640e641e8cb57.tar.lz
yuzu-80eacdf89b55528a66b2e94391e640e641e8cb57.tar.xz
yuzu-80eacdf89b55528a66b2e94391e640e641e8cb57.tar.zst
yuzu-80eacdf89b55528a66b2e94391e640e641e8cb57.zip
Diffstat (limited to 'src/video_core/texture_cache/format_lookup_table.h')
-rw-r--r--src/video_core/texture_cache/format_lookup_table.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/video_core/texture_cache/format_lookup_table.h b/src/video_core/texture_cache/format_lookup_table.h
new file mode 100644
index 000000000..8da7481cd
--- /dev/null
+++ b/src/video_core/texture_cache/format_lookup_table.h
@@ -0,0 +1,51 @@
+// Copyright 2019 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <array>
+#include <numeric>
+#include "video_core/surface.h"
+#include "video_core/textures/texture.h"
+
+namespace VideoCommon {
+
+class FormatLookupTable {
+public:
+ explicit FormatLookupTable();
+
+ VideoCore::Surface::PixelFormat GetPixelFormat(
+ Tegra::Texture::TextureFormat format, bool is_srgb,
+ Tegra::Texture::ComponentType red_component, Tegra::Texture::ComponentType green_component,
+ Tegra::Texture::ComponentType blue_component,
+ Tegra::Texture::ComponentType alpha_component) const noexcept;
+
+private:
+ static_assert(VideoCore::Surface::MaxPixelFormat <= std::numeric_limits<u8>::max());
+
+ static constexpr std::size_t NumTextureFormats = 128;
+
+ static constexpr std::size_t PerComponent = 8;
+ static constexpr std::size_t PerComponents2 = PerComponent * PerComponent;
+ static constexpr std::size_t PerComponents3 = PerComponents2 * PerComponent;
+ static constexpr std::size_t PerComponents4 = PerComponents3 * PerComponent;
+ static constexpr std::size_t PerFormat = PerComponents4 * 2;
+
+ static std::size_t CalculateIndex(Tegra::Texture::TextureFormat format, bool is_srgb,
+ Tegra::Texture::ComponentType red_component,
+ Tegra::Texture::ComponentType green_component,
+ Tegra::Texture::ComponentType blue_component,
+ Tegra::Texture::ComponentType alpha_component) noexcept;
+
+ void Set(Tegra::Texture::TextureFormat format, bool is_srgb,
+ Tegra::Texture::ComponentType red_component,
+ Tegra::Texture::ComponentType green_component,
+ Tegra::Texture::ComponentType blue_component,
+ Tegra::Texture::ComponentType alpha_component,
+ VideoCore::Surface::PixelFormat pixel_format);
+
+ std::array<u8, NumTextureFormats * PerFormat> table;
+};
+
+} // namespace VideoCommon