Introduce usage of clang-format to format vulkan.hpp and the other sources.
This commit is contained in:
@@ -18,61 +18,73 @@
|
||||
#include "../utils/math.hpp"
|
||||
#include "../utils/utils.hpp"
|
||||
#include "vulkan/vulkan.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#define GLM_FORCE_RADIANS
|
||||
#pragma warning(disable:4201) // disable warning C4201: nonstandard extension used: nameless struct/union; needed to get glm/detail/type_vec?.hpp without warnings
|
||||
#pragma warning( disable : 4201 ) // disable warning C4201: nonstandard extension used: nameless struct/union; needed
|
||||
// to get glm/detail/type_vec?.hpp without warnings
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
static char const* AppName = "09_InitDescriptorSet";
|
||||
static char const* EngineName = "Vulkan.hpp";
|
||||
static char const * AppName = "09_InitDescriptorSet";
|
||||
static char const * EngineName = "Vulkan.hpp";
|
||||
|
||||
int main(int /*argc*/, char ** /*argv*/)
|
||||
int main( int /*argc*/, char ** /*argv*/ )
|
||||
{
|
||||
try
|
||||
{
|
||||
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName);
|
||||
#if !defined(NDEBUG)
|
||||
vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger(instance);
|
||||
vk::UniqueInstance instance = vk::su::createInstance( AppName, EngineName );
|
||||
#if !defined( NDEBUG )
|
||||
vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger( instance );
|
||||
#endif
|
||||
|
||||
vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front();
|
||||
|
||||
vk::UniqueDevice device = vk::su::createDevice(physicalDevice, vk::su::findGraphicsQueueFamilyIndex(physicalDevice.getQueueFamilyProperties()));
|
||||
vk::UniqueDevice device = vk::su::createDevice(
|
||||
physicalDevice, vk::su::findGraphicsQueueFamilyIndex( physicalDevice.getQueueFamilyProperties() ) );
|
||||
|
||||
vk::su::BufferData uniformBufferData(physicalDevice, device, sizeof(glm::mat4x4), vk::BufferUsageFlagBits::eUniformBuffer);
|
||||
vk::su::copyToDevice(device, uniformBufferData.deviceMemory, vk::su::createModelViewProjectionClipMatrix(vk::Extent2D(0, 0)));
|
||||
vk::su::BufferData uniformBufferData(
|
||||
physicalDevice, device, sizeof( glm::mat4x4 ), vk::BufferUsageFlagBits::eUniformBuffer );
|
||||
vk::su::copyToDevice(
|
||||
device, uniformBufferData.deviceMemory, vk::su::createModelViewProjectionClipMatrix( vk::Extent2D( 0, 0 ) ) );
|
||||
|
||||
vk::UniqueDescriptorSetLayout descriptorSetLayout = vk::su::createDescriptorSetLayout(device, { {vk::DescriptorType::eUniformBuffer, 1, vk::ShaderStageFlagBits::eVertex} });
|
||||
vk::UniqueDescriptorSetLayout descriptorSetLayout = vk::su::createDescriptorSetLayout(
|
||||
device, { { vk::DescriptorType::eUniformBuffer, 1, vk::ShaderStageFlagBits::eVertex } } );
|
||||
|
||||
/* VULKAN_HPP_KEY_START */
|
||||
|
||||
// create a descriptor pool
|
||||
vk::DescriptorPoolSize poolSize(vk::DescriptorType::eUniformBuffer, 1);
|
||||
vk::UniqueDescriptorPool descriptorPool = device->createDescriptorPoolUnique(vk::DescriptorPoolCreateInfo(vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet, 1, 1, &poolSize));
|
||||
vk::DescriptorPoolSize poolSize( vk::DescriptorType::eUniformBuffer, 1 );
|
||||
vk::UniqueDescriptorPool descriptorPool = device->createDescriptorPoolUnique(
|
||||
vk::DescriptorPoolCreateInfo( vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet, 1, 1, &poolSize ) );
|
||||
|
||||
// allocate a descriptor set
|
||||
vk::UniqueDescriptorSet descriptorSet = std::move(device->allocateDescriptorSetsUnique(vk::DescriptorSetAllocateInfo(*descriptorPool, 1, &*descriptorSetLayout)).front());
|
||||
vk::UniqueDescriptorSet descriptorSet = std::move(
|
||||
device->allocateDescriptorSetsUnique( vk::DescriptorSetAllocateInfo( *descriptorPool, 1, &*descriptorSetLayout ) )
|
||||
.front() );
|
||||
|
||||
vk::DescriptorBufferInfo descriptorBufferInfo(uniformBufferData.buffer.get(), 0, sizeof(glm::mat4x4));
|
||||
device->updateDescriptorSets(vk::WriteDescriptorSet(descriptorSet.get(), 0, 0, 1, vk::DescriptorType::eUniformBuffer, nullptr, &descriptorBufferInfo), {});
|
||||
vk::DescriptorBufferInfo descriptorBufferInfo( uniformBufferData.buffer.get(), 0, sizeof( glm::mat4x4 ) );
|
||||
device->updateDescriptorSets(
|
||||
vk::WriteDescriptorSet(
|
||||
descriptorSet.get(), 0, 0, 1, vk::DescriptorType::eUniformBuffer, nullptr, &descriptorBufferInfo ),
|
||||
{} );
|
||||
|
||||
/* VULKAN_HPP_KEY_END */
|
||||
}
|
||||
catch (vk::SystemError& err)
|
||||
catch ( vk::SystemError & err )
|
||||
{
|
||||
std::cout << "vk::SystemError: " << err.what() << std::endl;
|
||||
exit(-1);
|
||||
exit( -1 );
|
||||
}
|
||||
catch (std::runtime_error& err)
|
||||
catch ( std::runtime_error & err )
|
||||
{
|
||||
std::cout << "std::runtime_error: " << err.what() << std::endl;
|
||||
exit(-1);
|
||||
exit( -1 );
|
||||
}
|
||||
catch (...)
|
||||
catch ( ... )
|
||||
{
|
||||
std::cout << "unknown error\n";
|
||||
exit(-1);
|
||||
exit( -1 );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user