1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 12:12:50 +01:00

vk: Reimplement sampler disposal using the new pool mechanism

This commit is contained in:
kd-11 2023-05-22 20:31:13 +03:00 committed by kd-11
parent 427960fee8
commit bf78b197a3
3 changed files with 34 additions and 10 deletions

View File

@ -54,19 +54,16 @@ namespace vk
ensure(max_allowed_samplers);
rsx_log.warning("Trimming allocated samplers. Allocated = %u, Max = %u", allocated_sampler_count, limits.maxSamplerAllocationCount);
#if 0
for (auto It = m_sampler_pool.begin(); It != m_sampler_pool.end();)
auto filter_expr = [](const cached_sampler_object_t& sampler)
{
if (!It->second->has_refs())
{
dispose(It->second);
It = m_sampler_pool.erase(It);
continue;
}
// Pick only where we have no ref
return !sampler.has_refs();
};
++It;
for (auto& object : m_sampler_pool.collect(filter_expr))
{
dispose(object);
}
#endif
}
}

View File

@ -186,4 +186,29 @@ namespace vk
m_custom_color_sampler_pool.emplace (key.base_key, std::move(object));
}
std::vector<std::unique_ptr<cached_sampler_object_t>> sampler_pool_t::collect(std::function<bool(const cached_sampler_object_t&)> predicate)
{
std::vector<std::unique_ptr<cached_sampler_object_t>> result;
const auto collect_fn = [&](auto& container)
{
for (auto It = container.begin(); It != container.end();)
{
if (!predicate(*It->second))
{
It++;
continue;
}
result.emplace_back(std::move(It->second));
It = container.erase(It);
}
};
collect_fn(m_generic_sampler_pool);
collect_fn(m_custom_color_sampler_pool);
return result;
}
}

View File

@ -83,5 +83,7 @@ namespace vk
vk::sampler* find(const sampler_pool_key_t& key) const;
void emplace(const sampler_pool_key_t& key, std::unique_ptr<cached_sampler_object_t>& object);
std::vector<std::unique_ptr<cached_sampler_object_t>> collect(std::function<bool(const cached_sampler_object_t&)> predicate);
};
}