diff options
| author | 2019-06-13 09:46:36 -0400 | |
|---|---|---|
| committer | 2019-06-20 21:38:34 -0300 | |
| commit | 2d83553ea7ab2629e7e1a83cc3345c0115d69453 (patch) | |
| tree | 95b51806a042ff95aa9bd857dd659d16a7fa02de /src | |
| parent | fermi2d: Correct Origin Mode (diff) | |
| download | yuzu-2d83553ea7ab2629e7e1a83cc3345c0115d69453.tar.gz yuzu-2d83553ea7ab2629e7e1a83cc3345c0115d69453.tar.xz yuzu-2d83553ea7ab2629e7e1a83cc3345c0115d69453.zip | |
texture_cache: Implement siblings texture formats.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/texture_cache/surface_base.h | 4 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 39 |
2 files changed, 31 insertions, 12 deletions
diff --git a/src/video_core/texture_cache/surface_base.h b/src/video_core/texture_cache/surface_base.h index 9d19ecd5f..58265e9d3 100644 --- a/src/video_core/texture_cache/surface_base.h +++ b/src/video_core/texture_cache/surface_base.h | |||
| @@ -132,6 +132,10 @@ public: | |||
| 132 | return params.pixel_format == pixel_format; | 132 | return params.pixel_format == pixel_format; |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | VideoCore::Surface::PixelFormat GetFormat() const { | ||
| 136 | return params.pixel_format; | ||
| 137 | } | ||
| 138 | |||
| 135 | bool MatchTarget(VideoCore::Surface::SurfaceTarget target) const { | 139 | bool MatchTarget(VideoCore::Surface::SurfaceTarget target) const { |
| 136 | return params.target == target; | 140 | return params.target == target; |
| 137 | } | 141 | } |
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index c95b1b976..022416706 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -43,6 +43,8 @@ class RasterizerInterface; | |||
| 43 | 43 | ||
| 44 | namespace VideoCommon { | 44 | namespace VideoCommon { |
| 45 | 45 | ||
| 46 | using VideoCore::Surface::PixelFormat; | ||
| 47 | |||
| 46 | using VideoCore::Surface::SurfaceTarget; | 48 | using VideoCore::Surface::SurfaceTarget; |
| 47 | using RenderTargetConfig = Tegra::Engines::Maxwell3D::Regs::RenderTargetConfig; | 49 | using RenderTargetConfig = Tegra::Engines::Maxwell3D::Regs::RenderTargetConfig; |
| 48 | 50 | ||
| @@ -96,7 +98,7 @@ public: | |||
| 96 | return {}; | 98 | return {}; |
| 97 | } | 99 | } |
| 98 | const auto params{SurfaceParams::CreateForTexture(system, config, entry)}; | 100 | const auto params{SurfaceParams::CreateForTexture(system, config, entry)}; |
| 99 | return GetSurface(gpu_addr, params, true).second; | 101 | return GetSurface(gpu_addr, params, true, false).second; |
| 100 | } | 102 | } |
| 101 | 103 | ||
| 102 | TView GetDepthBufferSurface(bool preserve_contents) { | 104 | TView GetDepthBufferSurface(bool preserve_contents) { |
| @@ -118,7 +120,7 @@ public: | |||
| 118 | system, regs.zeta_width, regs.zeta_height, regs.zeta.format, | 120 | system, regs.zeta_width, regs.zeta_height, regs.zeta.format, |
| 119 | regs.zeta.memory_layout.block_width, regs.zeta.memory_layout.block_height, | 121 | regs.zeta.memory_layout.block_width, regs.zeta.memory_layout.block_height, |
| 120 | regs.zeta.memory_layout.block_depth, regs.zeta.memory_layout.type)}; | 122 | regs.zeta.memory_layout.block_depth, regs.zeta.memory_layout.type)}; |
| 121 | auto surface_view = GetSurface(gpu_addr, depth_params, preserve_contents); | 123 | auto surface_view = GetSurface(gpu_addr, depth_params, preserve_contents, true); |
| 122 | if (depth_buffer.target) | 124 | if (depth_buffer.target) |
| 123 | depth_buffer.target->MarkAsRenderTarget(false); | 125 | depth_buffer.target->MarkAsRenderTarget(false); |
| 124 | depth_buffer.target = surface_view.first; | 126 | depth_buffer.target = surface_view.first; |
| @@ -152,7 +154,7 @@ public: | |||
| 152 | } | 154 | } |
| 153 | 155 | ||
| 154 | auto surface_view = GetSurface(gpu_addr, SurfaceParams::CreateForFramebuffer(system, index), | 156 | auto surface_view = GetSurface(gpu_addr, SurfaceParams::CreateForFramebuffer(system, index), |
| 155 | preserve_contents); | 157 | preserve_contents, true); |
| 156 | if (render_targets[index].target) | 158 | if (render_targets[index].target) |
| 157 | render_targets[index].target->MarkAsRenderTarget(false); | 159 | render_targets[index].target->MarkAsRenderTarget(false); |
| 158 | render_targets[index].target = surface_view.first; | 160 | render_targets[index].target = surface_view.first; |
| @@ -226,6 +228,11 @@ protected: | |||
| 226 | } | 228 | } |
| 227 | SetEmptyDepthBuffer(); | 229 | SetEmptyDepthBuffer(); |
| 228 | staging_cache.SetSize(2); | 230 | staging_cache.SetSize(2); |
| 231 | siblings_table[PixelFormat::Z16] = PixelFormat::R16F; | ||
| 232 | siblings_table[PixelFormat::Z32F] = PixelFormat::R32F; | ||
| 233 | siblings_table[PixelFormat::Z32FS8] = PixelFormat::RG32F; | ||
| 234 | siblings_table[PixelFormat::R16F] = PixelFormat::Z16; | ||
| 235 | siblings_table[PixelFormat::R32F] = PixelFormat::Z32F; | ||
| 229 | } | 236 | } |
| 230 | 237 | ||
| 231 | ~TextureCache() = default; | 238 | ~TextureCache() = default; |
| @@ -289,7 +296,7 @@ protected: | |||
| 289 | const Tegra::Engines::Fermi2D::Regs::Surface& config) { | 296 | const Tegra::Engines::Fermi2D::Regs::Surface& config) { |
| 290 | SurfaceParams params = SurfaceParams::CreateForFermiCopySurface(config); | 297 | SurfaceParams params = SurfaceParams::CreateForFermiCopySurface(config); |
| 291 | const GPUVAddr gpu_addr = config.Address(); | 298 | const GPUVAddr gpu_addr = config.Address(); |
| 292 | return GetSurface(gpu_addr, params, true); | 299 | return GetSurface(gpu_addr, params, true, false); |
| 293 | } | 300 | } |
| 294 | 301 | ||
| 295 | Core::System& system; | 302 | Core::System& system; |
| @@ -406,16 +413,22 @@ private: | |||
| 406 | * @param params, the new surface params which we want to check. | 413 | * @param params, the new surface params which we want to check. |
| 407 | **/ | 414 | **/ |
| 408 | std::pair<TSurface, TView> ManageStructuralMatch(TSurface current_surface, | 415 | std::pair<TSurface, TView> ManageStructuralMatch(TSurface current_surface, |
| 409 | const SurfaceParams& params) { | 416 | const SurfaceParams& params, bool is_render) { |
| 410 | const bool is_mirage = !current_surface->MatchFormat(params.pixel_format); | 417 | const bool is_mirage = !current_surface->MatchFormat(params.pixel_format); |
| 418 | const bool matches_target = current_surface->MatchTarget(params.target); | ||
| 419 | auto match_check = ([&]() -> std::pair<TSurface, TView> { | ||
| 420 | if (matches_target) { | ||
| 421 | return {current_surface, current_surface->GetMainView()}; | ||
| 422 | } | ||
| 423 | return {current_surface, current_surface->EmplaceOverview(params)}; | ||
| 424 | }); | ||
| 411 | if (is_mirage) { | 425 | if (is_mirage) { |
| 426 | if (!is_render && siblings_table[current_surface->GetFormat()] == params.pixel_format) { | ||
| 427 | return match_check(); | ||
| 428 | } | ||
| 412 | return RebuildSurface(current_surface, params); | 429 | return RebuildSurface(current_surface, params); |
| 413 | } | 430 | } |
| 414 | const bool matches_target = current_surface->MatchTarget(params.target); | 431 | return match_check(); |
| 415 | if (matches_target) { | ||
| 416 | return {current_surface, current_surface->GetMainView()}; | ||
| 417 | } | ||
| 418 | return {current_surface, current_surface->EmplaceOverview(params)}; | ||
| 419 | } | 432 | } |
| 420 | 433 | ||
| 421 | /** | 434 | /** |
| @@ -490,7 +503,7 @@ private: | |||
| 490 | * @param preserve_contents, tells if the new surface should be loaded from meory or left blank. | 503 | * @param preserve_contents, tells if the new surface should be loaded from meory or left blank. |
| 491 | **/ | 504 | **/ |
| 492 | std::pair<TSurface, TView> GetSurface(const GPUVAddr gpu_addr, const SurfaceParams& params, | 505 | std::pair<TSurface, TView> GetSurface(const GPUVAddr gpu_addr, const SurfaceParams& params, |
| 493 | bool preserve_contents) { | 506 | bool preserve_contents, bool is_render) { |
| 494 | 507 | ||
| 495 | const auto host_ptr{memory_manager->GetPointer(gpu_addr)}; | 508 | const auto host_ptr{memory_manager->GetPointer(gpu_addr)}; |
| 496 | const auto cache_addr{ToCacheAddr(host_ptr)}; | 509 | const auto cache_addr{ToCacheAddr(host_ptr)}; |
| @@ -524,7 +537,7 @@ private: | |||
| 524 | (params.target != SurfaceTarget::Texture3D || | 537 | (params.target != SurfaceTarget::Texture3D || |
| 525 | current_surface->MatchTarget(params.target))) { | 538 | current_surface->MatchTarget(params.target))) { |
| 526 | if (s_result == MatchStructureResult::FullMatch) { | 539 | if (s_result == MatchStructureResult::FullMatch) { |
| 527 | return ManageStructuralMatch(current_surface, params); | 540 | return ManageStructuralMatch(current_surface, params, is_render); |
| 528 | } else { | 541 | } else { |
| 529 | return RebuildSurface(current_surface, params); | 542 | return RebuildSurface(current_surface, params); |
| 530 | } | 543 | } |
| @@ -724,6 +737,8 @@ private: | |||
| 724 | // Guards the cache for protection conflicts. | 737 | // Guards the cache for protection conflicts. |
| 725 | bool guard_cache{}; | 738 | bool guard_cache{}; |
| 726 | 739 | ||
| 740 | std::unordered_map<PixelFormat, PixelFormat> siblings_table; | ||
| 741 | |||
| 727 | // The internal Cache is different for the Texture Cache. It's based on buckets | 742 | // The internal Cache is different for the Texture Cache. It's based on buckets |
| 728 | // of 1MB. This fits better for the purpose of this cache as textures are normaly | 743 | // of 1MB. This fits better for the purpose of this cache as textures are normaly |
| 729 | // large in size. | 744 | // large in size. |