Index: vulkan-game.cpp
===================================================================
--- vulkan-game.cpp	(revision 90880fb20c607160a5a48bacee6fd39c33e88e18)
+++ vulkan-game.cpp	(revision 2f4ff8c378d4f7cbab4858c6a7dca849b7f57882)
@@ -77,11 +77,11 @@
                      , gui(nullptr)
                      , window(nullptr)
-                     , vp_mats_modelPipeline()
+                     , uniforms_modelPipeline()
                      , objects_modelPipeline()
-                     , vp_mats_shipPipeline()
+                     , uniforms_shipPipeline()
                      , objects_shipPipeline()
-                     , vp_mats_asteroidPipeline()
+                     , uniforms_asteroidPipeline()
                      , objects_asteroidPipeline()
-                     , vp_mats_laserPipeline()
+                     , uniforms_laserPipeline()
                      , objects_laserPipeline()
                      , uniforms_explosionPipeline()
@@ -110,24 +110,24 @@
    vkGetPhysicalDeviceProperties(physicalDevice, &deviceProperties);
 
-   vp_mats_modelPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange,
-                                                     deviceProperties.limits.minUniformBufferOffsetAlignment);
+   uniforms_modelPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange,
+                                                      deviceProperties.limits.minUniformBufferOffsetAlignment);
 
    objects_modelPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.maxStorageBufferRange,
                                                           deviceProperties.limits.minStorageBufferOffsetAlignment);
 
-   vp_mats_shipPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange,
-                                                    deviceProperties.limits.minUniformBufferOffsetAlignment);
+   uniforms_shipPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange,
+                                                     deviceProperties.limits.minUniformBufferOffsetAlignment);
 
    objects_shipPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.maxStorageBufferRange,
                                                          deviceProperties.limits.minStorageBufferOffsetAlignment);
 
-   vp_mats_asteroidPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange,
-                                                        deviceProperties.limits.minUniformBufferOffsetAlignment);
+   uniforms_asteroidPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange,
+                                                         deviceProperties.limits.minUniformBufferOffsetAlignment);
 
    objects_asteroidPipeline = VulkanBuffer<SSBO_Asteroid>(10, deviceProperties.limits.maxStorageBufferRange,
                                                           deviceProperties.limits.minStorageBufferOffsetAlignment);
 
