mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-11-03 23:28:48 +00:00 
			
		
		
		
	gl_rasterizer_cache: unlink watchers if surface is moved to remove_surfaces but is not immediately removed
This commit is contained in:
		
							parent
							
								
									777af04f4a
								
							
						
					
					
						commit
						ebdef4fd69
					
				
					 2 changed files with 11 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -1300,6 +1300,7 @@ SurfaceRect_Tuple RasterizerCacheOpenGL::GetSurfaceSubRect(const SurfaceParams&
 | 
			
		|||
 | 
			
		||||
            // Delete the expanded surface, this can't be done safely yet
 | 
			
		||||
            // because it may still be in use
 | 
			
		||||
            surface->UnlinkAllWatcher(); // unlink watchers as if this surface is already deleted
 | 
			
		||||
            remove_surfaces.emplace(surface);
 | 
			
		||||
 | 
			
		||||
            surface = new_surface;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -397,6 +397,16 @@ struct CachedSurface : SurfaceParams, std::enable_shared_from_this<CachedSurface
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void UnlinkAllWatcher() {
 | 
			
		||||
        for (const auto& watcher : watchers) {
 | 
			
		||||
            if (auto locked = watcher.lock()) {
 | 
			
		||||
                locked->valid = false;
 | 
			
		||||
                locked->surface.reset();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        watchers.clear();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    std::list<std::weak_ptr<SurfaceWatcher>> watchers;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue