This repository has been archived by the owner on Dec 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 226
/
RaytracingAOPC12.h
135 lines (105 loc) · 3.83 KB
/
RaytracingAOPC12.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
//--------------------------------------------------------------------------------------
// D3D12RaytracingAO.h
//
// Advanced Technology Group (ATG)
// Copyright (C) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------
#pragma once
#include "DeviceResources.h"
#include "GeneralHelper.h"
#include "StepTimer.h"
#include "AORaytracingHlslCompat.h"
#include "Menus.h"
#include "Mesh.h"
#include "Lighting.h"
#include "AO.h"
#include "SSAO.h"
namespace GlobalRootSignatureParams {
enum Value
{
OutputViewSlot = 0,
AccelerationStructureSlot,
SceneConstantSlot,
VertexBuffersSlot,
Count
};
}
namespace LocalRootSignatureParams {
enum Value
{
CubeConstantSlot = 0,
Count
};
}
// A basic sample implementation that creates a D3D12 device and
// provides a render loop.
class Sample final : public DX::IDeviceNotify
{
public:
Sample() noexcept(false);
~Sample();
Sample(Sample&&) = default;
Sample& operator= (Sample&&) = default;
Sample(Sample const&) = delete;
Sample& operator= (Sample const&) = delete;
// Initialization and management
void Initialize(HWND window, int width, int height);
// Basic render loop
void Tick();
// IDeviceNotify
virtual void OnDeviceLost() override;
virtual void OnDeviceRestored() override;
// Messages
void OnActivated();
void OnDeactivated();
void OnSuspending();
void OnResuming();
void OnWindowMoved();
void OnWindowSizeChanged(int width, int height);
// Properties
void GetDefaultSize(int& width, int& height) const;
private:
void Update(DX::StepTimer const& timer);
void Render();
void Clear();
void CreateDeviceDependentResources();
void CreateWindowSizeDependentResources();
// Device resources
std::shared_ptr<DX::DeviceResources> m_deviceResources;
// Rendering loop timer
DX::StepTimer m_timer;
// Input devices
std::unique_ptr<DirectX::GamePad> m_gamePad;
std::unique_ptr<DirectX::Keyboard> m_keyboard;
DirectX::GamePad::ButtonStateTracker m_gamePadButtons;
DirectX::Keyboard::KeyboardStateTracker m_keyboardButtons;
void UpdateCameraMatrices();
void InitializeScene();
void CreateConstantBuffers();
void SetupLighting();
// DirectXTK objects
std::unique_ptr<DirectX::GraphicsMemory> m_graphicsMemory;
// Constant Buffers
union AlignedSceneConstantBuffer
{
SceneConstantBuffer constants;
uint8_t alignmentPadding[CalculateConstantBufferByteSize(sizeof(SceneConstantBuffer))];
};
std::vector<AlignedSceneConstantBuffer*> m_mappedSceneConstantData;
std::vector<Microsoft::WRL::ComPtr<ID3D12Resource>> m_mappedSceneConstantResource;
// Unmapped versions of bound data so we are not constantly copying small packets to the GPU
std::vector<SceneConstantBuffer> m_sceneCB;
// Lighting model
std::unique_ptr<Lighting> m_ssao, m_ao;
// Mesh
std::vector<std::string> m_meshFiles;
std::shared_ptr<Mesh> m_mesh;
unsigned int m_meshIndex;
// Menus
std::shared_ptr<Menus> m_menus;
// Split
bool m_isSplit;
bool m_isSplitMode;
// Camera
float m_radius;
};