Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
ComputeSystemCPU.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2026 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
10
12
16{
17public:
19
20 // See: ComputeSystem
21 virtual ComputeShaderResult CreateComputeShader(const char *inName, uint32 inGroupSizeX, uint32 inGroupSizeY, uint32 inGroupSizeZ) override;
22 virtual ComputeBufferResult CreateComputeBuffer(ComputeBuffer::EType inType, uint64 inSize, uint inStride, const void *inData = nullptr) override;
23 virtual ComputeQueueResult CreateComputeQueue() override;
24
26
27 void RegisterShader(const char *inName, CreateShader inCreateShader)
28 {
29 mShaderRegistry[inName] = inCreateShader;
30 }
31
32private:
33 using ShaderRegistry = UnorderedMap<string_view, CreateShader>;
34 ShaderRegistry mShaderRegistry;
35};
36
37// Internal helpers
38#define JPH_SHADER_WRAPPER_FUNCTION_NAME(name) RegisterShader##name
39#define JPH_SHADER_WRAPPER_FUNCTION(sys, name) void JPH_EXPORT JPH_SHADER_WRAPPER_FUNCTION_NAME(name)(ComputeSystemCPU *sys)
40
42#define JPH_DECLARE_REGISTER_SHADER(name) namespace JPH { class ComputeSystemCPU; JPH_SHADER_WRAPPER_FUNCTION(, name); }
43
45#define JPH_REGISTER_SHADER(sys, name) JPH::JPH_SHADER_WRAPPER_FUNCTION_NAME(name)(sys)
46
#define JPH_EXPORT
Definition Core.h:275
std::uint64_t uint64
Definition Core.h:504
unsigned int uint
Definition Core.h:500
#define JPH_NAMESPACE_END
Definition Core.h:425
std::uint32_t uint32
Definition Core.h:503
#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
EType
Type of buffer.
Definition ComputeBuffer.h:24
ShaderWrapper *(*)() CreateShader
Definition ComputeShaderCPU.h:19
Definition ComputeSystemCPU.h:16
ComputeShaderCPU::CreateShader CreateShader
Definition ComputeSystemCPU.h:25
void RegisterShader(const char *inName, CreateShader inCreateShader)
Definition ComputeSystemCPU.h:27
Interface to run a workload on the GPU.
Definition ComputeSystem.h:15
virtual ComputeQueueResult CreateComputeQueue()=0
Create a queue for executing compute shaders.
virtual ComputeBufferResult CreateComputeBuffer(ComputeBuffer::EType inType, uint64 inSize, uint inStride, const void *inData=nullptr)=0
Create a buffer for use with a compute shader.
virtual ComputeShaderResult CreateComputeShader(const char *inName, uint32 inGroupSizeX, uint32 inGroupSizeY=1, uint32 inGroupSizeZ=1)=0
Compile a compute shader.
Helper class that either contains a valid result or an error.
Definition Result.h:12
Definition UnorderedMap.h:30