Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
ComputeQueue.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2025 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
9
11
12class ComputeShader;
13class ComputeBuffer;
14
16class JPH_EXPORT ComputeQueue : public RefTarget<ComputeQueue>, public NonCopyable
17{
18public:
20
22 virtual ~ComputeQueue() = default;
23
26 virtual void SetShader(const ComputeShader *inShader) = 0;
27
29 enum class EBarrier
30 {
31 Yes,
32 No
33 };
34
36 virtual void SetConstantBuffer(const char *inName, const ComputeBuffer *inBuffer) = 0;
37
39 virtual void SetBuffer(const char *inName, const ComputeBuffer *inBuffer) = 0;
40
45 virtual void SetRWBuffer(const char *inName, ComputeBuffer *inBuffer, EBarrier inBarrier = EBarrier::Yes) = 0;
46
48 virtual void Dispatch(uint inThreadGroupsX, uint inThreadGroupsY = 1, uint inThreadGroupsZ = 1) = 0;
49
51 virtual void ScheduleReadback(ComputeBuffer *inDst, const ComputeBuffer *inSrc) = 0;
52
54 virtual void Execute() = 0;
55
57 virtual void Wait() = 0;
58
61 {
62 Execute();
63 Wait();
64 }
65};
66
#define JPH_EXPORT
Definition Core.h:275
unsigned int uint
Definition Core.h:500
#define JPH_NAMESPACE_END
Definition Core.h:425
#define JPH_NAMESPACE_BEGIN
Definition Core.h:419
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:50
Buffer that can be read from / written to by a compute shader.
Definition ComputeBuffer.h:14
A command queue for executing compute workloads on the GPU.
Definition ComputeQueue.h:17
EBarrier
If a barrier should be placed before accessing the buffer.
Definition ComputeQueue.h:30
virtual void Wait()=0
After executing, this waits until execution is done.
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...
virtual void ScheduleReadback(ComputeBuffer *inDst, const ComputeBuffer *inSrc)=0
Schedule buffer to be copied from GPU to CPU.
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 e...
virtual void SetShader(const ComputeShader *inShader)=0
virtual void Execute()=0
Execute accumulated command list.
virtual void Dispatch(uint inThreadGroupsX, uint inThreadGroupsY=1, uint inThreadGroupsZ=1)=0
Dispatch a compute shader with the specified number of thread groups.
void ExecuteAndWait()
Execute and wait for the command list to finish.
Definition ComputeQueue.h:60
virtual JPH_OVERRIDE_NEW_DELETE ~ComputeQueue()=default
Destructor.
virtual void SetRWBuffer(const char *inName, ComputeBuffer *inBuffer, EBarrier inBarrier=EBarrier::Yes)=0
Compute shader handle.
Definition ComputeShader.h:14
Class that makes another class non-copyable. Usage: Inherit from NonCopyable.
Definition NonCopyable.h:11
Definition Reference.h:35