Diligent Engine  v.2.4.g
DepthStencilState.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019-2021 Diligent Graphics LLC
3  * Copyright 2015-2019 Egor Yusov
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * In no event and under no legal theory, whether in tort (including negligence),
18  * contract, or otherwise, unless required by applicable law (such as deliberate
19  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
20  * liable for any damages, including any direct, indirect, special, incidental,
21  * or consequential damages of any character arising as a result of this License or
22  * out of the use or inability to use the software (including but not limited to damages
23  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
24  * all other commercial damages or losses), even if such Contributor has been advised
25  * of the possibility of such damages.
26  */
27 
28 #pragma once
29 
30 // clang-format off
31 
34 
35 #include "GraphicsTypes.h"
36 
38 
39 
40 
49 {
52 
56 
60 
64 
68 
72 
76 
81 
86 
89 };
90 
92 
99 {
103 
107 
111 
115 
116 
117 #if DILIGENT_CPP_INTERFACE
118  // We have to explicitly define constructors because otherwise Apple's clang fails to compile the following legitimate code:
119  // StencilOpDesc{STENCIL_OP_KEEP, STENCIL_OP_KEEP, STENCIL_OP_KEEP, COMPARISON_FUNC_ALWAYS}
120 
121  StencilOpDesc()noexcept{}
122 
123  StencilOpDesc(STENCIL_OP _StencilFailOp,
124  STENCIL_OP _StencilDepthFailOp,
125  STENCIL_OP _StencilPassOp,
126  COMPARISON_FUNCTION _StencilFunc)noexcept :
127  StencilFailOp {_StencilFailOp },
128  StencilDepthFailOp {_StencilDepthFailOp},
129  StencilPassOp {_StencilPassOp },
130  StencilFunc {_StencilFunc }
131  {}
132 
134 
139  bool operator== (const StencilOpDesc& rhs) const
140  {
141  return StencilFailOp == rhs.StencilFailOp &&
142  StencilDepthFailOp == rhs.StencilDepthFailOp &&
143  StencilPassOp == rhs.StencilPassOp &&
144  StencilFunc == rhs.StencilFunc;
145  }
146 #endif
147 };
149 
151 
158 {
162  Bool DepthEnable DEFAULT_INITIALIZER(True);
163 
165  Bool DepthWriteEnable DEFAULT_INITIALIZER(True);
166 
171 
173  Bool StencilEnable DEFAULT_INITIALIZER(False);
174 
177  Uint8 StencilReadMask DEFAULT_INITIALIZER(0xFF);
178 
181  Uint8 StencilWriteMask DEFAULT_INITIALIZER(0xFF);
182 
185 
188 
189 
190 #if DILIGENT_CPP_INTERFACE
191  // We have to explicitly define constructors because otherwise Apple's clang fails to compile the following legitimate code:
192  // DepthStencilStateDesc{False, False}
193 
195 
197  Bool _DepthWriteEnable,
199  Bool _StencilEnable = DepthStencilStateDesc{}.StencilEnable,
200  Uint8 _StencilReadMask = DepthStencilStateDesc{}.StencilReadMask,
201  Uint8 _StencilWriteMask = DepthStencilStateDesc{}.StencilWriteMask,
202  StencilOpDesc _FrontFace = StencilOpDesc{},
203  StencilOpDesc _BackFace = StencilOpDesc{})noexcept :
204  DepthEnable {_DepthEnable },
205  DepthWriteEnable{_DepthWriteEnable},
206  DepthFunc {_DepthFunc },
207  StencilEnable {_StencilEnable },
208  StencilReadMask {_StencilReadMask },
209  StencilWriteMask{_StencilWriteMask},
210  FrontFace {_FrontFace },
211  BackFace {_BackFace }
212  {}
213 
215 
220  bool operator== (const DepthStencilStateDesc& rhs) const
221  {
222  return DepthEnable == rhs.DepthEnable &&
223  DepthWriteEnable == rhs.DepthWriteEnable &&
224  DepthFunc == rhs.DepthFunc &&
225  StencilEnable == rhs.StencilEnable &&
226  StencilReadMask == rhs.StencilReadMask &&
227  StencilWriteMask == rhs.StencilWriteMask &&
228  FrontFace == rhs.FrontFace &&
229  BackFace == rhs.BackFace;
230  }
231 #endif
232 };
234 
Diligent::STENCIL_OP_KEEP
@ STENCIL_OP_KEEP
Keep the existing stencil data. Direct3D counterpart: D3D11_STENCIL_OP_KEEP/D3D12_STENCIL_OP_KEEP....
Definition: DepthStencilState.h:55
Diligent::DepthStencilStateDesc::DepthStencilStateDesc
DepthStencilStateDesc(Bool _DepthEnable, Bool _DepthWriteEnable, COMPARISON_FUNCTION _DepthFunc=DepthStencilStateDesc{}.DepthFunc, Bool _StencilEnable=DepthStencilStateDesc{}.StencilEnable, Uint8 _StencilReadMask=DepthStencilStateDesc{}.StencilReadMask, Uint8 _StencilWriteMask=DepthStencilStateDesc{}.StencilWriteMask, StencilOpDesc _FrontFace=StencilOpDesc{}, StencilOpDesc _BackFace=StencilOpDesc{}) noexcept
Definition: DepthStencilState.h:196
Diligent::STENCIL_OP_UNDEFINED
@ STENCIL_OP_UNDEFINED
Undefined operation.
Definition: DepthStencilState.h:51
Diligent::StencilOpDesc
struct StencilOpDesc StencilOpDesc
Definition: DepthStencilState.h:148
Diligent::STENCIL_OP_DECR_WRAP
@ STENCIL_OP_DECR_WRAP
Decrement the current stencil value, and wrap the value to the maximum representable unsigned value w...
Definition: DepthStencilState.h:85
Diligent::STENCIL_OP_ZERO
@ STENCIL_OP_ZERO
Set the stencil data to 0. Direct3D counterpart: D3D11_STENCIL_OP_ZERO/D3D12_STENCIL_OP_ZERO....
Definition: DepthStencilState.h:59
Diligent::DepthStencilStateDesc::StencilEnable
Bool StencilEnable
Enable stencil opertaions. Default value: False.
Definition: DepthStencilState.h:173
Diligent::StencilOpDesc::StencilDepthFailOp
STENCIL_OP StencilDepthFailOp
The stencil operation to perform when stencil testing passes and depth testing fails....
Definition: DepthStencilState.h:106
Diligent::STENCIL_OP_REPLACE
@ STENCIL_OP_REPLACE
Set the stencil data to the reference value set by calling IDeviceContext::SetStencilRef()....
Definition: DepthStencilState.h:63
Diligent::operator==
bool operator==(const Plane3D &p1, const Plane3D &p2)
Definition: AdvancedMath.hpp:442
Diligent::DepthStencilStateDesc::StencilWriteMask
Uint8 StencilWriteMask
Identify which bits of the depth-stencil buffer are accessed when writing stencil data....
Definition: DepthStencilState.h:181
Diligent::StencilOpDesc::StencilFunc
COMPARISON_FUNCTION StencilFunc
A function that compares stencil data against existing stencil data. Default value: Diligent::COMPARI...
Definition: DepthStencilState.h:114
Diligent::STENCIL_OP_INCR_WRAP
@ STENCIL_OP_INCR_WRAP
Increment the current stencil value, and wrap the value to zero when incrementing the maximum represe...
Definition: DepthStencilState.h:80
Diligent::COMPARISON_FUNC_LESS
@ COMPARISON_FUNC_LESS
Comparison passes if the source data is less than the destination data. Direct3D counterpart: D3D11_...
Definition: GraphicsTypes.h:942
Diligent::DepthStencilStateDesc::BackFace
StencilOpDesc BackFace
Identify stencil operations for the back-facing triangles, see Diligent::StencilOpDesc.
Definition: DepthStencilState.h:187
Diligent::DepthStencilStateDesc::StencilReadMask
Uint8 StencilReadMask
Identify which bits of the depth-stencil buffer are accessed when reading stencil data....
Definition: DepthStencilState.h:177
Diligent::Int8
int8_t Int8
8-bit signed integer
Definition: BasicTypes.h:48
Diligent::StencilOpDesc
Describes stencil operations that are performed based on the results of depth test.
Definition: DepthStencilState.h:98
Diligent::STENCIL_OP_NUM_OPS
@ STENCIL_OP_NUM_OPS
Helper value that stores the total number of stencil operations in the enumeration.
Definition: DepthStencilState.h:88
DILIGENT_END_NAMESPACE
#define DILIGENT_END_NAMESPACE
Definition: CommonDefinitions.h:86
Diligent::DepthStencilStateDesc::DepthStencilStateDesc
DepthStencilStateDesc() noexcept
Definition: DepthStencilState.h:194
Diligent::StencilOpDesc::StencilOpDesc
StencilOpDesc(STENCIL_OP _StencilFailOp, STENCIL_OP _StencilDepthFailOp, STENCIL_OP _StencilPassOp, COMPARISON_FUNCTION _StencilFunc) noexcept
Definition: DepthStencilState.h:123
Diligent::StencilOpDesc::StencilOpDesc
StencilOpDesc() noexcept
Definition: DepthStencilState.h:121
Diligent::DepthStencilStateDesc::DepthFunc
COMPARISON_FUNCTION DepthFunc
A function that compares depth data against existing depth data. See Diligent::COMPARISON_FUNCTION fo...
Definition: DepthStencilState.h:170
Diligent::StencilOpDesc::StencilFailOp
STENCIL_OP StencilFailOp
The stencil operation to perform when stencil testing fails. Default value: Diligent::STENCIL_OP_KEEP...
Definition: DepthStencilState.h:102
DEFAULT_INITIALIZER
#define DEFAULT_INITIALIZER(x)
Definition: CommonDefinitions.h:93
Diligent::Bool
bool Bool
Boolean.
Definition: BasicTypes.h:59
Diligent::COMPARISON_FUNCTION
COMPARISON_FUNCTION
Comparison function.
Definition: GraphicsTypes.h:931
Diligent::STENCIL_OP_INCR_SAT
@ STENCIL_OP_INCR_SAT
Increment the current stencil value, and clamp to the maximum representable unsigned value....
Definition: DepthStencilState.h:67
Diligent::DepthStencilStateDesc::DepthWriteEnable
Bool DepthWriteEnable
Enable or disable writes to a depth buffer. Default value: True.
Definition: DepthStencilState.h:165
Diligent::DepthStencilStateDesc
struct DepthStencilStateDesc DepthStencilStateDesc
Definition: DepthStencilState.h:233
Diligent::STENCIL_OP_INVERT
@ STENCIL_OP_INVERT
Bitwise invert the current stencil buffer value. Direct3D counterpart: D3D11_STENCIL_OP_INVERT/D3D12...
Definition: DepthStencilState.h:75
Diligent::STENCIL_OP
STENCIL_OP
Stencil operation.
Definition: DepthStencilState.h:48
DILIGENT_TYPED_ENUM
#define DILIGENT_TYPED_ENUM(EnumName, EnumType)
Definition: CommonDefinitions.h:88
Diligent::DepthStencilStateDesc::FrontFace
StencilOpDesc FrontFace
Identify stencil operations for the front-facing triangles, see Diligent::StencilOpDesc.
Definition: DepthStencilState.h:184
Diligent::Uint8
uint8_t Uint8
8-bit unsigned integer
Definition: BasicTypes.h:53
DILIGENT_BEGIN_NAMESPACE
#define DILIGENT_BEGIN_NAMESPACE(Name)
Definition: CommonDefinitions.h:82
GraphicsTypes.h
Diligent::StencilOpDesc::StencilPassOp
STENCIL_OP StencilPassOp
The stencil operation to perform when stencil testing and depth testing both pass....
Definition: DepthStencilState.h:110
Diligent::COMPARISON_FUNC_ALWAYS
@ COMPARISON_FUNC_ALWAYS
Comparison always passes. Direct3D counterpart: D3D11_COMPARISON_ALWAYS/D3D12_COMPARISON_FUNC_ALWAY...
Definition: GraphicsTypes.h:966
Diligent::STENCIL_OP_DECR_SAT
@ STENCIL_OP_DECR_SAT
Decrement the current stencil value, and clamp to 0. Direct3D counterpart: D3D11_STENCIL_OP_DECR_SAT...
Definition: DepthStencilState.h:71
Diligent::DepthStencilStateDesc::DepthEnable
Bool DepthEnable
Enable depth-stencil operations. When it is set to False, depth test always passes,...
Definition: DepthStencilState.h:162
Diligent::DepthStencilStateDesc
Depth stencil state description.
Definition: DepthStencilState.h:157
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37