Skip to content

Commit fb53178

Browse files
Updated documentation for Bound Box Renderer, Env Map Renderer and other components
1 parent f7f346a commit fb53178

File tree

8 files changed

+248
-85
lines changed

8 files changed

+248
-85
lines changed

Components/interface/BoundBoxRenderer.hpp

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
* of the possibility of such damages.
2525
*/
2626

27+
#pragma once
28+
29+
/// \file
30+
/// Defines BoundBoxRenderer class
31+
2732
#include <unordered_map>
2833
#include <vector>
2934
#include <memory>
@@ -39,34 +44,45 @@
3944
namespace Diligent
4045
{
4146

42-
/// Renders the bounding box.
47+
/// Bounding box renderer.
4348
class BoundBoxRenderer
4449
{
4550
public:
51+
/// Bound box renderer creation info.
4652
struct CreateInfo
4753
{
48-
IRenderDevice* pDevice = nullptr;
49-
IRenderStateCache* pStateCache = nullptr;
50-
IBuffer* pCameraAttribsCB = nullptr;
54+
/// Render device.
55+
IRenderDevice* pDevice = nullptr;
56+
57+
/// An optional render state cache.
58+
IRenderStateCache* pStateCache = nullptr;
59+
60+
/// A buffer that contains camera attributes.
61+
IBuffer* pCameraAttribsCB = nullptr;
5162

52-
Uint8 NumRenderTargets = 1;
63+
/// The number of render targets.
64+
Uint8 NumRenderTargets = 1;
65+
66+
/// Render target formats.
5367
TEXTURE_FORMAT RTVFormats[DILIGENT_MAX_RENDER_TARGETS] = {TEX_FORMAT_RGBA8_UNORM_SRGB};
54-
TEXTURE_FORMAT DSVFormat = TEX_FORMAT_D32_FLOAT;
68+
69+
/// Depth-stencil view format.
70+
TEXTURE_FORMAT DSVFormat = TEX_FORMAT_D32_FLOAT;
5571

5672
/// A bit mask that defines the render targets to render to.
57-
///
58-
/// \remarks If bit N is set, the N-th render target's color write mask will be set to
59-
/// COLOR_MASK_ALL. Otherwise, it will be set to COLOR_MASK_NONE.
73+
74+
/// If bit N is set, the N-th render target's color write mask will be set to
75+
/// Diligent::COLOR_MASK_ALL. Otherwise, it will be set to Diligent::COLOR_MASK_NONE.
6076
Uint32 RenderTargetMask = 0x1u;
6177

6278
const char* PSMainSource = nullptr;
6379

6480
/// Whether shader matrices are laid out in row-major order in GPU memory.
65-
///
66-
/// \remarks By default, shader matrices are laid out in column-major order
67-
/// in GPU memory. If this option is set to true, shaders will be compiled
68-
/// with the SHADER_COMPILE_FLAG_PACK_MATRIX_ROW_MAJOR flag and
69-
/// use the row-major layout.
81+
82+
/// By default, shader matrices are laid out in column-major order
83+
/// in GPU memory. If this option is set to true, shaders will be compiled
84+
/// with the Diligent::SHADER_COMPILE_FLAG_PACK_MATRIX_ROW_MAJOR flag and
85+
/// use the row-major layout.
7086
bool PackMatrixRowMajor = false;
7187

7288
/// Whether to compile shaders asynchronously.
@@ -78,6 +94,7 @@ class BoundBoxRenderer
7894
/// Option flags.
7995
enum OPTION_FLAGS : Uint32
8096
{
97+
/// No options.
8198
OPTION_FLAG_NONE = 0u,
8299

83100
/// Manually convert shader output to sRGB color space.
@@ -90,28 +107,39 @@ class BoundBoxRenderer
90107
OPTION_FLAG_USE_REVERSE_DEPTH = 1u << 2u
91108
};
92109

110+
/// Render attributes.
93111
struct RenderAttribs
94112
{
95113
/// Bounding box transformation matrix.
114+
96115
/// Can't be null.
97116
const float4x4* BoundBoxTransform = nullptr;
98117

99118
/// Bounding box color.
119+
100120
/// If null, white color will be used.
101121
const float4* Color = nullptr;
102122

103123
/// Pattern length in pixels.
104124
float PatternLength = 32;
105125

106126
/// Pattern mask.
127+
107128
/// Each bit defines whether the corresponding 1/32 section of the pattern is filled or not.
108129
/// For example, use 0x0000FFFFu to draw a dashed line.
109130
Uint32 PatternMask = 0xFFFFFFFFu;
110131

111132
/// Render options.
112133
OPTION_FLAGS Options = OPTION_FLAG_NONE;
113134
};
135+
136+
/// Prepares the renderer.
137+
138+
/// \param [in] pContext - Device context.
139+
/// \param [in] Attribs - Render attributes.
114140
void Prepare(IDeviceContext* pContext, const RenderAttribs& Attribs);
141+
142+
/// Renders the bounding box.
115143
void Render(IDeviceContext* pContext);
116144

117145
private:

Components/interface/CoordinateGridRenderer.hpp

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626

2727
#pragma once
2828

29+
/// \file
30+
/// Defines CoordinateGridRenderer class
31+
2932
#include <unordered_map>
3033
#include <vector>
3134

@@ -47,21 +50,40 @@ struct CameraAttribs;
4750
struct CoordinateGridAttribs;
4851
} // namespace HLSL
4952

53+
54+
/// Coordinate grid renderer.
5055
class CoordinateGridRenderer
5156
{
5257
public:
58+
/// Feature flags.
5359
enum FEATURE_FLAGS : Uint32
5460
{
55-
FEATURE_FLAG_NONE = 0u,
61+
/// No feature flags.
62+
FEATURE_FLAG_NONE = 0u,
63+
64+
/// Convert pixel shader output to sRGB.
5665
FEATURE_FLAG_CONVERT_TO_SRGB = 1u << 0u,
66+
67+
/// Render grid in YZ plane.
5768
FEATURE_FLAG_RENDER_PLANE_YZ = 1u << 1u,
69+
70+
/// Render grid in XZ plane.
5871
FEATURE_FLAG_RENDER_PLANE_XZ = 1u << 2u,
72+
73+
/// Render grid in XY plane.
5974
FEATURE_FLAG_RENDER_PLANE_XY = 1u << 3u,
60-
FEATURE_FLAG_RENDER_AXIS_X = 1u << 4u,
61-
FEATURE_FLAG_RENDER_AXIS_Y = 1u << 5u,
62-
FEATURE_FLAG_RENDER_AXIS_Z = 1u << 6u,
75+
76+
/// Render X axis.
77+
FEATURE_FLAG_RENDER_AXIS_X = 1u << 4u,
78+
79+
/// Render Y axis.
80+
FEATURE_FLAG_RENDER_AXIS_Y = 1u << 5u,
81+
82+
/// Render Z axis.
83+
FEATURE_FLAG_RENDER_AXIS_Z = 1u << 6u,
6384
};
6485

86+
/// Render attributes.
6587
struct RenderAttributes
6688
{
6789
/// Render device that may be used to create new objects needed for this frame, if any.
@@ -92,18 +114,29 @@ class CoordinateGridRenderer
92114
const HLSL::CoordinateGridAttribs* pAttribs = nullptr;
93115
};
94116

117+
/// Create info.
95118
struct CreateInfo
96119
{
120+
/// Whether shader matrices are laid out in row-major order in GPU memory.
121+
122+
/// By default, shader matrices are laid out in column-major order
123+
/// in GPU memory. If this option is set to true, shaders will be compiled
124+
/// with the Diligent::SHADER_COMPILE_FLAG_PACK_MATRIX_ROW_MAJOR flag and
125+
/// use the row-major layout.
97126
bool PackMatrixRowMajor = false;
98127
};
99128

100129
public:
130+
/// Creates a new coordinate grid renderer.
101131
CoordinateGridRenderer(IRenderDevice* pDevice, const CreateInfo& CI);
102132

133+
/// Renders the coordinate grid.
103134
void Render(const RenderAttributes& Attribs);
104135

136+
/// Adds the coordinate grid UI elements.
105137
static bool UpdateUI(HLSL::CoordinateGridAttribs& Attribs, FEATURE_FLAGS& FeatureFlags);
106138

139+
/// Adds the coordinate grid shader macros.
107140
static void AddShaderMacros(FEATURE_FLAGS FeatureFlags, ShaderMacroHelper& Macros);
108141

109142
private:

Components/interface/DepthRangeCalculator.hpp

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
* of the possibility of such damages.
2525
*/
2626

27+
#pragma once
28+
29+
/// \file
30+
/// Defines DepthRangeCalculator class
31+
2732
#include <memory>
2833

2934
#include "../../../DiligentCore/Graphics/GraphicsEngine/interface/RenderDevice.h"
@@ -48,12 +53,12 @@ namespace Diligent
4853
/// float SceneFarDepth;
4954
/// };
5055
///
51-
/// SceneNearZ is always less than SceneFarZ.
52-
/// SceneNearDepth is the depth value corresponding to SceneNearZ.
53-
/// SceneFarDepth is the depth value corresponding to SceneFarZ.
54-
/// Note that if reverse depth is used, SceneNearDepth will be greater than SceneFarDepth.
56+
/// * `SceneNearZ` is always less than `SceneFarZ`.
57+
/// * `SceneNearDepth` is the depth value corresponding to `SceneNearZ`.
58+
/// * `SceneFarDepth` is the depth value corresponding to `SceneFarZ`.
59+
/// * Note that if reverse depth is used, `SceneNearDepth` will be greater than `SceneFarDepth`.
5560
///
56-
/// \remarks SceneNearZ and SceneFarZ must be positive values.
61+
/// \remarks `SceneNearZ` and `SceneFarZ` must be positive values.
5762
class DepthRangeCalculator
5863
{
5964
public:
@@ -68,10 +73,10 @@ class DepthRangeCalculator
6873

6974
/// Whether shader matrices are laid out in row-major order in GPU memory.
7075
///
71-
/// \remarks By default, shader matrices are laid out in column-major order
72-
/// in GPU memory. If this option is set to true, shaders will be compiled
73-
/// with the SHADER_COMPILE_FLAG_PACK_MATRIX_ROW_MAJOR flag and
74-
/// use the row-major layout.
76+
/// By default, shader matrices are laid out in column-major order
77+
/// in GPU memory. If this option is set to true, shaders will be compiled
78+
/// with the SHADER_COMPILE_FLAG_PACK_MATRIX_ROW_MAJOR flag and
79+
/// use the row-major layout.
7580
bool PackMatrixRowMajor = false;
7681

7782
/// Whether to compile shaders asynchronously.
@@ -82,7 +87,7 @@ class DepthRangeCalculator
8287
};
8388

8489
/// Constructs a depth range calculator object.
85-
///
90+
8691
/// \param [in] CI Create info.
8792
///
8893
/// In case of failure, an exception is thrown.
@@ -105,7 +110,7 @@ class DepthRangeCalculator
105110
IDeviceContext* pContext = nullptr;
106111

107112
/// Shader resource binding object.
108-
///
113+
109114
/// The SRB must be created using the CreateSRB() method.
110115
IShaderResourceBinding* pSRB = nullptr;
111116

@@ -117,11 +122,11 @@ class DepthRangeCalculator
117122
};
118123

119124
/// Computes the depth range.
120-
///
125+
121126
/// \param [in] Attribs Method attributes.
122127
///
123128
/// The near/far depth values are written to the depth range buffer.
124-
/// If the ReadBackData option was set to true in the CreateInfo structure,
129+
/// If the `ReadBackData` option was set to true in the `CreateInfo` structure,
125130
/// the depth range will also be read back to the CPU and can be accessed using
126131
/// the GetDepthRange() method.
127132
///
@@ -148,7 +153,7 @@ class DepthRangeCalculator
148153
};
149154

150155
/// Returns the depth range read back to the CPU.
151-
///
156+
152157
/// \param [in] pCtx If not null, the function will poll the read back queue for the latest data.
153158
/// \return The depth range read back to the CPU.
154159
const DepthRange& GetDepthRange(IDeviceContext* pCtx = nullptr);

0 commit comments

Comments
 (0)