2
0

ComputeSystemDX12.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2025 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. #include <Jolt/Core/UnorderedMap.h>
  6. #include <Jolt/Compute/ComputeSystem.h>
  7. #ifdef JPH_USE_DX12
  8. #include <Jolt/Compute/DX12/IncludeDX12.h>
  9. JPH_NAMESPACE_BEGIN
  10. /// Interface to run a workload on the GPU using DirectX 12.
  11. /// Minimal implementation that can integrate with your own DirectX 12 setup.
  12. class JPH_EXPORT ComputeSystemDX12 : public ComputeSystem
  13. {
  14. public:
  15. JPH_DECLARE_RTTI_VIRTUAL(JPH_EXPORT, ComputeSystemDX12)
  16. /// How we want to compile our shaders
  17. enum class EDebug
  18. {
  19. NoDebugSymbols,
  20. DebugSymbols
  21. };
  22. /// Initialize / shutdown
  23. void Initialize(ID3D12Device *inDevice, EDebug inDebug);
  24. void Shutdown();
  25. // See: ComputeSystem
  26. virtual ComputeShaderResult CreateComputeShader(const char *inName, uint32 inGroupSizeX, uint32 inGroupSizeY, uint32 inGroupSizeZ) override;
  27. virtual ComputeBufferResult CreateComputeBuffer(ComputeBuffer::EType inType, uint64 inSize, uint inStride, const void *inData = nullptr) override;
  28. virtual ComputeQueueResult CreateComputeQueue() override;
  29. /// Access to the DX12 device
  30. ID3D12Device * GetDevice() const { return mDevice.Get(); }
  31. // Function to create a ID3D12Resource on specified heap with specified state
  32. ComPtr<ID3D12Resource> CreateD3DResource(D3D12_HEAP_TYPE inHeapType, D3D12_RESOURCE_STATES inResourceState, D3D12_RESOURCE_FLAGS inFlags, uint64 inSize);
  33. private:
  34. ComPtr<ID3D12Device> mDevice;
  35. EDebug mDebug = EDebug::NoDebugSymbols;
  36. };
  37. JPH_NAMESPACE_END
  38. #endif // JPH_USE_DX12