1
0
Fork 0

rasterizer_cache: Handle texture cubes with duplicate faces (#6710)

This commit is contained in:
GPUCode 2023-07-21 01:55:19 +03:00 committed by GitHub
parent a9e390b1b1
commit b5e1a27a7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 16 deletions

View File

@ -10,6 +10,7 @@
#include "common/alignment.h"
#include "common/logging/log.h"
#include "common/microprofile.h"
#include "common/scope_exit.h"
#include "common/settings.h"
#include "core/memory.h"
#include "video_core/custom_textures/custom_tex_manager.h"
@ -1367,24 +1368,26 @@ void RasterizerCache<T>::UnregisterSurface(SurfaceId surface_id) {
surfaces.erase(vector_it);
});
if (True(surface.flags & SurfaceFlagBits::Tracked)) {
auto it = texture_cube_cache.begin();
while (it != texture_cube_cache.end()) {
std::array<SurfaceId, 6>& face_ids = it->second.face_ids;
const auto array_it = std::find(face_ids.begin(), face_ids.end(), surface_id);
if (array_it != face_ids.end()) {
*array_it = SurfaceId{};
}
if (std::none_of(face_ids.begin(), face_ids.end(), [](SurfaceId id) { return id; })) {
slot_surfaces.erase(it->second.surface_id);
it = texture_cube_cache.erase(it);
continue;
}
it++;
}
SCOPE_EXIT({ slot_surfaces.erase(surface_id); });
if (False(surface.flags & SurfaceFlagBits::Tracked)) {
return;
}
slot_surfaces.erase(surface_id);
std::erase_if(texture_cube_cache, [&](auto& pair) {
TextureCube& cube = pair.second;
for (SurfaceId& face_id : cube.face_ids) {
if (face_id == surface_id) {
face_id = SurfaceId{};
}
}
if (std::none_of(cube.face_ids.begin(), cube.face_ids.end(),
[](SurfaceId id) { return id; })) {
slot_surfaces.erase(cube.surface_id);
return true;
}
return false;
});
}
template <class T>