Skip to content

Commit d4e821f

Browse files
Updated Sampler and Resource Mapping documentation
1 parent 91fd6a1 commit d4e821f

File tree

3 files changed

+48
-34
lines changed

3 files changed

+48
-34
lines changed

Graphics/GraphicsEngine/interface/ResourceMapping.h

Lines changed: 12 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");
@@ -41,31 +41,30 @@ static DILIGENT_CONSTEXPR INTERFACE_ID IID_ResourceMapping =
4141
/// Describes the resource mapping object entry
4242
struct ResourceMappingEntry
4343
{
44-
// clang-format off
45-
4644
/// Object name
47-
const Char* Name DEFAULT_INITIALIZER(nullptr);
45+
const Char* Name DEFAULT_INITIALIZER(nullptr);
4846

4947
/// Pointer to the object's interface
50-
IDeviceObject* pObject DEFAULT_INITIALIZER(nullptr);
48+
IDeviceObject* pObject DEFAULT_INITIALIZER(nullptr);
5149

52-
Uint32 ArrayIndex DEFAULT_INITIALIZER(0);
50+
/// For array resources, index in the array
51+
Uint32 ArrayIndex DEFAULT_INITIALIZER(0);
5352

5453

5554
#if DILIGENT_CPP_INTERFACE
56-
constexpr ResourceMappingEntry() noexcept {}
55+
constexpr ResourceMappingEntry() noexcept
56+
{}
5757

5858
/// Initializes the structure members
5959

6060
/// \param [in] _Name - Object name.
6161
/// \param [in] _pObject - Pointer to the object.
6262
/// \param [in] _ArrayIndex - For array resources, index in the array
63-
constexpr ResourceMappingEntry (const Char* _Name, IDeviceObject* _pObject, Uint32 _ArrayIndex = 0)noexcept :
64-
Name { _Name },
65-
pObject { _pObject },
63+
constexpr ResourceMappingEntry(const Char* _Name, IDeviceObject* _pObject, Uint32 _ArrayIndex = 0) noexcept :
64+
Name{_Name},
65+
pObject{_pObject},
6666
ArrayIndex{_ArrayIndex}
6767
{}
68-
// clang-format on
6968
#endif
7069
};
7170
typedef struct ResourceMappingEntry ResourceMappingEntry;
@@ -160,8 +159,8 @@ DILIGENT_BEGIN_INTERFACE(IResourceMapping, IObject)
160159
///
161160
/// \return Pointer to the object with the given name and array index.
162161
///
163-
/// \remarks The method does *NOT* increase the reference counter
164-
/// of the returned object, so Release() must not be called.
162+
/// \remarks The method does **NOT** increase the reference counter
163+
/// of the returned object, so Release() **must not** be called.
165164
/// The pointer is guaranteed to be valid until the object is removed
166165
/// from the resource mapping, or the mapping is destroyed.
167166
VIRTUAL IDeviceObject* METHOD(GetResource)(THIS_

Graphics/GraphicsEngine/interface/Sampler.h

Lines changed: 33 additions & 18 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");
@@ -45,6 +45,7 @@ static DILIGENT_CONSTEXPR INTERFACE_ID IID_Sampler =
4545
/// Sampler flags
4646
DILIGENT_TYPED_ENUM(SAMPLER_FLAGS, Uint8)
4747
{
48+
/// No flags are set.
4849
SAMPLER_FLAG_NONE = 0,
4950

5051
/// Specifies that the sampler will read from a subsampled texture created with MISC_TEXTURE_FLAG_SUBSAMPLED flag.
@@ -69,22 +70,25 @@ DEFINE_FLAG_ENUM_OPERATORS(SAMPLER_FLAGS)
6970
/// To create an anisotropic filter, all three filters must either be Diligent::FILTER_TYPE_ANISOTROPIC
7071
/// or Diligent::FILTER_TYPE_COMPARISON_ANISOTROPIC.
7172
///
72-
/// MipFilter cannot be comparison filter except for Diligent::FILTER_TYPE_ANISOTROPIC if all
73+
/// `MipFilter` cannot be comparison filter except for Diligent::FILTER_TYPE_ANISOTROPIC if all
7374
/// three filters have that value.
7475
///
75-
/// Both MinFilter and MagFilter must either be regular filters or comparison filters.
76+
/// Both `MinFilter` and `MagFilter` must either be regular filters or comparison filters.
7677
/// Mixing comparison and regular filters is an error.
7778
struct SamplerDesc DILIGENT_DERIVE(DeviceObjectAttribs)
7879

7980
/// Texture minification filter, see Diligent::FILTER_TYPE for details.
81+
8082
/// Default value: Diligent::FILTER_TYPE_LINEAR.
8183
FILTER_TYPE MinFilter DEFAULT_INITIALIZER(FILTER_TYPE_LINEAR);
8284

8385
/// Texture magnification filter, see Diligent::FILTER_TYPE for details.
86+
8487
/// Default value: Diligent::FILTER_TYPE_LINEAR.
8588
FILTER_TYPE MagFilter DEFAULT_INITIALIZER(FILTER_TYPE_LINEAR);
8689

8790
/// Mip filter, see Diligent::FILTER_TYPE for details.
91+
8892
/// Only FILTER_TYPE_POINT, FILTER_TYPE_LINEAR, FILTER_TYPE_ANISOTROPIC, and
8993
/// FILTER_TYPE_COMPARISON_ANISOTROPIC are allowed.
9094
/// Default value: Diligent::FILTER_TYPE_LINEAR.
@@ -95,49 +99,60 @@ struct SamplerDesc DILIGENT_DERIVE(DeviceObjectAttribs)
9599
TEXTURE_ADDRESS_MODE AddressU DEFAULT_INITIALIZER(TEXTURE_ADDRESS_CLAMP);
96100

97101
/// Texture address mode for V coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details
102+
98103
/// Default value: Diligent::TEXTURE_ADDRESS_CLAMP.
99104
TEXTURE_ADDRESS_MODE AddressV DEFAULT_INITIALIZER(TEXTURE_ADDRESS_CLAMP);
100105

101106
/// Texture address mode for W coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details
107+
102108
/// Default value: Diligent::TEXTURE_ADDRESS_CLAMP.
103109
TEXTURE_ADDRESS_MODE AddressW DEFAULT_INITIALIZER(TEXTURE_ADDRESS_CLAMP);
104110

105111
/// Sampler flags, see Diligent::SAMPLER_FLAGS for details.
106112
SAMPLER_FLAGS Flags DEFAULT_INITIALIZER(SAMPLER_FLAG_NONE);
107113

108114
/// Indicates whether to use unnormalized texture coordinates.
115+
116+
/// When set to `True`, the range of the image coordinates used to lookup
117+
/// the texel is in the range of 0 to the image size in each dimension.
118+
/// When set to `False`, the range of image coordinates is 0.0 to 1.0.
109119
///
110-
/// \remarks When set to True, the range of the image coordinates used to lookup
111-
/// the texel is in the range of 0 to the image size in each dimension.
112-
/// When set to False, the range of image coordinates is 0.0 to 1.0.
113-
///
114-
/// Unnormalized coordinates are only supported in Vulkan and Metal.
120+
/// Unnormalized coordinates are only supported in Vulkan and Metal.
115121
Bool UnnormalizedCoords DEFAULT_INITIALIZER(False);
116122

117-
/// Offset from the calculated mipmap level. For example, if a sampler calculates that a texture
118-
/// should be sampled at mipmap level 1.2 and MipLODBias is 2.3, then the texture will be sampled at
119-
/// mipmap level 3.5. Default value: 0.
123+
/// Offset from the calculated mipmap level.
124+
125+
/// For example, if a sampler calculates that a texture should be sampled at mipmap
126+
/// level 1.2 and MipLODBias is 2.3, then the texture will be sampled at
127+
/// mipmap level 3.5.
128+
///
129+
/// Default value: 0.
120130
Float32 MipLODBias DEFAULT_INITIALIZER(0);
121131

122132
/// Maximum anisotropy level for the anisotropic filter. Default value: 0.
123133
Uint32 MaxAnisotropy DEFAULT_INITIALIZER(0);
124134

125-
/// A function that compares sampled data against existing sampled data when comparison
126-
/// filter is used. Default value: Diligent::COMPARISON_FUNC_NEVER.
135+
/// A function that compares sampled data against existing sampled data when comparison filter is used.
136+
137+
/// Default value: Diligent::COMPARISON_FUNC_NEVER.
127138
COMPARISON_FUNCTION ComparisonFunc DEFAULT_INITIALIZER(COMPARISON_FUNC_NEVER);
128139

129-
/// Border color to use if TEXTURE_ADDRESS_BORDER is specified for AddressU, AddressV, or AddressW.
130-
/// Default value: {0,0,0,0}
140+
/// Border color to use if TEXTURE_ADDRESS_BORDER is specified for `AddressU`, `AddressV`, or `AddressW`.
141+
142+
/// Default value: `{0, 0, 0, 0}`
131143
Float32 BorderColor[4] DEFAULT_INITIALIZER({});
132144

133145
/// Specifies the minimum value that LOD is clamped to before accessing the texture MIP levels.
134-
/// Must be less than or equal to MaxLOD.
146+
147+
/// Must be less than or equal to `MaxLOD`.
148+
///
135149
/// Default value: 0.
136150
float MinLOD DEFAULT_INITIALIZER(0);
137151

138152
/// Specifies the maximum value that LOD is clamped to before accessing the texture MIP levels.
139-
/// Must be greater than or equal to MinLOD.
140-
/// Default value: +FLT_MAX.
153+
154+
/// Must be greater than or equal to `MinLOD`.
155+
/// Default value: `+FLT_MAX`.
141156
float MaxLOD DEFAULT_INITIALIZER(+3.402823466e+38F);
142157

143158
//

Graphics/GraphicsEngine/src/SamplerBase.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2024 Diligent Graphics LLC
2+
* Copyright 2019-2025 Diligent Graphics LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -41,8 +41,8 @@ namespace Diligent
4141

4242
void ValidateSamplerDesc(const SamplerDesc& Desc, const IRenderDevice* pDevice)
4343
{
44-
const auto& DeviceInfo = pDevice->GetDeviceInfo();
45-
const auto& AdapterInfo = pDevice->GetAdapterInfo();
44+
const RenderDeviceInfo& DeviceInfo = pDevice->GetDeviceInfo();
45+
const GraphicsAdapterInfo& AdapterInfo = pDevice->GetAdapterInfo();
4646
if (Desc.Flags & (SAMPLER_FLAG_SUBSAMPLED | SAMPLER_FLAG_SUBSAMPLED_COARSE_RECONSTRUCTION))
4747
{
4848
VERIFY_SAMPLER(AdapterInfo.ShadingRate.CapFlags & SHADING_RATE_CAP_FLAG_SUBSAMPLED_RENDER_TARGET,

0 commit comments

Comments
 (0)