Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
ComputeSystemVK.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
8
9#ifdef JPH_USE_VK
10
12
14
17class JPH_EXPORT ComputeSystemVK : public ComputeSystem
18{
19public:
21
22 // Initialize / shutdown the compute system
23 bool Initialize(VkPhysicalDevice inPhysicalDevice, VkDevice inDevice, uint32 inComputeQueueIndex, ComputeSystemResult &outResult);
24 void Shutdown();
25
26 // See: ComputeSystem
27 virtual ComputeShaderResult CreateComputeShader(const char *inName, uint32 inGroupSizeX, uint32 inGroupSizeY, uint32 inGroupSizeZ) override;
28 virtual ComputeBufferResult CreateComputeBuffer(ComputeBuffer::EType inType, uint64 inSize, uint inStride, const void *inData = nullptr) override;
29 virtual ComputeQueueResult CreateComputeQueue() override;
30
32 VkDevice GetDevice() const { return mDevice; }
33
35 virtual bool CreateBuffer(VkDeviceSize inSize, VkBufferUsageFlags inUsage, VkMemoryPropertyFlags inProperties, BufferVK &outBuffer) = 0;
36 virtual void FreeBuffer(BufferVK &ioBuffer) = 0;
37 virtual void * MapBuffer(BufferVK &ioBuffer) = 0;
38 virtual void UnmapBuffer(BufferVK &ioBuffer) = 0;
39
40protected:
42 virtual bool InitializeMemory() = 0;
43 virtual void ShutdownMemory() = 0;
44
45 VkPhysicalDevice mPhysicalDevice = VK_NULL_HANDLE;
46 VkDevice mDevice = VK_NULL_HANDLE;
47 uint32 mComputeQueueIndex = 0;
48 PFN_vkSetDebugUtilsObjectNameEXT mVkSetDebugUtilsObjectNameEXT = nullptr;
49
50private:
51 // Buffer that can be bound when we have no buffer
52 BufferVK mDummyBuffer;
53};
54
56
57#endif // JPH_USE_VK
#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
Simple wrapper class to manage a Vulkan buffer.
Definition BufferVK.h:34
EType
Type of buffer.
Definition ComputeBuffer.h:24
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