diff options
| author | 2019-06-13 10:39:45 -0400 | |
|---|---|---|
| committer | 2019-06-20 21:38:34 -0300 | |
| commit | 3dd76432141a5cbc97bed15788984b37e44aa4a5 (patch) | |
| tree | 47d1c0e5dddb4d448026a5ec62480017d4510e28 /src | |
| parent | texture_cache: Remove old rasterizer cache (diff) | |
| download | yuzu-3dd76432141a5cbc97bed15788984b37e44aa4a5.tar.gz yuzu-3dd76432141a5cbc97bed15788984b37e44aa4a5.tar.xz yuzu-3dd76432141a5cbc97bed15788984b37e44aa4a5.zip | |
texture_cache: Use siblings textures on Rebuild and fix possible error on blitting
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 33 |
2 files changed, 24 insertions, 11 deletions
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index 7c1d14138..d30d04cd5 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp | |||
| @@ -522,7 +522,7 @@ void TextureCacheOpenGL::ImageBlit(View& src_view, View& dst_view, | |||
| 522 | 522 | ||
| 523 | glBlitFramebuffer(src_rect.left, src_rect.top, src_rect.right, src_rect.bottom, dst_rect.left, | 523 | glBlitFramebuffer(src_rect.left, src_rect.top, src_rect.right, src_rect.bottom, dst_rect.left, |
| 524 | dst_rect.top, dst_rect.right, dst_rect.bottom, buffers, | 524 | dst_rect.top, dst_rect.right, dst_rect.bottom, buffers, |
| 525 | is_linear ? GL_LINEAR : GL_NEAREST); | 525 | is_linear && (buffers == GL_COLOR_BUFFER_BIT) ? GL_LINEAR : GL_NEAREST); |
| 526 | } | 526 | } |
| 527 | 527 | ||
| 528 | void TextureCacheOpenGL::BufferCopy(Surface& src_surface, Surface& dst_surface) { | 528 | void TextureCacheOpenGL::BufferCopy(Surface& src_surface, Surface& dst_surface) { |
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 022416706..201c4d42e 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -220,7 +220,6 @@ public: | |||
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | protected: | 222 | protected: |
| 223 | |||
| 224 | TextureCache(Core::System& system, VideoCore::RasterizerInterface& rasterizer) | 223 | TextureCache(Core::System& system, VideoCore::RasterizerInterface& rasterizer) |
| 225 | : system{system}, rasterizer{rasterizer} { | 224 | : system{system}, rasterizer{rasterizer} { |
| 226 | for (std::size_t i = 0; i < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets; i++) { | 225 | for (std::size_t i = 0; i < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets; i++) { |
| @@ -233,6 +232,7 @@ protected: | |||
| 233 | siblings_table[PixelFormat::Z32FS8] = PixelFormat::RG32F; | 232 | siblings_table[PixelFormat::Z32FS8] = PixelFormat::RG32F; |
| 234 | siblings_table[PixelFormat::R16F] = PixelFormat::Z16; | 233 | siblings_table[PixelFormat::R16F] = PixelFormat::Z16; |
| 235 | siblings_table[PixelFormat::R32F] = PixelFormat::Z32F; | 234 | siblings_table[PixelFormat::R32F] = PixelFormat::Z32F; |
| 235 | siblings_table[PixelFormat::RG32F] = PixelFormat::Z32FS8; | ||
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | ~TextureCache() = default; | 238 | ~TextureCache() = default; |
| @@ -385,15 +385,27 @@ private: | |||
| 385 | * @param current_surface, the registered surface in the cache which we want to convert. | 385 | * @param current_surface, the registered surface in the cache which we want to convert. |
| 386 | * @param params, the new surface params which we'll use to recreate the surface. | 386 | * @param params, the new surface params which we'll use to recreate the surface. |
| 387 | **/ | 387 | **/ |
| 388 | std::pair<TSurface, TView> RebuildSurface(TSurface current_surface, | 388 | std::pair<TSurface, TView> RebuildSurface(TSurface current_surface, const SurfaceParams& params, |
| 389 | const SurfaceParams& params) { | 389 | bool is_render) { |
| 390 | const auto gpu_addr = current_surface->GetGpuAddr(); | 390 | const auto gpu_addr = current_surface->GetGpuAddr(); |
| 391 | TSurface new_surface = GetUncachedSurface(gpu_addr, params); | ||
| 392 | const auto& cr_params = current_surface->GetSurfaceParams(); | 391 | const auto& cr_params = current_surface->GetSurfaceParams(); |
| 393 | if (cr_params.type != params.type || (cr_params.component_type != params.component_type)) { | 392 | TSurface new_surface; |
| 393 | if (cr_params.pixel_format != params.pixel_format && !is_render && | ||
| 394 | siblings_table[cr_params.pixel_format] == params.pixel_format) { | ||
| 395 | SurfaceParams new_params = params; | ||
| 396 | new_params.pixel_format = cr_params.pixel_format; | ||
| 397 | new_params.component_type = cr_params.component_type; | ||
| 398 | new_params.type = cr_params.type; | ||
| 399 | new_surface = GetUncachedSurface(gpu_addr, new_params); | ||
| 400 | } else { | ||
| 401 | new_surface = GetUncachedSurface(gpu_addr, params); | ||
| 402 | } | ||
| 403 | const auto& final_params = new_surface->GetSurfaceParams(); | ||
| 404 | if (cr_params.type != final_params.type || | ||
| 405 | (cr_params.component_type != final_params.component_type)) { | ||
| 394 | BufferCopy(current_surface, new_surface); | 406 | BufferCopy(current_surface, new_surface); |
| 395 | } else { | 407 | } else { |
| 396 | std::vector<CopyParams> bricks = current_surface->BreakDown(params); | 408 | std::vector<CopyParams> bricks = current_surface->BreakDown(final_params); |
| 397 | for (auto& brick : bricks) { | 409 | for (auto& brick : bricks) { |
| 398 | ImageCopy(current_surface, new_surface, brick); | 410 | ImageCopy(current_surface, new_surface, brick); |
| 399 | } | 411 | } |
| @@ -426,7 +438,7 @@ private: | |||
| 426 | if (!is_render && siblings_table[current_surface->GetFormat()] == params.pixel_format) { | 438 | if (!is_render && siblings_table[current_surface->GetFormat()] == params.pixel_format) { |
| 427 | return match_check(); | 439 | return match_check(); |
| 428 | } | 440 | } |
| 429 | return RebuildSurface(current_surface, params); | 441 | return RebuildSurface(current_surface, params, is_render); |
| 430 | } | 442 | } |
| 431 | return match_check(); | 443 | return match_check(); |
| 432 | } | 444 | } |
| @@ -539,7 +551,7 @@ private: | |||
| 539 | if (s_result == MatchStructureResult::FullMatch) { | 551 | if (s_result == MatchStructureResult::FullMatch) { |
| 540 | return ManageStructuralMatch(current_surface, params, is_render); | 552 | return ManageStructuralMatch(current_surface, params, is_render); |
| 541 | } else { | 553 | } else { |
| 542 | return RebuildSurface(current_surface, params); | 554 | return RebuildSurface(current_surface, params, is_render); |
| 543 | } | 555 | } |
| 544 | } | 556 | } |
| 545 | } | 557 | } |
| @@ -599,7 +611,8 @@ private: | |||
| 599 | new_params.width = wh; | 611 | new_params.width = wh; |
| 600 | new_params.height = hh; | 612 | new_params.height = hh; |
| 601 | new_params.pixel_format = params.pixel_format; | 613 | new_params.pixel_format = params.pixel_format; |
| 602 | std::pair<TSurface, TView> pair = RebuildSurface(current_surface, new_params); | 614 | std::pair<TSurface, TView> pair = |
| 615 | RebuildSurface(current_surface, new_params, is_render); | ||
| 603 | std::optional<TView> mirage_view = | 616 | std::optional<TView> mirage_view = |
| 604 | pair.first->EmplaceView(params, gpu_addr, candidate_size); | 617 | pair.first->EmplaceView(params, gpu_addr, candidate_size); |
| 605 | if (mirage_view) | 618 | if (mirage_view) |
| @@ -616,7 +629,7 @@ private: | |||
| 616 | } | 629 | } |
| 617 | // This is the case the texture is a part of the parent. | 630 | // This is the case the texture is a part of the parent. |
| 618 | if (current_surface->MatchesSubTexture(params, gpu_addr)) { | 631 | if (current_surface->MatchesSubTexture(params, gpu_addr)) { |
| 619 | return RebuildSurface(current_surface, params); | 632 | return RebuildSurface(current_surface, params, is_render); |
| 620 | } | 633 | } |
| 621 | } else { | 634 | } else { |
| 622 | // If there are many overlaps, odds are they are subtextures of the candidate | 635 | // If there are many overlaps, odds are they are subtextures of the candidate |