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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
|
/*
* 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
/// Definition of the Diligent::IRenderPass interface and related data structures
#include "DeviceObject.h"
DILIGENT_BEGIN_NAMESPACE(Diligent)
// {B818DEC7-174D-447A-A8E4-94D21C57B40A}
static const struct INTERFACE_ID IID_RenderPass =
{ 0xb818dec7, 0x174d, 0x447a, { 0xa8, 0xe4, 0x94, 0xd2, 0x1c, 0x57, 0xb4, 0xa } };
/// Render pass attachment load operation
/// Vulkan counterpart: [VkAttachmentLoadOp](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VkAttachmentLoadOp).
/// D3D12 counterpart: [D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE](https://docs.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_render_pass_beginning_access_type).
DILIGENT_TYPED_ENUM(ATTACHMENT_LOAD_OP, Uint8)
{
/// The previous contents of the texture within the render area will be preserved.
/// Vulkan counterpart: VK_ATTACHMENT_LOAD_OP_LOAD.
/// D3D12 counterpart: D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE.
ATTACHMENT_LOAD_OP_LOAD = 0,
/// The contents within the render area will be cleared to a uniform value, which is
/// specified when a render pass instance is begun.
/// Vulkan counterpart: VK_ATTACHMENT_LOAD_OP_CLEAR.
/// D3D12 counterpart: D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR.
ATTACHMENT_LOAD_OP_CLEAR,
/// The previous contents within the area need not be preserved; the contents of
/// the attachment will be undefined inside the render area.
/// Vulkan counterpart: VK_ATTACHMENT_LOAD_OP_DONT_CARE.
/// D3D12 counterpart: D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_DISCARD.
ATTACHMENT_LOAD_OP_DISCARD
};
/// Render pass attachment store operation
/// Vulkan counterpart: [VkAttachmentStoreOp](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VkAttachmentStoreOp).
/// D3D12 counterpart: [D3D12_RENDER_PASS_ENDING_ACCESS_TYPE](https://docs.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_render_pass_ending_access_type).
DILIGENT_TYPED_ENUM(ATTACHMENT_STORE_OP, Uint8)
{
/// The contents generated during the render pass and within the render area are written to memory.
/// Vulkan counterpart: VK_ATTACHMENT_STORE_OP_STORE.
/// D3D12 counterpart: D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE.
ATTACHMENT_STORE_OP_STORE = 0,
/// The contents within the render area are not needed after rendering, and may be discarded;
/// the contents of the attachment will be undefined inside the render area.
/// Vulkan counterpart: VK_ATTACHMENT_STORE_OP_DONT_CARE.
/// D3D12 counterpart: D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_DISCARD.
ATTACHMENT_STORE_OP_DISCARD
};
/// Render pass attachment description.
struct RenderPassAttachmentDesc
{
/// The format of the texture view that will be used for the attachment.
TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN);
/// The number of samples in the texture.
Uint8 SampleCount DEFAULT_INITIALIZER(1);
/// Load operation that specifies how the contents of color and depth components of
/// the attachment are treated at the beginning of the subpass where it is first used.
ATTACHMENT_LOAD_OP LoadOp DEFAULT_INITIALIZER(ATTACHMENT_LOAD_OP_LOAD);
/// Store operation how the contents of color and depth components of the attachment
/// are treated at the end of the subpass where it is last used.
ATTACHMENT_STORE_OP StoreOp DEFAULT_INITIALIZER(ATTACHMENT_STORE_OP_STORE);
/// Load operation that specifies how the contents of the stencil component of the
/// attachment is treated at the beginning of the subpass where it is first used.
/// This value is ignored when the format does not have stencil component.
ATTACHMENT_LOAD_OP StencilLoadOp DEFAULT_INITIALIZER(ATTACHMENT_LOAD_OP_LOAD);
/// Store operation how the contents of the stencil component of the attachment
/// is treated at the end of the subpass where it is last used.
/// This value is ignored when the format does not have stencil component.
ATTACHMENT_STORE_OP StencilStoreOp DEFAULT_INITIALIZER(ATTACHMENT_STORE_OP_STORE);
/// The state the attachment texture subresource will be in when a render pass instance begins.
RESOURCE_STATE InitialState DEFAULT_INITIALIZER(RESOURCE_STATE_UNKNOWN);
/// The state the attachment texture subresource will be transitioned to when a render pass instance ends.
RESOURCE_STATE FinalState DEFAULT_INITIALIZER(RESOURCE_STATE_UNKNOWN);
#if DILIGENT_CPP_INTERFACE
/// 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 RenderPassAttachmentDesc& RHS)const
{
return Format == RHS.Format &&
SampleCount == RHS.SampleCount &&
LoadOp == RHS.LoadOp &&
StoreOp == RHS.StoreOp &&
StencilLoadOp == RHS.StencilLoadOp &&
StencilStoreOp == RHS.StencilStoreOp &&
InitialState == RHS.InitialState &&
FinalState == RHS.FinalState;
}
#endif
};
typedef struct RenderPassAttachmentDesc RenderPassAttachmentDesc;
#define ATTACHMENT_UNUSED (~0U)
/// Attachment reference description.
struct AttachmentReference
{
/// Either an integer value identifying an attachment at the corresponding index in RenderPassDesc::pAttachments,
/// or ATTACHMENT_UNUSED to signify that this attachment is not used.
Uint32 AttachmentIndex DEFAULT_INITIALIZER(0);
/// The state of the attachment during the subpass.
RESOURCE_STATE State DEFAULT_INITIALIZER(RESOURCE_STATE_UNKNOWN);
#if DILIGENT_CPP_INTERFACE
AttachmentReference()noexcept{}
AttachmentReference(Uint32 _AttachmentIndex,
RESOURCE_STATE _State)noexcept :
AttachmentIndex{_AttachmentIndex},
State {_State}
{}
/// 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 AttachmentReference& RHS) const
{
return AttachmentIndex == RHS.AttachmentIndex &&
State == RHS.State;
}
bool operator != (const AttachmentReference& RHS) const
{
return !(*this == RHS);
}
#endif
};
typedef struct AttachmentReference AttachmentReference;
/// Render pass subpass decription.
struct SubpassDesc
{
/// The number of input attachments the subpass uses.
Uint32 InputAttachmentCount DEFAULT_INITIALIZER(0);
/// Pointer to the array of input attachments, see Diligent::AttachmentReference.
const AttachmentReference* pInputAttachments DEFAULT_INITIALIZER(nullptr);
/// The number of color render target attachments.
Uint32 RenderTargetAttachmentCount DEFAULT_INITIALIZER(0);
/// Pointer to the array of color render target attachments, see Diligent::AttachmentReference.
/// Each element of the pRenderTargetAttachments array corresponds to an output in the pixel shader,
/// i.e. if the shader declares an output variable decorated with a render target index X, then it uses
/// the attachment provided in pRenderTargetAttachments[X]. If the attachment index is ATTACHMENT_UNUSED,
/// writes to this render target are ignored.
const AttachmentReference* pRenderTargetAttachments DEFAULT_INITIALIZER(nullptr);
/// Pointer to the array of resolve attachments, see Diligent::AttachmentReference.
/// If pResolveAttachments is not NULL, each of its elements corresponds to a render target attachment
/// (the element in pRenderTargetAttachments at the same index), and a multisample resolve operation is
/// defined for each attachment. At the end of each subpass, multisample resolve operations read the subpass's
/// color attachments, and resolve the samples for each pixel within the render area to the same pixel location
/// in the corresponding resolve attachments, unless the resolve attachment index is ATTACHMENT_UNUSED.
const AttachmentReference* pResolveAttachments DEFAULT_INITIALIZER(nullptr);
/// Pointer to the depth-stencil attachment, see Diligent::AttachmentReference.
const AttachmentReference* pDepthStencilAttachment DEFAULT_INITIALIZER(nullptr);
/// The number of preserve attachments.
Uint32 PreserveAttachmentCount DEFAULT_INITIALIZER(0);
/// Pointer to the array of preserve attachments, see Diligent::AttachmentReference.
const Uint32* pPreserveAttachments DEFAULT_INITIALIZER(nullptr);
#if DILIGENT_CPP_INTERFACE
/// 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 SubpassDesc& RHS)const
{
if (InputAttachmentCount != RHS.InputAttachmentCount ||
RenderTargetAttachmentCount != RHS.RenderTargetAttachmentCount ||
PreserveAttachmentCount != RHS.PreserveAttachmentCount)
return false;
for(Uint32 i=0; i < InputAttachmentCount; ++i)
{
if (pInputAttachments[i] != RHS.pInputAttachments[i])
return false;
}
for(Uint32 i=0; i < RenderTargetAttachmentCount; ++i)
{
if (pRenderTargetAttachments[i] != RHS.pRenderTargetAttachments[i])
return false;
}
if ((pResolveAttachments == nullptr && RHS.pResolveAttachments != nullptr) ||
(pResolveAttachments != nullptr && RHS.pResolveAttachments == nullptr))
return false;
if (pResolveAttachments != nullptr && RHS.pResolveAttachments != nullptr)
{
for(Uint32 i=0; i < RenderTargetAttachmentCount; ++i)
{
if (pResolveAttachments[i] != RHS.pResolveAttachments[i])
return false;
}
}
if ((pDepthStencilAttachment == nullptr && RHS.pDepthStencilAttachment != nullptr) ||
(pDepthStencilAttachment != nullptr && RHS.pDepthStencilAttachment == nullptr))
return false;
if (pDepthStencilAttachment != nullptr && RHS.pDepthStencilAttachment != nullptr)
{
if (*pDepthStencilAttachment != *RHS.pDepthStencilAttachment)
return false;
}
if ((pPreserveAttachments == nullptr && RHS.pPreserveAttachments != nullptr) ||
(pPreserveAttachments != nullptr && RHS.pPreserveAttachments == nullptr))
return false;
if (pPreserveAttachments != nullptr && RHS.pPreserveAttachments != nullptr)
{
for(Uint32 i=0; i < PreserveAttachmentCount; ++i)
{
if (pPreserveAttachments[i] != RHS.pPreserveAttachments[i])
return false;
}
}
return true;
}
#endif
};
typedef struct SubpassDesc SubpassDesc;
#define SUBPASS_EXTERNAL (~0U)
/// Subpass dependency description
struct SubpassDependencyDesc
{
/// The subpass index of the first subpass in the dependency, or SUBPASS_EXTERNAL.
Uint32 SrcSubpass DEFAULT_INITIALIZER(0);
/// The subpass index of the second subpass in the dependency, or SUBPASS_EXTERNAL.
Uint32 DstSubpass DEFAULT_INITIALIZER(0);
/// A bitmask of PIPELINE_STAGE_FLAGS specifying the source stage mask.
PIPELINE_STAGE_FLAGS SrcStageMask DEFAULT_INITIALIZER(PIPELINE_STAGE_FLAG_UNDEFINED);
/// A bitmask of PIPELINE_STAGE_FLAGS specifying the destination stage mask.
PIPELINE_STAGE_FLAGS DstStageMask DEFAULT_INITIALIZER(PIPELINE_STAGE_FLAG_UNDEFINED);
/// A bitmask of ACCESS_FLAGS specifying a source access mask.
ACCESS_FLAGS SrcAccessMask DEFAULT_INITIALIZER(ACCESS_FLAG_NONE);
/// A bitmask of ACCESS_FLAGS specifying a destination access mask.
ACCESS_FLAGS DstAccessMask DEFAULT_INITIALIZER(ACCESS_FLAG_NONE);
#if DILIGENT_CPP_INTERFACE
/// 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 SubpassDependencyDesc& RHS) const
{
return SrcSubpass == RHS.SrcSubpass &&
DstSubpass == RHS.DstSubpass &&
SrcStageMask == RHS.SrcStageMask &&
DstStageMask == RHS.DstStageMask &&
SrcAccessMask == RHS.SrcAccessMask &&
DstAccessMask == RHS.DstAccessMask;
}
bool operator != (const SubpassDependencyDesc& RHS) const
{
return !(*this == RHS);
}
#endif
};
typedef struct SubpassDependencyDesc SubpassDependencyDesc;
/// Render pass description
struct RenderPassDesc DILIGENT_DERIVE(DeviceObjectAttribs)
/// The number of attachments used by the render pass.
Uint32 AttachmentCount DEFAULT_INITIALIZER(0);
/// Pointer to the array of subpass attachments, see Diligent::RenderPassAttachmentDesc.
const RenderPassAttachmentDesc* pAttachments DEFAULT_INITIALIZER(nullptr);
/// The number of subpasses in the render pass.
Uint32 SubpassCount DEFAULT_INITIALIZER(0);
/// Pointer to the array of subpass descriptions, see Diligent::SubpassDesc.
const SubpassDesc* pSubpasses DEFAULT_INITIALIZER(nullptr);
/// The number of memory dependencies between pairs of subpasses.
Uint32 DependencyCount DEFAULT_INITIALIZER(0);
/// Pointer to the array of subpass dependencies, see Diligent::SubpassDependencyDesc.
const SubpassDependencyDesc* pDependencies DEFAULT_INITIALIZER(nullptr);
};
typedef struct RenderPassDesc RenderPassDesc;
#if DILIGENT_CPP_INTERFACE
/// Render pass interface
/// Render pass has no methods.
class IRenderPass : public IDeviceObject
{
public:
virtual const RenderPassDesc& DILIGENT_CALL_TYPE GetDesc() const override = 0;
};
#else
struct IRenderPass;
// C requires that a struct or union has at least one member
//struct IRenderPassMethods
//{
//};
struct IRenderPassVtbl
{
struct IObjectMethods Object;
struct IDeviceObjectMethods DeviceObject;
//struct IRenderPassMethods RenderPass;
};
typedef struct IRenderPass
{
struct IRenderPassVtbl* pVtbl;
} IRenderPass;
#endif
DILIGENT_END_NAMESPACE // namespace Diligent
|