@@ -950,4 +950,58 @@ SHADER_STATUS GetPipelineStateCreateInfoShadersStatus(const CreateInfoType& CI,
950950
951951size_t ComputeRenderTargetFormatsHash (Uint32 NumRenderTargets, const TEXTURE_FORMAT RTVFormats[], TEXTURE_FORMAT DSVFormat);
952952
953+
954+ // / Returns the string containing the device features
955+ // /
956+ // / \param Features - device features.
957+ // / \param NumColumns - the number of columns in the output.
958+ // / \param Indent - indentation of the first column.
959+ // / \param Spacing - spacing between columns.
960+ // / \param Flags - flags to control which features to include in the output.
961+ // / If (1<<State) & Flags is true, the feature will be included.
962+ // / \return string containing the device features.
963+ template <typename FeaturesType>
964+ std::string GetDeviceFeaturesString (const FeaturesType& Features,
965+ size_t NumColumns,
966+ int Indent = 4 ,
967+ int Spacing = 4 ,
968+ Uint32 Flags = ~0u )
969+ {
970+ VERIFY_EXPR (NumColumns > 0 );
971+
972+ std::vector<std::string> FeatureStrings;
973+ std::vector<size_t > ColWidth (NumColumns);
974+ FeaturesType::Enumerate (Features,
975+ [&](const char * Name, DEVICE_FEATURE_STATE State) {
976+ if ((Flags & (1u << State)) != 0u )
977+ {
978+ std::string FeatureStateStr{Name};
979+ FeatureStateStr += " : " ;
980+ FeatureStateStr += GetDeviceFeatureStateString (State);
981+
982+ size_t col = FeatureStrings.size () % NumColumns;
983+ ColWidth[col] = std::max (ColWidth[col], FeatureStateStr.length ());
984+
985+ FeatureStrings.emplace_back (std::move (FeatureStateStr));
986+ }
987+ return true ;
988+ });
989+
990+ std::stringstream ss;
991+ for (size_t i = 0 ; i < FeatureStrings.size ();)
992+ {
993+ for (size_t col = 0 ; col < NumColumns && i < FeatureStrings.size (); ++col, ++i)
994+ {
995+ if (col == 0 && i > 0 )
996+ ss << std::endl;
997+ ss << std::setw (col == 0 ? Indent : Spacing) << std::left << ' ' ;
998+ if (col + 1 < NumColumns && i + 1 < FeatureStrings.size ())
999+ ss << std::setw (static_cast <int >(ColWidth[col])) << std::left;
1000+ ss << FeatureStrings[i];
1001+ }
1002+ }
1003+
1004+ return ss.str ();
1005+ }
1006+
9531007} // namespace Diligent
0 commit comments