summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-06-29 23:54:13 +0200
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-06-29 23:54:13 +0200
commitdd9ace502bfd2239ceddad8c5c41baf0e10e2144 (patch)
treee5634c45c4db3803f49ef6f440510b946f031d6b
parenttexture_cache: Address feedback (diff)
downloadyuzu-dd9ace502bfd2239ceddad8c5c41baf0e10e2144.tar
yuzu-dd9ace502bfd2239ceddad8c5c41baf0e10e2144.tar.gz
yuzu-dd9ace502bfd2239ceddad8c5c41baf0e10e2144.tar.bz2
yuzu-dd9ace502bfd2239ceddad8c5c41baf0e10e2144.tar.lz
yuzu-dd9ace502bfd2239ceddad8c5c41baf0e10e2144.tar.xz
yuzu-dd9ace502bfd2239ceddad8c5c41baf0e10e2144.tar.zst
yuzu-dd9ace502bfd2239ceddad8c5c41baf0e10e2144.zip
-rw-r--r--src/video_core/texture_cache/texture_cache.h23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 9436a5ff2..9fcf87744 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -4,6 +4,8 @@
#pragma once
+#include <algorithm>
+#include <array>
#include <memory>
#include <mutex>
#include <set>
@@ -244,20 +246,19 @@ protected:
for (std::size_t i = 0; i < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets; i++) {
SetEmptyColorBuffer(i);
}
+
SetEmptyDepthBuffer();
staging_cache.SetSize(2);
+
const auto make_siblings = [this](PixelFormat a, PixelFormat b) {
- siblings_table[a] = b;
- siblings_table[b] = a;
+ siblings_table[static_cast<std::size_t>(a)] = b;
+ siblings_table[static_cast<std::size_t>(b)] = a;
};
- const auto max_formats = static_cast<u32>(PixelFormat::Max);
- siblings_table.reserve(max_formats);
- for (u32 i = 0; i < max_formats; i++) {
- siblings_table[static_cast<PixelFormat>(i)] = PixelFormat::Invalid;
- }
+ std::fill(siblings_table.begin(), siblings_table.end(), PixelFormat::Invalid);
make_siblings(PixelFormat::Z16, PixelFormat::R16U);
make_siblings(PixelFormat::Z32F, PixelFormat::R32F);
make_siblings(PixelFormat::Z32FS8, PixelFormat::RG32F);
+
sampled_textures_stack.resize(64);
}
@@ -426,7 +427,8 @@ private:
const auto& cr_params = current_surface->GetSurfaceParams();
TSurface new_surface;
if (cr_params.pixel_format != params.pixel_format && !is_render &&
- siblings_table[cr_params.pixel_format] == params.pixel_format) {
+ siblings_table[static_cast<std::size_t>(cr_params.pixel_format)] ==
+ params.pixel_format) {
SurfaceParams new_params = params;
new_params.pixel_format = cr_params.pixel_format;
new_params.component_type = cr_params.component_type;
@@ -472,7 +474,8 @@ private:
if (!is_mirage) {
return match_check();
}
- if (!is_render && siblings_table[current_surface->GetFormat()] == params.pixel_format) {
+ if (!is_render && siblings_table[static_cast<std::size_t>(current_surface->GetFormat())] ==
+ params.pixel_format) {
return match_check();
}
return RebuildSurface(current_surface, params, is_render);
@@ -786,7 +789,7 @@ private:
// The siblings table is for formats that can inter exchange with one another
// without causing issues. This is only valid when a conflict occurs on a non
// rendering use.
- std::unordered_map<PixelFormat, PixelFormat> siblings_table;
+ std::array<PixelFormat, static_cast<std::size_t>(PixelFormat::Max)> siblings_table;
// The internal Cache is different for the Texture Cache. It's based on buckets
// of 1MB. This fits better for the purpose of this cache as textures are normaly