summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2019-06-29 18:54:13 -0300
committerGravatar ReinUsesLisp2019-06-29 18:54:13 -0300
commitdd9ace502bfd2239ceddad8c5c41baf0e10e2144 (patch)
treee5634c45c4db3803f49ef6f440510b946f031d6b /src
parenttexture_cache: Address feedback (diff)
downloadyuzu-dd9ace502bfd2239ceddad8c5c41baf0e10e2144.tar.gz
yuzu-dd9ace502bfd2239ceddad8c5c41baf0e10e2144.tar.xz
yuzu-dd9ace502bfd2239ceddad8c5c41baf0e10e2144.zip
texture_cache: Use std::array for siblings_table
Diffstat (limited to 'src')
-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 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <algorithm>
8#include <array>
7#include <memory> 9#include <memory>
8#include <mutex> 10#include <mutex>
9#include <set> 11#include <set>
@@ -244,20 +246,19 @@ protected:
244 for (std::size_t i = 0; i < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets; i++) { 246 for (std::size_t i = 0; i < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets; i++) {
245 SetEmptyColorBuffer(i); 247 SetEmptyColorBuffer(i);
246 } 248 }
249
247 SetEmptyDepthBuffer(); 250 SetEmptyDepthBuffer();
248 staging_cache.SetSize(2); 251 staging_cache.SetSize(2);
252
249 const auto make_siblings = [this](PixelFormat a, PixelFormat b) { 253 const auto make_siblings = [this](PixelFormat a, PixelFormat b) {
250 siblings_table[a] = b; 254 siblings_table[static_cast<std::size_t>(a)] = b;
251 siblings_table[b] = a; 255 siblings_table[static_cast<std::size_t>(b)] = a;
252 }; 256 };
253 const auto max_formats = static_cast<u32>(PixelFormat::Max); 257 std::fill(siblings_table.begin(), siblings_table.end(), PixelFormat::Invalid);
254 siblings_table.reserve(max_formats);
255 for (u32 i = 0; i < max_formats; i++) {
256 siblings_table[static_cast<PixelFormat>(i)] = PixelFormat::Invalid;
257 }
258 make_siblings(PixelFormat::Z16, PixelFormat::R16U); 258 make_siblings(PixelFormat::Z16, PixelFormat::R16U);
259 make_siblings(PixelFormat::Z32F, PixelFormat::R32F); 259 make_siblings(PixelFormat::Z32F, PixelFormat::R32F);
260 make_siblings(PixelFormat::Z32FS8, PixelFormat::RG32F); 260 make_siblings(PixelFormat::Z32FS8, PixelFormat::RG32F);
261
261 sampled_textures_stack.resize(64); 262 sampled_textures_stack.resize(64);
262 } 263 }
263 264
@@ -426,7 +427,8 @@ private:
426 const auto& cr_params = current_surface->GetSurfaceParams(); 427 const auto& cr_params = current_surface->GetSurfaceParams();
427 TSurface new_surface; 428 TSurface new_surface;
428 if (cr_params.pixel_format != params.pixel_format && !is_render && 429 if (cr_params.pixel_format != params.pixel_format && !is_render &&
429 siblings_table[cr_params.pixel_format] == params.pixel_format) { 430 siblings_table[static_cast<std::size_t>(cr_params.pixel_format)] ==
431 params.pixel_format) {
430 SurfaceParams new_params = params; 432 SurfaceParams new_params = params;
431 new_params.pixel_format = cr_params.pixel_format; 433 new_params.pixel_format = cr_params.pixel_format;
432 new_params.component_type = cr_params.component_type; 434 new_params.component_type = cr_params.component_type;
@@ -472,7 +474,8 @@ private:
472 if (!is_mirage) { 474 if (!is_mirage) {
473 return match_check(); 475 return match_check();
474 } 476 }
475 if (!is_render && siblings_table[current_surface->GetFormat()] == params.pixel_format) { 477 if (!is_render && siblings_table[static_cast<std::size_t>(current_surface->GetFormat())] ==
478 params.pixel_format) {
476 return match_check(); 479 return match_check();
477 } 480 }
478 return RebuildSurface(current_surface, params, is_render); 481 return RebuildSurface(current_surface, params, is_render);
@@ -786,7 +789,7 @@ private:
786 // The siblings table is for formats that can inter exchange with one another 789 // The siblings table is for formats that can inter exchange with one another
787 // without causing issues. This is only valid when a conflict occurs on a non 790 // without causing issues. This is only valid when a conflict occurs on a non
788 // rendering use. 791 // rendering use.
789 std::unordered_map<PixelFormat, PixelFormat> siblings_table; 792 std::array<PixelFormat, static_cast<std::size_t>(PixelFormat::Max)> siblings_table;
790 793
791 // The internal Cache is different for the Texture Cache. It's based on buckets 794 // The internal Cache is different for the Texture Cache. It's based on buckets
792 // of 1MB. This fits better for the purpose of this cache as textures are normaly 795 // of 1MB. This fits better for the purpose of this cache as textures are normaly