Skip to content

Commit 0360fca

Browse files
Graphics Accessories: updated documentation
1 parent be99069 commit 0360fca

File tree

2 files changed

+127
-67
lines changed

2 files changed

+127
-67
lines changed

Graphics/GraphicsAccessories/interface/GraphicsAccessories.hpp

Lines changed: 126 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -177,40 +177,46 @@ const Char* GetValueTypeString(VALUE_TYPE Val);
177177
/// format attributes.
178178
const TextureFormatAttribs& GetTextureFormatAttribs(TEXTURE_FORMAT Format);
179179

180-
/// Converts value type to component type, for example:
181-
/// * VT_UINT8, true, false -> COMPONENT_TYPE_UNORM
182-
/// * VT_UINT8, false, false -> COMPONENT_TYPE_UINT
183-
/// * VT_UINT8, true, true -> COMPONENT_TYPE_UNORM_SRGB
180+
/// Converts value type to component type.
181+
182+
/// For example:
183+
/// * `VT_UINT8, true, false -> COMPONENT_TYPE_UNORM`
184+
/// * `VT_UINT8, false, false -> COMPONENT_TYPE_UINT`
185+
/// * `VT_UINT8, true, true -> COMPONENT_TYPE_UNORM_SRGB`
184186
///
185187
/// \note Use GetValueSize() to get the component size.
186188
COMPONENT_TYPE ValueTypeToComponentType(VALUE_TYPE ValType, bool IsNormalized, bool IsSRGB);
187189

188-
/// Converts component type and size to value type, for example:
189-
/// * COMPONENT_TYPE_UNORM, 1 -> VT_UINT8
190-
/// * COMPONENT_TYPE_FLOAT, 4 -> VT_FLOAT32
190+
/// Converts component type and size to value type
191+
192+
/// For example:
193+
/// * `COMPONENT_TYPE_UNORM, 1 -> VT_UINT8`
194+
/// * `COMPONENT_TYPE_FLOAT, 4 -> VT_FLOAT32`
191195
VALUE_TYPE ComponentTypeToValueType(COMPONENT_TYPE CompType, Uint32 Size);
192196

193-
/// Returns texture format for the specified component type, size and number of components, for example:
194-
/// * COMPONENT_TYPE_UNORM, 1, 4 -> TEX_FORMAT_RGBA8_UNORM
195-
/// * COMPONENT_TYPE_FLOAT, 4, 1 -> TEX_FORMAT_R32_FLOAT
197+
/// Returns texture format for the specified component type, size and number of components
198+
199+
/// For example:
200+
/// * `COMPONENT_TYPE_UNORM, 1, 4 -> TEX_FORMAT_RGBA8_UNORM`
201+
/// * `COMPONENT_TYPE_FLOAT, 4, 1 -> TEX_FORMAT_R32_FLOAT`
196202
///
197-
/// If the format is not found, TEXTURE_FORMAT_UNKNOWN is returned.
203+
/// If the format is not found, `TEXTURE_FORMAT_UNKNOWN` is returned.
198204
TEXTURE_FORMAT TextureComponentAttribsToTextureFormat(COMPONENT_TYPE CompType, Uint32 ComponentSize, Uint32 NumComponents);
199205

200206

201207
/// Returns the default format for a specified texture view type
202208

