Blender
V5.3
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
8
9
#pragma once
10
11
#include "
BLI_threads.hh
"
12
#include "
BLI_vector.hh
"
13
#include "
GPU_context.hh
"
14
15
#include <atomic>
16
#include <condition_variable>
17
#include <functional>
18
#include <memory>
19
#include <mutex>
20
#include <thread>
21
22
namespace
blender::gpu
{
23
24
using
WorkCallback
= void (*)(
void
*);
25
using
WorkID
=
uint64_t
;
26
32
class
GPUWorker
{
33
private
:
34
Vector<std::unique_ptr<std::thread>
> threads_;
35
ThreadQueue
*work_queue_;
36
WorkCallback
callback_;
37
38
public
:
39
enum class
ContextType
{
41
Main
,
43
PerThread,
44
};
45
52
GPUWorker
(
uint32_t
threads_count,
ContextType
context_type,
WorkCallback
callback);
53
~GPUWorker
();
54
55
WorkID
push_work
(
void
*work,
ThreadQueueWorkPriority
priority);
56
bool
cancel_work
(
WorkID
id
);
57
bool
is_empty
();
58
59
private
:
60
void
run(std::shared_ptr<GPUSecondaryContext> context);
61
};
62
63
}
// namespace blender::gpu
BLI_threads.hh
BLI_vector.hh
GPU_context.hh
blender::gpu::GPUWorker
Definition
GPU_worker.hh:32
blender::gpu::GPUWorker::GPUWorker
GPUWorker(uint32_t threads_count, ContextType context_type, WorkCallback callback)
Definition
gpu_worker.cc:13
blender::gpu::GPUWorker::ContextType
ContextType
Definition
GPU_worker.hh:39
blender::gpu::GPUWorker::is_empty
bool is_empty()
Definition
gpu_worker.cc:51
blender::gpu::GPUWorker::push_work
WorkID push_work(void *work, ThreadQueueWorkPriority priority)
Definition
gpu_worker.cc:41
blender::gpu::GPUWorker::cancel_work
bool cancel_work(WorkID id)
Definition
gpu_worker.cc:46
blender::gpu
Definition
blf_internal_types.hh:35
blender::gpu::WorkCallback
void(*)(void *) WorkCallback
Definition
GPU_worker.hh:24
blender::gpu::WorkID
uint64_t WorkID
Definition
GPU_worker.hh:25
blender::uint64_t
unsigned __int64 uint64_t
Definition
BKE_text.h:91
blender::ThreadQueueWorkPriority
ThreadQueueWorkPriority
Definition
BLI_threads.hh:165
blender::uint32_t
unsigned int uint32_t
Definition
BKE_text.h:81
blender::Main
Definition
BKE_main.hh:243
blender::ThreadQueue
Definition
threads.cc:615
lexit::Vector
Definition
vector.hh:68
Generated on
for Blender by
doxygen
1.18.0