Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
ComputeBufferDX12.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_DX12
10
12
14
15class ComputeSystemDX12;
16
18class JPH_EXPORT ComputeBufferDX12 final : public ComputeBuffer
19{
20public:
22
24 ComputeBufferDX12(ComputeSystemDX12 *inComputeSystem, EType inType, uint64 inSize, uint inStride);
25
26 bool Initialize(const void *inData);
27
28 ID3D12Resource * GetResourceCPU() const { return mBufferCPU.Get(); }
29 ID3D12Resource * GetResourceGPU() const { return mBufferGPU.Get(); }
30 ComPtr<ID3D12Resource> ReleaseResourceCPU() const { return std::move(mBufferCPU); }
31
32 bool Barrier(ID3D12GraphicsCommandList *inCommandList, D3D12_RESOURCE_STATES inTo) const;
33 void RWBarrier(ID3D12GraphicsCommandList *inCommandList);
34 bool SyncCPUToGPU(ID3D12GraphicsCommandList *inCommandList) const;
35
37
38private:
39 virtual void * MapInternal(EMode inMode) override;
40 virtual void UnmapInternal() override;
41
42 ComputeSystemDX12 * mComputeSystem;
43 mutable ComPtr<ID3D12Resource> mBufferCPU;
44 ComPtr<ID3D12Resource> mBufferGPU;
45 mutable bool mNeedsSync = false;
46 mutable D3D12_RESOURCE_STATES mCurrentState = D3D12_RESOURCE_STATE_COPY_DEST;
47};
48
50
51#endif // JPH_USE_DX12
#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
#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:18
virtual ComputeBufferResult CreateReadBackBuffer() const =0
virtual void * MapInternal(EMode inMode)=0
virtual void UnmapInternal()=0
Helper class that either contains a valid result or an error.
Definition Result.h:12