mirror of
https://github.com/starr-dusT/yuzu-mainline
synced 2024-03-05 21:12:25 -08:00
texture_cache: Optimize GetSurface and use references on functions that don't change a surface.
This commit is contained in:
parent
60bf761afb
commit
3809041c24
@ -450,7 +450,7 @@ Surface TextureCacheOpenGL::CreateSurface(GPUVAddr gpu_addr, const SurfaceParams
|
||||
return std::make_shared<CachedSurface>(gpu_addr, params);
|
||||
}
|
||||
|
||||
void TextureCacheOpenGL::ImageCopy(Surface src_surface, Surface dst_surface,
|
||||
void TextureCacheOpenGL::ImageCopy(Surface& src_surface, Surface& dst_surface,
|
||||
const VideoCommon::CopyParams& copy_params) {
|
||||
if (!support_info.depth_color_image_copies) {
|
||||
const auto& src_params = src_surface->GetSurfaceParams();
|
||||
@ -471,7 +471,7 @@ void TextureCacheOpenGL::ImageCopy(Surface src_surface, Surface dst_surface,
|
||||
copy_params.depth);
|
||||
}
|
||||
|
||||
void TextureCacheOpenGL::ImageBlit(View src_view, View dst_view,
|
||||
void TextureCacheOpenGL::ImageBlit(View& src_view, View& dst_view,
|
||||
const Tegra::Engines::Fermi2D::Config& copy_config) {
|
||||
const auto& src_params{src_view->GetSurfaceParams()};
|
||||
const auto& dst_params{dst_view->GetSurfaceParams()};
|
||||
@ -528,7 +528,7 @@ void TextureCacheOpenGL::ImageBlit(View src_view, View dst_view,
|
||||
is_linear ? GL_LINEAR : GL_NEAREST);
|
||||
}
|
||||
|
||||
void TextureCacheOpenGL::BufferCopy(Surface src_surface, Surface dst_surface) {
|
||||
void TextureCacheOpenGL::BufferCopy(Surface& src_surface, Surface& dst_surface) {
|
||||
const auto& src_params = src_surface->GetSurfaceParams();
|
||||
const auto& dst_params = dst_surface->GetSurfaceParams();
|
||||
|
||||
|
@ -137,13 +137,13 @@ public:
|
||||
protected:
|
||||
Surface CreateSurface(GPUVAddr gpu_addr, const SurfaceParams& params) override;
|
||||
|
||||
void ImageCopy(Surface src_surface, Surface dst_surface,
|
||||
void ImageCopy(Surface& src_surface, Surface& dst_surface,
|
||||
const VideoCommon::CopyParams& copy_params) override;
|
||||
|
||||
void ImageBlit(View src_view, View dst_view,
|
||||
void ImageBlit(View& src_view, View& dst_view,
|
||||
const Tegra::Engines::Fermi2D::Config& copy_config) override;
|
||||
|
||||
void BufferCopy(Surface src_surface, Surface dst_surface) override;
|
||||
void BufferCopy(Surface& src_surface, Surface& dst_surface) override;
|
||||
|
||||
private:
|
||||
GLuint FetchPBO(std::size_t buffer_size);
|
||||
|
@ -234,15 +234,15 @@ protected:
|
||||
|
||||
virtual TSurface CreateSurface(GPUVAddr gpu_addr, const SurfaceParams& params) = 0;
|
||||
|
||||
virtual void ImageCopy(TSurface src_surface, TSurface dst_surface,
|
||||
virtual void ImageCopy(TSurface& src_surface, TSurface& dst_surface,
|
||||
const CopyParams& copy_params) = 0;
|
||||
|
||||
virtual void ImageBlit(TView src_view, TView dst_view,
|
||||
virtual void ImageBlit(TView& src_view, TView& dst_view,
|
||||
const Tegra::Engines::Fermi2D::Config& copy_config) = 0;
|
||||
|
||||
// Depending on the backend, a buffer copy can be slow as it means deoptimizing the texture
|
||||
// and reading it from a sepparate buffer.
|
||||
virtual void BufferCopy(TSurface src_surface, TSurface dst_surface) = 0;
|
||||
virtual void BufferCopy(TSurface& src_surface, TSurface& dst_surface) = 0;
|
||||
|
||||
void Register(TSurface surface) {
|
||||
std::lock_guard lock{mutex};
|
||||
@ -516,8 +516,9 @@ private:
|
||||
// Step 1
|
||||
// Check Level 1 Cache for a fast structural match. If candidate surface
|
||||
// matches at certain level we are pretty much done.
|
||||
if (l1_cache.count(cache_addr) > 0) {
|
||||
TSurface current_surface = l1_cache[cache_addr];
|
||||
auto iter = l1_cache.find(cache_addr);
|
||||
if (iter != l1_cache.end()) {
|
||||
TSurface& current_surface = iter->second;
|
||||
auto topological_result = current_surface->MatchesTopology(params);
|
||||
if (topological_result != MatchTopologyResult::FullMatch) {
|
||||
std::vector<TSurface> overlaps{current_surface};
|
||||
@ -526,7 +527,6 @@ private:
|
||||
}
|
||||
MatchStructureResult s_result = current_surface->MatchesStructure(params);
|
||||
if (s_result != MatchStructureResult::None &&
|
||||
current_surface->GetGpuAddr() == gpu_addr &&
|
||||
(params.target != SurfaceTarget::Texture3D ||
|
||||
current_surface->MatchTarget(params.target))) {
|
||||
if (s_result == MatchStructureResult::FullMatch) {
|
||||
|
Loading…
Reference in New Issue
Block a user