-   vp_mats_laserPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange,
-                                                     deviceProperties.limits.minUniformBufferOffsetAlignment);
+   uniforms_laserPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange,
+                                                      deviceProperties.limits.minUniformBufferOffsetAlignment);
 
    objects_laserPipeline = VulkanBuffer<SSBO_Laser>(2, deviceProperties.limits.maxStorageBufferRange,
@@ -157,14 +157,18 @@
    modelPipeline.addAttribute(VK_FORMAT_R32_UINT, offset_of(&ModelVertex::objIndex));
 
-   createBufferSet(vp_mats_modelPipeline.memorySize(),
+   createBufferSet(uniforms_modelPipeline.memorySize(),
                    VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    uniformBuffers_modelPipeline);
+
+   uniforms_modelPipeline.map(uniformBuffers_modelPipeline.memory, device);
 
    createBufferSet(objects_modelPipeline.memorySize(),
                    VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
                    | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    storageBuffers_modelPipeline);
+
+   objects_modelPipeline.map(storageBuffers_modelPipeline.memory, device);
 
    modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
@@ -227,14 +231,18 @@
    shipPipeline.addAttribute(VK_FORMAT_R32_UINT, offset_of(&ModelVertex::objIndex));
 
-   createBufferSet(vp_mats_shipPipeline.memorySize(),
+   createBufferSet(uniforms_shipPipeline.memorySize(),
                    VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    uniformBuffers_shipPipeline);
+
+   uniforms_shipPipeline.map(uniformBuffers_shipPipeline.memory, device);
 
    createBufferSet(objects_shipPipeline.memorySize(),
                    VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
                    | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    storageBuffers_shipPipeline);
+
+   objects_shipPipeline.map(storageBuffers_shipPipeline.memory, device);
 
    shipPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
@@ -494,14 +502,18 @@
    asteroidPipeline.addAttribute(VK_FORMAT_R32_UINT, offset_of(&ModelVertex::objIndex));
 
-   createBufferSet(vp_mats_asteroidPipeline.memorySize(),
+   createBufferSet(uniforms_asteroidPipeline.memorySize(),
                    VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    uniformBuffers_asteroidPipeline);
+
+   uniforms_asteroidPipeline.map(uniformBuffers_asteroidPipeline.memory, device);
 
    createBufferSet(objects_asteroidPipeline.memorySize(),
                    VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
                    | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    storageBuffers_asteroidPipeline);
+
+   objects_asteroidPipeline.map(storageBuffers_asteroidPipeline.memory, device);
 
    asteroidPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
@@ -519,14 +531,18 @@
    laserPipeline.addAttribute(VK_FORMAT_R32_UINT, offset_of(&LaserVertex::objIndex));
 
-   createBufferSet(vp_mats_laserPipeline.memorySize(),
+   createBufferSet(uniforms_laserPipeline.memorySize(),
                    VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    uniformBuffers_laserPipeline);
+
+   uniforms_laserPipeline.map(uniformBuffers_laserPipeline.memory, device);
 
    createBufferSet(objects_laserPipeline.memorySize(),
                    VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
                    | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    storageBuffers_laserPipeline);
+
+   objects_laserPipeline.map(storageBuffers_laserPipeline.memory, device);
 
    laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
@@ -548,12 +564,16 @@
    createBufferSet(uniforms_explosionPipeline.memorySize(),
                    VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    uniformBuffers_explosionPipeline);
+
+   uniforms_explosionPipeline.map(uniformBuffers_explosionPipeline.memory, device);
 
    createBufferSet(objects_explosionPipeline.memorySize(),
                    VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
                    | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    storageBuffers_explosionPipeline);
+
+   objects_explosionPipeline.map(storageBuffers_explosionPipeline.memory, device);
 
    explosionPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
@@ -945,15 +965,18 @@
 void VulkanGame::updateScene() {
 
-   vp_mats_modelPipeline.data()->view = viewMat;
-   vp_mats_modelPipeline.data()->proj = projMat;
-
-   vp_mats_shipPipeline.data()->view = viewMat;
-   vp_mats_shipPipeline.data()->proj = projMat;
-
-   vp_mats_asteroidPipeline.data()->view = viewMat;
-   vp_mats_asteroidPipeline.data()->proj = projMat;
-
-   vp_mats_laserPipeline.data()->view = viewMat;
-   vp_mats_laserPipeline.data()->proj = projMat;
+   // TODO: I can probably use one buffer to store the view and projection mats
+   // and share it across all the shader pipelines
+
+   uniforms_modelPipeline.data()->view = viewMat;
+   uniforms_modelPipeline.data()->proj = projMat;
+
+   uniforms_shipPipeline.data()->view = viewMat;
+   uniforms_shipPipeline.data()->proj = projMat;
+
+   uniforms_asteroidPipeline.data()->view = viewMat;
+   uniforms_asteroidPipeline.data()->proj = projMat;
+
+   uniforms_laserPipeline.data()->view = viewMat;
+   uniforms_laserPipeline.data()->proj = projMat;
 
    uniforms_explosionPipeline.data()->view = viewMat;
@@ -1059,6 +1082,10 @@
 
    if (objects_modelPipeline.resized) {
+      objects_modelPipeline.unmap(storageBuffers_modelPipeline.memory, device);
+
       resizeBufferSet(storageBuffers_modelPipeline, objects_modelPipeline.memorySize(), resourceCommandPool,
                       graphicsQueue, true);
+
+      objects_modelPipeline.map(storageBuffers_modelPipeline.memory, device);
 
       objects_modelPipeline.resize();
@@ -1080,13 +1107,19 @@
    }
 
-   VulkanUtils::copyDataToMemory(device, vp_mats_modelPipeline.data(), uniformBuffers_modelPipeline.memory[imageIndex],
-                                 0, vp_mats_modelPipeline.memorySize(), false);
-
-   VulkanUtils::copyDataToMemory(device, objects_modelPipeline.data(), storageBuffers_modelPipeline.memory[imageIndex],
-                                 0, objects_modelPipeline.memorySize(), false);
+   VulkanUtils::copyDataToMappedMemory(device, uniforms_modelPipeline.data(), uniforms_modelPipeline.mapped(imageIndex),
+                                       uniformBuffers_modelPipeline.memory[imageIndex],
+                                       uniforms_modelPipeline.memorySize(), true);
+
+   VulkanUtils::copyDataToMappedMemory(device, objects_modelPipeline.data(), objects_modelPipeline.mapped(imageIndex),
+                                       storageBuffers_modelPipeline.memory[imageIndex],
+                                       objects_modelPipeline.memorySize(), true);
 
    if (objects_shipPipeline.resized) {
+      objects_shipPipeline.unmap(storageBuffers_shipPipeline.memory, device);
+
       resizeBufferSet(storageBuffers_shipPipeline, objects_shipPipeline.memorySize(), resourceCommandPool,
                       graphicsQueue, true);
+
+      objects_shipPipeline.map(storageBuffers_shipPipeline.memory, device);
 
       objects_shipPipeline.resize();
@@ -1104,13 +1137,19 @@
    }
 
-   VulkanUtils::copyDataToMemory(device, vp_mats_shipPipeline.data(), uniformBuffers_shipPipeline.memory[imageIndex],
-                                 0, vp_mats_shipPipeline.memorySize(), false);
-
-   VulkanUtils::copyDataToMemory(device, objects_shipPipeline.data(), storageBuffers_shipPipeline.memory[imageIndex],
-                                 0, objects_shipPipeline.memorySize(), false);
+   VulkanUtils::copyDataToMappedMemory(device, uniforms_shipPipeline.data(), uniforms_shipPipeline.mapped(imageIndex),
+                                       uniformBuffers_shipPipeline.memory[imageIndex],
+                                       uniforms_shipPipeline.memorySize(), true);
+
+   VulkanUtils::copyDataToMappedMemory(device, objects_shipPipeline.data(), objects_shipPipeline.mapped(imageIndex),
+                                       storageBuffers_shipPipeline.memory[imageIndex],
+                                       objects_shipPipeline.memorySize(), true);
 
    if (objects_asteroidPipeline.resized) {
+      objects_asteroidPipeline.unmap(storageBuffers_asteroidPipeline.memory, device);
+
       resizeBufferSet(storageBuffers_asteroidPipeline, objects_asteroidPipeline.memorySize(), resourceCommandPool,
                       graphicsQueue, true);
+
+      objects_asteroidPipeline.map(storageBuffers_asteroidPipeline.memory, device);
 
       objects_asteroidPipeline.resize();
@@ -1151,13 +1190,19 @@
    }
 
-   VulkanUtils::copyDataToMemory(device, vp_mats_asteroidPipeline.data(), uniformBuffers_asteroidPipeline.memory[imageIndex],
-                                 0, vp_mats_asteroidPipeline.memorySize(), false);
-
-   VulkanUtils::copyDataToMemory(device, objects_asteroidPipeline.data(), storageBuffers_asteroidPipeline.memory[imageIndex],
-                                 0, objects_asteroidPipeline.memorySize(), false);
+   VulkanUtils::copyDataToMappedMemory(device, uniforms_asteroidPipeline.data(), uniforms_asteroidPipeline.mapped(imageIndex),
+                                       uniformBuffers_asteroidPipeline.memory[imageIndex],
+                                       uniforms_asteroidPipeline.memorySize(), true);
+
+   VulkanUtils::copyDataToMappedMemory(device, objects_asteroidPipeline.data(), objects_asteroidPipeline.mapped(imageIndex),
+                                       storageBuffers_asteroidPipeline.memory[imageIndex],
+                                       objects_asteroidPipeline.memorySize(), true);
 
    if (objects_laserPipeline.resized) {
+      objects_laserPipeline.unmap(storageBuffers_laserPipeline.memory, device);
+
       resizeBufferSet(storageBuffers_laserPipeline, objects_laserPipeline.memorySize(), resourceCommandPool,
                       graphicsQueue, true);
+
+      objects_laserPipeline.map(storageBuffers_laserPipeline.memory, device);
 
       objects_laserPipeline.resize();
@@ -1181,13 +1226,19 @@
    }
 
-   VulkanUtils::copyDataToMemory(device, vp_mats_laserPipeline.data(), uniformBuffers_laserPipeline.memory[imageIndex],
-                                 0, vp_mats_laserPipeline.memorySize(), false);
-
-   VulkanUtils::copyDataToMemory(device, objects_laserPipeline.data(), storageBuffers_laserPipeline.memory[imageIndex],
-                                 0, objects_laserPipeline.memorySize(), false);
+   VulkanUtils::copyDataToMappedMemory(device, uniforms_laserPipeline.data(), uniforms_laserPipeline.mapped(imageIndex),
+                                       uniformBuffers_laserPipeline.memory[imageIndex],
+                                       uniforms_laserPipeline.memorySize(), true);
+
+   VulkanUtils::copyDataToMappedMemory(device, objects_laserPipeline.data(), objects_laserPipeline.mapped(imageIndex),
+                                       storageBuffers_laserPipeline.memory[imageIndex],
+                                       objects_laserPipeline.memorySize(), true);
 
    if (objects_explosionPipeline.resized) {
+      objects_explosionPipeline.unmap(storageBuffers_explosionPipeline.memory, device);
+
       resizeBufferSet(storageBuffers_explosionPipeline, objects_explosionPipeline.memorySize(), resourceCommandPool,
                       graphicsQueue, true);
+
+      objects_explosionPipeline.map(storageBuffers_explosionPipeline.memory, device);
 
       objects_explosionPipeline.resize();
@@ -1210,9 +1261,11 @@
    }
 
-   VulkanUtils::copyDataToMemory(device, uniforms_explosionPipeline.data(), uniformBuffers_explosionPipeline.memory[imageIndex],
-                                 0, uniforms_explosionPipeline.memorySize(), false);
-
-   VulkanUtils::copyDataToMemory(device, objects_explosionPipeline.data(), storageBuffers_explosionPipeline.memory[imageIndex],
-                                 0, objects_explosionPipeline.memorySize(), false);
+   VulkanUtils::copyDataToMappedMemory(device, uniforms_explosionPipeline.data(), uniforms_explosionPipeline.mapped(imageIndex),
+                                       uniformBuffers_explosionPipeline.memory[imageIndex],
+                                       uniforms_explosionPipeline.memorySize(), true);
+
+   VulkanUtils::copyDataToMappedMemory(device, objects_explosionPipeline.data(), objects_explosionPipeline.mapped(imageIndex),
+                                       storageBuffers_explosionPipeline.memory[imageIndex],
+                                       objects_explosionPipeline.memorySize(), true);
 }
 
@@ -2253,14 +2306,18 @@
    createSyncObjects();
 
-   createBufferSet(vp_mats_modelPipeline.memorySize(),
+   createBufferSet(uniforms_modelPipeline.memorySize(),
                    VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    uniformBuffers_modelPipeline);
+
+   uniforms_modelPipeline.map(uniformBuffers_modelPipeline.memory, device);
 
    createBufferSet(objects_modelPipeline.memorySize(),
                    VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
                    | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    storageBuffers_modelPipeline);
+
+    objects_modelPipeline.map(storageBuffers_modelPipeline.memory, device);
 
    modelPipeline.updateRenderPass(renderPass);
@@ -2269,14 +2326,18 @@
    modelPipeline.createDescriptorSets(swapChainImages.size());
 
-   createBufferSet(vp_mats_shipPipeline.memorySize(),
+   createBufferSet(uniforms_shipPipeline.memorySize(),
                    VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    uniformBuffers_shipPipeline);
+
+   uniforms_shipPipeline.map(uniformBuffers_shipPipeline.memory, device);
 
    createBufferSet(objects_shipPipeline.memorySize(),
                    VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
                    | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    storageBuffers_shipPipeline);
+
+    objects_shipPipeline.map(storageBuffers_shipPipeline.memory, device);
 
    shipPipeline.updateRenderPass(renderPass);
@@ -2285,14 +2346,18 @@
    shipPipeline.createDescriptorSets(swapChainImages.size());
 
-   createBufferSet(vp_mats_asteroidPipeline.memorySize(),
+   createBufferSet(uniforms_asteroidPipeline.memorySize(),
                    VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    uniformBuffers_asteroidPipeline);
+
+   uniforms_asteroidPipeline.map(uniformBuffers_asteroidPipeline.memory, device);
 
    createBufferSet(objects_asteroidPipeline.memorySize(),
                    VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
                    | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    storageBuffers_asteroidPipeline);
+
+    objects_asteroidPipeline.map(storageBuffers_asteroidPipeline.memory, device);
 
    asteroidPipeline.updateRenderPass(renderPass);
@@ -2301,14 +2366,18 @@
    asteroidPipeline.createDescriptorSets(swapChainImages.size());
 
-   createBufferSet(vp_mats_laserPipeline.memorySize(),
+   createBufferSet(uniforms_laserPipeline.memorySize(),
                    VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    uniformBuffers_laserPipeline);
+
+   uniforms_laserPipeline.map(uniformBuffers_laserPipeline.memory, device);
 
    createBufferSet(objects_laserPipeline.memorySize(),
                    VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
                    | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    storageBuffers_laserPipeline);
+
+    objects_laserPipeline.map(storageBuffers_laserPipeline.memory, device);
 
    laserPipeline.updateRenderPass(renderPass);
@@ -2319,12 +2388,16 @@
    createBufferSet(uniforms_explosionPipeline.memorySize(),
                    VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    uniformBuffers_explosionPipeline);
+
+   uniforms_explosionPipeline.map(uniformBuffers_explosionPipeline.memory, device);
 
    createBufferSet(objects_explosionPipeline.memorySize(),
                    VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
                    | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
-                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                    storageBuffers_explosionPipeline);
+
+    objects_explosionPipeline.map(storageBuffers_explosionPipeline.memory, device);
 
    explosionPipeline.updateRenderPass(renderPass);
@@ -2349,8 +2422,6 @@
 
    modelPipeline.cleanup();
-   shipPipeline.cleanup();
-   asteroidPipeline.cleanup();
-   laserPipeline.cleanup();
-   explosionPipeline.cleanup();
+
+   uniforms_modelPipeline.unmap(uniformBuffers_modelPipeline.memory, device);
 
    for (size_t i = 0; i < uniformBuffers_modelPipeline.buffers.size(); i++) {
@@ -2359,4 +2430,6 @@
    }
 
+   objects_modelPipeline.unmap(storageBuffers_modelPipeline.memory, device);
+
    for (size_t i = 0; i < storageBuffers_modelPipeline.buffers.size(); i++) {
       vkDestroyBuffer(device, storageBuffers_modelPipeline.buffers[i], nullptr);
@@ -2364,4 +2437,8 @@
    }
 
+   shipPipeline.cleanup();
+
+   uniforms_shipPipeline.unmap(uniformBuffers_shipPipeline.memory, device);
+
    for (size_t i = 0; i < uniformBuffers_shipPipeline.buffers.size(); i++) {
       vkDestroyBuffer(device, uniformBuffers_shipPipeline.buffers[i], nullptr);
@@ -2369,4 +2446,6 @@
    }
 
+   objects_shipPipeline.unmap(storageBuffers_shipPipeline.memory, device);
+
    for (size_t i = 0; i < storageBuffers_shipPipeline.buffers.size(); i++) {
       vkDestroyBuffer(device, storageBuffers_shipPipeline.buffers[i], nullptr);
@@ -2374,4 +2453,8 @@
    }
 
+   asteroidPipeline.cleanup();
+
+   uniforms_asteroidPipeline.unmap(uniformBuffers_asteroidPipeline.memory, device);
+
    for (size_t i = 0; i < uniformBuffers_asteroidPipeline.buffers.size(); i++) {
       vkDestroyBuffer(device, uniformBuffers_asteroidPipeline.buffers[i], nullptr);
@@ -2379,4 +2462,6 @@
    }
 
+   objects_asteroidPipeline.unmap(storageBuffers_asteroidPipeline.memory, device);
+
    for (size_t i = 0; i < storageBuffers_asteroidPipeline.buffers.size(); i++) {
       vkDestroyBuffer(device, storageBuffers_asteroidPipeline.buffers[i], nullptr);
@@ -2384,4 +2469,8 @@
    }
 
+   laserPipeline.cleanup();
+
+   uniforms_laserPipeline.unmap(uniformBuffers_laserPipeline.memory, device);
+
    for (size_t i = 0; i < uniformBuffers_laserPipeline.buffers.size(); i++) {
       vkDestroyBuffer(device, uniformBuffers_laserPipeline.buffers[i], nullptr);
@@ -2389,4 +2478,6 @@
    }
 
+   objects_laserPipeline.unmap(storageBuffers_laserPipeline.memory, device);
+
    for (size_t i = 0; i < storageBuffers_laserPipeline.buffers.size(); i++) {
       vkDestroyBuffer(device, storageBuffers_laserPipeline.buffers[i], nullptr);
@@ -2394,8 +2485,14 @@
    }
 
+   explosionPipeline.cleanup();
+
+   uniforms_explosionPipeline.unmap(uniformBuffers_explosionPipeline.memory, device);
+
    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);
    }
+
+   objects_explosionPipeline.unmap(storageBuffers_explosionPipeline.memory, device);
 
    for (size_t i = 0; i < storageBuffers_explosionPipeline.buffers.size(); i++) {
