mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-08-08 09:09:46 +00:00
vk: Reimplement sampler disposal using the new pool mechanism
This commit is contained in:
parent
427960fee8
commit
bf78b197a3
3 changed files with 34 additions and 10 deletions
|
@ -54,19 +54,16 @@ namespace vk
|
||||||
ensure(max_allowed_samplers);
|
ensure(max_allowed_samplers);
|
||||||
rsx_log.warning("Trimming allocated samplers. Allocated = %u, Max = %u", allocated_sampler_count, limits.maxSamplerAllocationCount);
|
rsx_log.warning("Trimming allocated samplers. Allocated = %u, Max = %u", allocated_sampler_count, limits.maxSamplerAllocationCount);
|
||||||
|
|
||||||
#if 0
|
auto filter_expr = [](const cached_sampler_object_t& sampler)
|
||||||
for (auto It = m_sampler_pool.begin(); It != m_sampler_pool.end();)
|
|
||||||
{
|
{
|
||||||
if (!It->second->has_refs())
|
// Pick only where we have no ref
|
||||||
{
|
return !sampler.has_refs();
|
||||||
dispose(It->second);
|
};
|
||||||
It = m_sampler_pool.erase(It);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
++It;
|
for (auto& object : m_sampler_pool.collect(filter_expr))
|
||||||
|
{
|
||||||
|
dispose(object);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,4 +186,29 @@ namespace vk
|
||||||
|
|
||||||
m_custom_color_sampler_pool.emplace (key.base_key, std::move(object));
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,5 +83,7 @@ namespace vk
|
||||||
vk::sampler* find(const sampler_pool_key_t& key) const;
|
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);
|
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);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue