|
|
@ -273,7 +273,7 @@ struct hash<VideoCommon::ViewKey> {
|
|
|
|
|
|
|
|
|
|
|
|
namespace VideoCommon {
|
|
|
|
namespace VideoCommon {
|
|
|
|
|
|
|
|
|
|
|
|
template <typename TView, typename TExecutionContext>
|
|
|
|
template <typename TTextureCache, typename TView, typename TExecutionContext>
|
|
|
|
class SurfaceBase {
|
|
|
|
class SurfaceBase {
|
|
|
|
static_assert(std::is_trivially_copyable_v<TExecutionContext>);
|
|
|
|
static_assert(std::is_trivially_copyable_v<TExecutionContext>);
|
|
|
|
|
|
|
|
|
|
|
@ -331,6 +331,9 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
void MarkAsModified(bool is_modified_) {
|
|
|
|
void MarkAsModified(bool is_modified_) {
|
|
|
|
is_modified = is_modified_;
|
|
|
|
is_modified = is_modified_;
|
|
|
|
|
|
|
|
if (is_modified_) {
|
|
|
|
|
|
|
|
modification_tick = texture_cache.Tick();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const SurfaceParams& GetSurfaceParams() const {
|
|
|
|
const SurfaceParams& GetSurfaceParams() const {
|
|
|
@ -358,13 +361,18 @@ public:
|
|
|
|
is_registered = false;
|
|
|
|
is_registered = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
u64 GetModificationTick() const {
|
|
|
|
|
|
|
|
return modification_tick;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool IsRegistered() const {
|
|
|
|
bool IsRegistered() const {
|
|
|
|
return is_registered;
|
|
|
|
return is_registered;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
|
explicit SurfaceBase(const SurfaceParams& params)
|
|
|
|
explicit SurfaceBase(TTextureCache& texture_cache, const SurfaceParams& params)
|
|
|
|
: params{params}, view_offset_map{params.CreateViewOffsetMap()} {}
|
|
|
|
: params{params}, texture_cache{texture_cache}, view_offset_map{
|
|
|
|
|
|
|
|
params.CreateViewOffsetMap()} {}
|
|
|
|
|
|
|
|
|
|
|
|
~SurfaceBase() = default;
|
|
|
|
~SurfaceBase() = default;
|
|
|
|
|
|
|
|
|
|
|
@ -389,12 +397,14 @@ private:
|
|
|
|
return view.get();
|
|
|
|
return view.get();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TTextureCache& texture_cache;
|
|
|
|
const std::map<u64, std::pair<u32, u32>> view_offset_map;
|
|
|
|
const std::map<u64, std::pair<u32, u32>> view_offset_map;
|
|
|
|
|
|
|
|
|
|
|
|
GPUVAddr gpu_addr{};
|
|
|
|
GPUVAddr gpu_addr{};
|
|
|
|
VAddr cpu_addr{};
|
|
|
|
VAddr cpu_addr{};
|
|
|
|
u8* host_ptr{};
|
|
|
|
u8* host_ptr{};
|
|
|
|
CacheAddr cache_addr{};
|
|
|
|
CacheAddr cache_addr{};
|
|
|
|
|
|
|
|
u64 modification_tick{};
|
|
|
|
bool is_modified{};
|
|
|
|
bool is_modified{};
|
|
|
|
bool is_registered{};
|
|
|
|
bool is_registered{};
|
|
|
|
std::unordered_map<ViewKey, std::unique_ptr<TView>> views;
|
|
|
|
std::unordered_map<ViewKey, std::unique_ptr<TView>> views;
|
|
|
@ -475,6 +485,10 @@ public:
|
|
|
|
return it != registered_surfaces.end() ? *it->second.begin() : nullptr;
|
|
|
|
return it != registered_surfaces.end() ? *it->second.begin() : nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
u64 Tick() {
|
|
|
|
|
|
|
|
return ++ticks;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
|
TextureCache(Core::System& system, VideoCore::RasterizerInterface& rasterizer)
|
|
|
|
TextureCache(Core::System& system, VideoCore::RasterizerInterface& rasterizer)
|
|
|
|
: system{system}, rasterizer{rasterizer} {}
|
|
|
|
: system{system}, rasterizer{rasterizer} {}
|
|
|
@ -521,7 +535,7 @@ private:
|
|
|
|
|
|
|
|
|
|
|
|
const auto host_ptr{memory_manager.GetPointer(gpu_addr)};
|
|
|
|
const auto host_ptr{memory_manager.GetPointer(gpu_addr)};
|
|
|
|
const auto cache_addr{ToCacheAddr(host_ptr)};
|
|
|
|
const auto cache_addr{ToCacheAddr(host_ptr)};
|
|
|
|
const auto overlaps{GetSurfacesInRegion(cache_addr, params.GetGuestSizeInBytes())};
|
|
|
|
auto overlaps{GetSurfacesInRegion(cache_addr, params.GetGuestSizeInBytes())};
|
|
|
|
if (overlaps.empty()) {
|
|
|
|
if (overlaps.empty()) {
|
|
|
|
return LoadSurfaceView(exctx, gpu_addr, *cpu_addr, host_ptr, params, preserve_contents);
|
|
|
|
return LoadSurfaceView(exctx, gpu_addr, *cpu_addr, host_ptr, params, preserve_contents);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -544,8 +558,8 @@ private:
|
|
|
|
|
|
|
|
|
|
|
|
for (const auto& surface : overlaps) {
|
|
|
|
for (const auto& surface : overlaps) {
|
|
|
|
if (!fast_view) {
|
|
|
|
if (!fast_view) {
|
|
|
|
// Flush even when we don't care about the contents, to preserve memory not written
|
|
|
|
// Flush even when we don't care about the contents, to preserve memory not
|
|
|
|
// by the new surface.
|
|
|
|
// written by the new surface.
|
|
|
|
exctx = surface->FlushBuffer(exctx);
|
|
|
|
exctx = surface->FlushBuffer(exctx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Unregister(surface);
|
|
|
|
Unregister(surface);
|
|
|
@ -614,6 +628,8 @@ private:
|
|
|
|
|
|
|
|
|
|
|
|
VideoCore::RasterizerInterface& rasterizer;
|
|
|
|
VideoCore::RasterizerInterface& rasterizer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
u64 ticks{};
|
|
|
|
|
|
|
|
|
|
|
|
IntervalMap registered_surfaces;
|
|
|
|
IntervalMap registered_surfaces;
|
|
|
|
|
|
|
|
|
|
|
|
/// The surface reserve is a "backup" cache, this is where we put unique surfaces that have
|
|
|
|
/// The surface reserve is a "backup" cache, this is where we put unique surfaces that have
|
|
|
@ -653,6 +669,10 @@ public:
|
|
|
|
return Base::TryFindFramebufferSurface(host_ptr);
|
|
|
|
return Base::TryFindFramebufferSurface(host_ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
u64 Tick() {
|
|
|
|
|
|
|
|
return Base::Tick();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
|
explicit TextureCacheContextless(Core::System& system,
|
|
|
|
explicit TextureCacheContextless(Core::System& system,
|
|
|
|
VideoCore::RasterizerInterface& rasterizer)
|
|
|
|
VideoCore::RasterizerInterface& rasterizer)
|
|
|
@ -678,8 +698,8 @@ private:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <typename TView>
|
|
|
|
template <typename TTextureCache, typename TView>
|
|
|
|
class SurfaceBaseContextless : public SurfaceBase<TView, DummyExecutionContext> {
|
|
|
|
class SurfaceBaseContextless : public SurfaceBase<TTextureCache, TView, DummyExecutionContext> {
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
DummyExecutionContext FlushBuffer(DummyExecutionContext) {
|
|
|
|
DummyExecutionContext FlushBuffer(DummyExecutionContext) {
|
|
|
|
FlushBufferImpl();
|
|
|
|
FlushBufferImpl();
|
|
|
@ -692,8 +712,8 @@ public:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
|
explicit SurfaceBaseContextless(const SurfaceParams& params)
|
|
|
|
explicit SurfaceBaseContextless(TTextureCache& texture_cache, const SurfaceParams& params)
|
|
|
|
: SurfaceBase<TView, DummyExecutionContext>{params} {}
|
|
|
|
: SurfaceBase<TTextureCache, TView, DummyExecutionContext>{texture_cache, params} {}
|
|
|
|
|
|
|
|
|
|
|
|
virtual void FlushBufferImpl() = 0;
|
|
|
|
virtual void FlushBufferImpl() = 0;
|
|
|
|
|
|
|
|
|
|
|
|