203209
/// The default view is defined as follows:
204210
/// * For a fully qualified texture format, the SRV/RTV/UAV view format is the same as texture format;
205-
/// DSV format, if available, is adjusted accordingly (R32_FLOAT -> D32_FLOAT)
206-
/// * For 32-bit typeless formats, default view is XXXX32_FLOAT (where XXXX are the actual format components)\n
207-
/// * For 16-bit typeless formats, default view is XXXX16_FLOAT (where XXXX are the actual format components)\n
208-
/// ** R16_TYPELESS is special. If BIND_DEPTH_STENCIL flag is set, it is translated to R16_UNORM/D16_UNORM;
209-
/// otherwise it is translated to R16_FLOAT.
210-
/// * For 8-bit typeless formats, default view is XXXX8_UNORM (where XXXX are the actual format components)\n
211-
/// * sRGB is always chosen if it is available (RGBA8_UNORM_SRGB, TEX_FORMAT_BC1_UNORM_SRGB, etc.)
212-
/// * For combined depth-stencil formats, SRV format references depth component (R24_UNORM_X8_TYPELESS for D24S8 formats, and
213-
/// R32_FLOAT_X8X24_TYPELESS for D32S8X24 formats)
211+
/// DSV format, if available, is adjusted accordingly (`R32_FLOAT -> D32_FLOAT`)
212+
/// * For 32-bit typeless formats, default view is `XXXX32_FLOAT` (where `XXXX` are the actual format components)\n
213+
/// * For 16-bit typeless formats, default view is `XXXX16_FLOAT` (where `XXXX` are the actual format components)\n
214+
/// ** `R16_TYPELESS` is special. If `BIND_DEPTH_STENCIL` flag is set, it is translated to `R16_UNORM`/`D16_UNORM`;
215+
/// otherwise it is translated to `R16_FLOAT`.
216+
/// * For 8-bit typeless formats, default view is `XXXX8_UNORM` (where `XXXX` are the actual format components)\n
217+
/// * sRGB is always chosen if it is available (`RGBA8_UNORM_SRGB`, `TEX_FORMAT_BC1_UNORM_SRGB`, etc.)
218+
/// * For combined depth-stencil formats, SRV format references depth component (`R24_UNORM_X8_TYPELESS` for `D24S8` formats, and
219+
/// `R32_FLOAT_X8X24_TYPELESS` for `D32S8X24` formats)
214220
/// * For compressed formats, only SRV format is defined
215221
///
216222
/// \param [in] Format - texture format, for which the view format is requested
@@ -267,7 +273,7 @@ String GetShaderStagesString(SHADER_TYPE ShaderStages);
267273
const Char* GetShaderVariableTypeLiteralName(SHADER_RESOURCE_VARIABLE_TYPE VarType, bool bGetFullName = false);
268274

269275
/// Returns the literal name of a shader resource type. For instance,
270-
/// for SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, if bGetFullName == true, "SHADER_RESOURCE_TYPE_CONSTANT_BUFFER" will be returned;
276+
/// for `SHADER_RESOURCE_TYPE_CONSTANT_BUFFER`, if `bGetFullName == true`, `"SHADER_RESOURCE_TYPE_CONSTANT_BUFFER"` will be returned;
271277
/// if bGetFullName == false, "constant buffer" will be returned
272278

273279
/// \param [in] ResourceType - Resource type.
@@ -437,18 +443,42 @@ inline String GetObjectDescString(const BufferDesc& BuffDesc)
437443
return Str;
438444
}
439445

446+
/// Returns the string representation of the QUERY_TYPE enum value (e.g. "QUERY_TYPE_OCCLUSION")
440447
const char* GetQueryTypeString(QUERY_TYPE QueryType);
441448

449+
/// Returns the string representation of the SURFACE_TRANSFORM enum value (e.g. "SURFACE_TRANSFORM_ROTATE_90")
442450
const char* GetSurfaceTransformString(SURFACE_TRANSFORM SrfTransform);
443451

452+
/// Returns the string representation of the PIPELINE_TYPE enum value (e.g. "PIPELINE_TYPE_COMPUTE")
444453
const char* GetPipelineTypeString(PIPELINE_TYPE PipelineType);
445454

455+
/// Returns the string representation of the SHADER_COMPILER enum value (e.g. "SHADER_COMPILER_GLSLANG")
446456
const char* GetShaderCompilerTypeString(SHADER_COMPILER Compiler);
447457

458+
/// Returns the string representation of the ARCHIVE_DEVICE_DATA_FLAGS enum value
459+
460+
/// \param [in] Flag - Archive device data flag.
461+
/// \param [in] bGetFullName - Whether to return full name of the enum value
462+
/// \return Literal name of the archive device data flag.
463+
///
464+
/// For example, if bGetFullName == true, "ARCHIVE_DEVICE_DATA_FLAG_D3D11" will be returned;
465+
/// if bGetFullName == false, "D3D11" will be returned.
466+
///
467+
/// \note A single flag must be passed to this function.
448468
const char* GetArchiveDeviceDataFlagString(ARCHIVE_DEVICE_DATA_FLAGS Flag, bool bGetFullName = false);
449469

