Fix #127286: fixing memory release after light probe bake
GPU resources created during Light probe bake job were added to discard pool, but the pool itself was never notified by worker thread to release resources. Bake job creates dedicated `GPUContext` for its needs and later deletes it within the same thread. Pull Request: https://projects.blender.org/blender/blender/pulls/127977
This commit is contained in:
committed by
Jeroen Bakker
parent
bc1375a014
commit
2e11331dfc
@@ -402,11 +402,19 @@ VKDiscardPool &VKDevice::discard_pool_for_current_thread()
|
||||
void VKDevice::context_register(VKContext &context)
|
||||
{
|
||||
contexts_.append(std::reference_wrapper(context));
|
||||
current_thread_data().num_contexts += 1;
|
||||
}
|
||||
|
||||
void VKDevice::context_unregister(VKContext &context)
|
||||
{
|
||||
contexts_.remove(contexts_.first_index_of(std::reference_wrapper(context)));
|
||||
|
||||
auto &thread_data = current_thread_data();
|
||||
thread_data.num_contexts -= 1;
|
||||
BLI_assert(thread_data.num_contexts >= 0);
|
||||
if (thread_data.num_contexts == 0) {
|
||||
discard_pool_for_current_thread().destroy_discarded_resources(*this);
|
||||
}
|
||||
}
|
||||
Span<std::reference_wrapper<VKContext>> VKDevice::contexts_get() const
|
||||
{
|
||||
|
||||
@@ -82,6 +82,12 @@ class VKThreadData : public NonCopyable, NonMovable {
|
||||
*/
|
||||
int32_t rendering_depth = 0;
|
||||
|
||||
/**
|
||||
* Number of contexts registered in the current thread.
|
||||
* Discarded resources are destroyed when all contexts are unregistered.
|
||||
*/
|
||||
int32_t num_contexts = 0;
|
||||
|
||||
VKThreadData(VKDevice &device,
|
||||
pthread_t thread_id,
|
||||
std::unique_ptr<render_graph::VKCommandBufferInterface> command_buffer,
|
||||
|
||||
Reference in New Issue
Block a user