RavEngine
Loading...
Searching...
No Matches
D3D12Device.hpp
1#pragma once
2#include <RGL/Types.hpp>
3#include <RGL/Device.hpp>
4#include <RGL/Pipeline.hpp>
5#include "D3D12DynamicDescriptorHeap.hpp"
6#include <directx/d3d12.h>
7#include <dxgi1_6.h>
8#include <wrl.h>
9
10#undef CreateSemaphore
11
12namespace D3D12MA {
13 struct Allocator;
14}
15
16
17namespace RGL {
18
19 struct CommandQueueD3D12;
20
21 struct DeviceD3D12 : public IDevice, public std::enable_shared_from_this<DeviceD3D12>{
22
23 Microsoft::WRL::ComPtr<ID3D12Device2> device;
24 Microsoft::WRL::ComPtr<IDXGIAdapter4> adapter;
25 std::shared_ptr<CommandQueueD3D12> internalQueue;
26 Microsoft::WRL::ComPtr<ID3D12GraphicsCommandList2> internalCommandList;
27 Microsoft::WRL::ComPtr<D3D12MA::Allocator> allocator;
28 UINT g_RTVDescriptorHeapSize = 0;
29
30 Microsoft::WRL::ComPtr<ID3D12Fence> deviceRemovedFence;
31
32 Microsoft::WRL::ComPtr<ID3D12CommandSignature> multidrawSignature, multidrawIndexedSignature, dispatchIndirectSignature;
33
34 std::optional<D3D12DynamicDescriptorHeap<2048>> RTVHeap, DSVHeap;
35 std::optional<D3D12DynamicDescriptorHeap<65536>> CBV_SRV_UAVHeap;
36 std::optional<D3D12DynamicDescriptorHeap<2048>> SamplerHeap;
37
38 DeviceD3D12(decltype(adapter) adapter);
39 virtual ~DeviceD3D12();
40
41 void Flush();
42
43 // IDevice
44 std::string GetBrandString();
45 RGLSwapchainPtr CreateSwapchain(RGLSurfacePtr, RGLCommandQueuePtr, int, int) final;
46 RGLPipelineLayoutPtr CreatePipelineLayout(const PipelineLayoutDescriptor&) final;
47 RGLRenderPipelinePtr CreateRenderPipeline(const RenderPipelineDescriptor&) final;
48 RGLComputePipelinePtr CreateComputePipeline(const ComputePipelineDescriptor&) final;
49
50 RGLShaderLibraryPtr CreateShaderLibraryFromName(const std::string_view& name) final;
51 RGLShaderLibraryPtr CreateDefaultShaderLibrary() final;
52 RGLShaderLibraryPtr CreateShaderLibraryFromBytes(const std::span<const uint8_t>) final;
53 RGLShaderLibraryPtr CreateShaderLibrarySourceCode(const std::string_view, const FromSourceConfig& config) final;
54 RGLShaderLibraryPtr CreateShaderLibraryFromPath(const std::filesystem::path&) final;
55
56 RGLBufferPtr CreateBuffer(const BufferConfig&) final;
57 RGLTexturePtr CreateTextureWithData(const TextureConfig&, const TextureUploadData&) final;
58 RGLTexturePtr CreateTexture(const TextureConfig&) final;
59
60 RGLSamplerPtr CreateSampler(const SamplerConfig&) final;
61
62 DeviceData GetDeviceData() final;
63
64 TextureView GetGlobalBindlessTextureHeap() const final;
65
66 RGLCommandQueuePtr CreateCommandQueue(QueueType type) final;
67 RGLFencePtr CreateFence(bool preSignaled) final;
68 void BlockUntilIdle() final;
69
70 size_t GetTotalVRAM() const final;
71 size_t GetCurrentVRAMInUse() const final;
72 };
73
74 RGLDevicePtr CreateDefaultDeviceD3D12();
75}
Definition Buffer.hpp:21
Definition Pipeline.hpp:269
Definition D3D12Device.hpp:21
Definition ShaderLibrary.hpp:11
Definition Device.hpp:35
Definition Pipeline.hpp:59
Definition Pipeline.hpp:164
Definition Sampler.hpp:33
Definition Texture.hpp:138
Definition Texture.hpp:162
Definition Texture.hpp:43
Definition Device.hpp:17