Diligent Engine  v.2.4.g
RenderPass.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 "DeviceObject.h"
36 
38 
39 // {B818DEC7-174D-447A-A8E4-94D21C57B40A}
40 static const struct INTERFACE_ID IID_RenderPass =
41  { 0xb818dec7, 0x174d, 0x447a, { 0xa8, 0xe4, 0x94, 0xd2, 0x1c, 0x57, 0xb4, 0xa } };
42 
43 
48 {
53 
59 
65 };
66 
67 
72 {
77 
83 };
84 
85 
86 
89 {
92 
94  Uint8 SampleCount DEFAULT_INITIALIZER(1);
95 
99 
103 
108 
113 
116 
119 
120 
121 #if DILIGENT_CPP_INTERFACE
122 
129  {
130  return Format == RHS.Format &&
131  SampleCount == RHS.SampleCount &&
132  LoadOp == RHS.LoadOp &&
133  StoreOp == RHS.StoreOp &&
134  StencilLoadOp == RHS.StencilLoadOp &&
135  StencilStoreOp == RHS.StencilStoreOp &&
136  InitialState == RHS.InitialState &&
137  FinalState == RHS.FinalState;
138  }
139 #endif
140 };
142 
143 #define ATTACHMENT_UNUSED (~0U)
144 
147 {
150  Uint32 AttachmentIndex DEFAULT_INITIALIZER(0);
151 
154 
155 #if DILIGENT_CPP_INTERFACE
157 
158  AttachmentReference(Uint32 _AttachmentIndex,
159  RESOURCE_STATE _State)noexcept :
160  AttachmentIndex{_AttachmentIndex},
161  State {_State}
162  {}
163 
165 
170  bool operator == (const AttachmentReference& RHS) const
171  {
172  return AttachmentIndex == RHS.AttachmentIndex &&
173  State == RHS.State;
174  }
175 
176  bool operator != (const AttachmentReference& RHS) const
177  {
178  return !(*this == RHS);
179  }
180 #endif
181 };
183 
184 
187 {
189  Uint32 InputAttachmentCount DEFAULT_INITIALIZER(0);
190 
192  const AttachmentReference* pInputAttachments DEFAULT_INITIALIZER(nullptr);
193 
195  Uint32 RenderTargetAttachmentCount DEFAULT_INITIALIZER(0);
196 
198 
203  const AttachmentReference* pRenderTargetAttachments DEFAULT_INITIALIZER(nullptr);
204 
206 
212  const AttachmentReference* pResolveAttachments DEFAULT_INITIALIZER(nullptr);
213 
215  const AttachmentReference* pDepthStencilAttachment DEFAULT_INITIALIZER(nullptr);
216 
218  Uint32 PreserveAttachmentCount DEFAULT_INITIALIZER(0);
219 
221  const Uint32* pPreserveAttachments DEFAULT_INITIALIZER(nullptr);
222 
223 #if DILIGENT_CPP_INTERFACE
224 
230  bool operator == (const SubpassDesc& RHS)const
231  {
232  if (InputAttachmentCount != RHS.InputAttachmentCount ||
233  RenderTargetAttachmentCount != RHS.RenderTargetAttachmentCount ||
234  PreserveAttachmentCount != RHS.PreserveAttachmentCount)
235  return false;
236 
237  for(Uint32 i=0; i < InputAttachmentCount; ++i)
238  {
239  if (pInputAttachments[i] != RHS.pInputAttachments[i])
240  return false;
241  }
242 
243  for(Uint32 i=0; i < RenderTargetAttachmentCount; ++i)
244  {
245  if (pRenderTargetAttachments[i] != RHS.pRenderTargetAttachments[i])
246  return false;
247  }
248 
249  if ((pResolveAttachments == nullptr && RHS.pResolveAttachments != nullptr) ||
250  (pResolveAttachments != nullptr && RHS.pResolveAttachments == nullptr))
251  return false;
252 
253  if (pResolveAttachments != nullptr && RHS.pResolveAttachments != nullptr)
254  {
255  for(Uint32 i=0; i < RenderTargetAttachmentCount; ++i)
256  {
257  if (pResolveAttachments[i] != RHS.pResolveAttachments[i])
258  return false;
259  }
260  }
261 
262  if ((pDepthStencilAttachment == nullptr && RHS.pDepthStencilAttachment != nullptr) ||
263  (pDepthStencilAttachment != nullptr && RHS.pDepthStencilAttachment == nullptr))
264  return false;
265 
266  if (pDepthStencilAttachment != nullptr && RHS.pDepthStencilAttachment != nullptr)
267  {
268  if (*pDepthStencilAttachment != *RHS.pDepthStencilAttachment)
269  return false;
270  }
271 
272  if ((pPreserveAttachments == nullptr && RHS.pPreserveAttachments != nullptr) ||
273  (pPreserveAttachments != nullptr && RHS.pPreserveAttachments == nullptr))
274  return false;
275 
276  if (pPreserveAttachments != nullptr && RHS.pPreserveAttachments != nullptr)
277  {
278  for(Uint32 i=0; i < PreserveAttachmentCount; ++i)
279  {
280  if (pPreserveAttachments[i] != RHS.pPreserveAttachments[i])
281  return false;
282  }
283  }
284 
285  return true;
286  }
287 #endif
288 };
289 typedef struct SubpassDesc SubpassDesc;
290 
291 
292 #define SUBPASS_EXTERNAL (~0U)
293 
296 {
299 
302 
305 
308 
311 
314 
315 #if DILIGENT_CPP_INTERFACE
316 
322  bool operator == (const SubpassDependencyDesc& RHS) const
323  {
324  return SrcSubpass == RHS.SrcSubpass &&
325  DstSubpass == RHS.DstSubpass &&
326  SrcStageMask == RHS.SrcStageMask &&
327  DstStageMask == RHS.DstStageMask &&
328  SrcAccessMask == RHS.SrcAccessMask &&
329  DstAccessMask == RHS.DstAccessMask;
330  }
331 
332  bool operator != (const SubpassDependencyDesc& RHS) const
333  {
334  return !(*this == RHS);
335  }
336 #endif
337 };
339 
342 
344  Uint32 AttachmentCount DEFAULT_INITIALIZER(0);
345 
347  const RenderPassAttachmentDesc* pAttachments DEFAULT_INITIALIZER(nullptr);
348 
350  Uint32 SubpassCount DEFAULT_INITIALIZER(0);
351 
353  const SubpassDesc* pSubpasses DEFAULT_INITIALIZER(nullptr);
354 
356  Uint32 DependencyCount DEFAULT_INITIALIZER(0);
357 
359  const SubpassDependencyDesc* pDependencies DEFAULT_INITIALIZER(nullptr);
360 };
362 
363 
364 #if DILIGENT_CPP_INTERFACE
365 
367 
370 {
371 public:
372  virtual const RenderPassDesc& DILIGENT_CALL_TYPE GetDesc() const override = 0;
373 };
374 
375 #else
376 
377 struct IRenderPass;
378 
379 // C requires that a struct or union has at least one member
380 //struct IRenderPassMethods
381 //{
382 //};
383 
384 struct IRenderPassVtbl
385 {
386  struct IObjectMethods Object;
387  struct IDeviceObjectMethods DeviceObject;
388  //struct IRenderPassMethods RenderPass;
389 };
390 
391 typedef struct IRenderPass
392 {
393  struct IRenderPassVtbl* pVtbl;
394 } IRenderPass;
395 
396 #endif
397 
398 DILIGENT_END_NAMESPACE // namespace Diligent
Diligent::SubpassDesc::RenderTargetAttachmentCount
Uint32 RenderTargetAttachmentCount
The number of color render target attachments.
Definition: RenderPass.h:195
Diligent::INTERFACE_ID
struct INTERFACE_ID INTERFACE_ID
Definition: InterfaceID.h:54
Diligent::SubpassDesc::pResolveAttachments
const AttachmentReference * pResolveAttachments
Pointer to the array of resolve attachments, see Diligent::AttachmentReference.
Definition: RenderPass.h:212
Diligent::ATTACHMENT_STORE_OP
ATTACHMENT_STORE_OP
Render pass attachment store operation Vulkan counterpart: VkAttachmentStoreOp. D3D12 counterpart: D3...
Definition: RenderPass.h:71
Diligent::PIPELINE_STAGE_FLAG_UNDEFINED
@ PIPELINE_STAGE_FLAG_UNDEFINED
Undefined stage.
Definition: GraphicsTypes.h:2628
Diligent::RenderPassAttachmentDesc::StencilStoreOp
ATTACHMENT_STORE_OP StencilStoreOp
Store operation how the contents of the stencil component of the attachment is treated at the end of ...
Definition: RenderPass.h:112
Diligent::SubpassDesc::pDepthStencilAttachment
const AttachmentReference * pDepthStencilAttachment
Pointer to the depth-stencil attachment, see Diligent::AttachmentReference.
Definition: RenderPass.h:215
Diligent::RenderPassAttachmentDesc::LoadOp
ATTACHMENT_LOAD_OP LoadOp
Load operation that specifies how the contents of color and depth components of the attachment are tr...
Definition: RenderPass.h:98
Diligent::AttachmentReference
Attachment reference description.
Definition: RenderPass.h:146
Diligent::SubpassDependencyDesc::DstStageMask
PIPELINE_STAGE_FLAGS DstStageMask
A bitmask of PIPELINE_STAGE_FLAGS specifying the destination stage mask.
Definition: RenderPass.h:307
Diligent::SubpassDependencyDesc::SrcStageMask
PIPELINE_STAGE_FLAGS SrcStageMask
A bitmask of PIPELINE_STAGE_FLAGS specifying the source stage mask.
Definition: RenderPass.h:304
Diligent::AttachmentReference::AttachmentReference
AttachmentReference() noexcept
Definition: RenderPass.h:156
Diligent::PIPELINE_STAGE_FLAGS
PIPELINE_STAGE_FLAGS
Pipeline stage flags.
Definition: GraphicsTypes.h:2625
Diligent::operator==
bool operator==(const Plane3D &p1, const Plane3D &p2)
Definition: AdvancedMath.hpp:442
Diligent::ATTACHMENT_LOAD_OP_DISCARD
@ ATTACHMENT_LOAD_OP_DISCARD
The previous contents within the area need not be preserved; the contents of the attachment will be u...
Definition: RenderPass.h:64
Diligent::RenderPassDesc
Render pass description.
Definition: RenderPass.h:341
Diligent::RenderPassAttachmentDesc::Format
TEXTURE_FORMAT Format
The format of the texture view that will be used for the attachment.
Definition: RenderPass.h:91
Diligent::SubpassDependencyDesc
Subpass dependency description.
Definition: RenderPass.h:295
Diligent::IDeviceObject
Base interface for all objects created by the render device Diligent::IRenderDevice.
Definition: DeviceObject.h:52
Diligent::SubpassDependencyDesc::SrcSubpass
Uint32 SrcSubpass
The subpass index of the first subpass in the dependency, or SUBPASS_EXTERNAL.
Definition: RenderPass.h:298
Diligent::TEX_FORMAT_UNKNOWN
@ TEX_FORMAT_UNKNOWN
Unknown format.
Definition: GraphicsTypes.h:331
Diligent::SubpassDesc::pRenderTargetAttachments
const AttachmentReference * pRenderTargetAttachments
Pointer to the array of color render target attachments, see Diligent::AttachmentReference.
Definition: RenderPass.h:203
Diligent::ATTACHMENT_STORE_OP_DISCARD
@ ATTACHMENT_STORE_OP_DISCARD
The contents within the render area are not needed after rendering, and may be discarded; the content...
Definition: RenderPass.h:82
Diligent::DeviceObjectAttribs
Describes common device object attributes.
Definition: GraphicsTypes.h:1196
Diligent::SubpassDependencyDesc::DstSubpass
Uint32 DstSubpass
The subpass index of the second subpass in the dependency, or SUBPASS_EXTERNAL.
Definition: RenderPass.h:301
Diligent::RenderPassAttachmentDesc::FinalState
RESOURCE_STATE FinalState
The state the attachment texture subresource will be transitioned to when a render pass instance ends...
Definition: RenderPass.h:118
Diligent::RenderPassAttachmentDesc::InitialState
RESOURCE_STATE InitialState
The state the attachment texture subresource will be in when a render pass instance begins.
Definition: RenderPass.h:115
Diligent::RenderPassAttachmentDesc::StoreOp
ATTACHMENT_STORE_OP StoreOp
Store operation how the contents of color and depth components of the attachment are treated at the e...
Definition: RenderPass.h:102
DILIGENT_END_NAMESPACE
#define DILIGENT_END_NAMESPACE
Definition: CommonDefinitions.h:86
Diligent::ATTACHMENT_STORE_OP_STORE
@ ATTACHMENT_STORE_OP_STORE
The contents generated during the render pass and within the render area are written to memory....
Definition: RenderPass.h:76
Diligent::ATTACHMENT_LOAD_OP
ATTACHMENT_LOAD_OP
Render pass attachment load operation Vulkan counterpart: VkAttachmentLoadOp. D3D12 counterpart: D3D1...
Definition: RenderPass.h:47
DILIGENT_DERIVE
#define DILIGENT_DERIVE(TypeName)
Definition: CommonDefinitions.h:90
Diligent::SubpassDesc
Render pass subpass decription.
Definition: RenderPass.h:186
DILIGENT_CALL_TYPE
#define DILIGENT_CALL_TYPE
Definition: CommonDefinitions.h:45
Diligent::ATTACHMENT_LOAD_OP_CLEAR
@ ATTACHMENT_LOAD_OP_CLEAR
The contents within the render area will be cleared to a uniform value, which is specified when a ren...
Definition: RenderPass.h:58
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
DEFAULT_INITIALIZER
#define DEFAULT_INITIALIZER(x)
Definition: CommonDefinitions.h:93
Diligent::ACCESS_FLAGS
ACCESS_FLAGS
Access flag.
Definition: GraphicsTypes.h:2721
Diligent::SubpassDesc::InputAttachmentCount
Uint32 InputAttachmentCount
The number of input attachments the subpass uses.
Definition: RenderPass.h:189
Diligent::RESOURCE_STATE_UNKNOWN
@ RESOURCE_STATE_UNKNOWN
The resource state is not known to the engine and is managed by the application.
Definition: GraphicsTypes.h:2817
Diligent::ACCESS_FLAG_NONE
@ ACCESS_FLAG_NONE
No access.
Definition: GraphicsTypes.h:2724
Diligent::RenderPassAttachmentDesc::SampleCount
Uint8 SampleCount
The number of samples in the texture.
Definition: RenderPass.h:94
Diligent::AttachmentReference::State
RESOURCE_STATE State
The state of the attachment during the subpass.
Definition: RenderPass.h:153
DeviceObject.h
Diligent::TEXTURE_FORMAT
TEXTURE_FORMAT
Texture formats.
Definition: GraphicsTypes.h:328
Diligent::SubpassDesc::pPreserveAttachments
const Uint32 * pPreserveAttachments
Pointer to the array of preserve attachments, see Diligent::AttachmentReference.
Definition: RenderPass.h:221
Diligent::ATTACHMENT_LOAD_OP_LOAD
@ ATTACHMENT_LOAD_OP_LOAD
The previous contents of the texture within the render area will be preserved. Vulkan counterpart: VK...
Definition: RenderPass.h:52
Diligent::RenderPassAttachmentDesc
Render pass attachment description.
Definition: RenderPass.h:88
DILIGENT_TYPED_ENUM
#define DILIGENT_TYPED_ENUM(EnumName, EnumType)
Definition: CommonDefinitions.h:88
Diligent::SubpassDependencyDesc::DstAccessMask
ACCESS_FLAGS DstAccessMask
A bitmask of ACCESS_FLAGS specifying a destination access mask.
Definition: RenderPass.h:313
Diligent::RenderPassAttachmentDesc::StencilLoadOp
ATTACHMENT_LOAD_OP StencilLoadOp
Load operation that specifies how the contents of the stencil component of the attachment is treated ...
Definition: RenderPass.h:107
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
Diligent::AttachmentReference::AttachmentIndex
Uint32 AttachmentIndex
Either an integer value identifying an attachment at the corresponding index in RenderPassDesc::pAtta...
Definition: RenderPass.h:150
Diligent::RESOURCE_STATE
RESOURCE_STATE
Resource usage state.
Definition: GraphicsTypes.h:2814
Diligent::AttachmentReference::AttachmentReference
AttachmentReference(Uint32 _AttachmentIndex, RESOURCE_STATE _State) noexcept
Definition: RenderPass.h:158
Diligent::SubpassDesc::pInputAttachments
const AttachmentReference * pInputAttachments
Pointer to the array of input attachments, see Diligent::AttachmentReference.
Definition: RenderPass.h:192
Diligent::operator!=
bool operator!=(const STDAllocator< T, A > &left, const STDAllocator< U, A > &right)
Definition: STDAllocator.hpp:173
Diligent::SubpassDependencyDesc::SrcAccessMask
ACCESS_FLAGS SrcAccessMask
A bitmask of ACCESS_FLAGS specifying a source access mask.
Definition: RenderPass.h:310
Diligent::IRenderPass
Render pass interface.
Definition: RenderPass.h:369
Diligent::SubpassDesc::PreserveAttachmentCount
Uint32 PreserveAttachmentCount
The number of preserve attachments.
Definition: RenderPass.h:218
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37