Diligent Engine API Reference: D:/GitHub/DiligentEngine/DiligentCore/Graphics/GraphicsEngine/interface/DepthStencilState.h Source File

Diligent Engine API Reference

DepthStencilState.h
1 /* Copyright 2015-2018 Egor Yusov
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
12 *
13 * In no event and under no legal theory, whether in tort (including negligence),
14 * contract, or otherwise, unless required by applicable law (such as deliberate
15 * and grossly negligent acts) or agreed to in writing, shall any Contributor be
16 * liable for any damages, including any direct, indirect, special, incidental,
17 * or consequential damages of any character arising as a result of this License or
18 * out of the use or inability to use the software (including but not limited to damages
19 * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
20 * all other commercial damages or losses), even if such Contributor has been advised
21 * of the possibility of such damages.
22 */
23
24 #pragma once
25
28
29 #include "BasicTypes.h"
30
31 namespace Diligent
32 {
33
35
42 enum STENCIL_OP : Int32
43 {
45 STENCIL_OP_UNDEFINED = 0,
46
49 STENCIL_OP_KEEP = 1,
50
53 STENCIL_OP_ZERO = 2,
54
57 STENCIL_OP_REPLACE = 3,
58
61 STENCIL_OP_INCR_SAT = 4,
62
65 STENCIL_OP_DECR_SAT = 5,
66
69 STENCIL_OP_INVERT = 6,
70
74 STENCIL_OP_INCR_WRAP = 7,
75
79 STENCIL_OP_DECR_WRAP = 8,
80
82 STENCIL_OP_NUM_OPS
83 };
84
86
92 struct StencilOpDesc
93 {
95 STENCIL_OP StencilFailOp;
96
98 STENCIL_OP StencilDepthFailOp;
99
101 STENCIL_OP StencilPassOp;
102
105 COMPARISON_FUNCTION StencilFunc;
106
108
116 StencilOpDesc() :
117 StencilFailOp ( STENCIL_OP_KEEP ),
118 StencilDepthFailOp( STENCIL_OP_KEEP ),
119 StencilPassOp ( STENCIL_OP_KEEP ),
120 StencilFunc ( COMPARISON_FUNC_ALWAYS )
121 {}
122
124
129 bool operator == (const StencilOpDesc& rhs)const
130 {
131 return StencilFailOp == rhs.StencilFailOp &&
132 StencilDepthFailOp == rhs.StencilDepthFailOp &&
133 StencilPassOp == rhs.StencilPassOp &&
134 StencilFunc == rhs.StencilFunc;
135 }
136 };
137
139
145 struct DepthStencilStateDesc
146 {
150 Bool DepthEnable;
151
153 Bool DepthWriteEnable;
154
157 COMPARISON_FUNCTION DepthFunc;
158
160 Bool StencilEnable;
161
163 Uint8 StencilReadMask;
164
166 Uint8 StencilWriteMask;
167
169 StencilOpDesc FrontFace;
170
172 StencilOpDesc BackFace;
173
175
188 DepthStencilStateDesc(Bool _DepthEnable = True,
189 Bool _DepthWriteEnable = True,
190 COMPARISON_FUNCTION _DepthFunc = COMPARISON_FUNC_LESS,
191 Bool _StencilEnable = False,
192 Uint8 _StencilReadMask = 0xFF,
193 Uint8 _StencilWriteMask = 0xFF) :
194 DepthEnable ( _DepthEnable ),
195 DepthWriteEnable( _DepthWriteEnable ),
196 DepthFunc ( _DepthFunc ),
197 StencilEnable ( _StencilEnable ),
198 StencilReadMask ( _StencilReadMask ),
199 StencilWriteMask( _StencilWriteMask )
200 {}
201
203
208 bool operator == (const DepthStencilStateDesc& rhs)const
209 {
210 return DepthEnable == rhs.DepthEnable &&
211 DepthWriteEnable == rhs.DepthWriteEnable &&
212 DepthFunc == rhs.DepthFunc &&
213 StencilEnable == rhs.StencilEnable &&
214 StencilReadMask == rhs.StencilReadMask &&
215 StencilWriteMask == rhs.StencilWriteMask &&
216 FrontFace == rhs.FrontFace &&
217 BackFace == rhs.BackFace;
218 }
219 };
220
221 }
Diligent::StencilOpDesc::StencilPassOp
STENCIL_OP StencilPassOp
The stencil operation to perform when stencil testing and depth testing both pass.
Definition: DepthStencilState.h:101
Diligent::StencilOpDesc::StencilFunc
COMPARISON_FUNCTION StencilFunc
A function that compares stencil data against existing stencil data. See Diligent::COMPARISON_FUNCTIO...
Definition: DepthStencilState.h:105
Diligent::COMPARISON_FUNC_ALWAYS
Comparison always passes. Direct3D counterpart: D3D11_COMPARISON_ALWAYS/D3D12_COMPARISON_FUNC_ALWAY...
Definition: GraphicsTypes.h:882
Diligent::STENCIL_OP
STENCIL_OP
Stencil operation.
Definition: DepthStencilState.h:42
Diligent::DepthStencilStateDesc::StencilWriteMask
Uint8 StencilWriteMask
Identify which bits of the depth-stencil buffer are accessed when writing stencil data...
Definition: DepthStencilState.h:166
Diligent::DepthStencilStateDesc::DepthEnable
Bool DepthEnable
Enable depth-stencil operations. When it is set to False, depth test always passes, depth writes are disabled, and no stencil operations are performed.
Definition: DepthStencilState.h:150
Diligent::STENCIL_OP_KEEP
Keep the existing stencil data. Direct3D counterpart: D3D11_STENCIL_OP_KEEP/D3D12_STENCIL_OP_KEEP. OpenGL counterpart: GL_KEEP.
Definition: DepthStencilState.h:49
Diligent::DepthStencilStateDesc::StencilReadMask
Uint8 StencilReadMask
Identify which bits of the depth-stencil buffer are accessed when reading stencil data...
Definition: DepthStencilState.h:163
Diligent
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
Diligent::STENCIL_OP_REPLACE
Set the stencil data to the reference value set by calling IDeviceContext::SetStencilRef(). Direct3D counterpart: D3D11_STENCIL_OP_REPLACE/D3D12_STENCIL_OP_REPLACE. OpenGL counterpart: GL_REPLACE.
Definition: DepthStencilState.h:57
Diligent::STENCIL_OP_DECR_SAT
Decrement the current stencil value, and clamp to 0. Direct3D counterpart: D3D11_STENCIL_OP_DECR_SAT...
Definition: DepthStencilState.h:65
Diligent::DepthStencilStateDesc::DepthStencilStateDesc
DepthStencilStateDesc(Bool _DepthEnable=True, Bool _DepthWriteEnable=True, COMPARISON_FUNCTION _DepthFunc=COMPARISON_FUNC_LESS, Bool _StencilEnable=False, Uint8 _StencilReadMask=0xFF, Uint8 _StencilWriteMask=0xFF)
Initializes the structure members.
Definition: DepthStencilState.h:188
Diligent::DepthStencilStateDesc::FrontFace
StencilOpDesc FrontFace
Identify stencil operations for the front-facing triangles, see Diligent::StencilOpDesc.
Definition: DepthStencilState.h:169
Diligent::StencilOpDesc::StencilFailOp
STENCIL_OP StencilFailOp
The stencil operation to perform when stencil testing fails.
Definition: DepthStencilState.h:95
Diligent::STENCIL_OP_DECR_WRAP
Decrement the current stencil value, and wrap the value to the maximum representable unsigned value w...
Definition: DepthStencilState.h:79
Diligent::COMPARISON_FUNC_LESS
Comparison passes if the source data is less than the destination data. Direct3D counterpart: D3D11_...
Definition: GraphicsTypes.h:858
Diligent::StencilOpDesc
Describes stencil operations that are performed based on the results of depth test.
Definition: DepthStencilState.h:92
Diligent::STENCIL_OP_ZERO
Set the stencil data to 0. Direct3D counterpart: D3D11_STENCIL_OP_ZERO/D3D12_STENCIL_OP_ZERO. OpenGL counterpart: GL_ZERO.
Definition: DepthStencilState.h:53
Diligent::DepthStencilStateDesc::operator==
bool operator==(const DepthStencilStateDesc &rhs) const
Tests if two structures are equivalent.
Definition: DepthStencilState.h:208
Diligent::StencilOpDesc::StencilDepthFailOp
STENCIL_OP StencilDepthFailOp
The stencil operation to perform when stencil testing passes and depth testing fails.
Definition: DepthStencilState.h:98
Diligent::DepthStencilStateDesc::DepthWriteEnable
Bool DepthWriteEnable
Enable or disable writes to a depth buffer.
Definition: DepthStencilState.h:153
Diligent::DepthStencilStateDesc::BackFace
StencilOpDesc BackFace
Identify stencil operations for the back-facing triangles, see Diligent::StencilOpDesc.
Definition: DepthStencilState.h:172
Diligent::STENCIL_OP_INVERT
Bitwise invert the current stencil buffer value. Direct3D counterpart: D3D11_STENCIL_OP_INVERT/D3D12...
Definition: DepthStencilState.h:69
Diligent::STENCIL_OP_NUM_OPS
Helper value that stores the total number of stencil operations in the enumeration.
Definition: DepthStencilState.h:82
Diligent::DepthStencilStateDesc::StencilEnable
Bool StencilEnable
Enable stencil opertaions.
Definition: DepthStencilState.h:160
Diligent::DepthStencilStateDesc
Depth stencil state description.
Definition: DepthStencilState.h:145
Diligent::STENCIL_OP_INCR_WRAP
Increment the current stencil value, and wrap the value to zero when incrementing the maximum represe...
Definition: DepthStencilState.h:74
Diligent::STENCIL_OP_UNDEFINED
Undefined operation.
Definition: DepthStencilState.h:45
Diligent::StencilOpDesc::operator==
bool operator==(const StencilOpDesc &rhs) const
Tests if two structures are equivalent.
Definition: DepthStencilState.h:129
Diligent::STENCIL_OP_INCR_SAT
Increment the current stencil value, and clamp to the maximum representable unsigned value...
Definition: DepthStencilState.h:61
Diligent::COMPARISON_FUNCTION
COMPARISON_FUNCTION
Comparison function.
Definition: GraphicsTypes.h:847
Diligent::DepthStencilStateDesc::DepthFunc
COMPARISON_FUNCTION DepthFunc
A function that compares depth data against existing depth data. See Diligent::COMPARISON_FUNCTION fo...
Definition: DepthStencilState.h:157
Diligent::StencilOpDesc::StencilOpDesc
StencilOpDesc()
Initializes the structure members with default values.
Definition: DepthStencilState.h:116