yuzu-emu
/
yuzu
Archived
1
0
Fork 0

Devirtualize Register/Unregister and use a wrapper instead.

This commit is contained in:
Fernando Sahmkow 2019-02-27 20:36:06 -04:00 committed by FernandoS27
parent 5a9204dbd7
commit 7ea097e5c2
3 changed files with 8 additions and 12 deletions

View File

@ -104,7 +104,7 @@ protected:
} }
/// Register an object into the cache /// Register an object into the cache
virtual void Register(const T& object) { void Register(const T& object) {
object->SetIsRegistered(true); object->SetIsRegistered(true);
interval_cache.add({GetInterval(object), ObjectSet{object}}); interval_cache.add({GetInterval(object), ObjectSet{object}});
map_cache.insert({object->GetAddr(), object}); map_cache.insert({object->GetAddr(), object});
@ -112,7 +112,7 @@ protected:
} }
/// Unregisters an object from the cache /// Unregisters an object from the cache
virtual void Unregister(const T& object) { void Unregister(const T& object) {
object->SetIsRegistered(false); object->SetIsRegistered(false);
rasterizer.UpdatePagesCachedCount(object->GetAddr(), object->GetSizeInBytes(), -1); rasterizer.UpdatePagesCachedCount(object->GetAddr(), object->GetSizeInBytes(), -1);
// Only flush if use_accurate_gpu_emulation is enabled, as it incurs a performance hit // Only flush if use_accurate_gpu_emulation is enabled, as it incurs a performance hit

View File

@ -1009,7 +1009,7 @@ Surface RasterizerCacheOpenGL::GetSurface(const SurfaceParams& params, bool pres
// If surface parameters changed and we care about keeping the previous data, recreate // If surface parameters changed and we care about keeping the previous data, recreate
// the surface from the old one // the surface from the old one
Surface new_surface{RecreateSurface(surface, params)}; Surface new_surface{RecreateSurface(surface, params)};
Unregister(surface); UnregisterSurface(surface);
Register(new_surface); Register(new_surface);
if (new_surface->IsUploaded()) { if (new_surface->IsUploaded()) {
RegisterReinterpretSurface(new_surface); RegisterReinterpretSurface(new_surface);
@ -1017,7 +1017,7 @@ Surface RasterizerCacheOpenGL::GetSurface(const SurfaceParams& params, bool pres
return new_surface; return new_surface;
} else { } else {
// Delete the old surface before creating a new one to prevent collisions. // Delete the old surface before creating a new one to prevent collisions.
Unregister(surface); UnregisterSurface(surface);
} }
} }
@ -1368,12 +1368,12 @@ static bool IsReinterpretInvalidSecond(const Surface render_surface,
bool RasterizerCacheOpenGL::PartialReinterpretSurface(Surface triggering_surface, bool RasterizerCacheOpenGL::PartialReinterpretSurface(Surface triggering_surface,
Surface intersect) { Surface intersect) {
if (IsReinterpretInvalid(triggering_surface, intersect)) { if (IsReinterpretInvalid(triggering_surface, intersect)) {
Unregister(intersect); UnregisterSurface(intersect);
return false; return false;
} }
if (!LayerFitReinterpretSurface(*this, triggering_surface, intersect)) { if (!LayerFitReinterpretSurface(*this, triggering_surface, intersect)) {
if (IsReinterpretInvalidSecond(triggering_surface, intersect)) { if (IsReinterpretInvalidSecond(triggering_surface, intersect)) {
Unregister(intersect); UnregisterSurface(intersect);
return false; return false;
} }
FlushObject(intersect); FlushObject(intersect);

View File

@ -544,17 +544,13 @@ private:
return nullptr; return nullptr;
} }
void Register(const Surface& object) {
RasterizerCache<Surface>::Register(object);
}
/// Unregisters an object from the cache /// Unregisters an object from the cache
void Unregister(const Surface& object) { void UnregisterSurface(const Surface& object) {
if (object->IsReinterpreted()) { if (object->IsReinterpreted()) {
auto interval = GetReinterpretInterval(object); auto interval = GetReinterpretInterval(object);
reinterpreted_surfaces.erase(interval); reinterpreted_surfaces.erase(interval);
} }
RasterizerCache<Surface>::Unregister(object); Unregister(object);
} }
}; };