BRE12
GeometryPassCommandListRecorder.h
1 #pragma once
2 
3 #include <d3d12.h>
4 #include <DirectXMath.h>
5 #include <memory>
6 #include <vector>
7 
8 #include <CommandManager\CommandListPerFrame.h>
9 #include <DXUtils/D3DFactory.h>
10 #include <ResourceManager\FrameUploadCBufferPerFrame.h>
11 #include <ResourceManager/VertexAndIndexBufferCreator.h>
12 
13 namespace BRE {
14 struct FrameCBuffer;
15 
16 // To record command lists for deferred shading geometry pass.
17 // Steps:
18 // - Inherit from it and reimplement RecordAndPushCommandLists() method
19 // - Call RecordAndPushCommandLists() to create command lists to execute in the GPU
21 public:
22  struct GeometryData {
23  GeometryData() = default;
24 
27  std::vector<DirectX::XMFLOAT4X4> mWorldMatrices;
28  std::vector<DirectX::XMFLOAT4X4> mInverseTransposeWorldMatrices;
29  };
30  using GeometryDataVector = std::vector<GeometryData>;
31 
34  {}
35 
37  const GeometryPassCommandListRecorder& operator=(const GeometryPassCommandListRecorder&) = delete;
40 
41  // Preconditions:
42  // - "geometryBufferRenderTargetViews" must not be nullptr
43  // - "geometryBufferRenderTargetViewCount" must be greater than zero
44  void Init(const D3D12_CPU_DESCRIPTOR_HANDLE* geometryBufferRenderTargetViews,
45  const std::uint32_t geometryBufferRenderTargetViewCount,
46  const D3D12_CPU_DESCRIPTOR_HANDLE& depthBufferView) noexcept;
47 
48  // Preconditions:
49  // - Init() must be called before
50  virtual void RecordAndPushCommandLists(const FrameCBuffer& frameCBuffer) noexcept = 0;
51 
52  // This method validates all data (nullptr's, etc)
53  // When you inherit from this class, you should reimplement it to include
54  // new members
55  virtual bool IsDataValid() const noexcept;
56 
57 protected:
58  CommandListPerFrame mCommandListPerFrame;
59 
60  // Base command data. Once you inherits from this class, you should add
61  // more class members that represent the extra information you need (like resources, for example)
62 
63  std::vector<GeometryData> mGeometryDataVec;
64 
65  FrameUploadCBufferPerFrame mFrameUploadCBufferPerFrame;
66 
67  UploadBuffer* mObjectUploadCBuffers{ nullptr };
68  D3D12_GPU_DESCRIPTOR_HANDLE mStartObjectCBufferView;
69 
70  D3D12_GPU_DESCRIPTOR_HANDLE mStartMaterialCBufferView;
71  UploadBuffer* mMaterialUploadCBuffers{ nullptr };
72 
73  const D3D12_CPU_DESCRIPTOR_HANDLE* mGeometryBufferRenderTargetViews{ nullptr };
74  std::uint32_t mGeometryBufferRenderTargetViewCount{ 0U };
75 
76  D3D12_CPU_DESCRIPTOR_HANDLE mDepthBufferView{ 0UL };
77 };
78 
79 using GeometryPassCommandListRecorders = std::vector<std::unique_ptr<GeometryPassCommandListRecorder>>;
80 }
81 
Definition: Camera.cpp:8
Definition: VertexAndIndexBufferCreator.h:53
Definition: GeometryPassCommandListRecorder.h:20
Definition: GeometryPassCommandListRecorder.h:22
Definition: FrameUploadCBufferPerFrame.h:11
Definition: CBuffers.h:23
Definition: VertexAndIndexBufferCreator.h:36
Definition: CommandListPerFrame.h:16
Definition: UploadBuffer.h:9