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
|
/*
* Copyright 2019-2021 Diligent Graphics LLC
* Copyright 2015-2019 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* In no event and under no legal theory, whether in tort (including negligence),
* contract, or otherwise, unless required by applicable law (such as deliberate
* and grossly negligent acts) or agreed to in writing, shall any Contributor be
* liable for any damages, including any direct, indirect, special, incidental,
* or consequential damages of any character arising as a result of this License or
* out of the use or inability to use the software (including but not limited to damages
* for loss of goodwill, work stoppage, computer failure or malfunction, or any and
* all other commercial damages or losses), even if such Contributor has been advised
* of the possibility of such damages.
*/
#pragma once
// clang-format off
/// \file
/// Rasterizer state description
#include "GraphicsTypes.h"
DILIGENT_BEGIN_NAMESPACE(Diligent)
/// Fill mode
/// [D3D11_FILL_MODE]: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476131(v=vs.85).aspx
/// [D3D12_FILL_MODE]: https://msdn.microsoft.com/en-us/library/windows/desktop/dn770366(v=vs.85).aspx
/// This enumeration determines the fill mode to use when rendering triangles and mirrors the
/// [D3D11_FILL_MODE][]/[D3D12_FILL_MODE][] enum. It is used by RasterizerStateDesc structure to define the fill mode.
DILIGENT_TYPED_ENUM(FILL_MODE, Int8)
{
/// Undefined fill mode.
FILL_MODE_UNDEFINED = 0,
/// Rasterize triangles using wireframe fill. \n
/// Direct3D counterpart: D3D11_FILL_WIREFRAME/D3D12_FILL_MODE_WIREFRAME. OpenGL counterpart: GL_LINE.
FILL_MODE_WIREFRAME,
/// Rasterize triangles using solid fill. \n
/// Direct3D counterpart: D3D11_FILL_SOLID/D3D12_FILL_MODE_SOLID. OpenGL counterpart: GL_FILL.
FILL_MODE_SOLID,
/// Helper value that stores the total number of fill modes in the enumeration.
FILL_MODE_NUM_MODES
};
/// Cull mode
/// [D3D11_CULL_MODE]: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476108(v=vs.85).aspx
/// [D3D12_CULL_MODE]: https://msdn.microsoft.com/en-us/library/windows/desktop/dn770354(v=vs.85).aspx
/// This enumeration defines which triangles are not drawn during the rasterization and mirrors
/// [D3D11_CULL_MODE][]/[D3D12_CULL_MODE][] enum. It is used by RasterizerStateDesc structure to define the polygon cull mode.
DILIGENT_TYPED_ENUM(CULL_MODE, Int8)
{
/// Undefined cull mode.
CULL_MODE_UNDEFINED = 0,
/// Draw all triangles. \n
/// Direct3D counterpart: D3D11_CULL_NONE/D3D12_CULL_MODE_NONE. OpenGL counterpart: glDisable( GL_CULL_FACE ).
CULL_MODE_NONE,
/// Do not draw triangles that are front-facing. Front- and back-facing triangles are determined
/// by the RasterizerStateDesc::FrontCounterClockwise member. \n
/// Direct3D counterpart: D3D11_CULL_FRONT/D3D12_CULL_MODE_FRONT. OpenGL counterpart: GL_FRONT.
CULL_MODE_FRONT,
/// Do not draw triangles that are back-facing. Front- and back-facing triangles are determined
/// by the RasterizerStateDesc::FrontCounterClockwise member. \n
/// Direct3D counterpart: D3D11_CULL_BACK/D3D12_CULL_MODE_BACK. OpenGL counterpart: GL_BACK.
CULL_MODE_BACK,
/// Helper value that stores the total number of cull modes in the enumeration.
CULL_MODE_NUM_MODES
};
/// Rasterizer state description
/// This structure describes the rasterizer state and is part of the GraphicsPipelineDesc.
struct RasterizerStateDesc
{
/// Determines traingle fill mode, see Diligent::FILL_MODE for details.
/// Default value: Diligent::FILL_MODE_SOLID.
FILL_MODE FillMode DEFAULT_INITIALIZER(FILL_MODE_SOLID);
/// Determines traingle cull mode, see Diligent::CULL_MODE for details.
/// Default value: Diligent::CULL_MODE_BACK.
CULL_MODE CullMode DEFAULT_INITIALIZER(CULL_MODE_BACK);
/// Determines if a triangle is front- or back-facing. If this parameter is True,
/// a triangle will be considered front-facing if its vertices are counter-clockwise
/// on the render target and considered back-facing if they are clockwise.
/// If this parameter is False, the opposite is true.
/// Default value: False.
Bool FrontCounterClockwise DEFAULT_INITIALIZER(False);
/// Enable clipping against near and far clip planes.
/// Default value: True.
Bool DepthClipEnable DEFAULT_INITIALIZER(True);
/// Enable scissor-rectangle culling. All pixels outside an active scissor rectangle are culled.
/// Default value: False.
Bool ScissorEnable DEFAULT_INITIALIZER(False);
/// Specifies whether to enable line antialiasing.
/// Default value: False.
Bool AntialiasedLineEnable DEFAULT_INITIALIZER(False);
/// Constant value added to the depth of a given pixel.
/// Default value: 0.
Int32 DepthBias DEFAULT_INITIALIZER(0);
/// Maximum depth bias of a pixel.
/// \warning Depth bias clamp is not available in OpenGL
/// Default value: 0.
Float32 DepthBiasClamp DEFAULT_INITIALIZER(0.f);
/// Scalar that scales the given pixel's slope before adding to the pixel's depth.
/// Default value: 0.
Float32 SlopeScaledDepthBias DEFAULT_INITIALIZER(0.f);
#if DILIGENT_CPP_INTERFACE
RasterizerStateDesc()noexcept{}
RasterizerStateDesc(FILL_MODE _FillMode,
CULL_MODE _CullMode,
Bool _FrontCounterClockwise = RasterizerStateDesc{}.FrontCounterClockwise,
Bool _DepthClipEnable = RasterizerStateDesc{}.DepthClipEnable,
Bool _ScissorEnable = RasterizerStateDesc{}.ScissorEnable,
Bool _AntialiasedLineEnable = RasterizerStateDesc{}.AntialiasedLineEnable,
Int32 _DepthBias = RasterizerStateDesc{}.DepthBias,
Float32 _DepthBiasClamp = RasterizerStateDesc{}.DepthBiasClamp,
Float32 _SlopeScaledDepthBias = RasterizerStateDesc{}.SlopeScaledDepthBias)noexcept :
FillMode {_FillMode },
CullMode {_CullMode },
FrontCounterClockwise {_FrontCounterClockwise},
DepthClipEnable {_DepthClipEnable },
ScissorEnable {_ScissorEnable },
AntialiasedLineEnable {_AntialiasedLineEnable},
DepthBias {_DepthBias },
DepthBiasClamp {_DepthBiasClamp },
SlopeScaledDepthBias {_SlopeScaledDepthBias }
{
}
/// Tests if two structures are equivalent
/// \param [in] RHS - reference to the structure to perform comparison with
/// \return
/// - True if all members of the two structures are equal.
/// - False otherwise
bool operator == (const RasterizerStateDesc& RHS)const
{
return FillMode == RHS.FillMode &&
CullMode == RHS.CullMode &&
FrontCounterClockwise == RHS.FrontCounterClockwise &&
DepthBias == RHS.DepthBias &&
DepthBiasClamp == RHS.DepthBiasClamp &&
SlopeScaledDepthBias == RHS.SlopeScaledDepthBias &&
DepthClipEnable == RHS.DepthClipEnable &&
ScissorEnable == RHS.ScissorEnable &&
AntialiasedLineEnable == RHS.AntialiasedLineEnable;
}
#endif
};
typedef struct RasterizerStateDesc RasterizerStateDesc;
DILIGENT_END_NAMESPACE
|