Index: vulkan-game.cpp
===================================================================
--- vulkan-game.cpp	(revision 1abebc104018213f499c401642d6470cdfa7af9a)
+++ vulkan-game.cpp	(revision c163d8158510ee4d7f382dca6d405e0fbecdf4f3)
@@ -135,8 +135,8 @@
    createBufferSet(sizeof(UBO_VP_mats),
       VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-      uniformBuffers_modelPipeline, uniformBuffersMemory_modelPipeline, uniformBufferInfoList_modelPipeline);
+      uniformBuffers_modelPipeline);
 
    modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
-      VK_SHADER_STAGE_VERTEX_BIT, &uniformBufferInfoList_modelPipeline);
+      VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_modelPipeline.infoSet);
    modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
       VK_SHADER_STAGE_VERTEX_BIT, &storageBuffers_modelPipeline.infoSet);
@@ -206,8 +206,8 @@
    createBufferSet(sizeof(UBO_VP_mats),
       VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-      uniformBuffers_shipPipeline, uniformBuffersMemory_shipPipeline, uniformBufferInfoList_shipPipeline);
+      uniformBuffers_shipPipeline);
 
    shipPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
-      VK_SHADER_STAGE_VERTEX_BIT, &uniformBufferInfoList_shipPipeline);
+      VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_shipPipeline.infoSet);
    shipPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
       VK_SHADER_STAGE_VERTEX_BIT, &storageBuffers_shipPipeline.infoSet);
@@ -469,8 +469,8 @@
    createBufferSet(sizeof(UBO_VP_mats),
       VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-      uniformBuffers_asteroidPipeline, uniformBuffersMemory_asteroidPipeline, uniformBufferInfoList_asteroidPipeline);
+      uniformBuffers_asteroidPipeline);
 
    asteroidPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
-      VK_SHADER_STAGE_VERTEX_BIT, &uniformBufferInfoList_asteroidPipeline);
+      VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_asteroidPipeline.infoSet);
    asteroidPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
       VK_SHADER_STAGE_VERTEX_BIT, &storageBuffers_asteroidPipeline.infoSet);
@@ -487,8 +487,8 @@
    createBufferSet(sizeof(UBO_VP_mats),
       VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-      uniformBuffers_laserPipeline, uniformBuffersMemory_laserPipeline, uniformBufferInfoList_laserPipeline);
+      uniformBuffers_laserPipeline);
 
    laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
-      VK_SHADER_STAGE_VERTEX_BIT, &uniformBufferInfoList_laserPipeline);
+      VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_laserPipeline.infoSet);
    laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
       VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, &storageBuffers_laserPipeline.infoSet);
@@ -507,8 +507,8 @@
    createBufferSet(sizeof(UBO_Explosion),
       VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-      uniformBuffers_explosionPipeline, uniformBuffersMemory_explosionPipeline, uniformBufferInfoList_explosionPipeline);
+      uniformBuffers_explosionPipeline);
 
    explosionPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
-      VK_SHADER_STAGE_VERTEX_BIT, &uniformBufferInfoList_explosionPipeline);
+      VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_explosionPipeline.infoSet);
    explosionPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
       VK_SHADER_STAGE_VERTEX_BIT, &storageBuffers_explosionPipeline.infoSet);
@@ -624,6 +624,5 @@
       VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
       VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-      storageBuffers_modelPipeline.buffers, storageBuffers_modelPipeline.memory,
-      storageBuffers_modelPipeline.infoSet);
+      storageBuffers_modelPipeline);
 
    shipPipeline = GraphicsPipeline_Vulkan<ModelVertex>(
@@ -634,6 +633,5 @@
       VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
       VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-      storageBuffers_shipPipeline.buffers, storageBuffers_shipPipeline.memory,
-      storageBuffers_shipPipeline.infoSet);
+      storageBuffers_shipPipeline);
 
    asteroidPipeline = GraphicsPipeline_Vulkan<ModelVertex>(
@@ -644,6 +642,5 @@
       VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
       VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-      storageBuffers_asteroidPipeline.buffers, storageBuffers_asteroidPipeline.memory,
-      storageBuffers_asteroidPipeline.infoSet);
+      storageBuffers_asteroidPipeline);
 
    laserPipeline = GraphicsPipeline_Vulkan<LaserVertex>(
@@ -654,6 +651,5 @@
       VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
       VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-      storageBuffers_laserPipeline.buffers, storageBuffers_laserPipeline.memory,
-      storageBuffers_laserPipeline.infoSet);
+      storageBuffers_laserPipeline);
 
    explosionPipeline = GraphicsPipeline_Vulkan<ExplosionVertex>(
@@ -665,6 +661,5 @@
       VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
       VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-      storageBuffers_explosionPipeline.buffers, storageBuffers_explosionPipeline.memory,
-      storageBuffers_explosionPipeline.infoSet);
+      storageBuffers_explosionPipeline);
 }
 
