Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
ComputeQueue Class Referenceabstract

A command queue for executing compute workloads on the GPU. More...

#include <ComputeQueue.h>

Inheritance diagram for ComputeQueue:
RefTarget< ComputeQueue > NonCopyable

Public Types

enum class  EBarrier { Yes , No }
 If a barrier should be placed before accessing the buffer. More...
 

Public Member Functions

virtual JPH_OVERRIDE_NEW_DELETE ~ComputeQueue ()=default
 Destructor.
 
virtual void SetShader (const ComputeShader *inShader)=0
 
virtual void SetConstantBuffer (const char *inName, const ComputeBuffer *inBuffer)=0
 Bind a constant buffer to the shader. Note that the contents of the buffer cannot be modified until execution finishes.
 
virtual void SetBuffer (const char *inName, const ComputeBuffer *inBuffer)=0
 Bind a read only buffer to the shader. Note that the contents of the buffer cannot be modified on CPU until execution finishes (only relevant for buffers of type UploadBuffer).
 
virtual void SetRWBuffer (const char *inName, ComputeBuffer *inBuffer, EBarrier inBarrier=EBarrier::Yes)=0
 
virtual void Dispatch (uint inThreadGroupsX, uint inThreadGroupsY=1, uint inThreadGroupsZ=1)=0
 Dispatch a compute shader with the specified number of thread groups.
 
virtual void ScheduleReadback (ComputeBuffer *inDst, const ComputeBuffer *inSrc)=0
 Schedule buffer to be copied from GPU to CPU.
 
virtual void Execute ()=0
 Execute accumulated command list.
 
virtual void Wait ()=0
 After executing, this waits until execution is done.
 
void ExecuteAndWait ()
 Execute and wait for the command list to finish.
 
- Public Member Functions inherited from RefTarget< ComputeQueue >
 RefTarget ()=default
 Constructor.
 
 RefTarget (const RefTarget &)
 
 ~RefTarget ()
 assert no one is referencing us
 
void SetEmbedded () const
 
RefTargetoperator= (const RefTarget &)
 Assignment operator.
 
uint32 GetRefCount () const
 Get current refcount of this object.
 
void AddRef () const
 Add or release a reference to this object.
 
void Release () const
 
- Public Member Functions inherited from NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
void operator= (const NonCopyable &)=delete
 

Additional Inherited Members

- Static Public Member Functions inherited from RefTarget< ComputeQueue >
static int sInternalGetRefCountOffset ()
 INTERNAL HELPER FUNCTION USED BY SERIALIZATION.
 
- Protected Attributes inherited from RefTarget< ComputeQueue >
atomic< uint32mRefCount
 Current reference count.
 
- Static Protected Attributes inherited from RefTarget< ComputeQueue >
static constexpr uint32 cEmbedded
 A large value that gets added to the refcount to mark the object as embedded.
 

Detailed Description

A command queue for executing compute workloads on the GPU.

Member Enumeration Documentation

◆ EBarrier

enum class ComputeQueue::EBarrier
strong

If a barrier should be placed before accessing the buffer.

Enumerator
Yes 
No 

Constructor & Destructor Documentation

◆ ~ComputeQueue()

virtual JPH_OVERRIDE_NEW_DELETE ComputeQueue::~ComputeQueue ( )
virtualdefault

Destructor.

Member Function Documentation

◆ Dispatch()

virtual void ComputeQueue::Dispatch ( uint inThreadGroupsX,
uint inThreadGroupsY = 1,
uint inThreadGroupsZ = 1 )
pure virtual

Dispatch a compute shader with the specified number of thread groups.

◆ Execute()

virtual void ComputeQueue::Execute ( )
pure virtual

Execute accumulated command list.

◆ ExecuteAndWait()

void ComputeQueue::ExecuteAndWait ( )
inline

Execute and wait for the command list to finish.

◆ ScheduleReadback()

virtual void ComputeQueue::ScheduleReadback ( ComputeBuffer * inDst,
const ComputeBuffer * inSrc )
pure virtual

Schedule buffer to be copied from GPU to CPU.

◆ SetBuffer()

virtual void ComputeQueue::SetBuffer ( const char * inName,
const ComputeBuffer * inBuffer )
pure virtual

Bind a read only buffer to the shader. Note that the contents of the buffer cannot be modified on CPU until execution finishes (only relevant for buffers of type UploadBuffer).

◆ SetConstantBuffer()

virtual void ComputeQueue::SetConstantBuffer ( const char * inName,
const ComputeBuffer * inBuffer )
pure virtual

Bind a constant buffer to the shader. Note that the contents of the buffer cannot be modified until execution finishes.

◆ SetRWBuffer()

virtual void ComputeQueue::SetRWBuffer ( const char * inName,
ComputeBuffer * inBuffer,
EBarrier inBarrier = EBarrier::Yes )
pure virtual

Bind a read/write buffer to the shader.

Parameters
inNameName of the buffer as specified in the shader.
inBufferThe buffer to bind.
inBarrierIf set to Yes, a barrier will be placed before accessing the buffer to ensure all previous writes to the buffer are visible.

◆ SetShader()

virtual void ComputeQueue::SetShader ( const ComputeShader * inShader)
pure virtual

Activate a shader. Shader must be set first before buffers can be bound. After every Dispatch call, the shader must be set again and all buffers must be bound again.

◆ Wait()

virtual void ComputeQueue::Wait ( )
pure virtual

After executing, this waits until execution is done.


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