BRE12
GeometryPass.h
1 #pragma once
2 
3 #include <memory>
4 #include <vector>
5 
6 #include <CommandManager\CommandListPerFrame.h>
7 #include <GeometryPass\GeometryPassCommandListRecorder.h>
8 
9 struct D3D12_CPU_DESCRIPTOR_HANDLE;
10 struct ID3D12Resource;
11 
12 namespace BRE {
13 struct FrameCBuffer;
14 
15 // Pass responsible to execute recorders related with deferred shading geometry pass
16 class GeometryPass {
17 public:
18  // Geometry buffers
19  enum Buffers {
20  NORMAL_SMOOTHNESS = 0U, // 2 encoded normals based on octahedron encoding + 1 smoothness
21  BASECOLOR_METALMASK, // 3 base color + 1 metal mask
22  BUFFERS_COUNT
23  };
24 
25  GeometryPass(GeometryPassCommandListRecorders& geometryPassCommandListRecorders);
26  ~GeometryPass() = default;
27  GeometryPass(const GeometryPass&) = delete;
28  const GeometryPass& operator=(const GeometryPass&) = delete;
29  GeometryPass(GeometryPass&&) = delete;
30  GeometryPass& operator=(GeometryPass&&) = delete;
31 
32  // Preconditions:
33  // - You should fill recorders with GetCommandListRecorders() before
34  void Init(const D3D12_CPU_DESCRIPTOR_HANDLE& depthBufferView) noexcept;
35 
36  __forceinline Microsoft::WRL::ComPtr<ID3D12Resource>* GetGeometryBuffers() noexcept
37  {
38  return mGeometryBuffers;
39  }
40 
41  // Preconditions:
42  // - Init() must be called first
43  void Execute(const FrameCBuffer& frameCBuffer) noexcept;
44 
45 private:
46  // Method used internally for validation purposes
47  bool IsDataValid() const noexcept;
48 
49  void ExecuteBeginTask() noexcept;
50 
51  CommandListPerFrame mCommandListPerFrame;
52 
53  // Geometry buffers data
54  Microsoft::WRL::ComPtr<ID3D12Resource> mGeometryBuffers[BUFFERS_COUNT];
55  D3D12_CPU_DESCRIPTOR_HANDLE mGeometryBufferRenderTargetViews[BUFFERS_COUNT];
56 
57  D3D12_CPU_DESCRIPTOR_HANDLE mDepthBufferView{ 0UL };
58 
59  GeometryPassCommandListRecorders& mGeometryPassCommandListRecorders;
60 };
61 
62 }
63 
Definition: Camera.cpp:8
Definition: GeometryPass.h:16
Definition: CBuffers.h:23
Definition: CommandListPerFrame.h:16