Blender V5.3
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
22namespace blender::gpu {
23
24using WorkCallback = void (*)(void *);
26
32class GPUWorker {
33 private:
35 ThreadQueue *work_queue_;
36 WorkCallback callback_;
37
38 public:
39 enum class ContextType {
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
GPUWorker(uint32_t threads_count, ContextType context_type, WorkCallback callback)
Definition gpu_worker.cc:13
WorkID push_work(void *work, ThreadQueueWorkPriority priority)
Definition gpu_worker.cc:41
bool cancel_work(WorkID id)
Definition gpu_worker.cc:46
void(*)(void *) WorkCallback
Definition GPU_worker.hh:24
uint64_t WorkID
Definition GPU_worker.hh:25
unsigned __int64 uint64_t
Definition BKE_text.h:91
ThreadQueueWorkPriority
unsigned int uint32_t
Definition BKE_text.h:81