mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
Merge pull request #936 from bunnei/avoid-copies
gl_rasterizer_cache: Avoid superfluous surface copies.
This commit is contained in:
commit
cf82358ee6
3 changed files with 21 additions and 6 deletions
|
@ -285,8 +285,6 @@ Texture::TICEntry Maxwell3D::GetTICEntry(u32 tic_index) const {
|
||||||
|
|
||||||
// TODO(Subv): Different data types for separate components are not supported
|
// TODO(Subv): Different data types for separate components are not supported
|
||||||
ASSERT(r_type == g_type && r_type == b_type && r_type == a_type);
|
ASSERT(r_type == g_type && r_type == b_type && r_type == a_type);
|
||||||
// TODO(Subv): Only UNORM formats are supported for now.
|
|
||||||
ASSERT(r_type == Texture::ComponentType::UNORM);
|
|
||||||
|
|
||||||
return tic_entry;
|
return tic_entry;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,8 @@ struct FormatTuple {
|
||||||
params.height = Common::AlignUp(config.tic.Height(), GetCompressionFactor(params.pixel_format));
|
params.height = Common::AlignUp(config.tic.Height(), GetCompressionFactor(params.pixel_format));
|
||||||
params.unaligned_height = config.tic.Height();
|
params.unaligned_height = config.tic.Height();
|
||||||
params.size_in_bytes = params.SizeInBytes();
|
params.size_in_bytes = params.SizeInBytes();
|
||||||
|
params.cache_width = Common::AlignUp(params.width, 16);
|
||||||
|
params.cache_height = Common::AlignUp(params.height, 16);
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +65,8 @@ struct FormatTuple {
|
||||||
params.height = config.height;
|
params.height = config.height;
|
||||||
params.unaligned_height = config.height;
|
params.unaligned_height = config.height;
|
||||||
params.size_in_bytes = params.SizeInBytes();
|
params.size_in_bytes = params.SizeInBytes();
|
||||||
|
params.cache_width = Common::AlignUp(params.width, 16);
|
||||||
|
params.cache_height = Common::AlignUp(params.height, 16);
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,6 +86,8 @@ struct FormatTuple {
|
||||||
params.height = zeta_height;
|
params.height = zeta_height;
|
||||||
params.unaligned_height = zeta_height;
|
params.unaligned_height = zeta_height;
|
||||||
params.size_in_bytes = params.SizeInBytes();
|
params.size_in_bytes = params.SizeInBytes();
|
||||||
|
params.cache_width = Common::AlignUp(params.width, 16);
|
||||||
|
params.cache_height = Common::AlignUp(params.height, 16);
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -680,12 +686,12 @@ Surface RasterizerCacheOpenGL::GetSurface(const SurfaceParams& params) {
|
||||||
// If use_accurate_framebuffers is enabled, always load from memory
|
// If use_accurate_framebuffers is enabled, always load from memory
|
||||||
FlushSurface(surface);
|
FlushSurface(surface);
|
||||||
UnregisterSurface(surface);
|
UnregisterSurface(surface);
|
||||||
} else if (surface->GetSurfaceParams() != params) {
|
} else if (surface->GetSurfaceParams().IsCompatibleSurface(params)) {
|
||||||
// If surface parameters changed, recreate the surface from the old one
|
|
||||||
return RecreateSurface(surface, params);
|
|
||||||
} else {
|
|
||||||
// Use the cached surface as-is
|
// Use the cached surface as-is
|
||||||
return surface;
|
return surface;
|
||||||
|
} else {
|
||||||
|
// If surface parameters changed, recreate the surface from the old one
|
||||||
|
return RecreateSurface(surface, params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <boost/icl/interval_map.hpp>
|
#include <boost/icl/interval_map.hpp>
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/math_util.h"
|
#include "common/math_util.h"
|
||||||
#include "video_core/engines/maxwell_3d.h"
|
#include "video_core/engines/maxwell_3d.h"
|
||||||
|
@ -546,6 +547,12 @@ struct SurfaceParams {
|
||||||
return !operator==(other);
|
return !operator==(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Checks if surfaces are compatible for caching
|
||||||
|
bool IsCompatibleSurface(const SurfaceParams& other) const {
|
||||||
|
return std::tie(pixel_format, type, cache_width, cache_height) ==
|
||||||
|
std::tie(other.pixel_format, other.type, other.cache_width, other.cache_height);
|
||||||
|
}
|
||||||
|
|
||||||
Tegra::GPUVAddr addr;
|
Tegra::GPUVAddr addr;
|
||||||
bool is_tiled;
|
bool is_tiled;
|
||||||
u32 block_height;
|
u32 block_height;
|
||||||
|
@ -556,6 +563,10 @@ struct SurfaceParams {
|
||||||
u32 height;
|
u32 height;
|
||||||
u32 unaligned_height;
|
u32 unaligned_height;
|
||||||
size_t size_in_bytes;
|
size_t size_in_bytes;
|
||||||
|
|
||||||
|
// Parameters used for caching only
|
||||||
|
u32 cache_width;
|
||||||
|
u32 cache_height;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CachedSurface final {
|
class CachedSurface final {
|
||||||
|
|
Loading…
Reference in a new issue