texture_cache: More relaxed reconstruction

Only reupload textures when they've not been modified from the GPU.
This commit is contained in:
ReinUsesLisp 2020-05-29 23:52:47 -03:00
parent e454f7e7a7
commit 1ee1a5d3d6

View File

@ -656,19 +656,19 @@ private:
if (params.target == SurfaceTarget::Texture3D) { if (params.target == SurfaceTarget::Texture3D) {
return std::nullopt; return std::nullopt;
} }
const auto test_modified = [](TSurface& surface) { return surface->IsModified(); };
TSurface new_surface = GetUncachedSurface(gpu_addr, params); TSurface new_surface = GetUncachedSurface(gpu_addr, params);
std::size_t passed_tests = 0;
bool modified = false;
u32 num_resources = 0; if (std::none_of(overlaps.begin(), overlaps.end(), test_modified)) {
for (auto& surface : overlaps) {
const SurfaceParams& src_params = surface->GetSurfaceParams();
num_resources += src_params.depth * src_params.num_levels;
}
if (num_resources != params.depth * params.num_levels) {
LoadSurface(new_surface); LoadSurface(new_surface);
for (const auto& surface : overlaps) {
Unregister(surface);
}
Register(new_surface);
return {{new_surface, new_surface->GetMainView()}};
} }
std::size_t passed_tests = 0;
for (auto& surface : overlaps) { for (auto& surface : overlaps) {
const SurfaceParams& src_params = surface->GetSurfaceParams(); const SurfaceParams& src_params = surface->GetSurfaceParams();
const auto mipmap_layer{new_surface->GetLayerMipmap(surface->GetGpuAddr())}; const auto mipmap_layer{new_surface->GetLayerMipmap(surface->GetGpuAddr())};
@ -681,11 +681,6 @@ private:
} }
++passed_tests; ++passed_tests;
if (!surface->IsModified()) {
continue;
}
modified = true;
// Copy all mipmaps and layers // Copy all mipmaps and layers
const u32 block_width = params.GetDefaultBlockWidth(); const u32 block_width = params.GetDefaultBlockWidth();
const u32 block_height = params.GetDefaultBlockHeight(); const u32 block_height = params.GetDefaultBlockHeight();
@ -709,6 +704,7 @@ private:
return std::nullopt; return std::nullopt;
} }
const bool modified = std::any_of(overlaps.begin(), overlaps.end(), test_modified);
for (const auto& surface : overlaps) { for (const auto& surface : overlaps) {
Unregister(surface); Unregister(surface);
} }