samples: Remove C++14 codes

This commit is contained in:
mocabe 2020-01-31 04:51:32 +09:00 committed by Markus Tavenrath
parent 1572c0b1ba
commit 32d0bc6843
5 changed files with 23 additions and 26 deletions

View File

@ -21,8 +21,6 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
using namespace std::string_literals;
static char const* AppName = "EnableValidationWithCallback"; static char const* AppName = "EnableValidationWithCallback";
static char const* EngineName = "Vulkan.hpp"; static char const* EngineName = "Vulkan.hpp";
@ -46,35 +44,35 @@ VkBool32 debugMessageFunc(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity
std::string message; std::string message;
message += vk::to_string(static_cast<vk::DebugUtilsMessageSeverityFlagBitsEXT>(messageSeverity)) + ": " + vk::to_string(static_cast<vk::DebugUtilsMessageTypeFlagsEXT>(messageTypes)) + ":\n"; message += vk::to_string(static_cast<vk::DebugUtilsMessageSeverityFlagBitsEXT>(messageSeverity)) + ": " + vk::to_string(static_cast<vk::DebugUtilsMessageTypeFlagsEXT>(messageTypes)) + ":\n";
message += "\t"s + "messageIDName = <" + pCallbackData->pMessageIdName + ">\n"; message += std::string("\t") + "messageIDName = <" + pCallbackData->pMessageIdName + ">\n";
message += "\t"s + "messageIdNumber = " + std::to_string(pCallbackData->messageIdNumber) + "\n"; message += std::string("\t") + "messageIdNumber = " + std::to_string(pCallbackData->messageIdNumber) + "\n";
message += "\t"s + "message = <" + pCallbackData->pMessage + ">\n"; message += std::string("\t") + "message = <" + pCallbackData->pMessage + ">\n";
if (0 < pCallbackData->queueLabelCount) if (0 < pCallbackData->queueLabelCount)
{ {
message += "\t"s + "Queue Labels:\n"; message += std::string("\t") + "Queue Labels:\n";
for (uint8_t i = 0; i < pCallbackData->queueLabelCount; i++) for (uint8_t i = 0; i < pCallbackData->queueLabelCount; i++)
{ {
message += "\t\t"s + "labelName = <" + pCallbackData->pQueueLabels[i].pLabelName + ">\n"; message += std::string("\t\t") + "labelName = <" + pCallbackData->pQueueLabels[i].pLabelName + ">\n";
} }
} }
if (0 < pCallbackData->cmdBufLabelCount) if (0 < pCallbackData->cmdBufLabelCount)
{ {
message += "\t"s + "CommandBuffer Labels:\n"; message += std::string("\t") + "CommandBuffer Labels:\n";
for (uint8_t i = 0; i < pCallbackData->cmdBufLabelCount; i++) for (uint8_t i = 0; i < pCallbackData->cmdBufLabelCount; i++)
{ {
message += "\t\t"s + "labelName = <" + pCallbackData->pCmdBufLabels[i].pLabelName + ">\n"; message += std::string("\t\t") + "labelName = <" + pCallbackData->pCmdBufLabels[i].pLabelName + ">\n";
} }
} }
if (0 < pCallbackData->objectCount) if (0 < pCallbackData->objectCount)
{ {
for (uint8_t i = 0; i < pCallbackData->objectCount; i++) for (uint8_t i = 0; i < pCallbackData->objectCount; i++)
{ {
message += "\t"s + "Object " + std::to_string(i) + "\n"; message += std::string("\t") + "Object " + std::to_string(i) + "\n";
message += "\t\t"s + "objectType = " + vk::to_string(static_cast<vk::ObjectType>(pCallbackData->pObjects[i].objectType)) + "\n"; message += std::string("\t\t") + "objectType = " + vk::to_string(static_cast<vk::ObjectType>(pCallbackData->pObjects[i].objectType)) + "\n";
message += "\t\t"s + "objectHandle = " + std::to_string(pCallbackData->pObjects[i].objectHandle) + "\n"; message += std::string("\t\t") + "objectHandle = " + std::to_string(pCallbackData->pObjects[i].objectHandle) + "\n";
if (pCallbackData->pObjects[i].pObjectName) if (pCallbackData->pObjects[i].pObjectName)
{ {
message += "\t\t"s + "objectName = <" + pCallbackData->pObjects[i].pObjectName + ">\n"; message += std::string("\t\t") + "objectName = <" + pCallbackData->pObjects[i].pObjectName + ">\n";
} }
} }
} }

View File

@ -42,7 +42,7 @@ int main(int /*argc*/, char ** /*argv*/)
// To use PUSH_DESCRIPTOR, you must also specify GET_PHYSICAL_DEVICE_PROPERTIES_2 // To use PUSH_DESCRIPTOR, you must also specify GET_PHYSICAL_DEVICE_PROPERTIES_2
std::vector<vk::ExtensionProperties> extensionProperties = vk::enumerateInstanceExtensionProperties(); std::vector<vk::ExtensionProperties> extensionProperties = vk::enumerateInstanceExtensionProperties();
if (std::find_if(extensionProperties.begin(), extensionProperties.end(), [](auto ep) { return (strcmp(ep.extensionName,VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME) == 0); }) == extensionProperties.end()) if (std::find_if(extensionProperties.begin(), extensionProperties.end(), [](vk::ExtensionProperties ep) { return (strcmp(ep.extensionName,VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME) == 0); }) == extensionProperties.end())
{ {
std::cout << "No GET_PHYSICAL_DEVICE_PROPERTIES_2 extension" << std::endl; std::cout << "No GET_PHYSICAL_DEVICE_PROPERTIES_2 extension" << std::endl;
return 0; return 0;
@ -60,7 +60,7 @@ int main(int /*argc*/, char ** /*argv*/)
// Once instance is created, need to make sure the extension is available // Once instance is created, need to make sure the extension is available
extensionProperties = physicalDevice.enumerateDeviceExtensionProperties(); extensionProperties = physicalDevice.enumerateDeviceExtensionProperties();
if (std::find_if(extensionProperties.begin(), extensionProperties.end(), [](auto ep) { return (strcmp(ep.extensionName,VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME) == 0); }) == extensionProperties.end()) if (std::find_if(extensionProperties.begin(), extensionProperties.end(), [](vk::ExtensionProperties ep) { return (strcmp(ep.extensionName,VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME) == 0); }) == extensionProperties.end())
{ {
std::cout << "No extension for push descriptors" << std::endl; std::cout << "No extension for push descriptors" << std::endl;
return 0; return 0;

View File

@ -83,8 +83,8 @@ AccelerationStructureData createAccelerationStructureData(vk::PhysicalDevice con
vk::AccelerationStructureMemoryRequirementsInfoNV objectRequirements(vk::AccelerationStructureMemoryRequirementsTypeNV::eObject, *accelerationStructureData.acclerationStructure); vk::AccelerationStructureMemoryRequirementsInfoNV objectRequirements(vk::AccelerationStructureMemoryRequirementsTypeNV::eObject, *accelerationStructureData.acclerationStructure);
vk::DeviceSize resultSizeInBytes = device->getAccelerationStructureMemoryRequirementsNV(objectRequirements).memoryRequirements.size; vk::DeviceSize resultSizeInBytes = device->getAccelerationStructureMemoryRequirementsNV(objectRequirements).memoryRequirements.size;
assert(0 < resultSizeInBytes); assert(0 < resultSizeInBytes);
accelerationStructureData.resultBufferData = std::make_unique<vk::su::BufferData>(physicalDevice, device, resultSizeInBytes, vk::BufferUsageFlagBits::eRayTracingNV, accelerationStructureData.resultBufferData = std::unique_ptr<vk::su::BufferData>(new vk::su::BufferData(physicalDevice, device, resultSizeInBytes, vk::BufferUsageFlagBits::eRayTracingNV,
vk::MemoryPropertyFlagBits::eDeviceLocal); vk::MemoryPropertyFlagBits::eDeviceLocal));
vk::AccelerationStructureMemoryRequirementsInfoNV buildScratchRequirements(vk::AccelerationStructureMemoryRequirementsTypeNV::eBuildScratch, vk::AccelerationStructureMemoryRequirementsInfoNV buildScratchRequirements(vk::AccelerationStructureMemoryRequirementsTypeNV::eBuildScratch,
*accelerationStructureData.acclerationStructure); *accelerationStructureData.acclerationStructure);
@ -95,13 +95,13 @@ AccelerationStructureData createAccelerationStructureData(vk::PhysicalDevice con
device->getAccelerationStructureMemoryRequirementsNV(updateScratchRequirements).memoryRequirements.size); device->getAccelerationStructureMemoryRequirementsNV(updateScratchRequirements).memoryRequirements.size);
assert(0 < scratchSizeInBytes); assert(0 < scratchSizeInBytes);
accelerationStructureData.scratchBufferData = std::make_unique<vk::su::BufferData>(physicalDevice, device, scratchSizeInBytes, vk::BufferUsageFlagBits::eRayTracingNV, accelerationStructureData.scratchBufferData = std::unique_ptr<vk::su::BufferData>(new vk::su::BufferData(physicalDevice, device, scratchSizeInBytes, vk::BufferUsageFlagBits::eRayTracingNV,
vk::MemoryPropertyFlagBits::eDeviceLocal); vk::MemoryPropertyFlagBits::eDeviceLocal));
if (!instances.empty()) if (!instances.empty())
{ {
accelerationStructureData.instanceBufferData = std::make_unique<vk::su::BufferData>(physicalDevice, device, instances.size() * sizeof(GeometryInstanceData), accelerationStructureData.instanceBufferData = std::unique_ptr<vk::su::BufferData>(new vk::su::BufferData(physicalDevice, device, instances.size() * sizeof(GeometryInstanceData),
vk::BufferUsageFlagBits::eRayTracingNV); vk::BufferUsageFlagBits::eRayTracingNV));
std::vector<GeometryInstanceData> geometryInstanceData; std::vector<GeometryInstanceData> geometryInstanceData;
for(size_t i = 0; i < instances.size(); i++) for(size_t i = 0; i < instances.size(); i++)

View File

@ -41,4 +41,3 @@ target_link_libraries(utils PUBLIC glslang)
target_link_libraries(utils PUBLIC glslang-default-resource-limits) target_link_libraries(utils PUBLIC glslang-default-resource-limits)
target_link_libraries(utils PUBLIC SPIRV) target_link_libraries(utils PUBLIC SPIRV)
target_compile_definitions(utils PUBLIC VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1) target_compile_definitions(utils PUBLIC VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1)
target_compile_features(utils PUBLIC cxx_std_14)

View File

@ -448,7 +448,7 @@ namespace vk
for (size_t i = 0; i < sizeof(requestedFormats) / sizeof(requestedFormats[0]); i++) for (size_t i = 0; i < sizeof(requestedFormats) / sizeof(requestedFormats[0]); i++)
{ {
vk::Format requestedFormat = requestedFormats[i]; vk::Format requestedFormat = requestedFormats[i];
auto it = std::find_if(formats.begin(), formats.end(), [requestedFormat, requestedColorSpace](auto const& f) { return (f.format == requestedFormat) && (f.colorSpace == requestedColorSpace); }); auto it = std::find_if(formats.begin(), formats.end(), [requestedFormat, requestedColorSpace](vk::SurfaceFormatKHR const& f) { return (f.format == requestedFormat) && (f.colorSpace == requestedColorSpace); });
if (it != formats.end()) if (it != formats.end())
{ {
pickedFormat = *it; pickedFormat = *it;
@ -802,7 +802,7 @@ namespace vk
if (needsStaging) if (needsStaging)
{ {
assert((formatProperties.optimalTilingFeatures & formatFeatureFlags) == formatFeatureFlags); assert((formatProperties.optimalTilingFeatures & formatFeatureFlags) == formatFeatureFlags);
stagingBufferData = std::make_unique<BufferData>(physicalDevice, device, extent.width * extent.height * 4, vk::BufferUsageFlagBits::eTransferSrc); stagingBufferData = std::unique_ptr<BufferData>(new BufferData(physicalDevice, device, extent.width * extent.height * 4, vk::BufferUsageFlagBits::eTransferSrc));
imageTiling = vk::ImageTiling::eOptimal; imageTiling = vk::ImageTiling::eOptimal;
usageFlags |= vk::ImageUsageFlagBits::eTransferDst; usageFlags |= vk::ImageUsageFlagBits::eTransferDst;
initialLayout = vk::ImageLayout::eUndefined; initialLayout = vk::ImageLayout::eUndefined;
@ -813,8 +813,8 @@ namespace vk
initialLayout = vk::ImageLayout::ePreinitialized; initialLayout = vk::ImageLayout::ePreinitialized;
requirements = vk::MemoryPropertyFlagBits::eHostCoherent | vk::MemoryPropertyFlagBits::eHostVisible; requirements = vk::MemoryPropertyFlagBits::eHostCoherent | vk::MemoryPropertyFlagBits::eHostVisible;
} }
imageData = std::make_unique<ImageData>(physicalDevice, device, format, extent, imageTiling, usageFlags | vk::ImageUsageFlagBits::eSampled, initialLayout, requirements, imageData = std::unique_ptr<ImageData>(new ImageData(physicalDevice, device, format, extent, imageTiling, usageFlags | vk::ImageUsageFlagBits::eSampled, initialLayout, requirements,
vk::ImageAspectFlagBits::eColor); vk::ImageAspectFlagBits::eColor));
textureSampler = device->createSamplerUnique(vk::SamplerCreateInfo(vk::SamplerCreateFlags(), vk::Filter::eLinear, vk::Filter::eLinear, vk::SamplerMipmapMode::eLinear, textureSampler = device->createSamplerUnique(vk::SamplerCreateInfo(vk::SamplerCreateFlags(), vk::Filter::eLinear, vk::Filter::eLinear, vk::SamplerMipmapMode::eLinear,
vk::SamplerAddressMode::eRepeat, vk::SamplerAddressMode::eRepeat, vk::SamplerAddressMode::eRepeat, 0.0f, anisotropyEnable, vk::SamplerAddressMode::eRepeat, vk::SamplerAddressMode::eRepeat, vk::SamplerAddressMode::eRepeat, 0.0f, anisotropyEnable,