@@ -1166,13 +1161,13 @@
    explosion_UBO.cur_time = curTime;
 
-   VulkanUtils::copyDataToMemory(device, object_VP_mats, uniformBuffersMemory_modelPipeline[imageIndex], 0);
-
-   VulkanUtils::copyDataToMemory(device, ship_VP_mats, uniformBuffersMemory_shipPipeline[imageIndex], 0);
-
-   VulkanUtils::copyDataToMemory(device, asteroid_VP_mats, uniformBuffersMemory_asteroidPipeline[imageIndex], 0);
-
-   VulkanUtils::copyDataToMemory(device, laser_VP_mats, uniformBuffersMemory_laserPipeline[imageIndex], 0);
-
-   VulkanUtils::copyDataToMemory(device, explosion_UBO, uniformBuffersMemory_explosionPipeline[imageIndex], 0);
+   VulkanUtils::copyDataToMemory(device, object_VP_mats, uniformBuffers_modelPipeline.memory[imageIndex], 0);
+
+   VulkanUtils::copyDataToMemory(device, ship_VP_mats, uniformBuffers_shipPipeline.memory[imageIndex], 0);
+
+   VulkanUtils::copyDataToMemory(device, asteroid_VP_mats, uniformBuffers_asteroidPipeline.memory[imageIndex], 0);
+
+   VulkanUtils::copyDataToMemory(device, laser_VP_mats, uniformBuffers_laserPipeline.memory[imageIndex], 0);
+
+   VulkanUtils::copyDataToMemory(device, explosion_UBO, uniformBuffers_explosionPipeline.memory[imageIndex], 0);
 }
 
@@ -1943,16 +1938,15 @@
 
 void VulkanGame::createBufferSet(VkDeviceSize bufferSize, VkBufferUsageFlags flags, VkMemoryPropertyFlags properties,
-                                 vector<VkBuffer>& buffers, vector<VkDeviceMemory>& buffersMemory,
-                                 vector<VkDescriptorBufferInfo>& bufferInfoList) {
-   buffers.resize(swapChainImageCount);
-   buffersMemory.resize(swapChainImageCount);
-   bufferInfoList.resize(swapChainImageCount);
+                                 BufferSet& set) {
+   set.buffers.resize(swapChainImageCount);
+   set.memory.resize(swapChainImageCount);
+   set.infoSet.resize(swapChainImageCount);
 
    for (size_t i = 0; i < swapChainImageCount; i++) {
-      VulkanUtils::createBuffer(device, physicalDevice, bufferSize, flags, properties, buffers[i], buffersMemory[i]);
-
-      bufferInfoList[i].buffer = buffers[i];
-      bufferInfoList[i].offset = 0; // This is the offset from the start of the buffer, so always 0 for now
-      bufferInfoList[i].range = bufferSize; // Size of the update starting from offset, or VK_WHOLE_SIZE
+      VulkanUtils::createBuffer(device, physicalDevice, bufferSize, flags, properties, set.buffers[i], set.memory[i]);
+
+      set.infoSet[i].buffer = set.buffers[i];
+      set.infoSet[i].offset = 0; // This is the offset from the start of the buffer, so always 0 for now
+      set.infoSet[i].range = bufferSize; // Size of the update starting from offset, or VK_WHOLE_SIZE
    }
 }
@@ -2228,5 +2222,5 @@
    createBufferSet(sizeof(UBO_VP_mats),
       VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-      uniformBuffers_modelPipeline, uniformBuffersMemory_modelPipeline, uniformBufferInfoList_modelPipeline);
+      uniformBuffers_modelPipeline);
 
    modelPipeline.updateRenderPass(renderPass);
@@ -2237,5 +2231,5 @@
    createBufferSet(sizeof(UBO_VP_mats),
       VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-      uniformBuffers_shipPipeline, uniformBuffersMemory_shipPipeline, uniformBufferInfoList_shipPipeline);
