-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeferredBuffersClass.hpp
83 lines (55 loc) · 2.14 KB
/
DeferredBuffersClass.hpp
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
#ifndef DEFERREDBUFFERSCLASS_HPP
#define DEFERREDBUFFERSCLASS_HPP
// The DeferredBufferClass is just the "Render-To-Texture" Class re-written to handle an array
// of "Render-To-Texture"'s instead of just a single one. The outputs of the Deferred Shader
// will be writing to the texture buffers (render targets) of thiss class.
#include <d3d11.h>
#include <DirectXMath.h>
#include "Globals.hpp" // For ColorIDBuffer Description.
#define BUFFER_COUNT 4
#define GBUFFER_SHADERRESOURCE_COUNT (BUFFER_COUNT+1)
// ColorBuffer
// NormalBuffer
// DepthBuffer
class DeferredBuffersClass {
private:
// Used as rendertargets to which data will be outputted from Deferred Shader
ID3D11Texture2D* RenderTargetTextureArray[BUFFER_COUNT]; // DepthBuffer Texture2D is defined elsewhere
// Used as a lens to work with the RenderTargetTextureArray above.
ID3D11RenderTargetView* RenderTargetViewArray[BUFFER_COUNT];
ID3D11ShaderResourceView* ShaderResourceViewArray[GBUFFER_SHADERRESOURCE_COUNT]; // The final index is for the DepthStencilBuffer.
ID3D11Texture2D* DepthStencilBuffer;
ID3D11DepthStencilView* DepthStencilView;
public:
DeferredBuffersClass();
~DeferredBuffersClass();
void ReleaseAll();
ID3D11ShaderResourceView* *GetGBuffers();
ID3D11Texture2D* GetColorIDTexture();
/* ------------- COMMENTS -------------
Creates RenderTargetTexture's & RenderTargetView's & ShaderResourceView's.
Creates DepthBuffer & DepthStencilView & Viewport.
*/
void InitializeBuffers(
ID3D11Device* *Device,
UINT ScreenWidth,
UINT ScreenHeight
);
/* ------------- COMMENTS -------------
Sets all the internal RenderTargetView's to the OutputMerger stage in the GPU-pipeline.
The order of the RenderTargets in the array is the order of "SV_TargetX".
Also sets the internal DepthStenciLView to the pipeline.
*/
void SetAllRenderTargets(ID3D11DeviceContext* *DeviceContext);
/* ------------- COMMENTS -------------
Clears G-Buffers including the depth buffer.
*/
void ClearAllRenderTargets(
ID3D11DeviceContext* *DeviceContext,
float ClearColor_Red,
float ClearColor_Blue,
float ClearColor_Green,
float ClearColor_Alpha
);
};
#endif