KiCad PCB EDA Suite
Loading...
Searching...
No Matches
GPU_COMPUTE Class Reference

Process-wide compute service on its own headless device, separate from the canvas device. More...

#include <gpu_compute.h>

Public Member Functions

 ~GPU_COMPUTE ()
 
 GPU_COMPUTE (const GPU_COMPUTE &)=delete
 
GPU_COMPUTE & operator= (const GPU_COMPUTE &)=delete
 
const RHI_COMPUTE_DEVICE_LIMITS & DeviceLimits () const
 
RHI_COMPUTE_PIPELINE_LIMITS PipelineLimits (RHI_ComputePipelineHandle aPipeline)
 
RHI_BufferHandle CreateStorageBuffer (size_t aBytes)
 
RHI_ComputePipelineHandle CreatePipeline (const RHI_COMPUTE_PIPELINE_DESC &aDesc)
 
RHI_BindGroupLayoutHandle CreateBindGroupLayout (const RHI_BIND_GROUP_LAYOUT_DESC &aDesc)
 
RHI_BindGroupHandle CreateBindGroup (const RHI_BIND_GROUP_DESC &aDesc)
 
void DestroyBuffer (RHI_BufferHandle aBuffer)
 
void DestroyPipeline (RHI_ComputePipelineHandle aPipeline)
 
void DestroyBindGroupLayout (RHI_BindGroupLayoutHandle aLayout)
 
void DestroyBindGroup (RHI_BindGroupHandle aGroup)
 
RHI_COMPUTE_RESULT Submit (const RHI_COMPUTE_JOB &aJob)
 Run the whole job and copy its readbacks before returning.
 

Static Public Member Functions

static std::shared_ptr< GPU_COMPUTE > Get ()
 Return nullptr if compute is unavailable; replace a lost instance on the next call.
 

Private Member Functions

 GPU_COMPUTE (std::unique_ptr< RHI_DEVICE > aDevice)
 
template<typename F>
void destroy (F aDestroy)
 Destroy under the lock, then retire the release at once since no job can still be using it.
 

Private Attributes

std::mutex m_mutex
 
std::unique_ptr< RHI_DEVICE > m_device
 
RHI_COMPUTE_DEVICE_LIMITS m_limits
 
std::atomic< bool > m_lost { false }
 

Detailed Description

Process-wide compute service on its own headless device, separate from the canvas device.

Calls are serialised and block until done, so run long jobs from a worker thread.

Definition at line 33 of file gpu_compute.h.

Constructor & Destructor Documentation

◆ ~GPU_COMPUTE()

GPU_COMPUTE::~GPU_COMPUTE ( )
default

◆ GPU_COMPUTE() [1/2]

GPU_COMPUTE::GPU_COMPUTE ( const GPU_COMPUTE & )
delete

References GPU_COMPUTE().

Referenced by Get(), GPU_COMPUTE(), and operator=().

◆ GPU_COMPUTE() [2/2]

GPU_COMPUTE::GPU_COMPUTE ( std::unique_ptr< RHI_DEVICE > aDevice)
explicitprivate

Definition at line 25 of file gpu_compute.cpp.

References m_device, m_limits, and move.

Member Function Documentation

◆ CreateBindGroup()

RHI_BindGroupHandle GPU_COMPUTE::CreateBindGroup ( const RHI_BIND_GROUP_DESC & aDesc)

Definition at line 98 of file gpu_compute.cpp.

References m_device, and m_mutex.

◆ CreateBindGroupLayout()

RHI_BindGroupLayoutHandle GPU_COMPUTE::CreateBindGroupLayout ( const RHI_BIND_GROUP_LAYOUT_DESC & aDesc)

Definition at line 88 of file gpu_compute.cpp.

References m_device, m_mutex, and RhiValidateComputeBindGroupLayout().

◆ CreatePipeline()

RHI_ComputePipelineHandle GPU_COMPUTE::CreatePipeline ( const RHI_COMPUTE_PIPELINE_DESC & aDesc)

Definition at line 81 of file gpu_compute.cpp.

References m_device, and m_mutex.

◆ CreateStorageBuffer()

RHI_BufferHandle GPU_COMPUTE::CreateStorageBuffer ( size_t aBytes)

Definition at line 71 of file gpu_compute.cpp.

References m_device, m_limits, m_mutex, and STORAGE.

◆ destroy()

template<typename F>
void GPU_COMPUTE::destroy ( F aDestroy)
private

Destroy under the lock, then retire the release at once since no job can still be using it.

Definition at line 106 of file gpu_compute.cpp.

References F, m_device, m_mutex, and RHI_FRAMES_IN_FLIGHT.

Referenced by DestroyBindGroup(), DestroyBindGroupLayout(), DestroyBuffer(), and DestroyPipeline().

◆ DestroyBindGroup()

void GPU_COMPUTE::DestroyBindGroup ( RHI_BindGroupHandle aGroup)

Definition at line 147 of file gpu_compute.cpp.

References destroy(), and m_device.

◆ DestroyBindGroupLayout()

void GPU_COMPUTE::DestroyBindGroupLayout ( RHI_BindGroupLayoutHandle aLayout)

Definition at line 137 of file gpu_compute.cpp.

References destroy(), and m_device.

◆ DestroyBuffer()

void GPU_COMPUTE::DestroyBuffer ( RHI_BufferHandle aBuffer)

Definition at line 117 of file gpu_compute.cpp.

References destroy(), and m_device.

◆ DestroyPipeline()

void GPU_COMPUTE::DestroyPipeline ( RHI_ComputePipelineHandle aPipeline)

Definition at line 127 of file gpu_compute.cpp.

References destroy(), and m_device.

◆ DeviceLimits()

const RHI_COMPUTE_DEVICE_LIMITS & GPU_COMPUTE::DeviceLimits ( ) const
inline

Definition at line 43 of file gpu_compute.h.

References m_limits.

◆ Get()

std::shared_ptr< GPU_COMPUTE > GPU_COMPUTE::Get ( )
static

Return nullptr if compute is unavailable; replace a lost instance on the next call.

Definition at line 35 of file gpu_compute.cpp.

References GPU_COMPUTE(), and RhiCreatePlatformDevice().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ operator=()

GPU_COMPUTE & GPU_COMPUTE::operator= ( const GPU_COMPUTE & )
delete

References GPU_COMPUTE().

◆ PipelineLimits()

RHI_COMPUTE_PIPELINE_LIMITS GPU_COMPUTE::PipelineLimits ( RHI_ComputePipelineHandle aPipeline)

Definition at line 64 of file gpu_compute.cpp.

References m_device, and m_mutex.

◆ Submit()

RHI_COMPUTE_RESULT GPU_COMPUTE::Submit ( const RHI_COMPUTE_JOB & aJob)

Run the whole job and copy its readbacks before returning.

A job can be submitted again.

Definition at line 157 of file gpu_compute.cpp.

References DEVICE_LOST, m_device, m_lost, m_mutex, and result.

Member Data Documentation

◆ m_device

◆ m_limits

RHI_COMPUTE_DEVICE_LIMITS GPU_COMPUTE::m_limits
private

Definition at line 66 of file gpu_compute.h.

Referenced by CreateStorageBuffer(), DeviceLimits(), and GPU_COMPUTE().

◆ m_lost

std::atomic<bool> GPU_COMPUTE::m_lost { false }
private

Definition at line 67 of file gpu_compute.h.

Referenced by Submit().

◆ m_mutex

std::mutex GPU_COMPUTE::m_mutex
private

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