+      uniformBuffers_shipPipeline);
 
    shipPipeline.updateRenderPass(renderPass);
@@ -2246,5 +2240,5 @@
    createBufferSet(sizeof(UBO_VP_mats),
       VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-      uniformBuffers_asteroidPipeline, uniformBuffersMemory_asteroidPipeline, uniformBufferInfoList_asteroidPipeline);
+      uniformBuffers_asteroidPipeline);
 
    asteroidPipeline.updateRenderPass(renderPass);
@@ -2255,5 +2249,5 @@
    createBufferSet(sizeof(UBO_VP_mats),
       VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-      uniformBuffers_laserPipeline, uniformBuffersMemory_laserPipeline, uniformBufferInfoList_laserPipeline);
+      uniformBuffers_laserPipeline);
 
    laserPipeline.updateRenderPass(renderPass);
@@ -2264,5 +2258,5 @@
    createBufferSet(sizeof(UBO_Explosion),
       VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-      uniformBuffers_explosionPipeline, uniformBuffersMemory_explosionPipeline, uniformBufferInfoList_explosionPipeline);
+      uniformBuffers_explosionPipeline);
 
    explosionPipeline.updateRenderPass(renderPass);
@@ -2292,27 +2286,27 @@
    explosionPipeline.cleanup();
 
-   for (size_t i = 0; i < uniformBuffers_modelPipeline.size(); i++) {
-      vkDestroyBuffer(device, uniformBuffers_modelPipeline[i], nullptr);
-      vkFreeMemory(device, uniformBuffersMemory_modelPipeline[i], nullptr);
-   }
-
-   for (size_t i = 0; i < uniformBuffers_shipPipeline.size(); i++) {
-      vkDestroyBuffer(device, uniformBuffers_shipPipeline[i], nullptr);
-      vkFreeMemory(device, uniformBuffersMemory_shipPipeline[i], nullptr);
-   }
-
-   for (size_t i = 0; i < uniformBuffers_asteroidPipeline.size(); i++) {
-      vkDestroyBuffer(device, uniformBuffers_asteroidPipeline[i], nullptr);
-      vkFreeMemory(device, uniformBuffersMemory_asteroidPipeline[i], nullptr);
-   }
-
-   for (size_t i = 0; i < uniformBuffers_laserPipeline.size(); i++) {
-      vkDestroyBuffer(device, uniformBuffers_laserPipeline[i], nullptr);
-      vkFreeMemory(device, uniformBuffersMemory_laserPipeline[i], nullptr);
-   }
-
-   for (size_t i = 0; i < uniformBuffers_explosionPipeline.size(); i++) {
-      vkDestroyBuffer(device, uniformBuffers_explosionPipeline[i], nullptr);
-      vkFreeMemory(device, uniformBuffersMemory_explosionPipeline[i], nullptr);
+   for (size_t i = 0; i < uniformBuffers_modelPipeline.buffers.size(); i++) {
+      vkDestroyBuffer(device, uniformBuffers_modelPipeline.buffers[i], nullptr);
+      vkFreeMemory(device, uniformBuffers_modelPipeline.memory[i], nullptr);
+   }
+
+   for (size_t i = 0; i < uniformBuffers_shipPipeline.buffers.size(); i++) {
+      vkDestroyBuffer(device, uniformBuffers_shipPipeline.buffers[i], nullptr);
+      vkFreeMemory(device, uniformBuffers_shipPipeline.memory[i], nullptr);
+   }
+
+   for (size_t i = 0; i < uniformBuffers_asteroidPipeline.buffers.size(); i++) {
+      vkDestroyBuffer(device, uniformBuffers_asteroidPipeline.buffers[i], nullptr);
+      vkFreeMemory(device, uniformBuffers_asteroidPipeline.memory[i], nullptr);
+   }
+
+   for (size_t i = 0; i < uniformBuffers_laserPipeline.buffers.size(); i++) {
+      vkDestroyBuffer(device, uniformBuffers_laserPipeline.buffers[i], nullptr);
+      vkFreeMemory(device, uniformBuffers_laserPipeline.memory[i], nullptr);
+   }
+
+   for (size_t i = 0; i < uniformBuffers_explosionPipeline.buffers.size(); i++) {
+      vkDestroyBuffer(device, uniformBuffers_explosionPipeline.buffers[i], nullptr);
+      vkFreeMemory(device, uniformBuffers_explosionPipeline.memory[i], nullptr);
    }
 
