Skip to content

Commit b7503ea

Browse files
Updated swap chain, texture, texture view and TLAS documentation
1 parent 26c4b79 commit b7503ea

File tree

5 files changed

+115
-80
lines changed

5 files changed

+115
-80
lines changed

Graphics/GraphicsEngine/interface/Buffer.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,12 @@ DILIGENT_BEGIN_INTERFACE(IBuffer, IDeviceObject)
278278

279279
/// Returns native buffer handle specific to the underlying graphics API
280280

281-
/// \return pointer to ID3D11Resource interface, for D3D11 implementation\n
282-
/// pointer to ID3D12Resource interface, for D3D12 implementation\n
283-
/// GL buffer handle, for GL implementation
281+
/// \return A pointer to `ID3D11Resource` interface, for D3D11 implementation\n
282+
/// A pointer to `ID3D12Resource` interface, for D3D12 implementation\n
283+
/// `VkBuffer` handle, for Vulkan implementation\n
284+
/// GL buffer name, for OpenGL implementation\n
285+
/// `MtlBuffer`, for Metal implementation\n
286+
/// `WGPUBuffer`, for WGPU implementation\n
284287
VIRTUAL Uint64 METHOD(GetNativeHandle)(THIS) PURE;
285288

286289
/// Sets the buffer usage state.

Graphics/GraphicsEngine/interface/SwapChain.h

Lines changed: 13 additions & 13 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");
@@ -71,13 +71,13 @@ DILIGENT_BEGIN_INTERFACE(ISwapChain, IObject)
7171
/// \note When resizing non-primary swap chains, the engine unbinds the
7272
/// swap chain buffers from the output.
7373
///
74-
/// New width and height should not account for surface pre-transform. For example,
75-
/// if the window size is 1920 x 1080, but the surface is pre-rotated by 90 degrees,
76-
/// NewWidth should still be 1920, and NewHeight should still be 1080. It is highly
77-
/// recommended to always use SURFACE_TRANSFORM_OPTIMAL to let the engine select
78-
/// the most optimal pre-transform. However SURFACE_TRANSFORM_ROTATE_90 will also work in
79-
/// the scenario above. After the swap chain has been resized, its actual width will be 1080,
80-
/// actual height will be 1920, and PreTransform will be SURFACE_TRANSFORM_ROTATE_90.
74+
/// New width and height should not account for surface pre-transform. For example,
75+
/// if the window size is 1920 x 1080, but the surface is pre-rotated by 90 degrees,
76+
/// NewWidth should still be 1920, and NewHeight should still be 1080. It is highly
77+
/// recommended to always use Diligent::SURFACE_TRANSFORM_OPTIMAL to let the engine select
78+
/// the most optimal pre-transform. However Diligent::SURFACE_TRANSFORM_ROTATE_90 will also work in
79+
/// the scenario above. After the swap chain has been resized, its actual width will be 1080,
80+
/// actual height will be 1920, and `PreTransform` will be Diligent::SURFACE_TRANSFORM_ROTATE_90.
8181
VIRTUAL void METHOD(Resize)(THIS_
8282
Uint32 NewWidth,
8383
Uint32 NewHeight,
@@ -101,20 +101,20 @@ DILIGENT_BEGIN_INTERFACE(ISwapChain, IObject)
101101

102102
/// Returns render target view of the current back buffer in the swap chain
103103

104-
/// \note For Direct3D12 and Vulkan backends, the function returns
104+
/// For Direct3D12 and Vulkan backends, the function returns
105105
/// different pointer for every offscreen buffer in the swap chain
106106
/// (flipped by every call to ISwapChain::Present()). For Direct3D11
107107
/// backend it always returns the same pointer. For OpenGL/GLES backends
108108
/// the method returns null.
109109
///
110-
/// The method does *NOT* increment the reference counter of the returned object,
111-
/// so Release() must not be called.
110+
/// The method does **NOT** increment the reference counter of the returned object,
111+
/// so Release() **must not** be called.
112112
VIRTUAL ITextureView* METHOD(GetCurrentBackBufferRTV)(THIS) PURE;
113113

114114
/// Returns depth-stencil view of the depth buffer
115115

116-
/// The method does *NOT* increment the reference counter of the returned object,
117-
/// so Release() must not be called.
116+
/// The method does **NOT** increment the reference counter of the returned object,
117+
/// so Release() **must not** be called.
118118
VIRTUAL ITextureView* METHOD(GetDepthBufferDSV)(THIS) PURE;
119119
};
120120
DILIGENT_END_INTERFACE

