From 13b12dd55268291f01d450c5b348c559cc1ab293 Mon Sep 17 00:00:00 2001 From: Alejandro Saucedo Date: Sun, 9 Aug 2020 15:37:13 +0100 Subject: [PATCH] Reformat --- .gitignore | 2 ++ Makefile | 2 +- src/main.cpp | 70 +++++++++++++++++++++++++++++++++------------------- 3 files changed, 47 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index 5524ea4b1..4830267d1 100644 --- a/.gitignore +++ b/.gitignore @@ -173,4 +173,6 @@ compile_commands.json # Project files bin/ +external/boost/ +tmp/ diff --git a/Makefile b/Makefile index 3709a3fa1..2e40b9329 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ SCMP=/c/VulkanSDK/1.2.141.2/Bin32/glslangValidator.exe ####### Main Target Rules ####### -build: build_shaders +build: format build_shaders $(CC) \ -Wall \ src/* \ diff --git a/src/main.cpp b/src/main.cpp index 8bd2ca3d7..d650ff4d9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -91,11 +91,13 @@ class VulkanExample memReqs.memoryTypeBits >>= 1; } assert(memTypeFound); - VK_CHECK_RESULT(vkAllocateMemory(this->device, &memAlloc, nullptr, memory)); + VK_CHECK_RESULT( + vkAllocateMemory(this->device, &memAlloc, nullptr, memory)); if (data != nullptr) { void* mapped; - VK_CHECK_RESULT(vkMapMemory(this->device, *memory, 0, size, 0, &mapped)); + VK_CHECK_RESULT( + vkMapMemory(this->device, *memory, 0, size, 0, &mapped)); memcpy(mapped, data, size); vkUnmapMemory(this->device, *memory); } @@ -177,8 +179,11 @@ class VulkanExample vkGetInstanceProcAddr(this->instance, "vkCreateDebugReportCallbackEXT")); assert(vkCreateDebugReportCallbackEXT); - VK_CHECK_RESULT(vkCreateDebugReportCallbackEXT( - this->instance, &debugReportCreateInfo, nullptr, &debugReportCallback)); + VK_CHECK_RESULT( + vkCreateDebugReportCallbackEXT(this->instance, + &debugReportCreateInfo, + nullptr, + &debugReportCallback)); } #endif @@ -209,8 +214,9 @@ class VulkanExample std::vector queueFamilyProperties( queueFamilyCount); - vkGetPhysicalDeviceQueueFamilyProperties( - this->physicalDevice, &queueFamilyCount, queueFamilyProperties.data()); + vkGetPhysicalDeviceQueueFamilyProperties(this->physicalDevice, + &queueFamilyCount, + queueFamilyProperties.data()); for (uint32_t i = 0; i < static_cast(queueFamilyProperties.size()); @@ -283,8 +289,10 @@ class VulkanExample VkDescriptorPoolCreateInfo descriptorPoolInfo = vks::initializers::descriptorPoolCreateInfo( static_cast(poolSizes.size()), poolSizes.data(), 1); - VK_CHECK_RESULT(vkCreateDescriptorPool( - this->device, &descriptorPoolInfo, nullptr, &this->descriptorPool)); + VK_CHECK_RESULT(vkCreateDescriptorPool(this->device, + &descriptorPoolInfo, + nullptr, + &this->descriptorPool)); std::vector setLayoutBindings = { vks::initializers::descriptorSetLayoutBinding( @@ -295,20 +303,25 @@ class VulkanExample VkDescriptorSetLayoutCreateInfo descriptorLayout = vks::initializers::descriptorSetLayoutCreateInfo( setLayoutBindings); - VK_CHECK_RESULT(vkCreateDescriptorSetLayout( - this->device, &descriptorLayout, nullptr, &this->descriptorSetLayout)); + VK_CHECK_RESULT( + vkCreateDescriptorSetLayout(this->device, + &descriptorLayout, + nullptr, + &this->descriptorSetLayout)); VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo = - vks::initializers::pipelineLayoutCreateInfo(&this->descriptorSetLayout, - 1); - VK_CHECK_RESULT(vkCreatePipelineLayout( - this->device, &pipelineLayoutCreateInfo, nullptr, &this->pipelineLayout)); + vks::initializers::pipelineLayoutCreateInfo( + &this->descriptorSetLayout, 1); + VK_CHECK_RESULT(vkCreatePipelineLayout(this->device, + &pipelineLayoutCreateInfo, + nullptr, + &this->pipelineLayout)); VkDescriptorSetAllocateInfo allocInfo = vks::initializers::descriptorSetAllocateInfo( this->descriptorPool, &this->descriptorSetLayout, 1); - VK_CHECK_RESULT( - vkAllocateDescriptorSets(this->device, &allocInfo, &this->descriptorSet)); + VK_CHECK_RESULT(vkAllocateDescriptorSets( + this->device, &allocInfo, &this->descriptorSet)); VkDescriptorBufferInfo bufferDescriptor = { deviceBuffer, 0, @@ -388,7 +401,7 @@ class VulkanExample cmdPoolInfo.queueFamilyIndex = this->queueFamilyIndex; cmdPoolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; VK_CHECK_RESULT(vkCreateCommandPool( - this->device, &cmdPoolInfo, nullptr, &this->commandPool)); + this->device, &cmdPoolInfo, nullptr, &this->commandPool)); // Create a command buffer for compute operations VkCommandBufferAllocateInfo cmdBufAllocateInfo = @@ -400,8 +413,8 @@ class VulkanExample // Fence for compute CB sync VkFenceCreateInfo fenceCreateInfo = vks::initializers::fenceCreateInfo(VK_FENCE_CREATE_SIGNALED_BIT); - VK_CHECK_RESULT( - vkCreateFence(this->device, &fenceCreateInfo, nullptr, &this->fence)); + VK_CHECK_RESULT(vkCreateFence( + this->device, &fenceCreateInfo, nullptr, &this->fence)); } { @@ -424,11 +437,13 @@ class VulkanExample VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); - VK_CHECK_RESULT(vkBeginCommandBuffer(this->commandBuffer, &cmdBufInfo)); + VK_CHECK_RESULT( + vkBeginCommandBuffer(this->commandBuffer, &cmdBufInfo)); VkBufferCopy copyRegion = {}; copyRegion.size = bufferSize; - vkCmdCopyBuffer(this->commandBuffer, hostBuffer, deviceBuffer, 1, ©Region); + vkCmdCopyBuffer( + this->commandBuffer, hostBuffer, deviceBuffer, 1, ©Region); // Barrier to ensure that input buffer transfer is finished before // compute shader reads from it @@ -452,8 +467,9 @@ class VulkanExample 0, nullptr); - vkCmdBindPipeline( - this->commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, this->pipeline); + vkCmdBindPipeline(this->commandBuffer, + VK_PIPELINE_BIND_POINT_COMPUTE, + this->pipeline); vkCmdBindDescriptorSets(this->commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, @@ -522,9 +538,10 @@ class VulkanExample computeSubmitInfo.pWaitDstStageMask = &waitStageMask; computeSubmitInfo.commandBufferCount = 1; computeSubmitInfo.pCommandBuffers = &this->commandBuffer; - VK_CHECK_RESULT(vkQueueSubmit(this->queue, 1, &computeSubmitInfo, this->fence)); VK_CHECK_RESULT( - vkWaitForFences(this->device, 1, &this->fence, VK_TRUE, UINT64_MAX)); + vkQueueSubmit(this->queue, 1, &computeSubmitInfo, this->fence)); + VK_CHECK_RESULT(vkWaitForFences( + this->device, 1, &this->fence, VK_TRUE, UINT64_MAX)); // Make this->device writes visible to the host void* mapped; @@ -566,7 +583,8 @@ class VulkanExample ~VulkanExample() { vkDestroyPipelineLayout(this->device, this->pipelineLayout, nullptr); - vkDestroyDescriptorSetLayout(this->device, this->descriptorSetLayout, nullptr); + vkDestroyDescriptorSetLayout( + this->device, this->descriptorSetLayout, nullptr); vkDestroyDescriptorPool(this->device, this->descriptorPool, nullptr); vkDestroyPipeline(this->device, this->pipeline, nullptr); vkDestroyPipelineCache(this->device, this->pipelineCache, nullptr);