Move the vk::to_string functions into a separate header vulkan_to_string.hpp.

This commit is contained in:
asuessenbach
2022-07-26 11:13:43 +02:00
parent 0efb7e7954
commit 3aae157e5b
26 changed files with 8026 additions and 10566 deletions

View File

@@ -16,64 +16,15 @@
// Get memory properties per physical device.
#include "../utils/utils.hpp"
#include "vulkan/vulkan.hpp"
#include <sstream>
#include <vector>
#include <vulkan/vulkan.hpp>
#include <vulkan/vulkan_to_string.hpp>
static char const * AppName = "PhysicalDeviceMemoryProperties";
static char const * EngineName = "Vulkan.hpp";
#if defined( VULKAN_HPP_NO_TO_STRING )
namespace local
{
std::string to_string( vk::MemoryHeapFlags value )
{
if ( !value )
return "{}";
std::string result;
if ( value & vk::MemoryHeapFlagBits::eDeviceLocal )
result += "DeviceLocal | ";
if ( value & vk::MemoryHeapFlagBits::eMultiInstance )
result += "MultiInstance | ";
return "{ " + result.substr( 0, result.size() - 3 ) + " }";
}
std::string to_string( vk::MemoryPropertyFlags value )
{
if ( !value )
return "{}";
std::string result;
if ( value & vk::MemoryPropertyFlagBits::eDeviceLocal )
result += "DeviceLocal | ";
if ( value & vk::MemoryPropertyFlagBits::eHostVisible )
result += "HostVisible | ";
if ( value & vk::MemoryPropertyFlagBits::eHostCoherent )
result += "HostCoherent | ";
if ( value & vk::MemoryPropertyFlagBits::eHostCached )
result += "HostCached | ";
if ( value & vk::MemoryPropertyFlagBits::eLazilyAllocated )
result += "LazilyAllocated | ";
if ( value & vk::MemoryPropertyFlagBits::eProtected )
result += "Protected | ";
if ( value & vk::MemoryPropertyFlagBits::eDeviceCoherentAMD )
result += "DeviceCoherentAMD | ";
if ( value & vk::MemoryPropertyFlagBits::eDeviceUncachedAMD )
result += "DeviceUncachedAMD | ";
if ( value & vk::MemoryPropertyFlagBits::eRdmaCapableNV )
result += "RdmaCapableNV | ";
return "{ " + result.substr( 0, result.size() - 3 ) + " }";
}
} // namespace local
using local::to_string;
#else
using vk::to_string;
#endif
std::string formatSize( vk::DeviceSize size )
{
std::ostringstream oss;
@@ -125,7 +76,7 @@ int main( int /*argc*/, char ** /*argv*/ )
for ( uint32_t j = 0; j < memoryProperties.memoryHeapCount; j++ )
{
std::cout << " " << j << ": size = " << formatSize( memoryProperties.memoryHeaps[j].size )
<< ", flags = " << to_string( memoryProperties.memoryHeaps[j].flags ) << "\n";
<< ", flags = " << vk::to_string( memoryProperties.memoryHeaps[j].flags ) << "\n";
if ( containsMemoryBudget )
{
std::cout << " heapBudget = " << formatSize( memoryBudgetProperties.heapBudget[j] )
@@ -136,7 +87,7 @@ int main( int /*argc*/, char ** /*argv*/ )
for ( uint32_t j = 0; j < memoryProperties.memoryTypeCount; j++ )
{
std::cout << " " << j << ": heapIndex = " << memoryProperties.memoryTypes[j].heapIndex
<< ", flags = " << to_string( memoryProperties.memoryTypes[j].propertyFlags ) << "\n";
<< ", flags = " << vk::to_string( memoryProperties.memoryTypes[j].propertyFlags ) << "\n";
}
}