Graphics/GraphicsEngine/interface/Texture.h

Lines changed: 68 additions & 42 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");
@@ -49,6 +49,7 @@ static DILIGENT_CONSTEXPR INTERFACE_ID IID_Texture =
4949
/// The enumeration is used by TextureDesc to describe misc texture flags
5050
DILIGENT_TYPED_ENUM(MISC_TEXTURE_FLAGS, Uint8)
5151
{
52+
/// No special flags are set
5253
MISC_TEXTURE_FLAG_NONE = 0u,
5354

5455
/// Allow automatic mipmap generation with IDeviceContext::GenerateMips()
@@ -58,9 +59,9 @@ DILIGENT_TYPED_ENUM(MISC_TEXTURE_FLAGS, Uint8)
5859

5960
/// The texture will be used as a transient framebuffer attachment.
6061

61-
/// \note Memoryless textures may only be used within a render pass in a framebuffer;
62-
/// the corresponding subpass load operation must be CLEAR or DISCARD, and the
63-
/// subpass store operation must be DISCARD.
62+
/// Memoryless textures may only be used within a render pass in a framebuffer;
63+
/// the corresponding subpass load operation must be CLEAR or DISCARD, and the
64+
/// subpass store operation must be DISCARD.
6465
MISC_TEXTURE_FLAG_MEMORYLESS = 1u << 1,
6566

6667
/// For sparse textures, allow binding the same memory range in different texture
@@ -101,25 +102,30 @@ struct TextureDesc DILIGENT_DERIVE(DeviceObjectAttribs)
101102
};
102103
#endif
103104
/// Texture format, see Diligent::TEXTURE_FORMAT.
105+
104106
/// Use IRenderDevice::GetTextureFormatInfo() to check if format is supported.
105107
TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN);
106108

107109
/// Number of Mip levels in the texture. Multisampled textures can only have 1 Mip level.
110+
108111
/// Specify 0 to create full mipmap chain.
109112
Uint32 MipLevels DEFAULT_INITIALIZER(1);
110113

111-
/// Number of samples.\n
114+
/// The number of samples.
115+
112116
/// Only 2D textures or 2D texture arrays can be multisampled.
113117
Uint32 SampleCount DEFAULT_INITIALIZER(1);
114118

115-
/// Bind flags, see Diligent::BIND_FLAGS for details. \n
119+
/// Bind flags, see Diligent::BIND_FLAGS for details.
120+
116121
/// Use IRenderDevice::GetTextureFormatInfoExt() to check which bind flags are supported.
117122
BIND_FLAGS BindFlags DEFAULT_INITIALIZER(BIND_NONE);
118123

119124
/// Texture usage. See Diligent::USAGE for details.
120125
USAGE Usage DEFAULT_INITIALIZER(USAGE_DEFAULT);
121126

122127
/// CPU access flags or 0 if no CPU access is allowed,
128+
123129
/// see Diligent::CPU_ACCESS_FLAGS for details.
124130
CPU_ACCESS_FLAGS CPUAccessFlags DEFAULT_INITIALIZER(CPU_ACCESS_NONE);
125131

@@ -131,7 +137,7 @@ struct TextureDesc DILIGENT_DERIVE(DeviceObjectAttribs)
131137

132138
/// Defines which immediate contexts are allowed to execute commands that use this texture.
133139

