Blender V5.0
blender::gpu::GPUWorker Class Reference

#include <GPU_worker.hh>

Public Types

enum class  ContextType { Main , PerThread }

Public Member Functions

 GPUWorker (uint32_t threads_count, ContextType context_type, std::mutex &mutex, std::function< void *()> pop_work, std::function< void(void *)> do_work)
 ~GPUWorker ()
void wake_up ()

Detailed Description

Abstracts the creation and management of secondary threads with GPU contexts. Must be created from the main thread. Threads and their context remain alive until destruction.

Definition at line 24 of file GPU_worker.hh.

Member Enumeration Documentation

◆ ContextType

Enumerator
Main 

Use the main GPU context on the worker threads.

PerThread 

Use a different secondary GPU context for each worker thread.

Definition at line 32 of file GPU_worker.hh.

Constructor & Destructor Documentation

◆ GPUWorker()

blender::gpu::GPUWorker::GPUWorker ( uint32_t threads_count,
ContextType context_type,
std::mutex & mutex,
std::function< void *()> pop_work,
std::function< void(void *)> do_work )
Parameters
threads_countNumber of threads to span.
context_typeThe type of context each thread uses.
mutexMutex used when trying to acquire the next work (and reused internally for termination).
pop_workThe callback function that will be called to acquire the next work, should return a void pointer. NOTE: The mutex is locked when this function is called.
do_workThe callback function that will be called for each acquired work (passed as a void pointer). NOTE: The mutex is unlocked when this function is called.

Definition at line 9 of file gpu_worker.cc.

References i, mutex, PerThread, and UNUSED_VARS.

◆ ~GPUWorker()

blender::gpu::GPUWorker::~GPUWorker ( )

Definition at line 25 of file gpu_worker.cc.

References thread::join(), and lock.

Member Function Documentation

◆ wake_up()

void blender::gpu::GPUWorker::wake_up ( )
inline

Definition at line 59 of file GPU_worker.hh.


The documentation for this class was generated from the following files: