Skip to content

Commit 91fd6a1

Browse files
Updated Render Pass documentation
RenderPassBase: don't use auto where unnecessary
1 parent b5e47fe commit 91fd6a1

File tree

3 files changed

+64
-47
lines changed

3 files changed

+64
-47
lines changed

Graphics/GraphicsEngine/include/RenderPassBase.hpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 Diligent Graphics LLC
2+
* Copyright 2019-2025 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -93,7 +93,7 @@ class RenderPassBase : public DeviceObjectBase<typename EngineImplTraits::Render
9393
ValidateRenderPassDesc(this->m_Desc, pDevice->GetDeviceInfo(), pDevice->GetAdapterInfo());
9494
}
9595

96-
auto& RawAllocator = GetRawAllocator();
96+
IMemoryAllocator& RawAllocator = GetRawAllocator();
9797
FixedLinearAllocator MemPool{RawAllocator};
9898
ReserveSpace(this->m_Desc, MemPool);
9999

@@ -160,7 +160,7 @@ class RenderPassBase : public DeviceObjectBase<typename EngineImplTraits::Render
160160

161161
for (Uint32 subpass = 0; subpass < Desc.SubpassCount; ++subpass)
162162
{
163-
const auto& SrcSubpass = Desc.pSubpasses[subpass];
163+
const SubpassDesc& SrcSubpass = Desc.pSubpasses[subpass];
164164

165165
MemPool.AddSpace<AttachmentReference>(SrcSubpass.InputAttachmentCount); // Subpass.pInputAttachments
166166
MemPool.AddSpace<AttachmentReference>(SrcSubpass.RenderTargetAttachmentCount); // Subpass.pRenderTargetAttachments
@@ -188,9 +188,9 @@ class RenderPassBase : public DeviceObjectBase<typename EngineImplTraits::Render
188188

189189
if (Desc.AttachmentCount != 0)
190190
{
191-
const auto* SrcAttachments = Desc.pAttachments;
192-
auto* DstAttachments = MemPool.Allocate<RenderPassAttachmentDesc>(Desc.AttachmentCount);
193-
Desc.pAttachments = DstAttachments;
191+
const RenderPassAttachmentDesc* SrcAttachments = Desc.pAttachments;
192+
RenderPassAttachmentDesc* DstAttachments = MemPool.Allocate<RenderPassAttachmentDesc>(Desc.AttachmentCount);
193+
Desc.pAttachments = DstAttachments;
194194
for (Uint32 i = 0; i < Desc.AttachmentCount; ++i)
195195
{
196196
DstAttachments[i] = SrcAttachments[i];
@@ -199,9 +199,9 @@ class RenderPassBase : public DeviceObjectBase<typename EngineImplTraits::Render
199199
}
200200

201201
VERIFY(Desc.SubpassCount != 0, "Render pass must have at least one subpass");
202-
const auto* SrcSubpasses = Desc.pSubpasses;
203-
auto* DstSubpasses = MemPool.Allocate<SubpassDesc>(Desc.SubpassCount);
204-
Desc.pSubpasses = DstSubpasses;
202+
const SubpassDesc* SrcSubpasses = Desc.pSubpasses;
203+
SubpassDesc* DstSubpasses = MemPool.Allocate<SubpassDesc>(Desc.SubpassCount);
204+
Desc.pSubpasses = DstSubpasses;
205205

206206
const auto SetAttachmentState = [AttachmentStates, &Desc](Uint32 Subpass, Uint32 Attachment, RESOURCE_STATE State) //
207207
{
@@ -218,8 +218,8 @@ class RenderPassBase : public DeviceObjectBase<typename EngineImplTraits::Render
218218
SetAttachmentState(subpass, att, subpass > 0 ? GetAttachmentState(subpass - 1, att) : Desc.pAttachments[att].InitialState);
219219
}
220220

221-
const auto& SrcSubpass = SrcSubpasses[subpass];
222-
auto& DstSubpass = DstSubpasses[subpass];
221+
const SubpassDesc& SrcSubpass = SrcSubpasses[subpass];
222+
SubpassDesc& DstSubpass = DstSubpasses[subpass];
223223

224224
auto UpdateAttachmentStateAndFirstUseSubpass = [&SetAttachmentState, AttachmentFirstLastUse, subpass](const AttachmentReference& AttRef) //
225225
{
@@ -236,8 +236,8 @@ class RenderPassBase : public DeviceObjectBase<typename EngineImplTraits::Render
236236
DstSubpass = SrcSubpass;
237237
if (SrcSubpass.InputAttachmentCount != 0)
238238
{
239-
auto* DstInputAttachments = MemPool.Allocate<AttachmentReference>(SrcSubpass.InputAttachmentCount);
240-
DstSubpass.pInputAttachments = DstInputAttachments;
239+
AttachmentReference* DstInputAttachments = MemPool.Allocate<AttachmentReference>(SrcSubpass.InputAttachmentCount);
240+
DstSubpass.pInputAttachments = DstInputAttachments;
241241
for (Uint32 i = 0; i < SrcSubpass.InputAttachmentCount; ++i)
242242
{
243243
DstInputAttachments[i] = SrcSubpass.pInputAttachments[i];
@@ -249,8 +249,8 @@ class RenderPassBase : public DeviceObjectBase<typename EngineImplTraits::Render
249249

250250
if (SrcSubpass.RenderTargetAttachmentCount != 0)
251251
{
252-
auto* DstRenderTargetAttachments = MemPool.Allocate<AttachmentReference>(SrcSubpass.RenderTargetAttachmentCount);
253-
DstSubpass.pRenderTargetAttachments = DstRenderTargetAttachments;
252+
AttachmentReference* DstRenderTargetAttachments = MemPool.Allocate<AttachmentReference>(SrcSubpass.RenderTargetAttachmentCount);
253+
DstSubpass.pRenderTargetAttachments = DstRenderTargetAttachments;
254254
for (Uint32 i = 0; i < SrcSubpass.RenderTargetAttachmentCount; ++i)
255255
{
256256
DstRenderTargetAttachments[i] = SrcSubpass.pRenderTargetAttachments[i];
@@ -259,8 +259,8 @@ class RenderPassBase : public DeviceObjectBase<typename EngineImplTraits::Render
259259

260260
if (DstSubpass.pResolveAttachments != nullptr)
261261
{
262-
auto* DstResolveAttachments = MemPool.Allocate<AttachmentReference>(SrcSubpass.RenderTargetAttachmentCount);
263-
DstSubpass.pResolveAttachments = DstResolveAttachments;
262+
AttachmentReference* DstResolveAttachments = MemPool.Allocate<AttachmentReference>(SrcSubpass.RenderTargetAttachmentCount);
263+
DstSubpass.pResolveAttachments = DstResolveAttachments;
264264
for (Uint32 i = 0; i < SrcSubpass.RenderTargetAttachmentCount; ++i)
265265
{
266266
DstResolveAttachments[i] = SrcSubpass.pResolveAttachments[i];

Graphics/GraphicsEngine/interface/RenderPass.h

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2023 Diligent Graphics LLC
2+
* Copyright 2019-2025 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -63,6 +63,7 @@ DILIGENT_TYPED_ENUM(ATTACHMENT_LOAD_OP, Uint8)
6363
/// D3D12 counterpart: D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_DISCARD.
6464
ATTACHMENT_LOAD_OP_DISCARD,
6565

66+
/// Special value indicating the number of load operations in the enumeration.
6667
ATTACHMENT_LOAD_OP_COUNT
6768
};
6869

@@ -83,6 +84,7 @@ DILIGENT_TYPED_ENUM(ATTACHMENT_STORE_OP, Uint8)
8384
/// D3D12 counterpart: D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_DISCARD.
8485
ATTACHMENT_STORE_OP_DISCARD,
8586

87+
/// Special value indicating the number of store operations in the enumeration.
8688
ATTACHMENT_STORE_OP_COUNT
8789
};
8890

@@ -97,20 +99,28 @@ struct RenderPassAttachmentDesc
9799
/// The number of samples in the texture.
98100
Uint8 SampleCount DEFAULT_INITIALIZER(1);
99101

100-
/// Load operation that specifies how the contents of color and depth components of
102+
/// Load operation.
103+
104+
/// Specifies how the contents of color and depth components of
101105
/// the attachment are treated at the beginning of the subpass where it is first used.
102106
ATTACHMENT_LOAD_OP LoadOp DEFAULT_INITIALIZER(ATTACHMENT_LOAD_OP_LOAD);
103107

104-
/// Store operation how the contents of color and depth components of the attachment
108+
/// Store operation.
109+
110+
/// Defines how the contents of color and depth components of the attachment
105111
/// are treated at the end of the subpass where it is last used.
106112
ATTACHMENT_STORE_OP StoreOp DEFAULT_INITIALIZER(ATTACHMENT_STORE_OP_STORE);
107113

108-
/// Load operation that specifies how the contents of the stencil component of the
114+
/// Stencil load operation.
115+
116+
/// Specifies how the contents of the stencil component of the
109117
/// attachment is treated at the beginning of the subpass where it is first used.
110118
/// This value is ignored when the format does not have stencil component.
111119
ATTACHMENT_LOAD_OP StencilLoadOp DEFAULT_INITIALIZER(ATTACHMENT_LOAD_OP_LOAD);
112120

113-
/// Store operation how the contents of the stencil component of the attachment
121+
/// Stencil store operation.
122+
123+
/// Defines how the contents of the stencil component of the attachment
114124
/// is treated at the end of the subpass where it is last used.
115125
/// This value is ignored when the format does not have stencil component.
116126
ATTACHMENT_STORE_OP StencilStoreOp DEFAULT_INITIALIZER(ATTACHMENT_STORE_OP_STORE);
@@ -152,11 +162,14 @@ typedef struct RenderPassAttachmentDesc RenderPassAttachmentDesc;
152162
/// Special constant indicating that the render pass attachment is not used.
153163
#define DILIGENT_ATTACHMENT_UNUSED 0xFFFFFFFFU
154164

165+
/// Special constant indicating that the render pass attachment is not used.
155166
static DILIGENT_CONSTEXPR Uint32 ATTACHMENT_UNUSED = DILIGENT_ATTACHMENT_UNUSED;
156167

157168
/// Attachment reference description.
158169
struct AttachmentReference
159170
{
171+
/// Attachment index in the render pass attachment array.
172+
160173
/// Either an integer value identifying an attachment at the corresponding index in RenderPassDesc::pAttachments,
161174
/// or ATTACHMENT_UNUSED to signify that this attachment is not used.
162175
Uint32 AttachmentIndex DEFAULT_INITIALIZER(0);
@@ -201,6 +214,8 @@ struct ShadingRateAttachment
201214
/// Shading rate attachment reference, see Diligent::AttachmentReference.
202215
AttachmentReference Attachment DEFAULT_INITIALIZER({});
203216

217+
/// The size of the shading rate tile in pixels.
218+
204219
/// Each texel in the attachment contains shading rate for the whole tile.
205220
/// The size must be a power-of-two value between ShadingRateProperties::MinTileSize and ShadingRateProperties::MaxTileSize.
206221
/// Keep zero to use the default tile size.
@@ -247,15 +262,15 @@ struct SubpassDesc
247262

248263
/// Pointer to the array of color render target attachments, see Diligent::AttachmentReference.
249264

250-
/// Each element of the pRenderTargetAttachments array corresponds to an output in the pixel shader,
265+
/// Each element of the `pRenderTargetAttachments` array corresponds to an output in the pixel shader,
251266
/// i.e. if the shader declares an output variable decorated with a render target index X, then it uses
252-
/// the attachment provided in pRenderTargetAttachments[X]. If the attachment index is ATTACHMENT_UNUSED,
267+
/// the attachment provided in `pRenderTargetAttachments[X]`. If the attachment index is ATTACHMENT_UNUSED,
253268
/// writes to this render target are ignored.
254269
const AttachmentReference* pRenderTargetAttachments DEFAULT_INITIALIZER(nullptr);
255270

256271
/// Pointer to the array of resolve attachments, see Diligent::AttachmentReference.
257272

258-
/// If pResolveAttachments is not NULL, each of its elements corresponds to a render target attachment
273+
/// If `pResolveAttachments` is not `NULL`, each of its elements corresponds to a render target attachment
259274
/// (the element in pRenderTargetAttachments at the same index), and a multisample resolve operation is
260275
/// defined for each attachment. At the end of each subpass, multisample resolve operations read the subpass's
261276
/// color attachments, and resolve the samples for each pixel within the render area to the same pixel location
@@ -358,6 +373,7 @@ typedef struct SubpassDesc SubpassDesc;
358373
/// Special subpass index value expanding synchronization scope outside a subpass.
359374
#define DILIGENT_SUBPASS_EXTERNAL 0xFFFFFFFFU
360375

376+
/// Special subpass index value expanding synchronization scope outside a subpass.
361377
static DILIGENT_CONSTEXPR Uint32 SUBPASS_EXTERNAL = DILIGENT_SUBPASS_EXTERNAL;
362378

363379
/// Subpass dependency description
@@ -488,6 +504,7 @@ typedef struct RenderPassDesc RenderPassDesc;
488504
class IRenderPass : public IDeviceObject
489505
{
490506
public:
507+
/// Returns the render pass description.
491508
virtual const RenderPassDesc& DILIGENT_CALL_TYPE GetDesc() const override = 0;
492509
};
493510

0 commit comments

Comments
 (0)