11/*
2- * Copyright 2024 Diligent Graphics LLC
2+ * Copyright 2024-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.
3434#include " ../../../DiligentCore/Common/interface/RefCntAutoPtr.hpp"
3535#include " ../../../DiligentCore/Common/interface/HashUtils.hpp"
3636#include " ../../../DiligentCore/Common/interface/BasicMath.hpp"
37+ #include " ../../../DiligentCore/Primitives/interface/FlagEnum.h"
3738
3839namespace Diligent
3940{
@@ -68,6 +69,21 @@ class BoundBoxRenderer
6869 BoundBoxRenderer (const CreateInfo& CI);
6970 ~BoundBoxRenderer ();
7071
72+ // / Option flags.
73+ enum OPTION_FLAGS : Uint32
74+ {
75+ OPTION_FLAG_NONE = 0u ,
76+
77+ // / Manually convert shader output to sRGB color space.
78+ OPTION_FLAG_CONVERT_OUTPUT_TO_SRGB = 1u << 0u ,
79+
80+ // / Compute motion vectors.
81+ OPTION_FLAG_COMPUTE_MOTION_VECTORS = 1u << 1u ,
82+
83+ // / Use reverse depth (i.e. near plane is at 1.0, far plane is at 0.0).
84+ OPTION_FLAG_USE_REVERSE_DEPTH = 1u << 2u
85+ };
86+
7187 struct RenderAttribs
7288 {
7389 // / Bounding box transformation matrix.
@@ -86,43 +102,36 @@ class BoundBoxRenderer
86102 // / For example, use 0x0000FFFFu to draw a dashed line.
87103 Uint32 PatternMask = 0xFFFFFFFFu ;
88104
89- // / Manually convert shader output to sRGB color space.
90- bool ConvertOutputToSRGB = false ;
91-
92- bool ComputeMotionVectors = false ;
105+ // / Render options.
106+ OPTION_FLAGS Options = OPTION_FLAG_NONE;
93107 };
94108 void Prepare (IDeviceContext* pContext, const RenderAttribs& Attribs);
95109 void Render (IDeviceContext* pContext);
96110
97-
111+ private:
98112 struct PSOKey
99113 {
100- const bool ConvertOutputToSRGB;
101- const bool ComputeMotionVectors;
114+ const OPTION_FLAGS Flags;
102115
103- PSOKey (bool _ConvertOutputToSRGB,
104- bool _ComputeMotionVectors) :
105- ConvertOutputToSRGB{_ConvertOutputToSRGB},
106- ComputeMotionVectors{_ComputeMotionVectors}
116+ explicit PSOKey (OPTION_FLAGS _Flags) :
117+ Flags{_Flags}
107118 {}
108119
109120 constexpr bool operator ==(const PSOKey& rhs) const
110121 {
111- return (ConvertOutputToSRGB == rhs.ConvertOutputToSRGB &&
112- ComputeMotionVectors == rhs.ComputeMotionVectors );
122+ return Flags == rhs.Flags ;
113123 }
114124
115125 struct Hasher
116126 {
117127 size_t operator ()(const PSOKey& Key) const
118128 {
119- return ComputeHash (Key.ConvertOutputToSRGB );
129+ return ComputeHash (Key.Flags );
120130 }
121131 };
122132 };
123133 IPipelineState* GetPSO (const PSOKey& Key);
124134
125- private:
126135 RefCntAutoPtr<IRenderDevice> m_pDevice;
127136 RefCntAutoPtr<IRenderStateCache> m_pStateCache;
128137 RefCntAutoPtr<IBuffer> m_pCameraAttribsCB;
@@ -143,5 +152,7 @@ class BoundBoxRenderer
143152 struct BoundBoxShaderAttribs ;
144153 std::unique_ptr<BoundBoxShaderAttribs> m_ShaderAttribs;
145154};
155+ DEFINE_FLAG_ENUM_OPERATORS (BoundBoxRenderer::OPTION_FLAGS);
156+
146157
147158} // namespace Diligent
0 commit comments