video_core: Clear runtime on rasterizer cache flush
* When changing res scale or custom textures a large number of textures will be replaced so better not keep the old ones
This commit is contained in:
@ -1264,6 +1264,7 @@ void RasterizerCache<T>::UnregisterAll() {
|
|||||||
}
|
}
|
||||||
texture_cube_cache.clear();
|
texture_cube_cache.clear();
|
||||||
remove_surfaces.clear();
|
remove_surfaces.clear();
|
||||||
|
runtime.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@ -96,6 +96,11 @@ TextureRuntime::TextureRuntime(Driver& driver)
|
|||||||
|
|
||||||
TextureRuntime::~TextureRuntime() = default;
|
TextureRuntime::~TextureRuntime() = default;
|
||||||
|
|
||||||
|
void TextureRuntime::Clear() {
|
||||||
|
framebuffer_cache.clear();
|
||||||
|
texture_recycler.clear();
|
||||||
|
}
|
||||||
|
|
||||||
StagingData TextureRuntime::FindStaging(u32 size, bool upload) {
|
StagingData TextureRuntime::FindStaging(u32 size, bool upload) {
|
||||||
if (!upload) {
|
if (!upload) {
|
||||||
if (size > download_buffer.size()) {
|
if (size > download_buffer.size()) {
|
||||||
|
@ -97,6 +97,9 @@ public:
|
|||||||
/// Causes a GPU command flush
|
/// Causes a GPU command flush
|
||||||
void Finish() const {}
|
void Finish() const {}
|
||||||
|
|
||||||
|
/// Destroys runtime cached resources
|
||||||
|
void Clear();
|
||||||
|
|
||||||
/// Takes back ownership of the allocation for recycling
|
/// Takes back ownership of the allocation for recycling
|
||||||
void Recycle(const HostTextureTag tag, Allocation&& alloc);
|
void Recycle(const HostTextureTag tag, Allocation&& alloc);
|
||||||
|
|
||||||
|
@ -32,13 +32,17 @@ RenderpassCache::~RenderpassCache() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& [key, framebuffer] : framebuffers) {
|
ClearFramebuffers();
|
||||||
device.destroyFramebuffer(framebuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
device.destroyRenderPass(present_renderpass);
|
device.destroyRenderPass(present_renderpass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderpassCache::ClearFramebuffers() {
|
||||||
|
for (auto& [key, framebuffer] : framebuffers) {
|
||||||
|
instance.GetDevice().destroyFramebuffer(framebuffer);
|
||||||
|
}
|
||||||
|
framebuffers.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void RenderpassCache::EnterRenderpass(Surface* const color, Surface* const depth_stencil,
|
void RenderpassCache::EnterRenderpass(Surface* const color, Surface* const depth_stencil,
|
||||||
vk::Rect2D render_area, bool do_clear, vk::ClearValue clear) {
|
vk::Rect2D render_area, bool do_clear, vk::ClearValue clear) {
|
||||||
return EnterRenderpass(Framebuffer{color, depth_stencil, render_area}, do_clear, clear);
|
return EnterRenderpass(Framebuffer{color, depth_stencil, render_area}, do_clear, clear);
|
||||||
|
@ -49,6 +49,9 @@ public:
|
|||||||
RenderpassCache(const Instance& instance, Scheduler& scheduler);
|
RenderpassCache(const Instance& instance, Scheduler& scheduler);
|
||||||
~RenderpassCache();
|
~RenderpassCache();
|
||||||
|
|
||||||
|
/// Destroys cached framebuffers
|
||||||
|
void ClearFramebuffers();
|
||||||
|
|
||||||
/// Begins a new renderpass only when no other renderpass is currently active
|
/// Begins a new renderpass only when no other renderpass is currently active
|
||||||
void EnterRenderpass(const Framebuffer& framebuffer, bool do_clear = false,
|
void EnterRenderpass(const Framebuffer& framebuffer, bool do_clear = false,
|
||||||
vk::ClearValue clear = {});
|
vk::ClearValue clear = {});
|
||||||
|
@ -130,23 +130,7 @@ TextureRuntime::TextureRuntime(const Instance& instance, Scheduler& scheduler,
|
|||||||
}
|
}
|
||||||
|
|
||||||
TextureRuntime::~TextureRuntime() {
|
TextureRuntime::~TextureRuntime() {
|
||||||
VmaAllocator allocator = instance.GetAllocator();
|
Clear();
|
||||||
vk::Device device = instance.GetDevice();
|
|
||||||
device.waitIdle();
|
|
||||||
|
|
||||||
for (const auto& [key, alloc] : texture_recycler) {
|
|
||||||
vmaDestroyImage(allocator, alloc.image, alloc.allocation);
|
|
||||||
device.destroyImageView(alloc.image_view);
|
|
||||||
if (alloc.depth_view) {
|
|
||||||
device.destroyImageView(alloc.depth_view);
|
|
||||||
device.destroyImageView(alloc.stencil_view);
|
|
||||||
}
|
|
||||||
if (alloc.storage_view) {
|
|
||||||
device.destroyImageView(alloc.storage_view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
texture_recycler.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StagingData TextureRuntime::FindStaging(u32 size, bool upload) {
|
StagingData TextureRuntime::FindStaging(u32 size, bool upload) {
|
||||||
@ -164,6 +148,29 @@ void TextureRuntime::Finish() {
|
|||||||
scheduler.Finish();
|
scheduler.Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextureRuntime::Clear() {
|
||||||
|
scheduler.Finish();
|
||||||
|
|
||||||
|
VmaAllocator allocator = instance.GetAllocator();
|
||||||
|
vk::Device device = instance.GetDevice();
|
||||||
|
device.waitIdle();
|
||||||
|
|
||||||
|
renderpass_cache.ClearFramebuffers();
|
||||||
|
for (const auto& [key, alloc] : texture_recycler) {
|
||||||
|
vmaDestroyImage(allocator, alloc.image, alloc.allocation);
|
||||||
|
device.destroyImageView(alloc.image_view);
|
||||||
|
if (alloc.depth_view) {
|
||||||
|
device.destroyImageView(alloc.depth_view);
|
||||||
|
device.destroyImageView(alloc.stencil_view);
|
||||||
|
}
|
||||||
|
if (alloc.storage_view) {
|
||||||
|
device.destroyImageView(alloc.storage_view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
texture_recycler.clear();
|
||||||
|
}
|
||||||
|
|
||||||
Allocation TextureRuntime::Allocate(u32 width, u32 height, u32 levels,
|
Allocation TextureRuntime::Allocate(u32 width, u32 height, u32 levels,
|
||||||
VideoCore::PixelFormat format, VideoCore::TextureType type) {
|
VideoCore::PixelFormat format, VideoCore::TextureType type) {
|
||||||
const FormatTraits traits = instance.GetTraits(format);
|
const FormatTraits traits = instance.GetTraits(format);
|
||||||
|
@ -92,6 +92,9 @@ public:
|
|||||||
/// Causes a GPU command flush
|
/// Causes a GPU command flush
|
||||||
void Finish();
|
void Finish();
|
||||||
|
|
||||||
|
/// Destroys runtime cached resources
|
||||||
|
void Clear();
|
||||||
|
|
||||||
/// Takes back ownership of the allocation for recycling
|
/// Takes back ownership of the allocation for recycling
|
||||||
void Recycle(const HostTextureTag tag, Allocation&& alloc);
|
void Recycle(const HostTextureTag tag, Allocation&& alloc);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user