470+
471+
/// Returns the string representation of the DEVICE_FEATURE_STATE enum value
472+
473+
/// \param [in] State - Device feature state.
474+
/// \param [in] bGetFullName - Whether to return full name of the enum value
475+
/// \return Literal name of the device feature state.
476+
///
477+
/// For example, if bGetFullName == true, "DEVICE_FEATURE_STATE_ENABLED" will be returned;
478+
/// if bGetFullName == false, "Enabled" will be returned.
450479
const char* GetDeviceFeatureStateString(DEVICE_FEATURE_STATE State, bool bGetFullName = false);
451480

481+
452482
/// Returns the render device type string (e.g. "RENDER_DEVICE_TYPE_D3D11" when GetEnumString is true,
453483
/// or "Direct3D11" when GetEnumString is false).
454484
const char* GetRenderDeviceTypeString(RENDER_DEVICE_TYPE DeviceType, bool GetEnumString = false);
@@ -471,31 +501,42 @@ String GetShaderCodeBufferDescString(const ShaderCodeBufferDesc& Desc, size_t Gl
471501
/// Returns the string containing the shader code variable description.
472502
String GetShaderCodeVariableDescString(const ShaderCodeVariableDesc& Desc, size_t GlobalIdent = 0, size_t MemberIdent = 2);
473503

504+
/// Returns the string representation of the input element frequency (e.g. "undefined")
474505
const char* GetInputElementFrequencyString(INPUT_ELEMENT_FREQUENCY Frequency);
475506

476507
/// Returns the string containing the layout element description.
477508
String GetLayoutElementString(const LayoutElement& Element);
478509

510+
/// Returns valid pipeline resource flags for the specified shader resource type
479511
PIPELINE_RESOURCE_FLAGS GetValidPipelineResourceFlags(SHADER_RESOURCE_TYPE ResourceType);
480512

513+
/// Converts shader variable flags to corresponding pipeline resource flags
481514
PIPELINE_RESOURCE_FLAGS ShaderVariableFlagsToPipelineResourceFlags(SHADER_VARIABLE_FLAGS Flags);
482515

516+
/// Returns bind flags for the specified swap chain usage flags
483517
BIND_FLAGS SwapChainUsageFlagsToBindFlags(SWAP_CHAIN_USAGE_FLAGS SwapChainUsage);
484518

485519
ARCHIVE_DEVICE_DATA_FLAGS RenderDeviceTypeToArchiveDataFlag(RENDER_DEVICE_TYPE DevType);
486520
RENDER_DEVICE_TYPE ArchiveDataFlagToRenderDeviceType(ARCHIVE_DEVICE_DATA_FLAGS Flag);
487521

522+
/// Returns the number of mip levels for the specified texture dimensions
488523
Uint32 ComputeMipLevelsCount(Uint32 Width);
524+
525+
/// Returns the number of mip levels for the specified texture dimensions
489526
Uint32 ComputeMipLevelsCount(Uint32 Width, Uint32 Height);
527+
528+
/// Returns the number of mip levels for the specified texture dimensions
490529
Uint32 ComputeMipLevelsCount(Uint32 Width, Uint32 Height, Uint32 Depth);
491530

531+
/// Checks if the specified filter type is a point filter
492532
inline bool IsComparisonFilter(FILTER_TYPE FilterType)
493533
{
494534
return FilterType == FILTER_TYPE_COMPARISON_POINT ||
495535
FilterType == FILTER_TYPE_COMPARISON_LINEAR ||
496536
FilterType == FILTER_TYPE_COMPARISON_ANISOTROPIC;
497537
}
498538

539+
/// Checks if the specified filter type is an anisotropic filter
499540
inline bool IsAnisotropicFilter(FILTER_TYPE FilterType)
500541
{
501542
return FilterType == FILTER_TYPE_ANISOTROPIC ||
@@ -531,8 +572,9 @@ struct MipLevelProperties
531572
/// pixel block size), the storage height will be 12.
532573
Uint32 StorageHeight = 0;
533574

534-
/// Mip level depth. Note that logical and storage depths
535-
/// are always the same.
575+
/// Mip level depth.
576+
577+
/// \note that logical and storage depths are always the same.
536578
Uint32 Depth = 1;
537579

538580
/// Row size in bytes.
@@ -548,6 +590,7 @@ struct MipLevelProperties
548590
Uint64 MipSize = 0;
549591
};
550592

593+
/// Returns mip level properties for the specified texture description and mip level
551594
MipLevelProperties GetMipLevelProperties(const TextureDesc& TexDesc, Uint32 MipLevel);
552595

553596
ADAPTER_VENDOR VendorIdToAdapterVendor(Uint32 VendorId);
@@ -582,7 +625,7 @@ inline Int32 ExtractFirstShaderStageIndex(SHADER_TYPE& Stages)
582625

583626
VERIFY(Stages > SHADER_TYPE_UNKNOWN && Stages < SHADER_TYPE_LAST * 2, "Value ", Uint32{Stages}, " is not a valid SHADER_TYPE enum value");
584627

585-
const auto StageIndex = PlatformMisc::GetLSB(Stages);
628+
const Uint32 StageIndex = PlatformMisc::GetLSB(Stages);
586629
Stages &= ~static_cast<SHADER_TYPE>(1u << StageIndex);
587630
return StageIndex;
588631
}
@@ -656,26 +699,27 @@ PIPELINE_TYPE PipelineTypeFromShaderStages(SHADER_TYPE ShaderStages);
656699
///
657700
/// \return Offset from the beginning of the buffer to the given location.
658701
///
659-
/// \remarks Alignment is applied to the subresource sizes, such that the beginning of data
660-
/// of every subresource starts at an offset aligned by 'Alignment'. The alignment
661-
/// is not applied to the row/depth strides and texels in all subresources are assumed
662-
/// to be tightly packed.
702+
/// \remarks
703+
/// Alignment is applied to the subresource sizes, such that the beginning of data
704+
/// of every subresource starts at an offset aligned by 'Alignment'. The alignment
705+
/// is not applied to the row/depth strides and texels in all subresources are assumed
706+
/// to be tightly packed.
663707
///
664-
/// Subres 0
665-
/// stride
666-
/// |<-------------->|
667-
/// |________________| Subres 1
668-
/// | | stride
669-
/// | | |<------->|
670-
/// | | |_________|
671-
/// | Subres 0 | | |
672-
/// | | | Subres 1|
673-
/// | | | | _
674-
/// |________________| |_________| ... |_|
675-
/// A A A
676-
/// | | |
677-
/// Buffer start Subres 1 offset, Subres N offset,
678-
/// aligned by 'Alignment' aligned by 'Alignment'
708+
/// Subres 0
709+
/// stride
710+
/// |<-------------->|
711+
/// |________________| Subres 1
712+
/// | | stride
713+
/// | | |<------->|
714+
/// | | |_________|
715+
/// | Subres 0 | | |
716+
/// | | | Subres 1|
717+
/// | | | | _
718+
/// |________________| |_________| ... |_|
719+
/// A A A
720+
/// | | |
721+
/// Buffer start Subres 1 offset, Subres N offset,
722+
/// aligned by 'Alignment' aligned by 'Alignment'
679723
///
680724
Uint64 GetStagingTextureLocationOffset(const TextureDesc& TexDesc,
681725
Uint32 ArraySlice,
@@ -773,46 +817,62 @@ String GetShaderResourcePrintName(const DescType& ResDesc, Uint32 ArrayIndex = 0
773817
return GetShaderResourcePrintName(ResDesc.Name, ResDesc.ArraySize, ArrayIndex);
774818
}
775819

776-
/// Converts UNORM format to a corresponding SRGB format, for example:
777-
/// RGBA8_UNORM -> RGBA8_UNORM_SRGB
778-
/// BC3_UNORM -> BC3_UNORM_SRGB
820+
/// Converts UNORM format to a corresponding SRGB format
821+
822+
/// For example:
823+
/// * `RGBA8_UNORM -> RGBA8_UNORM_SRGB`
824+
/// * `BC3_UNORM -> BC3_UNORM_SRGB`
779825
TEXTURE_FORMAT UnormFormatToSRGB(TEXTURE_FORMAT Fmt);
780826

781-
/// Converts SRGB format to a corresponding UNORM format, for example:
782-
/// RGBA8_UNORM_SRGB -> RGBA8_UNORM
783-
/// BC3_UNORM_SRGB -> BC3_UNORM
827+
/// Converts SRGB format to a corresponding UNORM format
828+
829+
/// For example:
830+
/// * `RGBA8_UNORM_SRGB -> RGBA8_UNORM`
831+
/// * `BC3_UNORM_SRGB -> BC3_UNORM`
784832
TEXTURE_FORMAT SRGBFormatToUnorm(TEXTURE_FORMAT Fmt);
785833

786-
/// Converts block-compressed format to a corresponding uncompressed format, for example:
787-
/// BC1_UNORM -> RGBA8_UNORM
788-
/// BC4_UNORM -> R8_UNORM
834+
/// Converts block-compressed format to a corresponding uncompressed format
835+
836+
/// For example:
837+
/// * `BC1_UNORM -> RGBA8_UNORM`
838+
/// * `BC4_UNORM -> R8_UNORM`
789839
TEXTURE_FORMAT BCFormatToUncompressed(TEXTURE_FORMAT Fmt);
790840

791-
/// Converts typeless format to a corresponding UNORM format, for example:
792-
/// RGBA8_TYPELESS -> RGBA8_UNORM
793-
/// BC1_TYPELESS -> BC1_UNORM
841+
/// Converts typeless format to a corresponding UNORM format
842+
843+
/// For example:
844+
/// * `RGBA8_TYPELESS -> RGBA8_UNORM`
845+
/// * `BC1_TYPELESS -> BC1_UNORM`
846+
///
794847
/// If the format is not typeless, or cannot be converted to UNORM, it is returned as is.
795848
TEXTURE_FORMAT TypelessFormatToUnorm(TEXTURE_FORMAT Fmt);
796849

797-
/// Converts typeless format to a corresponding SRGB format, for example:
798-
/// RGBA8_TYPELESS -> RGBA8_UNORM_SRGB
799-
/// BC1_TYPELESS -> BC1_UNORM_SRGB
850+
/// Converts typeless format to a corresponding SRGB format
851+
852+
/// For example:
853+
/// * `RGBA8_TYPELESS -> RGBA8_UNORM_SRGB`
854+
/// * `BC1_TYPELESS -> BC1_UNORM_SRGB`
855+
///
800856
/// If the format is not typeless, or cannot be converted to SRGB, it is returned as is.
801857
TEXTURE_FORMAT TypelessFormatToSRGB(TEXTURE_FORMAT Fmt);
802858

803-
859+
/// Checks if the format is an SRGB format
804860
bool IsSRGBFormat(TEXTURE_FORMAT Fmt);
805861

806862
String GetPipelineShadingRateFlagsString(PIPELINE_SHADING_RATE_FLAGS Flags);
807863

808-
/// Converts texture component mapping to a string, for example:
809-
/// {R, G, B, A} -> "rgba"
810-
/// {R, G, B, 1} -> "rgb1"
864+
/// Converts texture component mapping to a string
865+
866+
/// For example:
867+
/// * `{R, G, B, A} -> "rgba"`
868+
/// * `{R, G, B, 1} -> "rgb1"`
811869
String GetTextureComponentMappingString(const TextureComponentMapping& Mapping);
812870

813-
/// Converts texture component mapping string to the mapping, for example:
814-
/// "rgba" -> {R, G, B, A}
815-
/// "rgb1" -> {R, G, B, 1}
871+
/// Converts texture component mapping string to the mapping
872+
873+
/// For example:
874+
/// * `"rgba" -> {R, G, B, A}`
875+
/// * `"rgb1" -> {R, G, B, 1}`
816876
bool TextureComponentMappingFromString(const String& MappingStr, TextureComponentMapping& Mapping);
817877

818878

@@ -836,7 +896,7 @@ inline uint3 GetNumSparseTilesInMipLevel(const TextureDesc& Desc,
836896
Uint32 MipLevel)
837897
{
838898
// Texture dimensions may not be multiples of the tile size
839-
const auto MipProps = GetMipLevelProperties(Desc, MipLevel);
899+
const MipLevelProperties MipProps = GetMipLevelProperties(Desc, MipLevel);
840900
return GetNumSparseTilesInBox(Box{0, MipProps.StorageWidth, 0, MipProps.StorageHeight, 0, MipProps.Depth}, TileSize);
841901
}
842902

Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1635,7 +1635,7 @@ String GetPipelineResourceFlagsString(PIPELINE_RESOURCE_FLAGS Flags, bool GetFul
16351635
if (!Str.empty())
16361636
Str += DelimiterString;
16371637

1638-
auto Flag = ExtractLSB(Flags);
1638+
PIPELINE_RESOURCE_FLAGS Flag = ExtractLSB(Flags);
16391639

16401640
static_assert(PIPELINE_RESOURCE_FLAG_LAST == (1u << 4), "Please update the switch below to handle the new pipeline resource flag.");
16411641
switch (Flag)

0 commit comments

Comments
 (0)