forked from microsoft/Xbox-ATG-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRaytracingAOPC12.h
159 lines (122 loc) · 4.64 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//--------------------------------------------------------------------------------------
// 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
};
}
#pragma warning (push)
#pragma warning (disable:4324)
// A basic sample implementation that creates a D3D12 device and
// provides a render loop.
class Sample : public DX::IDeviceNotify
{
public:
Sample() noexcept(false);
~Sample();
// 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;
std::unique_ptr<DirectX::Mouse> m_mouse;
DirectX::GamePad::ButtonStateTracker m_gamePadButtons;
DirectX::Keyboard::KeyboardStateTracker m_keyboardButtons;
/////////////////////////////////////////////////////////////////////////////////
// START SAMPLE SPECIFIC
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
const float m_camStep = .1f;
float m_radius = -20.f;
XMVECTOR m_at;
XMVECTOR m_up;
// Assets
const wchar_t* m_assetList[2] = {
L"Media\\Meshes\\Dragon\\Dragon.sdkmesh",
L"Media\\Meshes\\Maze\\Maze1.sdkmesh",
};
#pragma warning (pop)
// END SAMPLE SPECIFIC
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// START RAYTRACING
bool CheckRaytracingSupported(IDXGIAdapter1* adapter);
// END RAYTRACING
/////////////////////////////////////////////////////////////////////////////////
};