Skip to content

Commit a30f1b3

Browse files
Graphics Accessories: added GetDeviceFeaturesString function
1 parent bfc4eba commit a30f1b3

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

Graphics/GraphicsAccessories/interface/GraphicsAccessories.hpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,4 +950,58 @@ SHADER_STATUS GetPipelineStateCreateInfoShadersStatus(const CreateInfoType& CI,
950950

951951
size_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

Graphics/GraphicsEngineVulkan/include/VulkanTypeConversions.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ DeviceFeatures VkFeaturesToDeviceFeatures(uint32_t
113113
DEVICE_FEATURE_STATE OptionalState = DEVICE_FEATURE_STATE_ENABLED);
114114

115115
DeviceFeaturesVk PhysicalDeviceFeaturesToDeviceFeaturesVk(const VulkanUtilities::VulkanPhysicalDevice::ExtensionFeatures& ExtFeatures,
116-
DEVICE_FEATURE_STATE OptionalState);
116+
DEVICE_FEATURE_STATE OptionalState = DEVICE_FEATURE_STATE_ENABLED);
117117

118118
SPARSE_TEXTURE_FLAGS VkSparseImageFormatFlagsToSparseTextureFlags(VkSparseImageFormatFlags Flags);
119119

0 commit comments

Comments
 (0)