Blender
V5.0
source
blender
gpu
GPU_worker.hh
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2025 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
5
#pragma once
6
7
#include "
BLI_vector.hh
"
8
#include "
GPU_context.hh
"
9
10
#include <atomic>
11
#include <condition_variable>
12
#include <functional>
13
#include <memory>
14
#include <mutex>
15
#include <thread>
16
17
namespace
blender::gpu
{
18
24
class
GPUWorker
{
25
private
:
26
Vector<std::unique_ptr<std::thread>
> threads_;
27
std::condition_variable condition_var_;
28
std::mutex &mutex_;
29
bool
terminate_ =
false
;
30
31
public
:
32
enum class
ContextType
{
34
Main
,
36
PerThread
,
37
};
38
51
GPUWorker
(uint32_t threads_count,
52
ContextType
context_type,
53
std::mutex &
mutex
,
54
std::function<
void
*()> pop_work,
55
std::function<
void
(
void
*)> do_work);
56
~GPUWorker
();
57
58
/* Wake up a single thread. */
59
void
wake_up
()
60
{
61
condition_var_.notify_one();
62
}
63
64
private
:
65
void
run(std::shared_ptr<GPUSecondaryContext> context,
66
std::function<
void
*()> pop_work,
67
std::function<
void
(
void
*)> do_work);
68
};
69
70
}
// namespace blender::gpu
BLI_vector.hh
GPU_context.hh
blender::Vector
Definition
BLI_vector.hh:76
blender::gpu::GPUWorker::~GPUWorker
~GPUWorker()
Definition
gpu_worker.cc:25
blender::gpu::GPUWorker::ContextType
ContextType
Definition
GPU_worker.hh:32
blender::gpu::GPUWorker::ContextType::PerThread
@ PerThread
Definition
GPU_worker.hh:36
blender::gpu::GPUWorker::wake_up
void wake_up()
Definition
GPU_worker.hh:59
blender::gpu::GPUWorker::GPUWorker
GPUWorker(uint32_t threads_count, ContextType context_type, std::mutex &mutex, std::function< void *()> pop_work, std::function< void(void *)> do_work)
Definition
gpu_worker.cc:9
mutex
ThreadMutex mutex
Definition
gpu_batch_presets.cc:39
blender::gpu
Definition
blf_internal_types.hh:32
Main
Definition
BKE_main.hh:160
Generated on
for Blender by
doxygen
1.16.1