134-
/// When ImmediateContextMask contains a bit at position n, the texture may be
140+
/// When `ImmediateContextMask` contains a bit at position n, the texture may be
135141
/// used in the immediate context with index n directly (see DeviceContextDesc::ContextId).
136142
/// It may also be used in a command list recorded by a deferred context that will be executed
137143
/// through that immediate context.
@@ -265,11 +271,13 @@ typedef struct TextureDesc TextureDesc;
265271
struct TextureSubResData
266272
{
267273
/// Pointer to the subresource data in CPU memory.
268-
/// If provided, pSrcBuffer must be null
274+
275+
/// If provided, `pSrcBuffer` must be null
269276
const void* pData DEFAULT_INITIALIZER(nullptr);
270277

271278
/// Pointer to the GPU buffer that contains subresource data.
272-
/// If provided, pData must be null
279+
280+
/// If provided, `pData` must be null
273281
struct IBuffer* pSrcBuffer DEFAULT_INITIALIZER(nullptr);
274282

275283
/// When updating data from the buffer (pSrcBuffer is not null),
@@ -279,8 +287,9 @@ struct TextureSubResData
279287
/// For 2D and 3D textures, row stride in bytes
280288
Uint64 Stride DEFAULT_INITIALIZER(0);
281289

282-
/// For 3D textures, depth slice stride in bytes
283-
/// \note On OpenGL, this must be a multiple of Stride
290+
/// For 3D textures, depth slice stride in bytes.
291+
292+
/// On OpenGL, this must be a multiple of `Stride`
284293
Uint64 DepthStride DEFAULT_INITIALIZER(0);
285294

286295

@@ -320,12 +329,13 @@ typedef struct TextureSubResData TextureSubResData;
320329
/// Describes the initial data to store in the texture
321330
struct TextureData
322331
{
323-
/// Pointer to the array of the TextureSubResData elements containing
332+
/// A pointer to the array of the TextureSubResData elements containing
324333
/// information about each subresource.
325334
TextureSubResData* pSubResources DEFAULT_INITIALIZER(nullptr);
326335

327-
/// Number of elements in pSubResources array.
328-
/// NumSubresources must exactly match the number
336+
/// The number of elements in `pSubResources` array.
337+
338+
/// `NumSubresources` must exactly match the number
329339
/// of subresources in the texture. Otherwise an error
330340
/// occurs.
331341
Uint32 NumSubresources DEFAULT_INITIALIZER(0);
@@ -353,10 +363,16 @@ struct TextureData
353363
};
354364
typedef struct TextureData TextureData;
355365

366+
/// Describes the data for one mapped subresource
356367
struct MappedTextureSubresource
357368
{
369+
/// Pointer to the mapped subresource data in CPU memory.
358370
PVoid pData DEFAULT_INITIALIZER(nullptr);
371+
372+
/// Row stride in bytes.
359373
Uint64 Stride DEFAULT_INITIALIZER(0);
374+
375+
/// Depth slice stride in bytes.
360376
Uint64 DepthStride DEFAULT_INITIALIZER(0);
361377

362378
#if DILIGENT_CPP_INTERFACE
@@ -388,6 +404,7 @@ struct SparseTextureProperties
388404
Uint64 MipTailStride DEFAULT_INITIALIZER(0);
389405

390406
/// Specifies the mip tail size in bytes.
407+
391408
/// \note Single mip tail for a 2D array may exceed the 32-bit limit.
392409
Uint64 MipTailSize DEFAULT_INITIALIZER(0);
393410

@@ -400,11 +417,11 @@ struct SparseTextureProperties
400417

401418
/// Size of the sparse memory block, in bytes.
402419

403-
/// \remarks The offset in the packed mip tail, memory offset and memory size that are used in sparse
404-
/// memory binding command must be multiples of the block size.
420+
/// The offset in the packed mip tail, memory offset and memory size that are used in sparse
421+
/// memory binding command must be multiples of the block size.
405422
///
406-
/// If the SPARSE_TEXTURE_FLAG_NONSTANDARD_BLOCK_SIZE flag is not set in the Flags member,
407-
/// the block size is equal to SparseResourceProperties::StandardBlockSize.
423+
/// If the Diligent::SPARSE_TEXTURE_FLAG_NONSTANDARD_BLOCK_SIZE flag is not set in the `Flags` member,
424+
/// the block size is equal to SparseResourceProperties::StandardBlockSize.
408425
Uint32 BlockSize DEFAULT_INITIALIZER(0);
409426

410427
/// Flags that describe additional packing modes.
@@ -432,20 +449,26 @@ DILIGENT_BEGIN_INTERFACE(ITexture, IDeviceObject)
432449
/// \param [in] ViewDesc - View description. See Diligent::TextureViewDesc for details.
433450
/// \param [out] ppView - Address of the memory location where the pointer to the view interface will be written to.
434451
///
435-
/// \remarks To create a shader resource view addressing the entire texture, set only TextureViewDesc::ViewType
436-
/// member of the ViewDesc parameter to Diligent::TEXTURE_VIEW_SHADER_RESOURCE and leave all other
437-
/// members in their default values. Using the same method, you can create render target or depth stencil
438-
/// view addressing the largest mip level.\n
439-
/// If texture view format is Diligent::TEX_FORMAT_UNKNOWN, the view format will match the texture format.\n
440-
/// If texture view type is Diligent::TEXTURE_VIEW_UNDEFINED, the type will match the texture type.\n
441-
/// If the number of mip levels is 0, and the view type is shader resource, the view will address all mip levels.
442-
/// For other view types it will address one mip level.\n
443-
/// If the number of slices is 0, all slices from FirstArraySlice or FirstDepthSlice will be referenced by the view.
444-
/// For non-array textures, the only allowed values for the number of slices are 0 and 1.\n
445-
/// Texture view will contain strong reference to the texture, so the texture will not be destroyed
446-
/// until all views are released.\n
447-
/// The function calls AddRef() for the created interface, so it must be released by
448-
/// a call to Release() when it is no longer needed.
452+
/// To create a shader resource view addressing the entire texture, set only TextureViewDesc::ViewType
453+
/// member of the ViewDesc parameter to Diligent::TEXTURE_VIEW_SHADER_RESOURCE and leave all other
454+
/// members in their default values. Using the same method, you can create render target or depth stencil
455+
/// view addressing the largest mip level.
456+
///
457+
/// If texture view format is Diligent::TEX_FORMAT_UNKNOWN, the view format will match the texture format.
458+
///
459+
/// If texture view type is Diligent::TEXTURE_VIEW_UNDEFINED, the type will match the texture type.
460+
/// If the number of mip levels is 0, and the view type is shader resource, the view will address all mip levels.
461+
///
462+
/// For other view types it will address one mip level.
463+
///
464+
/// If the number of slices is 0, all slices from FirstArraySlice or FirstDepthSlice will be referenced by the view.
465+
/// For non-array textures, the only allowed values for the number of slices are 0 and 1.
466+
///
467+
/// Texture view will contain strong reference to the texture, so the texture will not be destroyed
468+
/// until all views are released.
469+
///
470+
/// The function calls AddRef() for the created interface, so it must be released by
471+
/// a call to Release() when it is no longer needed.
449472
VIRTUAL void METHOD(CreateView)(THIS_
450473
const TextureViewDesc REF ViewDesc,
451474
ITextureView** ppView) PURE;
@@ -455,26 +478,29 @@ DILIGENT_BEGIN_INTERFACE(ITexture, IDeviceObject)
455478
/// \param [in] ViewType - Type of the requested view. See Diligent::TEXTURE_VIEW_TYPE.
456479
/// \return Pointer to the interface
457480
///
458-
/// \note The function does not increase the reference counter for the returned interface, so
459-
/// Release() must *NOT* be called.
481+
/// \note The function does **not** increase the reference counter for the returned interface, so
482+
/// Release() **must not** be called.
460483
VIRTUAL ITextureView* METHOD(GetDefaultView)(THIS_
461484
TEXTURE_VIEW_TYPE ViewType) PURE;
462485

463486

464487
/// Returns native texture handle specific to the underlying graphics API
465488

466-
/// \return pointer to ID3D11Resource interface, for D3D11 implementation\n
467-
/// pointer to ID3D12Resource interface, for D3D12 implementation\n
468-
/// GL buffer handle, for GL implementation
489+
/// \return A pointer to `ID3D11Resource` interface, for D3D11 implementation\n
490+
/// A pointer to `ID3D12Resource` interface, for D3D12 implementation\n
491+
/// `VkImage` handle, for Vulkan implementation\n
492+
/// GL texture name, for OpenGL implementation\n
493+
/// `MtlTexture`, for Metal implementation\n
494+
/// `WGPUTexture` for WebGPU implementation
469495
VIRTUAL Uint64 METHOD(GetNativeHandle)(THIS) PURE;
470496

471497
/// Sets the usage state for all texture subresources.
472498

473-
/// \note This method does not perform state transition, but
474-
/// resets the internal texture state to the given value.
475-
/// This method should be used after the application finished
476-
/// manually managing the texture state and wants to hand over
477-
/// state management back to the engine.
499+
/// This method does not perform state transition, but
500+
/// resets the internal texture state to the given value.
501+
/// This method should be used after the application finished
502+
/// manually managing the texture state and wants to hand over
503+
/// state management back to the engine.
478504
VIRTUAL void METHOD(SetState)(THIS_
479505
RESOURCE_STATE State) PURE;
480506

0 commit comments

Comments
 (0)