-
Notifications
You must be signed in to change notification settings - Fork 411
/
PostProcess.h
218 lines (168 loc) · 7.24 KB
/
PostProcess.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
//--------------------------------------------------------------------------------------
// File: PostProcess.h
//
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#pragma once
#ifdef _GAMING_XBOX_SCARLETT
#include <d3d12_xs.h>
#elif (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
#include <d3d12_x.h>
#elif defined(USING_DIRECTX_HEADERS)
#include <directx/d3d12.h>
#include <dxguids/dxguids.h>
#else
#include <d3d12.h>
#endif
#include <cstdint>
#include <memory>
#include <DirectXMath.h>
#include "RenderTargetState.h"
namespace DirectX
{
inline namespace DX12
{
//------------------------------------------------------------------------------
// Abstract interface representing a post-process pass
class IPostProcess
{
public:
virtual ~IPostProcess() = default;
IPostProcess(const IPostProcess&) = delete;
IPostProcess& operator=(const IPostProcess&) = delete;
virtual void __cdecl Process(_In_ ID3D12GraphicsCommandList* commandList) = 0;
protected:
IPostProcess() = default;
IPostProcess(IPostProcess&&) = default;
IPostProcess& operator=(IPostProcess&&) = default;
};
//------------------------------------------------------------------------------
// Basic post-process
class BasicPostProcess : public IPostProcess
{
public:
enum Effect : uint32_t
{
Copy,
Monochrome,
Sepia,
DownScale_2x2,
DownScale_4x4,
GaussianBlur_5x5,
BloomExtract,
BloomBlur,
Effect_Max
};
BasicPostProcess(_In_ ID3D12Device* device, const RenderTargetState& rtState, Effect fx);
BasicPostProcess(BasicPostProcess&&) noexcept;
BasicPostProcess& operator= (BasicPostProcess&&) noexcept;
BasicPostProcess(BasicPostProcess const&) = delete;
BasicPostProcess& operator= (BasicPostProcess const&) = delete;
~BasicPostProcess() override;
// IPostProcess methods.
void __cdecl Process(_In_ ID3D12GraphicsCommandList* commandList) override;
// Properties
void __cdecl SetSourceTexture(D3D12_GPU_DESCRIPTOR_HANDLE srvDescriptor, _In_opt_ ID3D12Resource* resource);
// Sets multiplier for GaussianBlur_5x5
void __cdecl SetGaussianParameter(float multiplier);
// Sets parameters for BloomExtract
void __cdecl SetBloomExtractParameter(float threshold);
// Sets parameters for BloomBlur
void __cdecl SetBloomBlurParameters(bool horizontal, float size, float brightness);
private:
// Private implementation.
class Impl;
std::unique_ptr<Impl> pImpl;
};
//------------------------------------------------------------------------------
// Dual-texure post-process
class DualPostProcess : public IPostProcess
{
public:
enum Effect : uint32_t
{
Merge,
BloomCombine,
Effect_Max
};
DualPostProcess(_In_ ID3D12Device* device, const RenderTargetState& rtState, Effect fx);
DualPostProcess(DualPostProcess&&) noexcept;
DualPostProcess& operator= (DualPostProcess&&) noexcept;
DualPostProcess(DualPostProcess const&) = delete;
DualPostProcess& operator= (DualPostProcess const&) = delete;
~DualPostProcess() override;
// IPostProcess methods.
void __cdecl Process(_In_ ID3D12GraphicsCommandList* commandList) override;
// Properties
void __cdecl SetSourceTexture(D3D12_GPU_DESCRIPTOR_HANDLE srvDescriptor);
void __cdecl SetSourceTexture2(D3D12_GPU_DESCRIPTOR_HANDLE srvDescriptor);
// Sets parameters for Merge
void __cdecl SetMergeParameters(float weight1, float weight2);
// Sets parameters for BloomCombine
void __cdecl SetBloomCombineParameters(float bloom, float base, float bloomSaturation, float baseSaturation);
private:
// Private implementation.
class Impl;
std::unique_ptr<Impl> pImpl;
};
//------------------------------------------------------------------------------
// Tone-map post-process
class ToneMapPostProcess : public IPostProcess
{
public:
// Tone-mapping operator
enum Operator : uint32_t
{
None, // Pass-through
Saturate, // Clamp [0,1]
Reinhard, // x/(1+x)
ACESFilmic,
Operator_Max
};
// Electro-Optical Transfer Function (EOTF)
enum TransferFunction : uint32_t
{
Linear, // Pass-through
SRGB, // sRGB (Rec.709 and approximate sRGB display curve)
ST2084, // HDR10 (Rec.2020 color primaries and ST.2084 display curve)
TransferFunction_Max
};
// Color Rotation Transform for HDR10
enum ColorPrimaryRotation : uint32_t
{
HDTV_to_UHDTV, // Rec.709 to Rec.2020
DCI_P3_D65_to_UHDTV, // DCI-P3-D65 (a.k.a Display P3 or P3D65) to Rec.2020
HDTV_to_DCI_P3_D65, // Rec.709 to DCI-P3-D65 (a.k.a Display P3 or P3D65)
};
ToneMapPostProcess(_In_ ID3D12Device* device, const RenderTargetState& rtState,
Operator op, TransferFunction func
#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
, bool mrt = false
#endif
);
ToneMapPostProcess(ToneMapPostProcess&&) noexcept;
ToneMapPostProcess& operator= (ToneMapPostProcess&&) noexcept;
ToneMapPostProcess(ToneMapPostProcess const&) = delete;
ToneMapPostProcess& operator= (ToneMapPostProcess const&) = delete;
~ToneMapPostProcess() override;
// IPostProcess methods.
void __cdecl Process(_In_ ID3D12GraphicsCommandList* commandList) override;
// Properties
void __cdecl SetHDRSourceTexture(D3D12_GPU_DESCRIPTOR_HANDLE srvDescriptor);
// Sets the Color Rotation Transform for HDR10 signal output
void __cdecl SetColorRotation(ColorPrimaryRotation value);
void __cdecl SetColorRotation(CXMMATRIX value);
// Sets exposure value for LDR tonemap operators
void __cdecl SetExposure(float exposureValue);
// Sets ST.2084 parameter for how bright white should be in nits
void __cdecl SetST2084Parameter(float paperWhiteNits);
private:
// Private implementation.
class Impl;
std::unique_ptr<Impl> pImpl;
};
}
}