mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-23 03:02:53 +01:00
vk: Release dirty resources to prevent mem leak
This commit is contained in:
parent
93032be4ab
commit
cc713a0091
@ -30,6 +30,7 @@ namespace vk
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::vector<cached_texture_object> m_cache;
|
std::vector<cached_texture_object> m_cache;
|
||||||
|
u32 num_dirty_textures = 0;
|
||||||
|
|
||||||
bool lock_memory_region(u32 start, u32 size)
|
bool lock_memory_region(u32 start, u32 size)
|
||||||
{
|
{
|
||||||
@ -126,6 +127,20 @@ namespace vk
|
|||||||
unlock_memory_region(obj.protected_rgn_start, obj.native_rsx_size);
|
unlock_memory_region(obj.protected_rgn_start, obj.native_rsx_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void purge_dirty_textures()
|
||||||
|
{
|
||||||
|
for (cached_texture_object &tex : m_cache)
|
||||||
|
{
|
||||||
|
if (tex.dirty && tex.exists)
|
||||||
|
{
|
||||||
|
tex.uploaded_texture.destroy();
|
||||||
|
tex.exists = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
num_dirty_textures = 0;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
texture_cache() {}
|
texture_cache() {}
|
||||||
@ -147,6 +162,15 @@ namespace vk
|
|||||||
|
|
||||||
vk::texture& upload_texture(command_buffer cmd, rsx::texture &tex, rsx::vk_render_targets &m_rtts)
|
vk::texture& upload_texture(command_buffer cmd, rsx::texture &tex, rsx::vk_render_targets &m_rtts)
|
||||||
{
|
{
|
||||||
|
if (num_dirty_textures > 32)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Should actually reuse available dirty textures whenever possible.
|
||||||
|
* For now, just remove them, from vram
|
||||||
|
*/
|
||||||
|
purge_dirty_textures();
|
||||||
|
}
|
||||||
|
|
||||||
const u32 texaddr = rsx::get_address(tex.offset(), tex.location());
|
const u32 texaddr = rsx::get_address(tex.offset(), tex.location());
|
||||||
const u32 range = (u32)get_texture_size(tex);
|
const u32 range = (u32)get_texture_size(tex);
|
||||||
|
|
||||||
@ -202,6 +226,7 @@ namespace vk
|
|||||||
{
|
{
|
||||||
unlock_object(tex);
|
unlock_object(tex);
|
||||||
|
|
||||||
|
num_dirty_textures++;
|
||||||
tex.native_rsx_address = 0;
|
tex.native_rsx_address = 0;
|
||||||
tex.dirty = true;
|
tex.dirty = true;
|
||||||
|
|
||||||
@ -233,6 +258,7 @@ namespace vk
|
|||||||
cto.dirty = true;
|
cto.dirty = true;
|
||||||
cto.native_rsx_address = 0;
|
cto.native_rsx_address = 0;
|
||||||
|
|
||||||
|
num_dirty_textures++;
|
||||||
m_cache.push_back(cto);
|
m_cache.push_back(cto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user