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

Diligent Engine API Reference

BlendState.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
43 enum BLEND_FACTOR : Int8
44 {
46 BLEND_FACTOR_UNDEFINED = 0,
47
50 BLEND_FACTOR_ZERO,
51
54 BLEND_FACTOR_ONE,
55
58 BLEND_FACTOR_SRC_COLOR,
59
62 BLEND_FACTOR_INV_SRC_COLOR,
63
66 BLEND_FACTOR_SRC_ALPHA,
67
70 BLEND_FACTOR_INV_SRC_ALPHA,
71
74 BLEND_FACTOR_DEST_ALPHA,
75
78 BLEND_FACTOR_INV_DEST_ALPHA,
79
82 BLEND_FACTOR_DEST_COLOR,
83
86 BLEND_FACTOR_INV_DEST_COLOR,
87
91 BLEND_FACTOR_SRC_ALPHA_SAT,
92
95 BLEND_FACTOR_BLEND_FACTOR,
96
99 BLEND_FACTOR_INV_BLEND_FACTOR,
100
103 BLEND_FACTOR_SRC1_COLOR,
104
107 BLEND_FACTOR_INV_SRC1_COLOR,
108
111 BLEND_FACTOR_SRC1_ALPHA,
112
115 BLEND_FACTOR_INV_SRC1_ALPHA,
116
118 BLEND_FACTOR_NUM_FACTORS
119 };
120
122
130 enum BLEND_OPERATION : Int8
131 {
133 BLEND_OPERATION_UNDEFINED = 0,
134
137 BLEND_OPERATION_ADD,
138
141 BLEND_OPERATION_SUBTRACT,
142
145 BLEND_OPERATION_REV_SUBTRACT,
146
149 BLEND_OPERATION_MIN,
150
153 BLEND_OPERATION_MAX,
154
156 BLEND_OPERATION_NUM_OPERATIONS
157 };
158
160
163 enum COLOR_MASK : Int32
164 {
166 COLOR_MASK_RED = 1,
167
169 COLOR_MASK_GREEN = 2,
170
172 COLOR_MASK_BLUE = 4,
173
175 COLOR_MASK_ALPHA = 8,
176
178 COLOR_MASK_ALL = ( ( ( COLOR_MASK_RED | COLOR_MASK_GREEN ) | COLOR_MASK_BLUE ) | COLOR_MASK_ALPHA )
179 };
180
181
183
189 enum LOGIC_OPERATION : Int8
190 {
193 LOGIC_OP_CLEAR = 0,
194
197 LOGIC_OP_SET,
198
201 LOGIC_OP_COPY,
202
205 LOGIC_OP_COPY_INVERTED,
206
209 LOGIC_OP_NOOP,
210
213 LOGIC_OP_INVERT,
214
217 LOGIC_OP_AND,
218
221 LOGIC_OP_NAND,
222
225 LOGIC_OP_OR,
226
229 LOGIC_OP_NOR,
230
233 LOGIC_OP_XOR,
234
237 LOGIC_OP_EQUIV,
238
241 LOGIC_OP_AND_REVERSE,
242
245 LOGIC_OP_AND_INVERTED,
246
249 LOGIC_OP_OR_REVERSE,
250
253 LOGIC_OP_OR_INVERTED,
254
256 LOGIC_OP_NUM_OPERATIONS
257 };
258
260
263 struct RenderTargetBlendDesc
264 {
266 Bool BlendEnable;
267
269 Bool LogicOperationEnable;
270
272 BLEND_FACTOR SrcBlend;
273
275 BLEND_FACTOR DestBlend;
276
279 BLEND_OPERATION BlendOp;
280
283 BLEND_FACTOR SrcBlendAlpha;
284
287 BLEND_FACTOR DestBlendAlpha;
288
291 BLEND_OPERATION BlendOpAlpha;
292
294 LOGIC_OPERATION LogicOp;
295
297 Uint32 RenderTargetWriteMask;
298
300
313 RenderTargetBlendDesc() :
314 BlendEnable ( False ),
315 LogicOperationEnable(False),
316 SrcBlend ( BLEND_FACTOR_ONE ),
317 DestBlend ( BLEND_FACTOR_ZERO ),
318 BlendOp ( BLEND_OPERATION_ADD ),
319 SrcBlendAlpha ( BLEND_FACTOR_ONE ),
320 DestBlendAlpha ( BLEND_FACTOR_ZERO ),
321 BlendOpAlpha ( BLEND_OPERATION_ADD ),
322 LogicOp ( LOGIC_OP_NOOP ),
323 RenderTargetWriteMask( COLOR_MASK_ALL )
324 {}
325
326
328
333 bool operator == (const RenderTargetBlendDesc& rhs)const
334 {
335 return BlendEnable == rhs.BlendEnable &&
336 LogicOperationEnable == rhs.LogicOperationEnable &&
337 SrcBlend == rhs.SrcBlend &&
338 DestBlend == rhs.DestBlend &&
339 BlendOp == rhs.BlendOp &&
340 SrcBlendAlpha == rhs.SrcBlendAlpha &&
341 DestBlendAlpha == rhs.DestBlendAlpha &&
342 BlendOpAlpha == rhs.BlendOpAlpha &&
343 LogicOp == rhs.LogicOp &&
344 RenderTargetWriteMask == rhs.RenderTargetWriteMask;
345 }
346 };
347
349
351 struct BlendStateDesc
352 {
355 Bool AlphaToCoverageEnable;
356
359 Bool IndependentBlendEnable;
360
362 static constexpr int MaxRenderTargets = 8;
363
366 RenderTargetBlendDesc RenderTargets[MaxRenderTargets];
367
369
377 BlendStateDesc() :
378 AlphaToCoverageEnable(False),
379 IndependentBlendEnable(False)
380 {
381 }
382
384
393 bool operator == (const BlendStateDesc& RHS)const
394 {
395 bool bRTsEqual = true;
396 for( int i = 0; i < MaxRenderTargets; ++i )
397 if( !(RenderTargets[i] == RHS.RenderTargets[i]) )
398 {
399 bRTsEqual = false;
400 break;
401 }
402
403 return bRTsEqual &&
404 AlphaToCoverageEnable == RHS.AlphaToCoverageEnable &&
405 IndependentBlendEnable== RHS.IndependentBlendEnable;
406 }
407 };
408
409 }
Diligent::LOGIC_OP_OR_REVERSE
Perform a logical OR and reverse operation on the render target. Direct3D12 counterpart: D3D12_LOGIC...
Definition: BlendState.h:249
Diligent::BLEND_OPERATION
BLEND_OPERATION
Blending operation.
Definition: BlendState.h:130
Diligent::BLEND_FACTOR_UNDEFINED
Undefined blend factor.
Definition: BlendState.h:46
Diligent::LOGIC_OP_OR
Perform a logical OR operation on the render target. Direct3D12 counterpart: D3D12_LOGIC_OP_OR.
Definition: BlendState.h:225
Diligent::RenderTargetBlendDesc::BlendOp
BLEND_OPERATION BlendOp
Defines how to combine the source and destination RGB values after applying the SrcBlend and DestBlen...
Definition: BlendState.h:279
Diligent::COLOR_MASK
COLOR_MASK
Color component write flags.
Definition: BlendState.h:163
Diligent::BLEND_OPERATION_NUM_OPERATIONS
Helper value that stores the total number of blend operations in the enumeration. ...
Definition: BlendState.h:156
Diligent::BLEND_FACTOR_ONE
The blend factor is one. Direct3D counterpart: D3D11_BLEND_ONE/D3D12_BLEND_ONE. OpenGL counterpart: ...
Definition: BlendState.h:54
Diligent::BlendStateDesc::BlendStateDesc
BlendStateDesc()
Constructor initializes structure members with default values.
Definition: BlendState.h:377
Diligent::COLOR_MASK_BLUE
Allow data to be stored in the blue component.
Definition: BlendState.h:172
Diligent::LOGIC_OP_EQUIV
Perform a logical equal operation on the render target. Direct3D12 counterpart: D3D12_LOGIC_OP_EQUIV...
Definition: BlendState.h:237
Diligent::BLEND_FACTOR_NUM_FACTORS
Helper value that stores the total number of blend factors in the enumeration.
Definition: BlendState.h:118
Diligent::BLEND_FACTOR_INV_SRC1_ALPHA
The blend factor is 1-A, where A is the second alpha data output from a pixel shader. Direct3D counterpart: D3D11_BLEND_INV_SRC1_ALPHA/D3D12_BLEND_INV_SRC1_ALPHA. OpenGL counterpart: GL_ONE_MINUS_SRC1_ALPHA.
Definition: BlendState.h:115
Diligent::BLEND_OPERATION_UNDEFINED
Undefined blend operation.
Definition: BlendState.h:133
Diligent::BlendStateDesc::AlphaToCoverageEnable
Bool AlphaToCoverageEnable
Specifies whether to use alpha-to-coverage as a multisampling technique when setting a pixel to a ren...
Definition: BlendState.h:355
Diligent
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
Diligent::BLEND_OPERATION_ADD
Add source and destination color components. Direct3D counterpart: D3D11_BLEND_OP_ADD/D3D12_BLEND_OP...
Definition: BlendState.h:137
Diligent::RenderTargetBlendDesc::RenderTargetBlendDesc
RenderTargetBlendDesc()
Constructor initializes structure members with default values.
Definition: BlendState.h:313
Diligent::BLEND_FACTOR_BLEND_FACTOR
The blend factor is the constant blend factor set with IDeviceContext::SetBlendFactors(). Direct3D counterpart: D3D11_BLEND_BLEND_FACTOR/D3D12_BLEND_BLEND_FACTOR. OpenGL counterpart: GL_CONSTANT_COLOR.
Definition: BlendState.h:95
Diligent::LOGIC_OP_AND
Perform a logical AND operation on the render target. Direct3D12 counterpart: D3D12_LOGIC_OP_AND.
Definition: BlendState.h:217
Diligent::BLEND_OPERATION_REV_SUBTRACT
Subtract source color components from destination color components. Direct3D counterpart: D3D11_BLEN...
Definition: BlendState.h:145
Diligent::RenderTargetBlendDesc::LogicOp
LOGIC_OPERATION LogicOp
Defines logical operation for the render target.
Definition: BlendState.h:294
Diligent::LOGIC_OP_COPY
Copy the render target. Direct3D12 counterpart: D3D12_LOGIC_OP_COPY.
Definition: BlendState.h:201
Diligent::COLOR_MASK_ALL
Allow data to be stored in all components.
Definition: BlendState.h:178
Diligent::BLEND_FACTOR_INV_DEST_COLOR
The blend factor is 1-RGB, where RGB is the data from a render target. Direct3D counterpart: D3D11_B...
Definition: BlendState.h:86
Diligent::BLEND_FACTOR_INV_DEST_ALPHA
The blend factor is 1-A, where A is alpha data from a render target. Direct3D counterpart: D3D11_BLE...
Definition: BlendState.h:78
Diligent::LOGIC_OP_NOR
Perform a logical NOR operation on the render target. Direct3D12 counterpart: D3D12_LOGIC_OP_NOR.
Definition: BlendState.h:229
Diligent::RenderTargetBlendDesc::LogicOperationEnable
Bool LogicOperationEnable
Enable or disable a logical operation for this render target.
Definition: BlendState.h:269
Diligent::COLOR_MASK_RED
Allow data to be stored in the red component.
Definition: BlendState.h:166
Diligent::LOGIC_OP_OR_INVERTED
Perform a logical OR and invert operation on the render target. Direct3D12 counterpart: D3D12_LOGIC_...
Definition: BlendState.h:253
Diligent::RenderTargetBlendDesc::DestBlendAlpha
BLEND_FACTOR DestBlendAlpha
Specifies the blend factor to apply to the alpha value in the render target. Blend factors that end i...
Definition: BlendState.h:287
Diligent::LOGIC_OP_AND_INVERTED
Perform a logical AND and invert operation on the render target. Direct3D12 counterpart: D3D12_LOGIC...
Definition: BlendState.h:245
Diligent::BLEND_FACTOR_SRC_ALPHA
The blend factor is alpha (A) data from a pixel shader. Direct3D counterpart: D3D11_BLEND_SRC_ALPHA/...
Definition: BlendState.h:66
Diligent::BlendStateDesc
Blend state description.
Definition: BlendState.h:351
Diligent::BLEND_FACTOR_SRC1_ALPHA
The blend factor is the second alpha (A) data output from a pixel shader. Direct3D counterpart: D3D1...
Definition: BlendState.h:111
Diligent::BlendStateDesc::operator==
bool operator==(const BlendStateDesc &RHS) const
Comparison operator tests if two structures are equivalent.
Definition: BlendState.h:393
Diligent::RenderTargetBlendDesc::SrcBlend
BLEND_FACTOR SrcBlend
Specifies the blend factor to apply to the RGB value output from the pixel shader.
Definition: BlendState.h:272
Diligent::BLEND_OPERATION_SUBTRACT
Subtract destination color components from source color components. Direct3D counterpart: D3D11_BLEN...
Definition: BlendState.h:141
Diligent::BLEND_OPERATION_MIN
Compute the minimum of source and destination color components. Direct3D counterpart: D3D11_BLEND_OP...
Definition: BlendState.h:149
Diligent::RenderTargetBlendDesc::RenderTargetWriteMask
Uint32 RenderTargetWriteMask
Render target write mask.
Definition: BlendState.h:297
Diligent::LOGIC_OP_NOOP
No operation is performed on the render target. Direct3D12 counterpart: D3D12_LOGIC_OP_NOOP.
Definition: BlendState.h:209
Diligent::BlendStateDesc::IndependentBlendEnable
Bool IndependentBlendEnable
Specifies whether to enable independent blending in simultaneous render targets. If set to False...
Definition: BlendState.h:359
Diligent::BLEND_FACTOR_INV_SRC1_COLOR
The blend factor is 1-RGB, where RGB is the second RGB data output from a pixel shader. Direct3D counterpart: D3D11_BLEND_INV_SRC1_COLOR/D3D12_BLEND_INV_SRC1_COLOR. OpenGL counterpart: GL_ONE_MINUS_SRC1_COLOR.
Definition: BlendState.h:107
Diligent::RenderTargetBlendDesc::operator==
bool operator==(const RenderTargetBlendDesc &rhs) const
Comparison operator tests if two structures are equivalent.
Definition: BlendState.h:333
Diligent::BLEND_FACTOR_INV_SRC_COLOR
The blend factor is 1-RGB, where RGB is the data from a pixel shader. Direct3D counterpart: D3D11_BL...
Definition: BlendState.h:62
Diligent::RenderTargetBlendDesc
Describes a blend state for a single render target.
Definition: BlendState.h:263
Diligent::COLOR_MASK_GREEN
Allow data to be stored in the green component.
Definition: BlendState.h:169
Diligent::LOGIC_OP_XOR
Perform a logical XOR operation on the render target. Direct3D12 counterpart: D3D12_LOGIC_OP_XOR.
Definition: BlendState.h:233
Diligent::RenderTargetBlendDesc::BlendOpAlpha
BLEND_OPERATION BlendOpAlpha
Defines how to combine the source and destination alpha values after applying the SrcBlendAlpha and D...
Definition: BlendState.h:291
Diligent::RenderTargetBlendDesc::SrcBlendAlpha
BLEND_FACTOR SrcBlendAlpha
Specifies the blend factor to apply to the alpha value output from the pixel shader. Blend factors that end in _COLOR are not allowed.
Definition: BlendState.h:283
Diligent::BLEND_FACTOR_SRC1_COLOR
The blend factor is the second RGB data output from a pixel shader. Direct3D counterpart: D3D11_BLEN...
Definition: BlendState.h:103
Diligent::BlendStateDesc::MaxRenderTargets
static constexpr int MaxRenderTargets
Constant member defining the maximum number of render targets.
Definition: BlendState.h:362
Diligent::BLEND_OPERATION_MAX
Compute the maximum of source and destination color components. Direct3D counterpart: D3D11_BLEND_OP...
Definition: BlendState.h:153
Diligent::LOGIC_OP_AND_REVERSE
Perform a logical AND and reverse operation on the render target. Direct3D12 counterpart: D3D12_LOGI...
Definition: BlendState.h:241
Diligent::LOGIC_OP_NUM_OPERATIONS
Helper value that stores the total number of logical operations in the enumeration.
Definition: BlendState.h:256
Diligent::RenderTargetBlendDesc::DestBlend
BLEND_FACTOR DestBlend
Specifies the blend factor to apply to the RGB value in the render target.
Definition: BlendState.h:275
Diligent::BLEND_FACTOR_SRC_ALPHA_SAT
The blend factor is (f,f,f,1), where f = min(As, 1-Ad), As is alpha data from a pixel shader...
Definition: BlendState.h:91
Diligent::BLEND_FACTOR_DEST_COLOR
The blend factor is RGB data from a render target. Direct3D counterpart: D3D11_BLEND_DEST_COLOR/D3D1...
Definition: BlendState.h:82
Diligent::BLEND_FACTOR_ZERO
The blend factor is zero. Direct3D counterpart: D3D11_BLEND_ZERO/D3D12_BLEND_ZERO. OpenGL counterpart: GL_ZERO.
Definition: BlendState.h:50
Diligent::COLOR_MASK_ALPHA
Allow data to be stored in the alpha component.
Definition: BlendState.h:175
Diligent::BLEND_FACTOR_DEST_ALPHA
The blend factor is alpha (A) data from a render target. Direct3D counterpart: D3D11_BLEND_DEST_ALPH...
Definition: BlendState.h:74
Diligent::BLEND_FACTOR
BLEND_FACTOR
Blend factors.
Definition: BlendState.h:43
Diligent::BLEND_FACTOR_INV_BLEND_FACTOR
The blend factor is one minus constant blend factor set with IDeviceContext::SetBlendFactors(). Direct3D counterpart: D3D11_BLEND_INV_BLEND_FACTOR/D3D12_BLEND_INV_BLEND_FACTOR. OpenGL counterpart: GL_ONE_MINUS_CONSTANT_COLOR.
Definition: BlendState.h:99
Diligent::BLEND_FACTOR_INV_SRC_ALPHA
The blend factor is 1-A, where A is alpha data from a pixel shader. Direct3D counterpart: D3D11_BLEN...
Definition: BlendState.h:70
Diligent::BlendStateDesc::RenderTargets
RenderTargetBlendDesc RenderTargets[MaxRenderTargets]
An array of RenderTargetBlendDesc structures that describe the blend states for render targets...
Definition: BlendState.h:366
Diligent::LOGIC_OP_NAND
Perform a logical NAND operation on the render target. Direct3D12 counterpart: D3D12_LOGIC_OP_NAND.
Definition: BlendState.h:221
Diligent::LOGIC_OP_CLEAR
Clear the render target. Direct3D12 counterpart: D3D12_LOGIC_OP_CLEAR.
Definition: BlendState.h:193
Diligent::RenderTargetBlendDesc::BlendEnable
Bool BlendEnable
Enable or disable blending for this render target.
Definition: BlendState.h:266
Diligent::BLEND_FACTOR_SRC_COLOR
The blend factor is RGB data from a pixel shader. Direct3D counterpart: D3D11_BLEND_SRC_COLOR/D3D12_...
Definition: BlendState.h:58
Diligent::LOGIC_OPERATION
LOGIC_OPERATION
Logic operation.
Definition: BlendState.h:189
Diligent::LOGIC_OP_SET
Set the render target. Direct3D12 counterpart: D3D12_LOGIC_OP_SET.
Definition: BlendState.h:197
Diligent::LOGIC_OP_INVERT
Invert the render target. Direct3D12 counterpart: D3D12_LOGIC_OP_INVERT.
Definition: BlendState.h:213
Diligent::LOGIC_OP_COPY_INVERTED
Perform an inverted-copy of the render target. Direct3D12 counterpart: D3D12_LOGIC_OP_COPY_INVERTED...
Definition: BlendState.h:205